@@ -26,6 +26,7 @@ import {
2626 customBlockOperationsMockFns ,
2727} from '@sim/testing/mocks/custom-block-operations.mock'
2828import { resetEnvFlagsMock , setEnvFlags } from '@sim/testing/mocks/env-flags.mock'
29+ import { environmentUtilsMockFns } from '@sim/testing/mocks/environment-utils.mock'
2930import {
3031 integrationsAvailabilityMock ,
3132 integrationsAvailabilityMockFns ,
@@ -253,6 +254,7 @@ describe('executeToolForCaller', () => {
253254 mocks . executeRegistryTool . mockResolvedValue ( { success : true , output : { markdown : '# Hi' } } )
254255 mocks . resolveBillingAttribution . mockResolvedValue ( { workspaceId : WORKSPACE_ID } )
255256 mocks . checkUsageLimits . mockResolvedValue ( { isExceeded : false } )
257+ environmentUtilsMockFns . mockGetEffectiveDecryptedEnv . mockResolvedValue ( { } )
256258 } )
257259
258260 it . each < PersonalApiKeyPrincipal | SessionPrincipal > ( [ principal , createSessionPrincipal ( ) ] ) (
@@ -512,23 +514,31 @@ describe('executeToolForCaller', () => {
512514 it . each ( [
513515 [ 'the key is omitted' , { input : { url : 'https://a.co' } } ] ,
514516 [
515- 'the key is a variable reference that may resolve empty' ,
517+ 'the key references an empty variable ' ,
516518 { input : { url : 'https://a.co' , apiKey : '{{FIRECRAWL_KEY}}' } } ,
517519 ] ,
518520 ] ) ( 'refuses a hosted-key call over the usage limit when %s' , async ( _case , input ) => {
519521 mocks . checkUsageLimits . mockResolvedValue ( { isExceeded : true , message : 'Usage limit exceeded' } )
522+ environmentUtilsMockFns . mockGetEffectiveDecryptedEnv . mockResolvedValue ( { FIRECRAWL_KEY : ' ' } )
520523
521524 await expect ( run ( input ) ) . rejects . toBeInstanceOf ( ToolUsageLimitExceededError )
522525 } )
523526
524527 it . each ( [
525528 [ 'the caller brings their own key' , { input : { url : 'https://a.co' , apiKey : 'sk-own' } } ] ,
529+ [
530+ 'the caller references a variable holding their own key' ,
531+ { input : { url : 'https://a.co' , apiKey : '{{FIRECRAWL_KEY}}' } } ,
532+ ] ,
526533 [
527534 'the tool has no hosted key' ,
528535 { toolId : 'zendesk_get_ticket' , input : { ticketId : '4' , subdomain : 'a' , apiToken : 't' } } ,
529536 ] ,
530537 ] ) ( 'does not gate on usage when %s' , async ( _case , input ) => {
531538 mocks . checkUsageLimits . mockResolvedValue ( { isExceeded : true , message : 'Usage limit exceeded' } )
539+ environmentUtilsMockFns . mockGetEffectiveDecryptedEnv . mockResolvedValue ( {
540+ FIRECRAWL_KEY : 'fc-own' ,
541+ } )
532542
533543 await expect ( run ( input ) ) . resolves . toMatchObject ( { status : 'succeeded' } )
534544 } )
0 commit comments