159 |
159 |
root_ca_cert = certificate_service.create_root_ca(root_ca_private_key,
|
160 |
160 |
Subject(common_name="RootFoo",
|
161 |
161 |
organization_unit="Department of Foo"))
|
162 |
|
print(root_ca_cert.certificate_id)
|
163 |
162 |
|
164 |
163 |
inter_ca_cert = certificate_service.create_ca(inter_ca_private_key, Subject(common_name="Intermediate CA"),
|
165 |
164 |
root_ca_cert,
|
166 |
165 |
root_ca_private_key, usages={SSL_ID: True})
|
167 |
|
print(inter_ca_cert.certificate_id)
|
168 |
|
print(inter_ca_cert.parent_id)
|
169 |
166 |
|
170 |
167 |
cert = certificate_service.create_end_cert(end_cert_private_key,
|
171 |
168 |
Subject("Foo Child", email_address="foo@bar.cz"), inter_ca_cert,
|
172 |
169 |
inter_ca_private_key, usages={AUTHENTICATION_ID: True})
|
173 |
|
print(cert.certificate_id)
|
174 |
|
print(cert.parent_id)
|
175 |
170 |
|
176 |
171 |
cot = certificate_service.get_chain_of_trust(cert.certificate_id)
|
177 |
172 |
assert len(cot) == 2
|
... | ... | |
215 |
210 |
cot = certificate_service.get_chain_of_trust(root_ca_cert.certificate_id, exclude_root=False)
|
216 |
211 |
assert len(cot) == 1
|
217 |
212 |
assert [root_ca_cert.certificate_id] == [cot[0].certificate_id]
|
|
213 |
|
|
214 |
|
|
215 |
def test_delete_cert(private_key_service, certificate_service):
|
|
216 |
root_ca_private_key = private_key_service.create_new_key(passphrase="foobar")
|
|
217 |
|
|
218 |
original_len = len(certificate_service.get_certificates())
|
|
219 |
|
|
220 |
root_ca_cert = certificate_service.create_root_ca(root_ca_private_key,
|
|
221 |
Subject(common_name="RootFoo",
|
|
222 |
organization_unit="Department of Foo"))
|
|
223 |
|
|
224 |
len_inserted = len(certificate_service.get_certificates())
|
|
225 |
|
|
226 |
assert original_len + 1 == len_inserted
|
|
227 |
|
|
228 |
# TODO delete should delete all children?
|
|
229 |
assert certificate_service.delete_certificate(root_ca_cert.certificate_id)
|
|
230 |
|
|
231 |
assert len_inserted - 1 == len(certificate_service.get_certificates())
|
Re #8472 - Implemented delete_certificate method in CertificateService and added a test validating it