mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-29 13:49:57 +00:00
OAuth2 (#32)
* make auth method asyncs * oauth2 demo support * full coverage * update docs
This commit is contained in:
@ -21,6 +21,10 @@ def test_from_option_valid() -> None:
|
||||
assert AuthSettings.from_option("no") == AuthSettings.Disabled
|
||||
assert AuthSettings.from_option("NO") == AuthSettings.Disabled
|
||||
|
||||
assert AuthSettings.from_option("oauth") == AuthSettings.OAuth
|
||||
assert AuthSettings.from_option("OAuth") == AuthSettings.OAuth
|
||||
assert AuthSettings.from_option("OAuth2") == AuthSettings.OAuth
|
||||
|
||||
assert AuthSettings.from_option("configuration") == AuthSettings.Configuration
|
||||
assert AuthSettings.from_option("ConFigUration") == AuthSettings.Configuration
|
||||
assert AuthSettings.from_option("mapping") == AuthSettings.Configuration
|
||||
|
@ -10,6 +10,7 @@ def test_from_option(user: User) -> None:
|
||||
# default is read access
|
||||
user.access = UserAccess.Write
|
||||
assert User.from_option(user.username, user.password) != user
|
||||
assert User.from_option(user.username, user.password, user.access) == user
|
||||
|
||||
|
||||
def test_from_option_empty() -> None:
|
||||
@ -32,6 +33,26 @@ def test_check_credentials_hash_password(user: User) -> None:
|
||||
assert not user.check_credentials(user.password, "salt")
|
||||
|
||||
|
||||
def test_check_credentials_empty_hash(user: User) -> None:
|
||||
"""
|
||||
must reject any authorization if the hash is invalid
|
||||
"""
|
||||
current_password = user.password
|
||||
assert not user.check_credentials(current_password, "salt")
|
||||
user.password = ""
|
||||
assert not user.check_credentials(current_password, "salt")
|
||||
|
||||
|
||||
def test_hash_password_empty_hash(user: User) -> None:
|
||||
"""
|
||||
must return empty string after hash in case if password not set
|
||||
"""
|
||||
user.password = ""
|
||||
assert user.hash_password("salt") == ""
|
||||
user.password = None
|
||||
assert user.hash_password("salt") == ""
|
||||
|
||||
|
||||
def test_generate_password() -> None:
|
||||
"""
|
||||
must generate password with specified length
|
||||
|
Reference in New Issue
Block a user