From 6a228725eecc265f59bc874ad9f3acfad92e5176 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Tue, 28 Nov 2023 05:29:19 -0800 Subject: [PATCH 1/2] Add missing asserts in test_sticky_identity --- tiled/_tests/test_authentication.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tiled/_tests/test_authentication.py b/tiled/_tests/test_authentication.py index e49e41a8c..f49d92c10 100644 --- a/tiled/_tests/test_authentication.py +++ b/tiled/_tests/test_authentication.py @@ -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". 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 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 From dbbe55e772df459065f6f2f2b2761cc9b60b75fa Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Tue, 28 Nov 2023 05:38:41 -0800 Subject: [PATCH 2/2] Fix assertion logic when testing: opt out of the stickiness --- tiled/_tests/test_authentication.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiled/_tests/test_authentication.py b/tiled/_tests/test_authentication.py index f49d92c10..50a79b8b0 100644 --- a/tiled/_tests/test_authentication.py +++ b/tiled/_tests/test_authentication.py @@ -466,14 +466,14 @@ def test_sticky_identity(enter_password, config): 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: 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: - assert 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"