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

Resue test infrastructure.

parent b0bd708b
...@@ -770,20 +770,22 @@ class OnlineTestWrongChecksum(OnlineMixin, unittest.TestCase): ...@@ -770,20 +770,22 @@ class OnlineTestWrongChecksum(OnlineMixin, unittest.TestCase):
class GenerateSignatureScriptTest(unittest.TestCase): class GenerateSignatureScriptTest(unittest.TestCase):
''' Class which must test the signature.py script. ''' ''' Class which must test the signature.py script. '''
def test_generate_certificate(self): def setUp(self):
key = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() + self.key = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() +
str(random.random())) str(random.random()))
certificate = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() self.certificate = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix()
+ str(random.random())) + str(random.random()))
common_name = str(random.random()) self.common_name = str(random.random())
try: def tearDown(self):
slapos.signature.generateCertificate(certificate, key, common_name) if os.path.exists(self.key):
result = subprocess.check_output(['openssl', 'x509', '-noout', '-subject', '-in', os.unlink(self.key)
certificate]) if os.path.exists(self.certificate):
self.assertEqual('subject= /CN=%s' % common_name, result.strip()) os.unlink(self.certificate)
finally:
if os.path.exists(key): def test_generate_certificate(self):
os.unlink(key) slapos.signature.generateCertificate(self.certificate, self.key,
if os.path.exists(certificate): self.common_name)
os.unlink(certificate) result = subprocess.check_output(['openssl', 'x509', '-noout', '-subject',
'-in', self.certificate])
self.assertEqual('subject= /CN=%s' % self.common_name, result.strip())
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