From 6138ff09975cefc7a3a5d44b8dd23f9986a4b7c7 Mon Sep 17 00:00:00 2001 From: Ejiro Asiuwhu Date: Wed, 25 Mar 2026 07:50:42 +0100 Subject: [PATCH] test: add failing tests for publishable_client_key and token store defaults - Test publishable_client_key header included/omitted in _build_headers - Test ExplicitTokenStore defaults to None without arguments - Test resolve_token_store dict branch defaults missing keys to None - Test StackServerApp/AsyncStackServerApp accept publishable_client_key --- sdks/implementations/python/tests/test_app.py | 8 ++++++++ sdks/implementations/python/tests/test_client.py | 10 ++++++++++ sdks/implementations/python/tests/test_token_store.py | 11 +++++++++++ 3 files changed, 29 insertions(+) diff --git a/sdks/implementations/python/tests/test_app.py b/sdks/implementations/python/tests/test_app.py index 3c789bb75..407d04975 100644 --- a/sdks/implementations/python/tests/test_app.py +++ b/sdks/implementations/python/tests/test_app.py @@ -64,6 +64,14 @@ class TestStackServerAppConstruction: ) assert app is not None + def test_constructs_with_publishable_client_key(self) -> None: + app = StackServerApp(project_id="proj", secret_server_key="sk", publishable_client_key="pk_test") + assert app is not None + + def test_async_constructs_with_publishable_client_key(self) -> None: + app = AsyncStackServerApp(project_id="proj", secret_server_key="sk", publishable_client_key="pk_test") + assert app is not None + def test_context_manager(self) -> None: with StackServerApp(project_id="proj", secret_server_key="sk") as app: assert app is not None diff --git a/sdks/implementations/python/tests/test_client.py b/sdks/implementations/python/tests/test_client.py index 7349d389e..cf87e72e0 100644 --- a/sdks/implementations/python/tests/test_client.py +++ b/sdks/implementations/python/tests/test_client.py @@ -71,6 +71,16 @@ class TestBuildHeaders: ) assert uuid_pattern.match(nonce), f"Nonce {nonce!r} is not a valid UUID v4" + def test_publishable_client_key_header_included(self) -> None: + client = SyncAPIClient(project_id="proj_123", secret_server_key="sk_secret", publishable_client_key="pk_test") + headers = client._build_headers() + assert headers["x-stack-publishable-client-key"] == "pk_test" + + def test_publishable_client_key_header_omitted_when_none(self) -> None: + client = SyncAPIClient(project_id="proj_123", secret_server_key="sk_secret") + headers = client._build_headers() + assert "x-stack-publishable-client-key" not in headers + # --------------------------------------------------------------------------- # URL building tests diff --git a/sdks/implementations/python/tests/test_token_store.py b/sdks/implementations/python/tests/test_token_store.py index 363459b8b..dfa566f9c 100644 --- a/sdks/implementations/python/tests/test_token_store.py +++ b/sdks/implementations/python/tests/test_token_store.py @@ -138,6 +138,17 @@ class TestExplicitTokenStore: assert store.get_stored_access_token() == "at_1" assert store.get_stored_refresh_token() == "rt_1" + def test_defaults_to_none_without_arguments(self) -> None: + store = ExplicitTokenStore() + assert store.get_stored_access_token() is None + assert store.get_stored_refresh_token() is None + + def test_partial_dict_defaults_missing_to_none(self) -> None: + store = resolve_token_store({"access_token": "at"}, "proj") + assert isinstance(store, ExplicitTokenStore) + assert store.get_stored_access_token() == "at" + assert store.get_stored_refresh_token() is None + # --------------------------------------------------------------------------- # RequestTokenStore