| 39 | |
| 40 | // Helper for fully-confirmed Claude Code CLI sessions (all 4 signals) |
| 41 | function createClaudeCodeSession( |
| 42 | userAgent: string, |
| 43 | allowedClients: string[] = [], |
| 44 | blockedClients: string[] = [], |
| 45 | betaHeader = "claude-code-test", |
| 46 | metadataUserId = LEGACY_METADATA_USER_ID |
| 47 | ): ProxySession { |
| 48 | const headers = new Headers(); |
| 49 | headers.set("x-app", "cli"); |
| 50 | headers.set("anthropic-beta", betaHeader); |
| 51 | return { |
| 52 | userAgent, |
| 53 | headers, |
| 54 | request: { message: { metadata: { user_id: metadataUserId } } }, |
| 55 | authState: { |
| 56 | user: { allowedClients, blockedClients }, |
| 57 | }, |
| 58 | } as unknown as ProxySession; |
| 59 | } |
| 60 | |
| 61 | describe("ProxyClientGuard", () => { |
| 62 | describe("when authState is missing", () => { |