Commit 83e06ad5 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_certificate_authority: Update test for Person/Certificate Login

parent c2054c7c
...@@ -72,9 +72,11 @@ class CertificateLoginMixin: ...@@ -72,9 +72,11 @@ class CertificateLoginMixin:
certificate_dict = { certificate_dict = {
"common_name" : self.getReference() "common_name" : self.getReference()
} }
if self.getReference and self.getSourceReference(): if self.getReference() and self.getSourceReference():
if csr is not None:
raise ValueError("This certificate already")
certificate_dict["id"] = self.getSourceReference() certificate_dict["id"] = self.getSourceReference()
crt_pem = caucase_connector.getCertificate(self.getSourceReference()) crt_pem = caucase_connector.getCertificate(int(self.getSourceReference()))
certificate_dict["certificate"] = crt_pem certificate_dict["certificate"] = crt_pem
# We should assert that reference is the CN of crt_pem # We should assert that reference is the CN of crt_pem
return certificate_dict return certificate_dict
...@@ -111,7 +113,7 @@ class CertificateLoginMixin: ...@@ -111,7 +113,7 @@ class CertificateLoginMixin:
else: else:
return self._getCertificate(csr=csr) return self._getCertificate(csr=csr)
def _revokeCertificate(self): def _revokeCertificate(self, key_pem=None):
if self.getDestinationReference() is not None or ( if self.getDestinationReference() is not None or (
self.getReference() is not None and self.getSourceReference() is None self.getReference() is not None and self.getSourceReference() is None
): ):
...@@ -119,12 +121,14 @@ class CertificateLoginMixin: ...@@ -119,12 +121,14 @@ class CertificateLoginMixin:
if self.getSourceReference() is not None: if self.getSourceReference() is not None:
caucase_connector = self._getCaucaseConnector() caucase_connector = self._getCaucaseConnector()
crt_pem = caucase_connector.getCertificate(self.getSourceReference()) crt_pem = caucase_connector.getCertificate(int(self.getSourceReference()))
caucase_connector.revokeCertificate(crt_pem) if key_pem is None:
return caucase_connector.revokeCertificate(crt_pem, key_pem)
return caucase_connector.revokeCertificate(crt_pem)
else: else:
raise ValueError("No certificate found to revoke!") raise ValueError("No certificate found to revoke!")
security.declarePrivate('revokeCertificate') security.declarePrivate('revokeCertificate')
def revokeCertificate(self): def revokeCertificate(self, key_pem=None):
"""Revokes existing certificate""" """Revokes existing certificate"""
self._revokeCertificate() self._revokeCertificate(key_pem=key_pem)
\ No newline at end of file \ No newline at end of file
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