@@ -607,27 +607,38 @@ describe('McpService best-effort discovery', () => {
607607 expectNoSharedStateWrites ( )
608608 } )
609609
610- it ( 'connects an authorized OAuth server with a grant-preserving provider and writes nothing when it is rejected' , async ( ) => {
611- mockGetWorkspaceServersRows . mockResolvedValue ( [ dbRow ( 'mcp-a' , 'A' , { authType : 'oauth' } ) ] )
612- mcpOauthMockFns . mockHasDecryptableOauthTokens . mockResolvedValue ( true )
613- mcpOauthMockFns . mockGetOrCreateOauthRow . mockResolvedValue ( {
614- id : 'oauth-row-1' ,
615- tokens : { access_token : 'expired' , token_type : 'bearer' } ,
616- } )
617- mockListTools . mockRejectedValueOnce ( new UnauthorizedError ( 'refresh rejected' ) )
618- MockMcpClient . mockClear ( )
619-
620- await expect (
621- mcpService . discoverServerTools ( MEMBER_B , 'mcp-a' , WORKSPACE_ID , 'cache-aside' , undefined , {
622- bestEffort : true ,
610+ it . each ( [
611+ [ 'a best-effort' , { bestEffort : true } ] ,
612+ [ 'a read-only' , { readOnly : true } ] ,
613+ ] ) (
614+ 'connects an authorized OAuth server in %s discovery with a grant-preserving provider and writes nothing when it is rejected' ,
615+ async ( _kind , options ) => {
616+ mockGetWorkspaceServersRows . mockResolvedValue ( [ dbRow ( 'mcp-a' , 'A' , { authType : 'oauth' } ) ] )
617+ mcpOauthMockFns . mockHasDecryptableOauthTokens . mockResolvedValue ( true )
618+ mcpOauthMockFns . mockGetOrCreateOauthRow . mockResolvedValue ( {
619+ id : 'oauth-row-1' ,
620+ tokens : { access_token : 'expired' , token_type : 'bearer' } ,
623621 } )
624- ) . rejects . toThrow ( 'refresh rejected' )
622+ mockListTools . mockRejectedValueOnce ( new UnauthorizedError ( 'refresh rejected' ) )
623+ MockMcpClient . mockClear ( )
625624
626- expect ( MockMcpClient . mock . calls [ 0 ] ?. [ 0 ] ) . toMatchObject ( {
627- oauthCredentials : { initialProvider : { preserveGrant : true } } ,
628- } )
629- expectNoSharedStateWrites ( )
630- } )
625+ await expect (
626+ mcpService . discoverServerTools (
627+ MEMBER_B ,
628+ 'mcp-a' ,
629+ WORKSPACE_ID ,
630+ 'cache-aside' ,
631+ undefined ,
632+ options
633+ )
634+ ) . rejects . toThrow ( 'refresh rejected' )
635+
636+ expect ( MockMcpClient . mock . calls [ 0 ] ?. [ 0 ] ) . toMatchObject ( {
637+ oauthCredentials : { initialProvider : { preserveGrant : true } } ,
638+ } )
639+ expectNoSharedStateWrites ( )
640+ }
641+ )
631642
632643 it ( 'warms the shared tool cache on success without stamping status' , async ( ) => {
633644 mockGetWorkspaceServersRows . mockResolvedValue ( [ dbRow ( 'mcp-a' , 'A' ) ] )
0 commit comments