@@ -4,18 +4,9 @@ import { providersUtilsMock, providersUtilsMockFns } from '@sim/testing/mocks/pr
44import { beforeEach , describe , expect , it , vi } from 'vitest'
55import type { BillingAttributionSnapshot } from '@/lib/billing/core/attribution'
66
7- const {
8- mockSearchKnowledgeAsExecutor,
9- mockResolveVertexAccessToken,
10- mockResolveBedrockCredentialSession,
11- } = vi . hoisted ( ( ) => ( {
7+ const { mockSearchKnowledgeAsExecutor, mockResolveVertexAccessToken } = vi . hoisted ( ( ) => ( {
128 mockSearchKnowledgeAsExecutor : vi . fn ( ) ,
139 mockResolveVertexAccessToken : vi . fn ( ) ,
14- mockResolveBedrockCredentialSession : vi . fn ( ) ,
15- } ) )
16-
17- vi . mock ( '@/lib/internal/llm/bedrock-credential' , ( ) => ( {
18- resolveBedrockCredentialSession : mockResolveBedrockCredentialSession ,
1910} ) )
2011
2112vi . mock ( '@/lib/internal/llm/credentials' , ( ) => ( {
@@ -232,58 +223,6 @@ describe('validateHallucination', () => {
232223 } )
233224 } )
234225
235- describe ( 'with a Bedrock model and a saved AWS credential' , ( ) => {
236- const bedrockInput = ( registry : ResolvedSecretTraceRegistry ) => ( {
237- ...createInput ( registry ) ,
238- model : 'bedrock/claude' ,
239- providerCredentials : { bedrockCredential : 'aws-cred' , bedrockRegion : 'eu-west-1' } ,
240- } )
241-
242- beforeEach ( ( ) => {
243- mockResolveBedrockCredentialSession . mockReset ( )
244- } )
245-
246- it ( "scores with the credential's session resolved for the acting user" , async ( ) => {
247- providersUtilsMockFns . mockGetProviderFromModel . mockReturnValue ( 'bedrock' )
248- const session = {
249- credentialId : 'aws-cred' ,
250- accessKeyId : 'ASIASESSIONKEY000001' ,
251- secretAccessKey : 'session-secret' ,
252- sessionToken : 'session-token' ,
253- }
254- mockResolveBedrockCredentialSession . mockResolvedValueOnce ( session )
255-
256- const result = await validateHallucination ( bedrockInput ( new ResolvedSecretTraceRegistry ( ) ) )
257-
258- expect ( result . error ) . toBeUndefined ( )
259- expect ( result ) . toMatchObject ( { passed : true , score : 8 } )
260- expect ( mockResolveBedrockCredentialSession ) . toHaveBeenCalledWith (
261- expect . objectContaining ( {
262- credentialId : 'aws-cred' ,
263- actingUserId : 'user-1' ,
264- workflowId : 'workflow-1' ,
265- workspaceId : 'workspace-1' ,
266- } )
267- )
268- expect ( mockExecuteProviderRequest . mock . calls [ 0 ] ?. [ 1 ] ) . toMatchObject ( {
269- bedrockSession : session ,
270- bedrockRegion : 'eu-west-1' ,
271- } )
272- } )
273-
274- it ( 'fails the check instead of calling the model when the credential cannot be used' , async ( ) => {
275- providersUtilsMockFns . mockGetProviderFromModel . mockReturnValue ( 'bedrock' )
276- mockResolveBedrockCredentialSession . mockRejectedValueOnce (
277- new Error ( 'Not authorized to use this AWS credential' )
278- )
279-
280- const result = await validateHallucination ( bedrockInput ( new ResolvedSecretTraceRegistry ( ) ) )
281-
282- expect ( result ) . toMatchObject ( { passed : false } )
283- expect ( mockExecuteProviderRequest ) . not . toHaveBeenCalled ( )
284- } )
285- } )
286-
287226 /**
288227 * Forwarding the caller's signal means the scoring model can now be aborted. A
289228 * cancelled run must not be reported as a guardrail verdict — `passed: false` would
0 commit comments