diff options
| author | Hunternif | 2021-08-04 01:56:00 +0100 |
|---|---|---|
| committer | Hunternif | 2021-08-04 01:56:00 +0100 |
| commit | ca861cdc44ca476cec2949f237bbc7503862ad58 (patch) | |
| tree | 520f918a9a77432bf283b46b4296812eb4332ffe /server/szurubooru/tests/func/test_auth.py | |
| parent | dd03540398fcab11bfc2c3cebed2fb7a78592c16 (diff) | |
| parent | 59452711668b9f7a7aeea3c57301b22882987c2b (diff) | |
Merge remote-tracking branch 'origin/master' into hunternif
# Conflicts:
# client/css/post-content-control.styl
# client/css/post-list-view.styl
# client/html/post_edit_sidebar.tpl
# client/js/controllers/post_list_controller.js
# client/js/controllers/post_main_controller.js
# client/js/controllers/post_upload_controller.js
# client/js/controllers/tag_controller.js
# client/js/controllers/user_list_controller.js
# client/js/controls/expander_control.js
# client/js/controls/post_content_control.js
# client/js/controls/post_edit_sidebar_control.js
# client/js/controls/post_readonly_sidebar_control.js
# client/js/controls/tag_input_control.js
# client/js/main.js
# client/js/models/abstract_list.js
# client/js/models/post.js
# client/js/models/post_list.js
# client/js/models/settings.js
# client/js/models/tag.js
# client/js/models/tag_list.js
# client/js/tags.js
# client/js/util/search.js
# client/js/util/touch.js
# client/js/util/uri.js
# client/js/util/views.js
# client/js/views/post_main_view.js
# client/js/views/post_upload_view.js
# client/js/views/posts_header_view.js
# client/js/views/posts_page_view.js
# client/js/views/settings_view.js
# client/js/views/tag_view.js
# client/package-lock.json
# client/package.json
# server/config.yaml.dist
# server/szurubooru/api/__init__.py
# server/szurubooru/api/post_api.py
# server/szurubooru/api/tag_api.py
# server/szurubooru/func/posts.py
# server/szurubooru/func/tags.py
# server/szurubooru/model/__init__.py
# server/szurubooru/model/post.py
# server/szurubooru/model/tag.py
# server/szurubooru/search/configs/__init__.py
# server/szurubooru/search/configs/post_search_config.py
# server/szurubooru/search/executor.py
# server/szurubooru/tests/api/test_post_retrieving.py
# server/szurubooru/tests/api/test_post_updating.py
# server/szurubooru/tests/api/test_tag_updating.py
# server/szurubooru/tests/conftest.py
# server/szurubooru/tests/func/test_posts.py
# server/szurubooru/tests/func/test_tags.py
# server/szurubooru/tests/search/configs/test_post_search_config.py
Diffstat (limited to 'server/szurubooru/tests/func/test_auth.py')
| -rw-r--r-- | server/szurubooru/tests/func/test_auth.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/server/szurubooru/tests/func/test_auth.py b/server/szurubooru/tests/func/test_auth.py index 6dc79bb..2141d3c 100644 --- a/server/szurubooru/tests/func/test_auth.py +++ b/server/szurubooru/tests/func/test_auth.py @@ -1,41 +1,44 @@ from datetime import datetime, timedelta + import pytest + from szurubooru.func import auth @pytest.fixture(autouse=True) def inject_config(config_injector): - config_injector({'secret': 'testSecret'}) + config_injector({"secret": "testSecret"}) def test_get_password_hash(): - salt, password = ('testSalt', 'pass') + salt, password = ("testSalt", "pass") result, revision = auth.get_password_hash(salt, password) assert result assert revision == 3 hash_parts = list( - filter(lambda e: e is not None and e != '', result.split('$'))) + filter(lambda e: e is not None and e != "", result.split("$")) + ) assert len(hash_parts) == 5 - assert hash_parts[0] == 'argon2id' + assert hash_parts[0] == "argon2id" def test_get_sha256_legacy_password_hash(): - salt, password = ('testSalt', 'pass') + salt, password = ("testSalt", "pass") result, revision = auth.get_sha256_legacy_password_hash(salt, password) - hash = '2031ac9631353ac9303719a7f808a24f79aa1d71712c98523e4bb4cce579428a' + hash = "2031ac9631353ac9303719a7f808a24f79aa1d71712c98523e4bb4cce579428a" assert result == hash assert revision == 2 def test_get_sha1_legacy_password_hash(): - salt, password = ('testSalt', 'pass') + salt, password = ("testSalt", "pass") result, revision = auth.get_sha1_legacy_password_hash(salt, password) - assert result == '1eb1f953d9be303a1b54627e903e6124cfb1245b' + assert result == "1eb1f953d9be303a1b54627e903e6124cfb1245b" assert revision == 1 def test_is_valid_password_auto_upgrades_user_password_hash(user_factory): - salt, password = ('testSalt', 'pass') + salt, password = ("testSalt", "pass") hash, revision = auth.get_sha256_legacy_password_hash(salt, password) user = user_factory(password_salt=salt, password_hash=hash) result = auth.is_valid_password(user, password) @@ -50,7 +53,7 @@ def test_is_valid_token(user_token_factory): def test_expired_token_is_invalid(user_token_factory): - past_expiration = (datetime.utcnow() - timedelta(minutes=30)) + past_expiration = datetime.utcnow() - timedelta(minutes=30) user_token = user_token_factory(expiration_time=past_expiration) assert not auth.is_valid_token(user_token) |