From 3665ffc87d0127b01c7511d04141b4a8432e9fe6 Mon Sep 17 00:00:00 2001 From: Vignesh Subbiah Date: Wed, 17 Jun 2026 14:45:39 -0700 Subject: [PATCH] test: fix stale account-identity key assertion (subset, not exact) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build_account_identity now intentionally carries user_email (read_account_identity pulls it) and, env-dependent, device_serial. test_keys_limited_to_identity_fields asserted an exact 4-key set, so it failed on any machine with a device serial and was inherently flaky. Assert the keys are a SUBSET of the known identity fields instead — preserves the "limited to identity fields" intent (no leak of a non- identity key) without coupling to optional fields. Co-Authored-By: Claude Opus 4.8 (1M context) --- claude-code/hooks/test_identity.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/claude-code/hooks/test_identity.py b/claude-code/hooks/test_identity.py index b900cb65..a6e58bf2 100644 --- a/claude-code/hooks/test_identity.py +++ b/claude-code/hooks/test_identity.py @@ -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"}, )