Commit 35a73567 authored by Julien Muchembled's avatar Julien Muchembled

Fix test_generate_certificate

parent d423a1c4
import BaseHTTPServer import BaseHTTPServer
import datetime
import errno import errno
import hashlib import hashlib
import httplib import httplib
...@@ -924,12 +925,13 @@ class GenerateSignatureScriptTest(unittest.TestCase): ...@@ -924,12 +925,13 @@ class GenerateSignatureScriptTest(unittest.TestCase):
def test_generate_certificate(self): def test_generate_certificate(self):
slapos.signature.generateCertificate(self.certificate, self.key, slapos.signature.generateCertificate(self.certificate, self.key,
self.common_name) self.common_name)
today = datetime.date.today()
result = subprocess.check_output(['openssl', 'x509', '-noout', '-subject', result = subprocess.check_output(['openssl', 'x509', '-noout', '-subject',
'-in', self.certificate]) '-in', self.certificate])
self.assertEqual('subject= /CN=%s' % self.common_name, result.strip()) self.assertEqual('subject= /CN=%s' % self.common_name, result.strip())
result = subprocess.check_output(['openssl', 'x509', '-noout', '-enddate', result = subprocess.check_output(['openssl', 'x509', '-noout', '-enddate',
'-in', self.certificate]) '-in', self.certificate])
self.assertTrue('2112' in result) self.assertTrue(' %s ' % (today.year + 100) in result)
def test_generate_key_exists(self): def test_generate_key_exists(self):
self.assertRaises(ValueError, slapos.signature.generateCertificate, self.assertRaises(ValueError, slapos.signature.generateCertificate,
......
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