From a0cae79b5b09a2e960a3e3f2e01d31bbd3296e15 Mon Sep 17 00:00:00 2001 From: Jeff West Date: Sun, 17 May 2026 08:35:17 -0500 Subject: [PATCH] test(integration): swap bad-auth probe from markets.list to portfolio.balance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit markets.list() no longer exercises the auth path — Kalshi began serving public market data unauthenticated, so a client with bad credentials gets a 200 back instead of 401/403 and the test "DID NOT RAISE". Switched to portfolio.balance(), which is account-scoped and always auth-required. Added a docstring note so future maintainers know why the endpoint choice matters. Closes 1 of 11 integration-test failures (#124). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/integration/test_errors.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_errors.py b/tests/integration/test_errors.py index 4da91c1..a3317e4 100644 --- a/tests/integration/test_errors.py +++ b/tests/integration/test_errors.py @@ -54,6 +54,11 @@ def test_bad_auth_returns_auth_error(self) -> None: Uses a throwaway client with a valid RSA key but wrong key_id, so signing succeeds but the server rejects the credentials. + + Targets ``portfolio.balance()`` because it is account-scoped and + always auth-required. ``markets.list()`` was previously used but + Kalshi began serving public market data unauthenticated, so it + no longer exercises the auth path. """ dummy_key = rsa.generate_private_key( public_exponent=65537, key_size=2048 @@ -68,7 +73,7 @@ def test_bad_auth_returns_auth_error(self) -> None: try: with pytest.raises(KalshiAuthError) as exc_info: - client.markets.list(limit=1) + client.portfolio.balance() exc = exc_info.value assert exc.status_code in (401, 403)