@@ -2,6 +2,10 @@ import {
22 billingAttributionMock ,
33 billingAttributionMockFns ,
44} from '@sim/testing/mocks/billing-attribution.mock'
5+ import {
6+ internalAwsCredentialsMock ,
7+ internalAwsCredentialsMockFns ,
8+ } from '@sim/testing/mocks/internal-aws-credentials.mock'
59import {
610 mothershipEnvironmentContextMock ,
711 mothershipEnvironmentContextMockFns ,
@@ -16,7 +20,6 @@ const mocks = vi.hoisted(() => ({
1620 importProvenance : vi . fn ( ) ,
1721 isComplete : vi . fn ( ) ,
1822 resolveVertexAccessToken : vi . fn ( ) ,
19- resolveAuthorizedAwsCredential : vi . fn ( ) ,
2023} ) )
2124
2225vi . mock ( '@/providers' , ( ) => providersMock )
@@ -28,9 +31,7 @@ vi.mock('@/lib/mothership/environment-context', () => mothershipEnvironmentConte
2831vi . mock ( '@/lib/internal/llm/credentials' , ( ) => ( {
2932 resolveVertexAccessToken : mocks . resolveVertexAccessToken ,
3033} ) )
31- vi . mock ( '@/lib/internal/aws/credentials' , ( ) => ( {
32- resolveAuthorizedAwsCredential : mocks . resolveAuthorizedAwsCredential ,
33- } ) )
34+ vi . mock ( '@/lib/internal/aws/credentials' , ( ) => internalAwsCredentialsMock )
3435vi . mock ( '@/lib/oauth/token-resolution' , ( ) => ( { recordCredentialAccess : vi . fn ( ) } ) )
3536vi . mock ( '@/lib/workspaces/permissions/utils' , ( ) => permissionsMock )
3637vi . mock ( '@/executor/utils/resolved-secret-content-projection' , ( ) => ( {
@@ -39,6 +40,7 @@ vi.mock('@/executor/utils/resolved-secret-content-projection', () => ({
3940vi . mock ( '@/ee/access-control/utils/permission-check' , ( ) => permissionCheckMock )
4041
4142const { mockRequireBillingAttributionHeader } = billingAttributionMockFns
43+ const { mockResolveAuthorizedAwsCredential } = internalAwsCredentialsMockFns
4244
4345import type { LlmOperationError } from '@/lib/internal/llm/errors'
4446import { executeLlmProviderOperation } from '@/lib/internal/llm/operations'
@@ -132,7 +134,7 @@ describe('executeLlmProviderOperation', () => {
132134
133135 it ( "signs a Bedrock call with the selected AWS credential's session for the caller" , async ( ) => {
134136 mocks . authorizeCredential . mockResolvedValueOnce ( AUTHORIZED_AWS_CREDENTIAL )
135- mocks . resolveAuthorizedAwsCredential . mockResolvedValueOnce ( {
137+ mockResolveAuthorizedAwsCredential . mockResolvedValueOnce ( {
136138 accessKeyId : 'ASIASESSIONKEY000001' ,
137139 secretAccessKey : 'session-secret' ,
138140 sessionToken : 'session-token' ,
@@ -148,7 +150,7 @@ describe('executeLlmProviderOperation', () => {
148150 }
149151 )
150152
151- expect ( mocks . resolveAuthorizedAwsCredential ) . toHaveBeenCalledWith (
153+ expect ( mockResolveAuthorizedAwsCredential ) . toHaveBeenCalledWith (
152154 'aws-cred' ,
153155 { workspaceId : 'workspace-1' , executionId : 'execution-1' } ,
154156 undefined
@@ -199,7 +201,7 @@ describe('executeLlmProviderOperation', () => {
199201 it ( 'fails a Bedrock call whose AWS credential cannot be resolved before provider work' , async ( ) => {
200202 mockExecuteProviderRequest . mockClear ( )
201203 mocks . authorizeCredential . mockResolvedValueOnce ( AUTHORIZED_AWS_CREDENTIAL )
202- mocks . resolveAuthorizedAwsCredential . mockRejectedValueOnce ( new Error ( 'AccessDenied' ) )
204+ mockResolveAuthorizedAwsCredential . mockRejectedValueOnce ( new Error ( 'AccessDenied' ) )
203205
204206 await expect (
205207 executeLlmProviderOperation ( BEDROCK_CREDENTIAL_INPUT , {
@@ -217,7 +219,7 @@ describe('executeLlmProviderOperation', () => {
217219 it ( 'reports an AWS credential STS could not resolve for a moment as unavailable, not invalid' , async ( ) => {
218220 mockExecuteProviderRequest . mockClear ( )
219221 mocks . authorizeCredential . mockResolvedValueOnce ( AUTHORIZED_AWS_CREDENTIAL )
220- mocks . resolveAuthorizedAwsCredential . mockRejectedValueOnce (
222+ mockResolveAuthorizedAwsCredential . mockRejectedValueOnce (
221223 Object . assign ( new Error ( 'Rate exceeded' ) , {
222224 name : 'ThrottlingException' ,
223225 $metadata : { httpStatusCode : 400 } ,
0 commit comments