diff options
Diffstat (limited to 'tests/conftest.py')
| -rw-r--r-- | tests/conftest.py | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 5dcc456..e555a49 100644 --- a/tests/conftest.py +++ b/tests/conftest.py | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # etoolkit | 1 | # etoolkit |
| 2 | # Copyright (C) 2021-2022 Simeon Simeonov | 2 | # Copyright (C) 2021-2024 Simeon Simeonov |
| 3 | 3 | ||
| 4 | # This program is free software: you can redistribute it and/or modify | 4 | # This program is free software: you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
| @@ -14,14 +14,16 @@ | |||
| 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | """Common fixtures""" | 16 | """Common fixtures""" |
| 17 | |||
| 17 | import json | 18 | import json |
| 18 | 19 | ||
| 19 | import pytest | 20 | import pytest |
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | @pytest.fixture | 23 | @pytest.fixture() |
| 23 | def config_data(): | 24 | def config_data(): |
| 24 | """config_data for testing""" | 25 | """config_data for testing""" |
| 26 | |||
| 25 | return { | 27 | return { |
| 26 | 'general': { | 28 | 'general': { |
| 27 | 'MASTER_PASSWORD_HASH': ( | 29 | 'MASTER_PASSWORD_HASH': ( |
| @@ -51,26 +53,47 @@ def config_data(): | |||
| 51 | } | 53 | } |
| 52 | 54 | ||
| 53 | 55 | ||
| 54 | @pytest.fixture | 56 | @pytest.fixture() |
| 55 | def config_file(tmp_path, config_data): | 57 | def config_file(tmp_path, config_data): |
| 56 | """temporary config file for testing that includes config_data""" | 58 | """temporary config file for testing that includes config_data""" |
| 57 | cf = tmp_path / "etoolkit.json" | 59 | |
| 60 | cf = tmp_path / 'etoolkit.json' | ||
| 58 | cf.write_text(json.dumps(config_data)) | 61 | cf.write_text(json.dumps(config_data)) |
| 59 | return str(cf) | 62 | return str(cf) |
| 60 | 63 | ||
| 61 | 64 | ||
| 62 | @pytest.fixture | 65 | @pytest.fixture() |
| 63 | def non_random_bytes_32(): | 66 | def non_random_bytes_32(): |
| 64 | """always use the same bytes instead of os.urandom(32)""" | 67 | """always use the same bytes instead of os.urandom(32)""" |
| 68 | |||
| 65 | return ( | 69 | return ( |
| 66 | b'\xb9\x8aY3U_\x00j\xb4\x086K\xd9\xdb\x88N' | 70 | b'\xb9\x8aY3U_\x00j\xb4\x086K\xd9\xdb\x88N' |
| 67 | b'\xcd;\xe8$#\xfa\x12\x05\x12\x0c~\x17\x89\xa7\xf3J' | 71 | b'\xcd;\xe8$#\xfa\x12\x05\x12\x0c~\x17\x89\xa7\xf3J' |
| 68 | ) | 72 | ) |
| 69 | 73 | ||
| 70 | 74 | ||
| 71 | @pytest.fixture | 75 | @pytest.fixture() |
| 76 | def non_random_bytes_61(): | ||
| 77 | """always use the same bytes instead of os.urandom(61)""" | ||
| 78 | |||
| 79 | return ( | ||
| 80 | b'D$\x99\xaa\xafiZ\xb4C\xa0%XTz)\xca\xedK\xcd\xa2F~\xff+\xa1[\xe2\xaa' | ||
| 81 | b'\xb2\xd3\x07\x13\xedb\xc2\x84\xfe\tS\r\xf0\x02_\xef\xe3\xde\xf1?e' | ||
| 82 | b'\xa4s(Q\x04\xcd\xc7T\x01_D\xb1' | ||
| 83 | ) | ||
| 84 | |||
| 85 | |||
| 86 | @pytest.fixture() | ||
| 87 | def nonexistent_config_file(tmp_path): | ||
| 88 | """temporary config file for testing that includes config_data""" | ||
| 89 | |||
| 90 | return str(tmp_path / 'etoolkitt.json') | ||
| 91 | |||
| 92 | |||
| 93 | @pytest.fixture() | ||
| 72 | def password_hash(): | 94 | def password_hash(): |
| 73 | """password hash for testing, corresponding to 'The very secret passwd'""" | 95 | """password hash for testing, corresponding to 'The very secret passwd'""" |
| 96 | |||
| 74 | return ( | 97 | return ( |
| 75 | 'pbkdf2_sha256$100000$uYpZM1VfAGq0CDZL2duITs076CQj+hIFEgx+F4mn80o=$h3' | 98 | 'pbkdf2_sha256$100000$uYpZM1VfAGq0CDZL2duITs076CQj+hIFEgx+F4mn80o=$h3' |
| 76 | 'PSPLCd37fP15zKdW4CBGn7CXE+q5UiydaF3vbeZHo=' | 99 | 'PSPLCd37fP15zKdW4CBGn7CXE+q5UiydaF3vbeZHo=' |
