Revize a3a691fd
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
tests/integration_tests/services/certificate_service_test.py | ||
---|---|---|
353 | 353 |
with pytest.raises(CertificateAlreadyRevokedException) as e: |
354 | 354 |
certificate_service_unique.set_certificate_revocation_status(root_ca_cert.certificate_id, "revoked", |
355 | 355 |
"unspecified") |
356 |
|
|
357 |
|
|
358 |
def test_get_certificate_status(certificate_service_unique, private_key_service_unique, |
|
359 |
certificate_repository_unique): |
|
360 |
# Create tests certificates |
|
361 |
root_ca_private_key = private_key_service_unique.create_new_key() |
|
362 |
expired_private_key = private_key_service_unique.create_new_key() |
|
363 |
revoked_private_key = private_key_service_unique.create_new_key() |
|
364 |
|
|
365 |
root_ca_cert = certificate_service_unique.create_root_ca(root_ca_private_key, |
|
366 |
Subject(common_name="RootFoo", |
|
367 |
organization_unit="Department of Foo"), |
|
368 |
days=1) |
|
369 |
|
|
370 |
# created cert will be expired immediately |
|
371 |
expired_cert = certificate_service_unique.create_end_cert(expired_private_key, |
|
372 |
Subject(common_name="Expired cert"), |
|
373 |
root_ca_cert, |
|
374 |
root_ca_private_key, usages={SSL_ID: True}, |
|
375 |
days=0) |
|
376 |
|
|
377 |
# this certificate will be revoked later |
|
378 |
revoked_cert = certificate_service_unique.create_end_cert(revoked_private_key, |
|
379 |
Subject(common_name="Revoked cert"), |
|
380 |
root_ca_cert, |
|
381 |
root_ca_private_key, usages={SSL_ID: True}, |
|
382 |
days=1) |
|
383 |
|
|
384 |
assert certificate_service_unique.get_certificate_state(root_ca_cert.certificate_id) == "valid" |
|
385 |
assert certificate_service_unique.get_certificate_state(expired_cert.certificate_id) == "expired" |
|
386 |
assert certificate_service_unique.get_certificate_state(revoked_cert.certificate_id) == "valid" |
|
387 |
|
|
388 |
certificate_service_unique.set_certificate_revocation_status(revoked_cert.certificate_id, "revoked", "unspecified") |
|
389 |
|
|
390 |
assert certificate_service_unique.get_certificate_state(revoked_cert.certificate_id) == "revoked" |
|
391 |
|
|
392 |
certificate_service_unique.set_certificate_revocation_status(expired_cert.certificate_id, "revoked", "unspecified") |
|
393 |
assert certificate_service_unique.get_certificate_state(expired_cert.certificate_id) == "revoked" |
|
394 |
|
|
395 |
with pytest.raises(CertificateNotFoundException) as e: |
|
396 |
certificate_service_unique.get_certificate_state(888) |
Také k dispozici: Unified diff
Re #8707 - Added integration test of the service