Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 9cb4bc4e

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Re #8708 - Added a test verifying the validity of the generate_pkcs_identity method in CertificateService when a chain of trust is empty

Zobrazit rozdíly:

tests/integration_tests/services/certificate_service_test.py
1
import re
1 2
import subprocess
2 3

  
3 4
import pytest
......
430 431
    assert root_ca_cert.pem_data in pkcs_info
431 432

  
432 433

  
434
def test_create_pkcs_identity_self_signed_cert(certificate_service_unique, private_key_service_unique):
435
    # create tests certificates
436
    root_ca_private_key = private_key_service_unique.create_new_key()
437

  
438
    root_ca_cert = certificate_service_unique.create_root_ca(root_ca_private_key,
439
                                                             Subject(common_name="RootFoo",
440
                                                                     organization_unit="Department of Foo"))
441

  
442
    # generate the identity
443
    pkcs = certificate_service_unique.generate_pkcs_identity(root_ca_cert.certificate_id, root_ca_private_key, "Foo Child's Identity", "pass")
444

  
445
    # print out the pkcs store in order to be able to check it
446
    pkcs_info = subprocess.check_output(
447
        ["openssl", "pkcs12", "-info", "-in", "-", "-nodes", "-passin", "pass:pass"],
448
        input=pkcs,
449
        stderr=subprocess.STDOUT).decode()
450

  
451
    assert root_ca_cert.pem_data in pkcs_info
452
    assert len(re.findall("BEGIN CERTIFICATE", pkcs_info)) == 1
453
    assert len(re.findall("END CERTIFICATE", pkcs_info)) == 1
454

  
455

  
433 456
def test_create_pkcs_identity_incorrect_id(certificate_service_unique):
434 457
    with pytest.raises(CertificateNotFoundException):
435 458
        certificate_service_unique.generate_pkcs_identity(999, None, None, None)

Také k dispozici: Unified diff