@@ -253,7 +253,7 @@ describe('defineAuthorizedWorkspaceUseCase', () => {
253253 ] )
254254 } )
255255
256- it ( 'fails fast when the operation and resource authorization hook disagree ' , async ( ) => {
256+ it ( 'requires policy-bound operations to define resource authorization' , async ( ) => {
257257 const execute = vi . fn ( async ( ) => ( { ok : true as const } ) )
258258 expect ( ( ) =>
259259 defineAuthorizedWorkspaceUseCase ( {
@@ -265,19 +265,33 @@ describe('defineAuthorizedWorkspaceUseCase', () => {
265265 } )
266266 ) . toThrow ( 'Operation test.resource_policy requires resource policy authorization' )
267267
268- expect ( ( ) =>
269- defineAuthorizedWorkspaceUseCase ( {
270- operation,
271- resolveContext : async ( _args : { principal : SessionPrincipal ; input : TestInput } ) =>
272- canonicalContext ,
273- authorizationOptions : { } ,
274- authorizeResource ( ) { } ,
275- execute,
276- } )
277- ) . toThrow ( 'Operation test.rename does not declare a resource policy binding' )
278268 expect ( execute ) . not . toHaveBeenCalled ( )
279269 } )
280270
271+ it ( 'keeps non-policy resource authorization available to ordinary operations' , async ( ) => {
272+ const authorizeResource = vi . fn ( )
273+ const useCase = defineAuthorizedWorkspaceUseCase ( {
274+ operation,
275+ resolveContext : async ( _args : { principal : SessionPrincipal ; input : TestInput } ) =>
276+ canonicalContext ,
277+ authorizationOptions : { } ,
278+ authorizeResource,
279+ async execute ( ) {
280+ return { ok : true as const }
281+ } ,
282+ } )
283+
284+ await expect (
285+ useCase . execute ( {
286+ principal : sessionPrincipal ,
287+ input : { resourceId : 'resource-1' } ,
288+ } )
289+ ) . resolves . toEqual ( { ok : true } )
290+ expect ( authorizeResource ) . toHaveBeenCalledWith (
291+ expect . objectContaining ( { context : canonicalContext } )
292+ )
293+ } )
294+
281295 it ( 'supports zero or many semantic audit entries' , async ( ) => {
282296 const buildUseCase = ( auditCount : number ) =>
283297 defineAuthorizedWorkspaceUseCase ( {
0 commit comments