-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
55 lines (40 loc) · 1.55 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pytest
from gpyg import GPG, CardOperator
@pytest.fixture(scope="module")
def scoped_homedir(tmp_path_factory: pytest.TempPathFactory) -> str:
return str(tmp_path_factory.mktemp("gpg-homedir").absolute())
@pytest.fixture
def homedir(tmp_path_factory: pytest.TempPathFactory) -> str:
return str(tmp_path_factory.mktemp("gpg-homedir").absolute())
@pytest.fixture(scope="module")
def scoped_instance(scoped_homedir) -> GPG:
return GPG(homedir=scoped_homedir, kill_existing_agent=True)
@pytest.fixture
def instance(homedir) -> GPG:
return GPG(homedir=homedir, kill_existing_agent=True)
@pytest.fixture(scope="module")
def environment(scoped_instance: GPG) -> GPG:
for user in range(4):
scoped_instance.keys.generate_key(
name=f"Test User {user}",
email=f"test-user-{user}@example.com",
comment=f"Test user # {user}",
passphrase=f"test-psk-{user}" if user < 2 else None,
)
return scoped_instance
@pytest.fixture(scope="module")
def smallenv(scoped_instance: GPG):
key = scoped_instance.keys.generate_key(
"user", email="[email protected]", passphrase="user"
)
return scoped_instance, key
@pytest.fixture
def interactive(instance: GPG):
signee = instance.keys.generate_key(
name="Signee", email="[email protected]", passphrase="signee"
)
signer = instance.keys.generate_key(
name="Signer", email="[email protected]", passphrase="signer"
)
with signee.edit(user=signer.fingerprint) as editor:
yield editor, signee, signer