1 |
6c098d6e
|
Stanislav Král
|
import subprocess
|
2 |
|
|
|
3 |
18588728
|
Stanislav Král
|
import pytest
|
4 |
|
|
|
5 |
6c098d6e
|
Stanislav Král
|
|
6 |
|
|
def test_private_key(service):
|
7 |
|
|
private_key = service.create_private_key()
|
8 |
|
|
|
9 |
|
|
# verify the private key
|
10 |
|
|
subprocess.check_output(["openssl", "rsa", "-in", "-", "-check"], input=bytes(private_key, encoding="utf-8"),
|
11 |
|
|
stderr=subprocess.STDOUT)
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
def test_encrypted_private_key(service):
|
15 |
|
|
private_key = service.create_private_key(passphrase="foobar")
|
16 |
|
|
|
17 |
|
|
# verify the private key providing a correct passphrase
|
18 |
|
|
subprocess.check_output(["openssl", "rsa", "-in", "-", "-passin", "pass:foobar", "-check"],
|
19 |
|
|
input=bytes(private_key, encoding="utf-8"), stderr=subprocess.STDOUT)
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
def test_encrypted_private_key_incorrect_pass(service):
|
23 |
|
|
private_key = service.create_private_key(passphrase="foobar")
|
24 |
|
|
|
25 |
|
|
# incorrect passphrase provided
|
26 |
|
|
with pytest.raises(subprocess.CalledProcessError):
|
27 |
|
|
subprocess.check_output(["openssl", "rsa", "-in", "-", "-passin", "pass:bazbaz", "-check"],
|
28 |
18588728
|
Stanislav Král
|
input=bytes(private_key, encoding="utf-8"), stderr=subprocess.STDOUT)
|