Commit bc328ce0 authored by Łukasz Nowak's avatar Łukasz Nowak

Check behaviour in case of exists key or certificate.

parent ab16cfcc
......@@ -776,12 +776,14 @@ class GenerateSignatureScriptTest(unittest.TestCase):
self.certificate = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix()
+ str(random.random()))
self.common_name = str(random.random())
self.key_exist = tempfile.NamedTemporaryFile(delete=False).name
self.certificate_exist = tempfile.NamedTemporaryFile(delete=False).name
def tearDown(self):
if os.path.exists(self.key):
os.unlink(self.key)
if os.path.exists(self.certificate):
os.unlink(self.certificate)
for f in [self.key, self.certificate, self.key_exist,
self.certificate_exist]:
if os.path.lexists(f):
os.unlink(f)
def test_generate_certificate(self):
slapos.signature.generateCertificate(self.certificate, self.key,
......@@ -789,3 +791,12 @@ class GenerateSignatureScriptTest(unittest.TestCase):
result = subprocess.check_output(['openssl', 'x509', '-noout', '-subject',
'-in', self.certificate])
self.assertEqual('subject= /CN=%s' % self.common_name, result.strip())
def test_generate_key_exists(self):
self.assertRaises(ValueError, slapos.signature.generateCertificate,
self.certificate, self.key_exist, self.common_name)
def test_generate_cert_exists(self):
self.assertRaises(ValueError, slapos.signature.generateCertificate,
self.certificate_exist, self.key, self.common_name)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment