[Freeipa-devel] [PATCH 0059] Make testcert automagically when needed by unit test

Petr Viktorin pviktori at redhat.com
Tue May 28 14:37:20 UTC 2013


On 05/27/2013 04:07 PM, Tomas Babej wrote:
> On 05/24/2013 02:02 PM, Petr Viktorin wrote:
>> On 05/24/2013 09:57 AM, Tomas Babej wrote:
>>> On 05/23/2013 07:17 PM, Tomas Babej wrote:
>>>> Hi,
>>>>
>>>> With this patch, there's no need to run make-testcert separately
>>>> before running make-test. Unit test framework will check whether
>>>> service.crt file exists, and if not, will generate one if needed.
>>>>
>>>> New location of service.crt file is in ~/.ipa directory.
>>>>
>>>> Part of https://fedorahosted.org/freeipa/ticket/3621
>>>>
>>>> Tomas
>>
>> Thanks, it works well.
>> However it would be nice to not repeat this code in every test that
>> needs the cert:
>>
>> +servercert = ''
>> +
>> +# Create the testing server cert if it does not already exist
>> +# Returns True if successful, error message if not
>> +if not os.path.exists(testcert.CERTPATH):
>> +    servercert_ret = testcert.main()
>> +
>> +if os.path.exists(testcert.CERTPATH):
>> +    fd = open(testcert.CERTPATH, 'r')
>> +    servercert = fd.readlines()
>> +    servercert = ''.join(servercert)
>> +    servercert = x509.strip_header(servercert)
>> +    fd.close()
>> +
>> +
>>
>> Please put this in testcert.py and just call something like
>> `servercert = testcert.get_testcert()`.
>>
>>  class test_host(Declarative):
>>
>> +    def setUp(self):
>> +        super(Declarative, self).setUp()
>> +        if servercert == '':
>> +            raise nose.SkipTest('Testcert generation problem: %s' %
>> +                                 servercert_ret)
>> +
>>
>> Do we really want to skip the test here? IMO if we cannot generate the
>> cert, we should fail (`assert servercert`).
>>
> Thank you for the comments.
>
> Updated patch attached.
>
> Tomas

Okay, I ran it again.
Please also remove make-testcert from the Makefile.

I now get lots of errors from the test suite, starting with these:
cannot connect to 
'https://vm-050.idm.lab.bos.redhat.com:443/ca/eeca/ca/profileSubmitSSLClient': 
[Errno -8054] (SEC_ERROR_REUSED_ISSUER_AND_SERIAL) You are attempting to 
import a cert with the same issuer/serial as an existing cert, but that 
is not the same cert.

Does this not happen in your setup?

-- 
Petr³




More information about the Freeipa-devel mailing list