diff --git a/x-pack/plugins/fleet/server/mocks.ts b/x-pack/plugins/fleet/server/mocks.ts index c8aef287e4432..57d6a4839eb6a 100644 --- a/x-pack/plugins/fleet/server/mocks.ts +++ b/x-pack/plugins/fleet/server/mocks.ts @@ -9,6 +9,7 @@ import { FleetAppContext } from './plugin'; import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks'; import { securityMock } from '../../security/server/mocks'; import { PackagePolicyServiceInterface } from './services/package_policy'; +import { AgentPolicyService, AgentService } from './services'; export const createAppContextStartContractMock = (): FleetAppContext => { return { @@ -35,3 +36,28 @@ export const createPackagePolicyServiceMock = () => { update: jest.fn(), } as jest.Mocked; }; + +/** + * Create mock AgentPolicyService + */ + +export const createMockAgentPolicyService = (): jest.Mocked => { + return { + get: jest.fn(), + list: jest.fn(), + getDefaultAgentPolicyId: jest.fn(), + getFullAgentPolicy: jest.fn(), + }; +}; + +/** + * Creates a mock AgentService + */ +export const createMockAgentService = (): jest.Mocked => { + return { + getAgentStatusById: jest.fn(), + authenticateAgentWithAccessToken: jest.fn(), + getAgent: jest.fn(), + listAgents: jest.fn(), + }; +}; diff --git a/x-pack/plugins/security_solution/common/endpoint/types/index.ts b/x-pack/plugins/security_solution/common/endpoint/types/index.ts index 5f126a7992b90..f873a701eb9bd 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/index.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/index.ts @@ -532,10 +532,19 @@ export type HostInfo = Immutable<{ host_status: HostStatus; policy_info?: { agent: { - configured: PolicyInfo; // as set in kibana - applied: PolicyInfo; // last reported running in agent (may lag behind configured) + /** + * As set in Kibana + */ + configured: PolicyInfo; + /** + * Last reported running in agent (may lag behind configured) + */ + applied: PolicyInfo; }; - endpoint: PolicyInfo; // current intended 'endpoint' package policy + /** + * Current intended 'endpoint' package policy + */ + endpoint: PolicyInfo; }; /* the version of the query strategy */ query_strategy_version: MetadataQueryStrategyVersions; diff --git a/x-pack/plugins/security_solution/server/endpoint/mocks.ts b/x-pack/plugins/security_solution/server/endpoint/mocks.ts index e5952b64afe9c..1268c8a4bc576 100644 --- a/x-pack/plugins/security_solution/server/endpoint/mocks.ts +++ b/x-pack/plugins/security_solution/server/endpoint/mocks.ts @@ -9,14 +9,12 @@ import { loggingSystemMock, savedObjectsServiceMock } from 'src/core/server/mock import { securityMock } from '../../../security/server/mocks'; import { alertsMock } from '../../../alerts/server/mocks'; import { xpackMocks } from '../../../../mocks'; +import { FleetStartContract, ExternalCallback, PackageService } from '../../../fleet/server'; import { - AgentService, - FleetStartContract, - ExternalCallback, - PackageService, - AgentPolicyService, -} from '../../../fleet/server'; -import { createPackagePolicyServiceMock } from '../../../fleet/server/mocks'; + createPackagePolicyServiceMock, + createMockAgentPolicyService, + createMockAgentService, +} from '../../../fleet/server/mocks'; import { AppClientFactory } from '../client'; import { createMockConfig } from '../lib/detection_engine/routes/__mocks__'; import { @@ -93,31 +91,6 @@ export const createMockPackageService = (): jest.Mocked => { }; }; -/** - * Create mock AgentPolicyService - */ - -export const createMockAgentPolicyService = (): jest.Mocked => { - return { - get: jest.fn(), - list: jest.fn(), - getDefaultAgentPolicyId: jest.fn(), - getFullAgentPolicy: jest.fn(), - }; -}; - -/** - * Creates a mock AgentService - */ -export const createMockAgentService = (): jest.Mocked => { - return { - getAgentStatusById: jest.fn(), - authenticateAgentWithAccessToken: jest.fn(), - getAgent: jest.fn(), - listAgents: jest.fn(), - }; -}; - /** * Creates a mock IndexPatternService for use in tests that need to interact with the Ingest Manager's * ESIndexPatternService. diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts index ed3c48ed6c677..e9a1f1e24fa55 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/agent_status.test.ts @@ -8,7 +8,7 @@ import { SavedObjectsClientContract } from 'kibana/server'; import { findAgentIDsByStatus } from './agent_status'; import { savedObjectsClientMock } from '../../../../../../../../src/core/server/mocks'; import { AgentService } from '../../../../../../fleet/server/services'; -import { createMockAgentService } from '../../../mocks'; +import { createMockAgentService } from '../../../../../../fleet/server/mocks'; import { Agent } from '../../../../../../fleet/common/types/models'; import { AgentStatusKueryHelper } from '../../../../../../fleet/common/services'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/unenroll.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/unenroll.test.ts index cd273f785033c..c88f11422d0f0 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/unenroll.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/unenroll.test.ts @@ -8,7 +8,7 @@ import { SavedObjectsClientContract } from 'kibana/server'; import { findAllUnenrolledAgentIds } from './unenroll'; import { savedObjectsClientMock } from '../../../../../../../../src/core/server/mocks'; import { AgentService } from '../../../../../../fleet/server/services'; -import { createMockAgentService } from '../../../mocks'; +import { createMockAgentService } from '../../../../../../fleet/server/mocks'; import { Agent } from '../../../../../../fleet/common/types/models'; describe('test find all unenrolled Agent id', () => { diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts index 009ce043db85e..0fc3f5135c8f6 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts @@ -5,10 +5,10 @@ */ import { EndpointAppContextService } from '../../endpoint_app_context_services'; import { - createMockAgentService, createMockEndpointAppContextServiceStartContract, createRouteHandlerContext, } from '../../mocks'; +import { createMockAgentService } from '../../../../../fleet/server/mocks'; import { getHostPolicyResponseHandler, getAgentPolicySummaryHandler } from './handlers'; import { ILegacyScopedClusterClient,