Commit 79071ceb authored by Boxiang Sun's avatar Boxiang Sun Committed by Rafael Monnerat

testCertificateAuthorityTool: Enable the duplicate certificate check

parent 44e0d582
...@@ -186,15 +186,17 @@ class CertificateAuthorityTool(BaseTool): ...@@ -186,15 +186,17 @@ class CertificateAuthorityTool(BaseTool):
# {key, certificate, id, common_name} # {key, certificate, id, common_name}
if not common_name: if not common_name:
raise ValueError("Invalid common name: %r" % common_name) raise ValueError("Invalid common name: %r" % common_name)
self._checkCertificateAuthority()
self._lockCertificateAuthority()
index = open(self.index).read().splitlines() index = open(self.index).read().splitlines()
valid_line_list = [q for q in index if q.startswith('V') and valid_line_list = [q for q in index if q.startswith('V') and
('CN=%s/' % common_name in q)] ('CN=%s/' % common_name in q)]
if len(valid_line_list) >= 1: if len(valid_line_list) >= 1:
self._unlockCertificateAuthority()
raise ValueError('The common name %r already has a certificate' raise ValueError('The common name %r already has a certificate'
'please revoke it before request a new one..' % common_name) 'please revoke it before request a new one..' % common_name)
self._checkCertificateAuthority()
self._lockCertificateAuthority()
try: try:
new_id = open(self.serial, 'r').read().strip().lower() new_id = open(self.serial, 'r').read().strip().lower()
key = os.path.join(self.certificate_authority_path, 'private', key = os.path.join(self.certificate_authority_path, 'private',
......
...@@ -75,8 +75,6 @@ class TestCertificateAuthority(ERP5TypeTestCase): ...@@ -75,8 +75,6 @@ class TestCertificateAuthority(ERP5TypeTestCase):
self.assertTrue('CN=%s' % user_id in certificate['certificate']) self.assertTrue('CN=%s' % user_id in certificate['certificate'])
person.revokeCertificate() person.revokeCertificate()
@unittest.skip(
"""Will be fixed when we rewrite certificate autority to use caucase.""")
def test_person_request_certificate_twice(self): def test_person_request_certificate_twice(self):
user_id, login = self._createPerson() user_id, login = self._createPerson()
self.loginByUserName(login) self.loginByUserName(login)
......
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