Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assertions to sticky id authentication tests #611

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tiled/_tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,29 +462,29 @@ def test_session_limit(enter_password, config):
def test_sticky_identity(enter_password, config):
# Log in as Alice.
with Context.from_app(build_app_from_config(config)) as context:
get_default_identity(context.api_uri) is None
assert get_default_identity(context.api_uri) is None
with enter_password("secret1"):
context.authenticate(username="alice")
assert context.whoami()["identities"][0]["id"] == "alice"
# The default identity is now set. The log was "sticky".
# The default identity is now set. The login was "sticky".
with Context.from_app(build_app_from_config(config)) as context:
get_default_identity(context.api_uri) is not None
assert get_default_identity(context.api_uri) is not None
context.authenticate()
assert context.whoami()["identities"][0]["id"] == "alice"
# Opt out of the stickiness (set_default=False).
with Context.from_app(build_app_from_config(config)) as context:
get_default_identity(context.api_uri) is None
assert get_default_identity(context.api_uri) is not None
with enter_password("secret2"):
context.authenticate(username="bob", set_default=False)
assert context.whoami()["identities"][0]["id"] == "bob"
# The default is still Alice.
with Context.from_app(build_app_from_config(config)) as context:
get_default_identity(context.api_uri) is not None
assert get_default_identity(context.api_uri) is not None
context.authenticate()
assert context.whoami()["identities"][0]["id"] == "alice"
# Clear the default.
clear_default_identity(context.api_uri)
get_default_identity(context.api_uri) is None
assert get_default_identity(context.api_uri) is None


@pytest.fixture
Expand Down