| 139 | } |
| 140 | |
| 141 | function makeServiceOauthSession(scopes: string[]): ResolvedAuthSession { |
| 142 | return { |
| 143 | principalKind: 'service_principal', |
| 144 | principalSource: 'service_oauth_env', |
| 145 | sessionState: 'usable', |
| 146 | headersKind: 'bearer', |
| 147 | providerAuthKind: 'noumena_first_party', |
| 148 | providerPlan: { |
| 149 | mode: 'noumena_managed', |
| 150 | source: 'service_credential', |
| 151 | staticKeyEnvVarName: null, |
| 152 | }, |
| 153 | isInteractive: true, |
| 154 | canRefresh: false, |
| 155 | canReauthenticateInteractively: false, |
| 156 | identity: { |
| 157 | email: null, |
| 158 | accountUuid: null, |
| 159 | organizationUuid: null, |
| 160 | organizationName: null, |
| 161 | }, |
| 162 | subscription: { |
| 163 | subscriptionName: null, |
| 164 | subscriptionType: null, |
| 165 | rateLimitTier: null, |
| 166 | }, |
| 167 | scopes, |
| 168 | hasUsableToken: true, |
| 169 | hasUsableApiKey: false, |
| 170 | accessToken: 'service-token', |
| 171 | accessTokenExpiresAt: Date.now() + 10 * 60 * 1_000, |
| 172 | refreshTokenPresent: false, |
| 173 | apiKey: null, |
| 174 | rawAuthTokenSource: 'CLAUDE_CODE_OAUTH_TOKEN', |
| 175 | rawApiKeySource: null, |
| 176 | recoveryAction: 'none', |
| 177 | recoveryMessage: null, |
| 178 | sourceDetails: { |
| 179 | usedLegacyCompat: false, |
| 180 | usedEnvVar: true, |
| 181 | usedFileDescriptor: false, |
| 182 | usedHelper: false, |
| 183 | }, |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | async function withMockCurrentSession<T>( |
| 188 | session: ResolvedAuthSession, |