From d8e6801f881a88c1dc464531391bf9be685d48c1 Mon Sep 17 00:00:00 2001 From: Rahul Johny Date: Wed, 4 Nov 2026 12:19:37 +0530 Subject: [PATCH 1/2] test: accept masked webhook auth_token in GET assertions (LW-481) GET /whisper-manage-callback now returns a stored, non-empty auth_token as "********" (an empty one stays ""). Accept either the raw token or the mask until the change is deployed everywhere; an empty token must still read back as "". Co-Authored-By: Claude Opus 5.5 --- tests/integration/client_v2_test.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/integration/client_v2_test.py b/tests/integration/client_v2_test.py index eed84b9..6ccbdf5 100644 --- a/tests/integration/client_v2_test.py +++ b/tests/integration/client_v2_test.py @@ -17,6 +17,8 @@ PERCENTAGE_TOLERANCE = 0.05 PAGE_HEIGHT_TOLERANCE = 5 OCR_SIMILARITY_THRESHOLD = 0.90 +# What the service returns in place of a stored, non-empty webhook auth_token +WEBHOOK_AUTH_TOKEN_MASK = "********" def test_get_usage_info(client_v2: LLMWhispererClientV2) -> None: @@ -221,7 +223,7 @@ def test_webhook(client_v2: LLMWhispererClientV2, url: str, token: str, webhook_ result = client_v2.get_webhook_details(webhook_name) assert isinstance(result, dict) assert result["url"] == url - assert result["auth_token"] == token + assert_webhook_auth_token(result["auth_token"], token) assert result["webhook_name"] == webhook_name result = client_v2.update_webhook_details(webhook_name, url, "new_token") @@ -230,7 +232,7 @@ def test_webhook(client_v2: LLMWhispererClientV2, url: str, token: str, webhook_ result = client_v2.get_webhook_details(webhook_name) assert isinstance(result, dict) - assert result["auth_token"] == "new_token" + assert_webhook_auth_token(result["auth_token"], "new_token") result = client_v2.delete_webhook(webhook_name) assert isinstance(result, dict) @@ -306,6 +308,18 @@ def test_whisper_line_splitter_strategy_reaches_service(client_v2: LLMWhispererC assert exc_info.value.error_message()["status_code"] == 400 # type: ignore[index] +def assert_webhook_auth_token(returned: str, sent: str) -> None: + """Checks the auth_token read back from a registered webhook. + + The service masks a stored token on read, and an empty token stays empty. + Environments that do not mask yet echo the token, so both are accepted. + """ + if sent: + assert returned in (sent, WEBHOOK_AUTH_TOKEN_MASK) + else: + assert returned == "" + + def assert_error_message(whisper_result: dict) -> None: assert isinstance(whisper_result, dict) assert whisper_result["status"] == "error" From ff1c857f2fb83ab1bc7ad3ef5e7501a368edb94b Mon Sep 17 00:00:00 2001 From: Rahul Johny Date: Wed, 4 Nov 2026 12:37:38 +0530 Subject: [PATCH 2/2] test: expect the last 4 characters in a masked webhook auth_token (LW-481) The service now shows a token longer than 4 characters as "********" plus its last 4 characters, a shorter one as "********", and an empty one as "". Compute that exact masked form and accept it or the raw token. Co-Authored-By: Claude Opus 5.5 --- tests/integration/client_v2_test.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/integration/client_v2_test.py b/tests/integration/client_v2_test.py index 6ccbdf5..2f3f50f 100644 --- a/tests/integration/client_v2_test.py +++ b/tests/integration/client_v2_test.py @@ -17,8 +17,11 @@ PERCENTAGE_TOLERANCE = 0.05 PAGE_HEIGHT_TOLERANCE = 5 OCR_SIMILARITY_THRESHOLD = 0.90 -# What the service returns in place of a stored, non-empty webhook auth_token +# What the service returns in place of a stored, non-empty webhook auth_token. +# A token longer than WEBHOOK_AUTH_TOKEN_VISIBLE_CHARS characters also shows its +# last WEBHOOK_AUTH_TOKEN_VISIBLE_CHARS characters after the mask. WEBHOOK_AUTH_TOKEN_MASK = "********" +WEBHOOK_AUTH_TOKEN_VISIBLE_CHARS = 4 def test_get_usage_info(client_v2: LLMWhispererClientV2) -> None: @@ -308,16 +311,22 @@ def test_whisper_line_splitter_strategy_reaches_service(client_v2: LLMWhispererC assert exc_info.value.error_message()["status_code"] == 400 # type: ignore[index] +def masked_webhook_auth_token(token: str) -> str: + """Returns the auth_token as the service shows it on read.""" + if not token: + return "" + if len(token) <= WEBHOOK_AUTH_TOKEN_VISIBLE_CHARS: + return WEBHOOK_AUTH_TOKEN_MASK + return WEBHOOK_AUTH_TOKEN_MASK + token[-WEBHOOK_AUTH_TOKEN_VISIBLE_CHARS:] + + def assert_webhook_auth_token(returned: str, sent: str) -> None: """Checks the auth_token read back from a registered webhook. The service masks a stored token on read, and an empty token stays empty. Environments that do not mask yet echo the token, so both are accepted. """ - if sent: - assert returned in (sent, WEBHOOK_AUTH_TOKEN_MASK) - else: - assert returned == "" + assert returned in (sent, masked_webhook_auth_token(sent)) def assert_error_message(whisper_result: dict) -> None: