@@ -38,6 +38,7 @@ vi.mock('@/lib/workspaces/utils', () => ({
3838vi . mock ( '@sim/workflow-authz' , ( ) => ( {
3939 getActiveWorkflowRecord : vi . fn ( ) . mockResolvedValue ( {
4040 id : 'workflow-1' ,
41+ userId : 'creator-1' ,
4142 workspaceId : 'workspace-1' ,
4243 isDeployed : true ,
4344 } ) ,
@@ -197,19 +198,23 @@ describe('preprocessExecution ban gate', () => {
197198 expect ( checkServerSideUsageLimits ) . not . toHaveBeenCalled ( )
198199 } )
199200
200- it ( 'checks the billing actor and the caller-provided userId in one call' , async ( ) => {
201+ it ( 'checks the billing actor, caller-provided userId, and workflow owner in one call' , async ( ) => {
201202 const result = await preprocessExecution ( baseOptions )
202203
203204 expect ( result . success ) . toBe ( true )
204205 expect ( mockGetActivelyBannedUserIds ) . toHaveBeenCalledTimes ( 1 )
205- expect ( mockGetActivelyBannedUserIds ) . toHaveBeenCalledWith ( [ 'billed-account-1' , 'owner-1' ] )
206+ expect ( mockGetActivelyBannedUserIds ) . toHaveBeenCalledWith ( [
207+ 'billed-account-1' ,
208+ 'owner-1' ,
209+ 'creator-1' ,
210+ ] )
206211 } )
207212
208- it ( 'excludes the "unknown" sentinel userId from the ban check ' , async ( ) => {
213+ it ( 'excludes the "unknown" sentinel userId but still checks the workflow owner ' , async ( ) => {
209214 const result = await preprocessExecution ( { ...baseOptions , userId : 'unknown' } )
210215
211216 expect ( result . success ) . toBe ( true )
212- expect ( mockGetActivelyBannedUserIds ) . toHaveBeenCalledWith ( [ 'billed-account-1' ] )
217+ expect ( mockGetActivelyBannedUserIds ) . toHaveBeenCalledWith ( [ 'billed-account-1' , 'creator-1' ] )
213218 } )
214219
215220 it ( 'fails closed with 500 when the ban check errors' , async ( ) => {
0 commit comments