Revize b62ebacd
Přidáno uživatelem Stanislav Král před asi 4 roky(ů)
tests/unit_tests/services/cryptography/create_crt_test.py | ||
---|---|---|
16 | 16 |
root_key = service.create_private_key() |
17 | 17 |
root_ca = service.create_sscrt(Subject(common_name="foo"), root_key) |
18 | 18 |
|
19 |
# create a private key to be used to make a CSR for the intermediate CA
|
|
19 |
# create a private key to be used to make a CSR for the child certificate
|
|
20 | 20 |
cert_key = service.create_private_key() |
21 | 21 |
|
22 |
# create a CA using the root CA
|
|
22 |
# create a cert using the root CA
|
|
23 | 23 |
cert = service.create_crt(Subject(common_name="bar", country="CZ"), cert_key, root_ca, root_key) |
24 | 24 |
|
25 | 25 |
cert_printed = export_crt(cert) |
... | ... | |
35 | 35 |
root_key = service.create_private_key(passphrase=root_key_passphrase) |
36 | 36 |
root_ca = service.create_sscrt(Subject(common_name="foo"), root_key, key_pass=root_key_passphrase) |
37 | 37 |
|
38 |
# create a private key to be used to make a CSR for the intermediate CA
|
|
39 |
inter_key_passphrase = "foobazbar"
|
|
40 |
inter_key = service.create_private_key(passphrase=inter_key_passphrase)
|
|
38 |
# create a private key to be used to make a CSR for the child certificate
|
|
39 |
cert_key_passphrase = "foobazbar"
|
|
40 |
cert_key = service.create_private_key(passphrase=cert_key_passphrase)
|
|
41 | 41 |
|
42 | 42 |
# create a certificate using the root CA |
43 |
cert = service.create_crt(Subject(common_name="bar", country="CZ"), inter_key, root_ca, root_key,
|
|
44 |
subject_key_pass=inter_key_passphrase, issuer_key_pass=root_key_passphrase)
|
|
43 |
cert = service.create_crt(Subject(common_name="bar", country="CZ"), cert_key, root_ca, root_key,
|
|
44 |
subject_key_pass=cert_key_passphrase, issuer_key_pass=root_key_passphrase)
|
|
45 | 45 |
|
46 | 46 |
cert_printed = export_crt(cert) |
47 | 47 |
|
... | ... | |
51 | 51 |
|
52 | 52 |
# some basic incorrect passphrase combinations |
53 | 53 |
passphrases = [ |
54 |
(inter_key, None),
|
|
55 |
(inter_key, "foofoobarbar"),
|
|
54 |
(cert_key, None),
|
|
55 |
(cert_key, "foofoobarbar"),
|
|
56 | 56 |
(None, root_key), |
57 | 57 |
("foofoobarbar", root_key), |
58 | 58 |
("foofoobarbar", "foofoobarbar"), |
... | ... | |
62 | 62 |
for (key_pass, issuer_key_pass) in passphrases: |
63 | 63 |
# try to create it using a wrong issuer passphrase |
64 | 64 |
with pytest.raises(CryptographyException) as e: |
65 |
service.create_crt(Subject(common_name="bar", country="CZ"), inter_key, root_ca, root_key,
|
|
65 |
service.create_crt(Subject(common_name="bar", country="CZ"), cert_key, root_ca, root_key,
|
|
66 | 66 |
subject_key_pass=key_pass, issuer_key_pass=issuer_key_pass) |
67 | 67 |
assert "bad decrypt" in e.value.message |
68 | 68 |
|
Také k dispozici: Unified diff
Re #8575 - Renamed some variable names in create_crt_test.py