File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
x-pack/solutions/security/plugins/security_solution/server/endpoint/routes/actions Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import type {
3636import { EndpointActionGenerator } from '../../../../common/endpoint/data_generators/endpoint_action_generator' ;
3737import { ActionStatusRequestSchema } from '../../../../common/api/endpoint' ;
3838import { AGENT_ACTIONS_RESULTS_INDEX } from '@kbn/fleet-plugin/common' ;
39+ import { AgentNotFoundError } from '@kbn/fleet-plugin/server' ;
3940
4041describe ( 'Endpoint Pending Action Summary API' , ( ) => {
4142 let endpointAppContextService : EndpointAppContextService ;
@@ -395,4 +396,17 @@ describe('Endpoint Pending Action Summary API', () => {
395396 } ,
396397 } ) ;
397398 } ) ;
399+
400+ it ( 'should return 404 when spaces is enabled and agent id is not accessible in space' , async ( ) => {
401+ // @ts -expect-error
402+ endpointAppContextService . experimentalFeatures . endpointManagementSpaceAwarenessEnabled = true ;
403+ (
404+ endpointAppContextService . getInternalFleetServices ( ) . agent . getByIds as jest . Mock
405+ ) . mockRejectedValue ( new AgentNotFoundError ( 'agent not found' ) ) ;
406+ const response = await getPendingStatus ( {
407+ query : { agent_ids : [ '123' ] } ,
408+ } ) ;
409+
410+ expect ( response . notFound ) . toHaveBeenCalled ( ) ;
411+ } ) ;
398412} ) ;
Original file line number Diff line number Diff line change @@ -72,6 +72,12 @@ export const actionStatusRequestHandler = function (
7272 ? [ ...new Set ( req . query . agent_ids ) ]
7373 : [ req . query . agent_ids ] ;
7474
75+ if ( endpointContext . service . experimentalFeatures . endpointManagementSpaceAwarenessEnabled ) {
76+ await endpointContext . service
77+ . getInternalFleetServices ( spaceId )
78+ . ensureInCurrentSpace ( { agentIds : agentIDs } ) ;
79+ }
80+
7581 const response = await getPendingActionsSummary ( endpointContext . service , spaceId , agentIDs ) ;
7682
7783 return res . ok ( {
You can’t perform that action at this time.
0 commit comments