@@ -674,7 +674,6 @@ describe('test endpoint routes', () => {
674674 expect ( esSearchMock ) . toHaveBeenCalledTimes ( 1 ) ;
675675 expect ( routeConfig . options ) . toEqual ( {
676676 authRequired : true ,
677- tags : [ 'access:securitySolution' ] ,
678677 } ) ;
679678 expect ( mockResponse . notFound ) . toBeCalled ( ) ;
680679 const message = mockResponse . notFound . mock . calls [ 0 ] [ 0 ] ?. body ;
@@ -706,7 +705,6 @@ describe('test endpoint routes', () => {
706705 expect ( esSearchMock ) . toHaveBeenCalledTimes ( 1 ) ;
707706 expect ( routeConfig . options ) . toEqual ( {
708707 authRequired : true ,
709- tags : [ 'access:securitySolution' ] ,
710708 } ) ;
711709 expect ( mockResponse . ok ) . toBeCalled ( ) ;
712710 const result = mockResponse . ok . mock . calls [ 0 ] [ 0 ] ?. body as HostInfo ;
@@ -741,7 +739,6 @@ describe('test endpoint routes', () => {
741739 expect ( esSearchMock ) . toHaveBeenCalledTimes ( 1 ) ;
742740 expect ( routeConfig . options ) . toEqual ( {
743741 authRequired : true ,
744- tags : [ 'access:securitySolution' ] ,
745742 } ) ;
746743 expect ( mockResponse . ok ) . toBeCalled ( ) ;
747744 const result = mockResponse . ok . mock . calls [ 0 ] [ 0 ] ?. body as HostInfo ;
@@ -778,7 +775,6 @@ describe('test endpoint routes', () => {
778775 expect ( esSearchMock ) . toHaveBeenCalledTimes ( 1 ) ;
779776 expect ( routeConfig . options ) . toEqual ( {
780777 authRequired : true ,
781- tags : [ 'access:securitySolution' ] ,
782778 } ) ;
783779 expect ( mockResponse . ok ) . toBeCalled ( ) ;
784780 const result = mockResponse . ok . mock . calls [ 0 ] [ 0 ] ?. body as HostInfo ;
@@ -814,15 +810,48 @@ describe('test endpoint routes', () => {
814810 expect ( mockResponse . badRequest ) . toBeCalled ( ) ;
815811 } ) ;
816812
817- it ( 'should get forbidden if no security solution access' , async ( ) => {
813+ it ( 'should work if no security solution access but has fleet access' , async ( ) => {
814+ const response = legacyMetadataSearchResponseMock (
815+ new EndpointDocGenerator ( ) . generateHostMetadata ( )
816+ ) ;
817+ const mockRequest = httpServerMock . createKibanaRequest ( {
818+ params : { id : response . hits . hits [ 0 ] . _id } ,
819+ } ) ;
820+ const esSearchMock = mockScopedClient . asInternalUser . search ;
821+
822+ mockAgentClient . getAgent . mockResolvedValue ( agentGenerator . generate ( { status : 'online' } ) ) ;
823+ esSearchMock . mockResponseOnce ( response ) ;
824+
825+ [ routeConfig , routeHandler ] = routerMock . get . mock . calls . find ( ( [ { path } ] ) =>
826+ path . startsWith ( HOST_METADATA_GET_ROUTE )
827+ ) ! ;
828+
829+ const contextOverrides = {
830+ endpointAuthz : getEndpointAuthzInitialStateMock ( {
831+ canReadSecuritySolution : false ,
832+ } ) ,
833+ } ;
834+ await routeHandler (
835+ createRouteHandlerContext ( mockScopedClient , mockSavedObjectClient , contextOverrides ) ,
836+ mockRequest ,
837+ mockResponse
838+ ) ;
839+
840+ expect ( mockResponse . ok ) . toBeCalled ( ) ;
841+ } ) ;
842+
843+ it ( 'should get forbidden if no security solution or fleet access' , async ( ) => {
818844 const mockRequest = httpServerMock . createKibanaRequest ( ) ;
819845
820846 [ routeConfig , routeHandler ] = routerMock . get . mock . calls . find ( ( [ { path } ] ) =>
821847 path . startsWith ( HOST_METADATA_GET_ROUTE )
822848 ) ! ;
823849
824850 const contextOverrides = {
825- endpointAuthz : getEndpointAuthzInitialStateMock ( { canReadSecuritySolution : false } ) ,
851+ endpointAuthz : getEndpointAuthzInitialStateMock ( {
852+ canAccessFleet : false ,
853+ canReadSecuritySolution : false ,
854+ } ) ,
826855 } ;
827856 await routeHandler (
828857 createRouteHandlerContext ( mockScopedClient , mockSavedObjectClient , contextOverrides ) ,
0 commit comments