summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py38
1 files changed, 15 insertions, 23 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 6cc8b9f..2e8eaf1 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -16,14 +16,14 @@
16"""Common fixtures""" 16"""Common fixtures"""
17 17
18import json 18import json
19import pathlib
19 20
20import pytest 21import pytest
21 22
22 23
23@pytest.fixture 24@pytest.fixture
24def config_data(): 25def config_data() -> dict:
25 """config_data for testing""" 26 """config_data for testing"""
26
27 return { 27 return {
28 'general': { 28 'general': {
29 'MASTER_PASSWORD_HASH': ( 29 'MASTER_PASSWORD_HASH': (
@@ -60,18 +60,16 @@ def config_data():
60 60
61 61
62@pytest.fixture 62@pytest.fixture
63def config_file(tmp_path, config_data): 63def config_file(tmp_path: pathlib.Path, config_data: dict) -> str:
64 """Temporary config file for testing that includes config_data""" 64 """Temporary config file for testing that includes config_data"""
65
66 cf = tmp_path / 'etoolkit.json' 65 cf = tmp_path / 'etoolkit.json'
67 cf.write_text(json.dumps(config_data)) 66 cf.write_text(json.dumps(config_data))
68 return str(cf) 67 return str(cf)
69 68
70 69
71@pytest.fixture 70@pytest.fixture
72def long_encrypted_value(): 71def long_encrypted_value() -> str:
73 """enc. value corresponding to 'Nobody expects the Spanish inquisition'""" 72 """enc. value corresponding to 'Nobody expects the Spanish inquisition'"""
74
75 return ( 73 return (
76 'enc-val$2$uYpZM1VfAGq0CDZL2duITs076CQj+hIFEgx+F4mn80o=$' 74 'enc-val$2$uYpZM1VfAGq0CDZL2duITs076CQj+hIFEgx+F4mn80o=$'
77 'UWP5YeRsh5/2vZ2J1UOS+BJti73Kbp6C1pJmCo8hF' 75 'UWP5YeRsh5/2vZ2J1UOS+BJti73Kbp6C1pJmCo8hF'
@@ -80,27 +78,26 @@ def long_encrypted_value():
80 78
81 79
82@pytest.fixture 80@pytest.fixture
83def long_value(): 81def long_value() -> str:
84 """standard value (> 32 bytes)""" 82 """standard value (> 32 bytes)"""
85 return 'Nobody expects the Spanish inquisition' 83 return 'Nobody expects the Spanish inquisition'
86 84
87 85
88@pytest.fixture 86@pytest.fixture
89def master_password(): 87def master_password() -> str:
90 """Master passord""" 88 """Master passord"""
91 return 'The very secret passwd' 89 return 'The very secret passwd'
92 90
93 91
94@pytest.fixture 92@pytest.fixture
95def new_master_password(): 93def new_master_password() -> str:
96 """Master passord""" 94 """Master passord"""
97 return 'New very secret passwd' 95 return 'New very secret passwd'
98 96
99 97
100@pytest.fixture 98@pytest.fixture
101def non_random_bytes_32(): 99def non_random_bytes_32() -> bytes:
102 """always use the same bytes instead of os.urandom(32)""" 100 """always use the same bytes instead of os.urandom(32)"""
103
104 return ( 101 return (
105 b'\xb9\x8aY3U_\x00j\xb4\x086K\xd9\xdb\x88N' 102 b'\xb9\x8aY3U_\x00j\xb4\x086K\xd9\xdb\x88N'
106 b'\xcd;\xe8$#\xfa\x12\x05\x12\x0c~\x17\x89\xa7\xf3J' 103 b'\xcd;\xe8$#\xfa\x12\x05\x12\x0c~\x17\x89\xa7\xf3J'
@@ -108,9 +105,8 @@ def non_random_bytes_32():
108 105
109 106
110@pytest.fixture 107@pytest.fixture
111def non_random_bytes_57(): 108def non_random_bytes_57() -> bytes:
112 """always use the same bytes instead of os.urandom(57)""" 109 """always use the same bytes instead of os.urandom(57)"""
113
114 return ( 110 return (
115 b'D$\x99\xaa\xafiZ\xb4C\xa0%XTz)\xca\xedK\xcd\xa2F~\xff+\xa1[\xe2\xaa' 111 b'D$\x99\xaa\xafiZ\xb4C\xa0%XTz)\xca\xedK\xcd\xa2F~\xff+\xa1[\xe2\xaa'
116 b'\xb2\xd3\x07\x13\xedb\xc2\x84\xfe\tS\r\xf0\x02_\xef\xe3\xde\xf1?e' 112 b'\xb2\xd3\x07\x13\xedb\xc2\x84\xfe\tS\r\xf0\x02_\xef\xe3\xde\xf1?e'
@@ -119,16 +115,14 @@ def non_random_bytes_57():
119 115
120 116
121@pytest.fixture 117@pytest.fixture
122def nonexistent_config_file(tmp_path): 118def nonexistent_config_file(tmp_path: pathlib.Path) -> str:
123 """temporary config file for testing that includes config_data""" 119 """temporary config file for testing that includes config_data"""
124
125 return str(tmp_path / 'etoolkitt.json') 120 return str(tmp_path / 'etoolkitt.json')
126 121
127 122
128@pytest.fixture 123@pytest.fixture
129def password_hash(): 124def password_hash() -> str:
130 """password hash for testing, corresponding to 'The very secret passwd'""" 125 """password hash for testing, corresponding to 'The very secret passwd'"""
131
132 return ( 126 return (
133 'pbkdf2_sha256$500000$UY3o78KUM1Btzxk3k3JCsijnwtJ2lx+hH9NewpVKxo8=$' 127 'pbkdf2_sha256$500000$UY3o78KUM1Btzxk3k3JCsijnwtJ2lx+hH9NewpVKxo8=$'
134 'tHwDm8OVKanC4DoYTigTCb0R3lQIa/CbBYj0B3TZtHg=' 128 'tHwDm8OVKanC4DoYTigTCb0R3lQIa/CbBYj0B3TZtHg='
@@ -136,9 +130,8 @@ def password_hash():
136 130
137 131
138@pytest.fixture 132@pytest.fixture
139def short_encrypted_value(): 133def short_encrypted_value() -> str:
140 """enc. value corresponding to 'secret1'""" 134 """enc. value corresponding to 'secret1'"""
141
142 return ( 135 return (
143 'enc-val$2$RCSZqq9pWrRDoCVYVHopyu1LzaJGfv8roVviqrLTBxM=$' 136 'enc-val$2$RCSZqq9pWrRDoCVYVHopyu1LzaJGfv8roVviqrLTBxM=$'
144 '+YYrZbwTBuG0Pl+WMQrvxLUtq5j8qYuQqzoIwgoGt7AaWZCJz+E7qoDeg3wke70ST8U=' 137 '+YYrZbwTBuG0Pl+WMQrvxLUtq5j8qYuQqzoIwgoGt7AaWZCJz+E7qoDeg3wke70ST8U='
@@ -146,9 +139,8 @@ def short_encrypted_value():
146 139
147 140
148@pytest.fixture 141@pytest.fixture
149def short_encrypted_value_v1(): 142def short_encrypted_value_v1() -> str:
150 """enc. value (enc-val 1) corresponding to 'secret1'""" 143 """enc. value (enc-val 1) corresponding to 'secret1'"""
151
152 return ( 144 return (
153 'enc-val$1$/cXpEMoZrTlb9yokGhw8tLTSUkqnqJ4ZoAkurNgMYx' 145 'enc-val$1$/cXpEMoZrTlb9yokGhw8tLTSUkqnqJ4ZoAkurNgMYx'
154 'w=$1VdkSMcZnLRwLiu1M8VlYcbelwmiVNY=' 146 'w=$1VdkSMcZnLRwLiu1M8VlYcbelwmiVNY='
@@ -156,12 +148,12 @@ def short_encrypted_value_v1():
156 148
157 149
158@pytest.fixture 150@pytest.fixture
159def short_value(): 151def short_value() -> str:
160 """standard value (< 32 bytes)""" 152 """standard value (< 32 bytes)"""
161 return 'secret1' 153 return 'secret1'
162 154
163 155
164@pytest.fixture 156@pytest.fixture
165def wrong_master_password(): 157def wrong_master_password() -> str:
166 """Wrong master passord""" 158 """Wrong master passord"""
167 return 'the very secret passwd' 159 return 'the very secret passwd'