aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/tests/func/test_auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/szurubooru/tests/func/test_auth.py')
-rw-r--r--server/szurubooru/tests/func/test_auth.py23
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)

© 2015 - 2026 Jakob L. Kreuze