Revize 857e9e12
Přidáno uživatelem Michal Seják před téměř 4 roky(ů)
tests/integration_tests/services/certificate_service_test.py | ||
---|---|---|
397 | 397 |
|
398 | 398 |
with pytest.raises(CertificateNotFoundException) as e: |
399 | 399 |
certificate_service_unique.get_certificate_state(888) |
400 |
|
|
401 |
|
|
402 |
def test_verify_key(private_key_service_unique): |
|
403 |
PASS = "awdoijaowdij" |
|
404 |
|
|
405 |
k1_no_p = private_key_service_unique.create_new_key() |
|
406 |
k2_p = private_key_service_unique.create_new_key(passphrase=PASS) |
|
407 |
|
|
408 |
assert private_key_service_unique.verify_key(k1_no_p.private_key, None) |
|
409 |
assert not private_key_service_unique.verify_key(k1_no_p.private_key, PASS) |
|
410 |
|
|
411 |
assert private_key_service_unique.verify_key(k2_p.private_key, PASS) |
|
412 |
assert not private_key_service_unique.verify_key(k2_p.private_key, None) |
|
413 |
assert not private_key_service_unique.verify_key(k2_p.private_key, PASS + "awd") |
|
414 |
|
|
415 |
|
|
416 |
def test_key_reusal(private_key_service_unique, private_key_repository_unique, cryptography_service): |
|
417 |
PASS = "awdoijaowdij" |
|
418 |
|
|
419 |
k1_no_p = private_key_service_unique.create_new_key() |
|
420 |
k2_p = private_key_service_unique.create_new_key(passphrase=PASS) |
|
421 |
|
|
422 |
assert private_key_service_unique.verify_key(k1_no_p.private_key, None) |
|
423 |
assert not private_key_service_unique.verify_key(k1_no_p.private_key, PASS) |
|
424 |
|
|
425 |
assert private_key_service_unique.verify_key(k2_p.private_key, PASS) |
|
426 |
assert not private_key_service_unique.verify_key(k2_p.private_key, None) |
|
427 |
assert not private_key_service_unique.verify_key(k2_p.private_key, PASS + "awd") |
|
428 |
|
|
429 |
l1 = len(private_key_repository_unique.read_all()) |
|
430 |
|
|
431 |
k1_no_p_copy = private_key_service_unique.wrap_custom_key(k1_no_p.private_key, k1_no_p.password) |
|
432 |
k2_p_copy = private_key_service_unique.wrap_custom_key(k2_p.private_key, k2_p.password) |
|
433 |
|
|
434 |
assert private_key_service_unique.verify_key(k1_no_p_copy.private_key, None) |
|
435 |
assert not private_key_service_unique.verify_key(k1_no_p_copy.private_key, PASS) |
|
436 |
|
|
437 |
assert private_key_service_unique.verify_key(k2_p_copy.private_key, PASS) |
|
438 |
assert not private_key_service_unique.verify_key(k2_p_copy.private_key, None) |
|
439 |
assert not private_key_service_unique.verify_key(k2_p_copy.private_key, PASS + "awd") |
|
440 |
|
|
441 |
l2 = len(private_key_repository_unique.read_all()) |
|
442 |
|
|
443 |
assert l1 == l2 |
|
444 |
|
|
445 |
pem = cryptography_service.create_private_key(PASS) |
|
446 |
k3 = private_key_service_unique.wrap_custom_key(pem, PASS) |
|
447 |
|
|
448 |
assert private_key_service_unique.verify_key(k3.private_key, PASS) |
|
449 |
assert not private_key_service_unique.verify_key(k3.private_key, None) |
|
450 |
assert not private_key_service_unique.verify_key(k3.private_key, PASS + "awd") |
|
451 |
|
|
452 |
l3 = len(private_key_repository_unique.read_all()) |
|
453 |
|
|
454 |
assert l2 == l3 - 1 |
Také k dispozici: Unified diff
Re #8705 - Added CertService tests for `verify_key` and key reusal functionality of `wrap_custom_key`.