Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions claude-code/hooks/test_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,13 @@ def test_returns_full_identity(self):
def test_keys_limited_to_identity_fields(self):
self._write_config({})
result = unbound.build_account_identity()
self.assertEqual(
set(result.keys()), {"org_id", "plan", "auth_mode", "email_domain"}
# Identity may also carry the full user_email and (env-dependent) the
# device_serial. Assert no key OUTSIDE the known identity fields leaks,
# rather than an exact set tied to optional fields.
self.assertLessEqual(
set(result.keys()),
{"org_id", "plan", "auth_mode", "email_domain",
"user_email", "device_serial"},
)
Comment on lines +239 to 243

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Subset assertion is correct but has no lower-bound check

assertLessEqual only verifies that no unexpected key leaks out; it doesn't assert that the core required fields (org_id, plan, auth_mode, email_domain) are always present in the result. If build_account_identity were changed to drop one of those keys silently, this test would still pass. The parallel test test_returns_full_identity does check specific keys, but it relies on a non-empty oauth config — this empty-config variant exercises the fallback path with all-None values and would benefit from also asserting the required keys are at least present as keys (even if their values are None).

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!



Expand Down