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

Resue test infrastructure.

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