Projekt

Obecné

Profil

Stáhnout (1.07 KB) Statistiky
| Větev: | Tag: | Revize:
1
import subprocess
2

    
3
import pytest
4

    
5

    
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
                                input=bytes(private_key, encoding="utf-8"), stderr=subprocess.STDOUT)
(6-6/10)