test(anthropic): scope OAuth-UA source check to header lines, not any mention
The salvaged test_token_exchange_ua_prefix did a naive whole-function substring check for 'claude-cli/', which false-positives on an explanatory comment that references the old (blocked) UA. Scope it to actual User-Agent header lines — mirroring the sibling test_no_claude_cli_in_source — so a comment documenting why claude-cli/ is avoided doesn't trip it. Mutation-checked: an actual claude-cli/ UA header still fails the test.
This commit is contained in:
parent
49e129e495
commit
5efbd7cb05
1 changed files with 10 additions and 3 deletions
|
|
@ -58,9 +58,16 @@ class TestOAuthUserAgentPrefix:
|
|||
except AttributeError:
|
||||
pytest.skip("run_hermes_oauth_login_pure not found")
|
||||
|
||||
assert "claude-cli/" not in source, (
|
||||
"run_hermes_oauth_login_pure still uses claude-cli/ UA"
|
||||
)
|
||||
# Only fail on claude-cli/ in an actual User-Agent header line — a
|
||||
# comment that references the old behavior (e.g. "Anthropic blocks
|
||||
# claude-cli/ on the OAuth endpoint") is allowed. Mirrors the
|
||||
# header-scoped check in test_no_claude_cli_in_source.
|
||||
for i, line in enumerate(source.split("\n"), 1):
|
||||
stripped = line.strip()
|
||||
if "claude-cli/" in stripped and ("User-Agent" in stripped or "user-agent" in stripped):
|
||||
pytest.fail(
|
||||
f"Line {i}: run_hermes_oauth_login_pure still uses claude-cli/ UA header: {stripped}"
|
||||
)
|
||||
assert "claude-code/" in source, (
|
||||
"run_hermes_oauth_login_pure should use claude-code/ UA"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue