def testCertificateWasCreatedWithConfigValues(pathToTempFile, customConfig):
    createCertificate(pathToTempFile, config=customConfig)
    loadedConfig = loadConfigurationFromCertificate(pathToTempFile)

    del customConfig['expires']  # written as date to config
    customConfig['serialNumber'] += 1  # incremented

    assert customConfig == loadedConfig
def testCertificateCreationWorksWithoutSomeEmptyvalues(key, value,
                                                       pathToTempFile,
                                                       customConfig):
    customConfig[key] = value

    createCertificate(pathToTempFile, config=customConfig)

    assert os.path.exists(pathToTempFile)
Exemplo n.º 3
0
def tempCertPath():
	with workInTemporaryDirectory() as tempDir:
		keyFile = os.path.join(tempDir, 'temp.pem')
		createCertificate(keyFile)

		yield keyFile
def testCertificateCreationWorksWithoutSomeValues(value, pathToTempFile,
                                                  customConfig):
    del customConfig[value]
    createCertificate(pathToTempFile, config=customConfig)

    assert os.path.exists(pathToTempFile)
def testCertificateCreationWithForeignHostnameRaisesException(customConfig):
    customConfig['commonName'] = u'this-should-not-be-hostname'

    with pytest.raises(CertificateCreationError):
        createCertificate(config=customConfig)
def testCertificateCreationWithoutValidExpireDateRaisesException(customConfig):
    customConfig['expires'] = u'hallo welt'

    with pytest.raises(CertificateCreationError):
        createCertificate(config=customConfig)
def testCertificateFileExistsAfterCreation(pathToTempFile):
    assert not os.path.exists(pathToTempFile)

    createCertificate(pathToTempFile)
    assert os.path.exists(pathToTempFile)