From fa1a76f66396234c815b0fa607705c8d3cc39bdd Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Mon, 2 Dec 2019 08:13:34 -0500 Subject: [PATCH 1/5] [Fleet] Use ingest policies in fleet --- .../plugins/fleet/common/return_types.ts | 1 + .../components/agent_enrollment.tsx | 17 -- .../enrollment_instructions/shell/index.tsx | 2 +- .../plugins/fleet/scripts/dev_agent/script.ts | 2 +- .../saved_objects_database/adapter_types.ts | 9 + .../saved_objects_database/default.ts | 16 ++ .../memorize_adapter.ts | 21 +- .../plugins/fleet/server/kibana.index.ts | 5 + .../legacy/plugins/fleet/server/libs/agent.ts | 18 +- .../server/libs/agent_policy.contract.test.ts | 186 ++++++++++++++++++ .../plugins/fleet/server/libs/agent_policy.ts | 68 +++++++ .../fleet/server/libs/compose/kibana.ts | 9 +- .../fleet/server/libs/compose/memorized.ts | 11 +- .../server/libs/install_templates/macos.ts | 2 +- .../plugins/fleet/server/libs/policy.ts | 1 + .../legacy/plugins/fleet/server/libs/types.ts | 2 + .../legacy/plugins/fleet/server/mappings.ts | 1 + .../server/repositories/agent_events/types.ts | 4 + .../server/repositories/agents/default.ts | 49 ++++- .../fleet/server/repositories/agents/types.ts | 7 +- .../server/repositories/policies/default.ts | 29 ++- .../server/repositories/policies/types.ts | 9 +- .../fleet/server/routes/agents/checkin.ts | 2 + .../fleet/server/routes/agents/enroll.ts | 8 + .../plugins/ingest/server/kibana.index.ts | 1 + .../plugins/ingest/server/libs/outputs.ts | 2 +- 26 files changed, 431 insertions(+), 51 deletions(-) create mode 100644 x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts create mode 100644 x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts diff --git a/x-pack/legacy/plugins/fleet/common/return_types.ts b/x-pack/legacy/plugins/fleet/common/return_types.ts index 2d3efaf96535b..96927484928ad 100644 --- a/x-pack/legacy/plugins/fleet/common/return_types.ts +++ b/x-pack/legacy/plugins/fleet/common/return_types.ts @@ -42,6 +42,7 @@ export interface ReturnTypeDelete extends BaseReturnType { export interface ReturnTypeCheckin extends BaseReturnType { action: 'checkin'; actions: Array<{ + id: string; type: string; data?: object; }>; diff --git a/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx b/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx index 4deead4c14d90..4ea62af5f06a6 100644 --- a/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx +++ b/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx @@ -17,7 +17,6 @@ import { EuiHorizontalRule, EuiSelect, EuiSpacer, - EuiSuperSelect, EuiText, EuiTitle, } from '@elastic/eui'; @@ -40,7 +39,6 @@ interface RouterProps { export const AgentEnrollmentFlyout: React.FC = ({ onClose, policies }) => { const libs = useLibs(); - const [selectedPolicy, setSelectedPolicy] = useState(''); const [quickInstallType, setQuickInstallType] = useState<'shell' | 'container' | 'tools'>( 'shell' ); @@ -138,21 +136,6 @@ export const AgentEnrollmentFlyout: React.FC = ({ onClose, policies const renderedInstructions = apiKey.data && ( - -
- -
-
- ({ value: p.id, inputDisplay: p.name }))} - valueOfSelected={selectedPolicy || ''} - onChange={value => setSelectedPolicy(value)} - /> - -
= ({ kibanaUrl, apiKey const [isManualInstallationOpen, setIsManualInstallationOpen] = useState(false); // Build quick installation command - const quickInstallInstructions = `API_KEY=${apiKey.api_key} curl ${kibanaUrl}/api/fleet/install/${currentPlatform} | bash`; + const quickInstallInstructions = `API_KEY=${apiKey.api_key} sh -c "$(curl ${kibanaUrl}/api/fleet/install/${currentPlatform})"`; return ( diff --git a/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts b/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts index 88de888d16200..5c4964e727e13 100644 --- a/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts @@ -83,7 +83,7 @@ async function checkin(kibanaURL: string, agent: Agent, log: ToolingLog) { } const json = await res.json(); - log.info('checkin', json); + log.info('checkin', JSON.stringify(json, null, 2)); } async function enroll(kibanaURL: string, apiKey: string, log: ToolingLog): Promise { diff --git a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/adapter_types.ts b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/adapter_types.ts index 39859e61cc44a..201d752f30b39 100644 --- a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/adapter_types.ts +++ b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/adapter_types.ts @@ -16,6 +16,9 @@ import { SavedObjectsCreateOptions, SavedObjectsBulkGetObject, SavedObjectsUpdateResponse, + SavedObjectsBulkUpdateObject, + SavedObjectsBulkUpdateOptions, + SavedObjectsBulkUpdateResponse, } from 'src/core/server'; import { FrameworkUser } from '../framework/adapter_types'; @@ -33,6 +36,12 @@ export interface SODatabaseAdapter { options?: SavedObjectsCreateOptions ): Promise>; + bulkUpdate( + user: FrameworkUser, + objects: Array>, + options?: SavedObjectsBulkUpdateOptions + ): Promise>; + delete( user: FrameworkUser, type: string, diff --git a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/default.ts b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/default.ts index 3cc4ea081ab60..cd7069eabc4c7 100644 --- a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/default.ts +++ b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/default.ts @@ -18,6 +18,8 @@ import { SavedObjectsUpdateResponse, SavedObjectsClient as SavedObjectsClientType, SavedObjectsLegacyService, + SavedObjectsBulkUpdateObject, + SavedObjectsBulkUpdateOptions, } from 'src/core/server'; import { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch'; import { SODatabaseAdapter as SODatabaseAdapterType } from './adapter_types'; @@ -78,6 +80,20 @@ export class SODatabaseAdapter implements SODatabaseAdapterType { return await this.getClient(user).bulkCreate(objects, options); } + /** + * Persists multiple documents batched together as a single request + * + * @param objects + * @param options + */ + async bulkUpdate( + user: FrameworkUser, + objects: Array>, + options?: SavedObjectsBulkUpdateOptions + ) { + return await this.getClient(user).bulkUpdate(objects, options); + } + /** * Deletes a SavedObject * diff --git a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/memorize_adapter.ts b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/memorize_adapter.ts index ecd6f79dc28d1..5c1bb873eafa8 100644 --- a/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/memorize_adapter.ts +++ b/x-pack/legacy/plugins/fleet/server/adapters/saved_objects_database/memorize_adapter.ts @@ -17,6 +17,8 @@ import { SavedObjectsCreateOptions, SavedObjectsBulkGetObject, SavedObjectsUpdateResponse, + SavedObjectsBulkUpdateObject, + SavedObjectsBulkUpdateOptions, } from 'src/core/server'; import { SODatabaseAdapter as SODatabaseAdapterType } from './adapter_types'; import { SODatabaseAdapter } from './default'; @@ -43,7 +45,24 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType { ); } - async bulkCreate( + public async bulkUpdate( + user: FrameworkUser, + objects: Array>, + options?: SavedObjectsBulkUpdateOptions + ) { + return Slapshot.memorize( + `bulkUpdate`, + () => { + if (!this.soAdadpter) { + throw new Error('An adapter must be provided when running tests online'); + } + return this.soAdadpter.bulkUpdate(user, objects, options); + }, + { pure: false } + ); + } + + public async bulkCreate( user: FrameworkUser, objects: Array>, options?: SavedObjectsCreateOptions diff --git a/x-pack/legacy/plugins/fleet/server/kibana.index.ts b/x-pack/legacy/plugins/fleet/server/kibana.index.ts index 9da5a91f3d62d..eb06594aa11ff 100644 --- a/x-pack/legacy/plugins/fleet/server/kibana.index.ts +++ b/x-pack/legacy/plugins/fleet/server/kibana.index.ts @@ -24,6 +24,11 @@ export const initServerWithKibana = (hapiServer: any) => { policyId: event.policyId, }); } + + if (event.type === 'updated') { + await libs.agentsPolicy.updateAgentsForPolicyId(user, event.policyId); + } + if (event.type === 'deleted') { await libs.agents.unenrollForPolicy(user, event.policyId); await libs.apiKeys.deleteEnrollmentApiKeyForPolicyId(user, event.policyId); diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent.ts b/x-pack/legacy/plugins/fleet/server/libs/agent.ts index a0b5240777733..befd6344e1592 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent.ts @@ -226,25 +226,31 @@ export class AgentLib { const actions = this._filterActionsForCheckin(agent); const now = new Date().toISOString(); - const updatedActions = actions.map(a => { - return { ...a, sent_at: now }; - }); const updateData: Partial = { last_checkin: now, - actions: updatedActions, }; if (localMetadata) { updateData.local_metadata = localMetadata; } - await this.agentsRepository.update(internalUser, agent.id, updateData); if (events.length > 0) { + // TODO move this to an AgentEvent lib https://github.com/elastic/kibana/issues/51976 + const acknowledgedActions = events + .filter(e => e.type === 'ACTION' && e.subtype === 'ACKNOWLEDGE') + .map(e => e.action_id); + + const updatedActions = actions.map(a => { + return { ...a, sent_at: acknowledgedActions.indexOf(a.id) >= 0 ? now : undefined }; + }); + updateData.actions = updatedActions; + await this.agentEventsRepository.createEventsForAgent(internalUser, agent.id, events); } + await this.agentsRepository.update(internalUser, agent.id, updateData); - return { actions, policy: null }; + return { actions: updateData.actions || actions, policy: null }; } public async addAction( diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts new file mode 100644 index 0000000000000..80c3d702041e2 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts @@ -0,0 +1,186 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import Slapshot from '@mattapperson/slapshot'; +import { FrameworkUser, internalAuthData } from '../adapters/framework/adapter_types'; +import { MemorizeSODatabaseAdapter } from '../adapters/saved_objects_database/memorize_adapter'; +import { SODatabaseAdapter } from '../adapters/saved_objects_database/default'; +import { FleetServerLib } from './types'; +import { compose } from './compose/memorized'; +import { MemorizedElasticsearchAdapter } from '../adapters/elasticsearch/memorize_adapter'; +import { ElasticsearchAdapter } from '../adapters/elasticsearch/default'; +import { Agent } from '../repositories/agents/types'; + +jest.mock('./framework'); +jest.mock('./policy', () => ({ + PolicyLib: class PolicyLib { + async getFullPolicy() { + return { + outputs: { + default: { + api_token: 'slfhsdlfhjjkshfkjh:sdfsdfsdfsdf', + id: 'default', + name: 'Default', + type: 'elasticsearch', + url: 'https://localhost:9200', + tlsCert: 'ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh', + }, + }, + streams: [ + { + metricsets: ['container', 'cpu'], + id: 'string', + type: 'etc', + output: { + use_output: 'default', + }, + }, + ], + }; + } + }, +})); + +function getUser(): FrameworkUser { + return ({ + kind: 'authenticated', + [internalAuthData]: { + headers: { + authorization: `Basic ${Buffer.from(`elastic:changeme`).toString('base64')}`, + }, + }, + } as unknown) as FrameworkUser; +} + +describe('ApiKeys Lib', () => { + let servers: any; + let soAdapter: MemorizeSODatabaseAdapter; + let esAdapter: MemorizedElasticsearchAdapter; + let libs: FleetServerLib; + + async function getAgentById(agentId: string) { + return await soAdapter.get(getUser(), 'agents', agentId); + } + + async function loadFixtures(agents: Array>) { + const agentIds: string[] = []; + for (const agent of agents) { + agentIds.push( + ( + await soAdapter.create(getUser(), 'agents', { + ...agent, + local_metadata: JSON.stringify(agent.local_metadata || {}), + user_provided_metadata: JSON.stringify(agent.user_provided_metadata || {}), + actions: agent.actions || [], + }) + ).id + ); + } + return agentIds; + } + + async function clearFixtures() { + const { saved_objects: savedObjects } = await soAdapter.find(getUser(), { + type: 'enrollment_api_keys', + perPage: 1000, + }); + for (const so of savedObjects) { + await soAdapter.delete(getUser(), 'enrollment_api_keys', so.id); + } + } + + beforeAll(async () => { + await Slapshot.callWhenOnline(async () => { + const { createKibanaServer } = await import( + '../../../../../test_utils/jest/contract_tests/servers' + ); + servers = await createKibanaServer({ + security: { enabled: false }, + }); + esAdapter = new MemorizedElasticsearchAdapter( + new ElasticsearchAdapter(servers.kbnServer.plugins.elasticsearch) + ); + soAdapter = new MemorizeSODatabaseAdapter( + new SODatabaseAdapter( + servers.kbnServer.savedObjects, + servers.kbnServer.plugins.elasticsearch + ) + ); + }); + + if (!soAdapter) { + soAdapter = new MemorizeSODatabaseAdapter(); + } + if (!esAdapter) { + esAdapter = new MemorizedElasticsearchAdapter(); + } + }); + + afterAll(async () => { + if (servers) { + await servers.shutdown; + } + }); + beforeEach(async () => { + await clearFixtures(); + libs = compose(servers ? servers.kbnServer : undefined); + }); + + describe('updateAgentForPolicyId', () => { + it('Should update the agent with the new policy', async () => { + const [agentId] = await loadFixtures([ + { + policy_id: 'default', + active: true, + }, + ]); + + await libs.agentsPolicy.updateAgentForPolicyId(getUser(), 'default', agentId); + const agent = await getAgentById(agentId); + + expect(agent?.attributes?.actions[0]).toMatchObject({ + type: 'POLICY_CHANGE', + }); + }); + }); + describe('updateAgentsForPolicyId', () => { + it('Should updates all agents with the new policy', async () => { + const [agent1Id, agent2Id, agent3Id] = await loadFixtures([ + { + policy_id: 'default', + active: true, + }, + { + policy_id: 'default', + active: true, + }, + { + policy_id: 'policy2', + active: true, + }, + ]); + + await libs.agentsPolicy.updateAgentsForPolicyId(getUser(), 'default'); + const agent1 = await getAgentById(agent1Id); + const agent2 = await getAgentById(agent2Id); + const agent3 = await getAgentById(agent3Id); + + expect(agent1?.attributes?.actions[0]).toMatchObject({ + type: 'POLICY_CHANGE', + }); + expect(agent2?.attributes?.actions[0]).toMatchObject({ + type: 'POLICY_CHANGE', + }); + expect(agent3?.attributes?.actions).toHaveLength(0); + }); + }); +}); diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts new file mode 100644 index 0000000000000..0dca3d3492831 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts @@ -0,0 +1,68 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import uuid from 'uuid'; +import { FrameworkUser } from '../adapters/framework/adapter_types'; +import { AgentsRepository, AgentAction } from '../repositories/agents/types'; +import { PolicyLib } from './policy'; +import { AgentPolicy } from '../repositories/policies/types'; + +/** + * This is the server lib to manage everything related to policies and agents + */ +export class AgentPolicyLib { + constructor( + private readonly agentsRepository: AgentsRepository, + private readonly policies: PolicyLib + ) {} + + public async updateAgentForPolicyId(user: FrameworkUser, policyId: string, agentId: string) { + const policy = await this.policies.getFullPolicy(user, policyId); + const agent = await this.agentsRepository.getById(user, agentId); + if (!agent) { + throw new Error('Agent not found'); + } + + await this.agentsRepository.update(user, agent.id, { + actions: [...agent.actions, this._createPolicyChangeAction(policy)], + }); + } + + public async updateAgentsForPolicyId(user: FrameworkUser, policyId: string) { + let hasMore = true; + let page = 1; + const policy = await this.policies.getFullPolicy(user, policyId); + while (hasMore) { + const { agents } = await this.agentsRepository.listForPolicy(user, policyId, { + page: page++, + perPage: 100, + }); + if (agents.length === 0) { + hasMore = false; + } + + const agentUpdate = agents.map(agent => { + return { + id: agent.id, + newData: { actions: [...agent.actions, this._createPolicyChangeAction(policy)] }, + }; + }); + + this.agentsRepository.bulkUpdate(user, agentUpdate); + } + } + + private _createPolicyChangeAction(policy: AgentPolicy | null): AgentAction { + return { + id: uuid.v4(), + type: 'POLICY_CHANGE', + created_at: new Date().toISOString(), + data: JSON.stringify({ + policy, + }), + }; + } +} diff --git a/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts b/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts index 0f42515ab50a6..0188fd3891aad 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts @@ -22,10 +22,14 @@ import { HttpAdapter } from '../../adapters/http_adapter/default'; import { AgentEventsRepository } from '../../repositories/agent_events/default'; import { InstallLib } from '../install'; import { ElasticsearchAdapter } from '../../adapters/elasticsearch/default'; +import { AgentPolicyLib } from '../agent_policy'; export function compose(server: any): FleetServerLib { const frameworkAdapter = new FrameworkAdapter(server); - const policyAdapter = new PoliciesRepository(server.plugins.ingest.policy); + const policyAdapter = new PoliciesRepository( + server.plugins.ingest.policy, + server.plugins.ingest.outputs + ); const framework = new FrameworkLib(frameworkAdapter); const soDatabaseAdapter = new SODatabaseAdapter( @@ -47,6 +51,8 @@ export function compose(server: any): FleetServerLib { const apiKeys = new ApiKeyLib(enrollmentApiKeysRepository, esAdapter, framework); const agents = new AgentLib(agentsRepository, agentEventsRepository, apiKeys, policies); + const agentsPolicy = new AgentPolicyLib(agentsRepository, policies); + const artifactRepository = new FileSystemArtifactRepository(os.tmpdir()); const artifacts = new ArtifactLib(artifactRepository, new HttpAdapter()); @@ -54,6 +60,7 @@ export function compose(server: any): FleetServerLib { return { agents, + agentsPolicy, apiKeys, policies, artifacts, diff --git a/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts b/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts index 2314757afa0f6..a9c4818eaaff4 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts @@ -25,10 +25,14 @@ import { ElasticsearchAdapter } from '../../adapters/elasticsearch/default'; import { MemorizeSODatabaseAdapter } from '../../adapters/saved_objects_database/memorize_adapter'; import { MemorizedElasticsearchAdapter } from '../../adapters/elasticsearch/memorize_adapter'; import { MemorizeEncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/memorize_adapter'; +import { AgentPolicyLib } from '../agent_policy'; export function compose(server?: any): FleetServerLib { const frameworkAdapter = new FrameworkAdapter(server); - const policyAdapter = new PoliciesRepository(server ? server.plugins.ingest.policy : undefined); + const policyRepository = new PoliciesRepository( + server && server.plugins.ingest.policy, + server && server.plugins.ingest.outputs + ); const framework = new FrameworkLib(frameworkAdapter); const soDatabaseAdapter = new MemorizeSODatabaseAdapter( @@ -49,13 +53,13 @@ export function compose(server?: any): FleetServerLib { encryptedObjectAdapter ); - const policies = new PolicyLib(policyAdapter); + const policies = new PolicyLib(policyRepository); const apiKeys = new ApiKeyLib(enrollmentApiKeysRepository, esAdapter, framework); const agents = new AgentLib(agentsRepository, agentEventsRepository, apiKeys, policies); const artifactRepository = new FileSystemArtifactRepository(os.tmpdir()); const artifacts = new ArtifactLib(artifactRepository, new HttpAdapter()); - + const agentsPolicy = new AgentPolicyLib(agentsRepository, policies); const install = new InstallLib(framework); return { @@ -65,5 +69,6 @@ export function compose(server?: any): FleetServerLib { artifacts, install, framework, + agentsPolicy, }; } diff --git a/x-pack/legacy/plugins/fleet/server/libs/install_templates/macos.ts b/x-pack/legacy/plugins/fleet/server/libs/install_templates/macos.ts index bec0eefcff70e..8e843c0c8655a 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/install_templates/macos.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/install_templates/macos.ts @@ -8,6 +8,6 @@ import { InstallTemplateFunction } from './types'; export const macosInstallTemplate: InstallTemplateFunction = variables => `#!/bin/sh -node scripts/dev_agent --enrollmentToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiRU5ST0xMTUVOVF9UT0tFTiIsInBvbGljeV9pZCI6ImQwM2Q5MmEwLWZkYTgtMTFlOS1hODgwLWY5MGYwMWQ5NzE1ZiIsImlhdCI6MTU3MjcyMzcxMX0.A5IRF1DnEMQowRzaJjeXVdauXHo40ZYvkg9IEQHIHPg --kibanaUrl=${variables.kibanaUrl} +eval "node scripts/dev_agent --enrollmentApiKey=$API_KEY --kibanaUrl=${variables.kibanaUrl}" `; diff --git a/x-pack/legacy/plugins/fleet/server/libs/policy.ts b/x-pack/legacy/plugins/fleet/server/libs/policy.ts index d1153339ab7d1..f94ef17b5ee6c 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/policy.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/policy.ts @@ -42,6 +42,7 @@ export class PolicyLib { return null; } const agentPolicy = { + id: policy.id, outputs: { ...( await this.policyAdapter.getPolicyOutputByIDs( diff --git a/x-pack/legacy/plugins/fleet/server/libs/types.ts b/x-pack/legacy/plugins/fleet/server/libs/types.ts index 56e771d96935e..b2abc431cb081 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/types.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/types.ts @@ -10,6 +10,7 @@ import { PolicyLib } from './policy'; import { ArtifactLib } from './artifact'; import { InstallLib } from './install'; import { FrameworkLib } from './framework'; +import { AgentPolicyLib } from './agent_policy'; export interface FleetServerLib { apiKeys: ApiKeyLib; @@ -18,4 +19,5 @@ export interface FleetServerLib { artifacts: ArtifactLib; install: InstallLib; framework: FrameworkLib; + agentsPolicy: AgentPolicyLib; } diff --git a/x-pack/legacy/plugins/fleet/server/mappings.ts b/x-pack/legacy/plugins/fleet/server/mappings.ts index cf659967072f4..e30cef2dde9e5 100644 --- a/x-pack/legacy/plugins/fleet/server/mappings.ts +++ b/x-pack/legacy/plugins/fleet/server/mappings.ts @@ -107,6 +107,7 @@ export const mappings = { properties: { type: { type: 'keyword' }, agent_id: { type: 'keyword' }, + action_id: { type: 'keyword' }, subtype: { type: 'keyword' }, timestamp: { type: 'date' }, message: { type: 'text' }, diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts index 2f745f8292bb2..4d11bd63883ba 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts @@ -11,6 +11,7 @@ export const RuntimeAgentEventType = t.union([ t.literal('STATE'), t.literal('ERROR'), t.literal('ACTION_RESULT'), + t.literal('ACTION'), ]); export const RuntimeAgentEventSubtype = t.union([ @@ -21,6 +22,7 @@ export const RuntimeAgentEventSubtype = t.union([ t.literal('FAILED'), t.literal('STOPPED'), t.literal('DATA_DUMP'), + t.literal('ACKNOWLEDGE'), ]); export const RuntimeAgentEvent = t.intersection( @@ -34,6 +36,7 @@ export const RuntimeAgentEvent = t.intersection( t.partial({ payload: t.any, data: t.string, + action_id: t.string, }), ], 'AgentEvent' @@ -52,6 +55,7 @@ export const RuntimeAgentEventSOAttributes = t.intersection( t.partial({ payload: t.string, data: t.string, + action_id: t.string, }), ], 'AgentEventSOAttribute' diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts b/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts index a8f3d980f7402..fbd7f4666069d 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts @@ -22,6 +22,8 @@ import { SortOptions, } from './types'; +const SO_TYPE = 'agents'; + export class AgentsRepository implements AgentsRepositoryType { constructor(private readonly soAdapter: SODatabaseAdapter) {} @@ -36,7 +38,7 @@ export class AgentsRepository implements AgentsRepositoryType { ): Promise { const so = await this.soAdapter.create( user, - 'agents', + SO_TYPE, { ...agent, local_metadata: JSON.stringify(agent.local_metadata || {}), @@ -60,7 +62,7 @@ export class AgentsRepository implements AgentsRepositoryType { * @param agent */ public async delete(user: FrameworkUser, agent: Agent) { - await this.soAdapter.delete(user, 'agents', agent.id); + await this.soAdapter.delete(user, SO_TYPE, agent.id); } /** @@ -68,7 +70,7 @@ export class AgentsRepository implements AgentsRepositoryType { * @param agent */ public async getById(user: FrameworkUser, id: string): Promise { - const response = await this.soAdapter.get(user, 'agents', id); + const response = await this.soAdapter.get(user, SO_TYPE, id); if (!response) { return null; } @@ -78,7 +80,7 @@ export class AgentsRepository implements AgentsRepositoryType { public async getByAccessApiKeyId(user: FrameworkUser, apiKeyId: string): Promise { const response = await this.soAdapter.find(user, { - type: 'agents', + type: SO_TYPE, searchFields: ['access_api_key_id'], search: apiKeyId, }); @@ -98,7 +100,7 @@ export class AgentsRepository implements AgentsRepositoryType { */ public async getBySharedId(user: FrameworkUser, sharedId: string): Promise { const response = await this.soAdapter.find(user, { - type: 'agents', + type: SO_TYPE, searchFields: ['shared_id'], search: sharedId, }); @@ -129,13 +131,44 @@ export class AgentsRepository implements AgentsRepositoryType { updateData.user_provided_metadata = JSON.stringify(newData.user_provided_metadata); } - const { error } = await this.soAdapter.update(user, 'agents', id, updateData); + const { error } = await this.soAdapter.update(user, SO_TYPE, id, updateData); if (error) { throw new Error(error.message); } } + /** + * Update an agent + * + * @param id + * @param newData + */ + public async bulkUpdate( + user: FrameworkUser, + updates: Array<{ id: string; newData: Partial }> + ) { + const bulkUpdateData = updates.map(({ id, newData }) => { + const { local_metadata, user_provided_metadata, ...data } = newData; + const updateData: Partial = { ...data }; + + if (newData.local_metadata) { + updateData.local_metadata = JSON.stringify(newData.local_metadata); + } + if (newData.user_provided_metadata) { + updateData.user_provided_metadata = JSON.stringify(newData.user_provided_metadata); + } + + return { + id, + attributes: updateData, + type: SO_TYPE, + }; + }); + + await this.soAdapter.bulkUpdate(user, bulkUpdateData); + } + /** * Find an agent by metadata * @param metadata @@ -151,7 +184,7 @@ export class AgentsRepository implements AgentsRepositoryType { // neet to play with saved object to know what it's possible to do here const res = await this.soAdapter.find(user, { - type: 'agents', + type: SO_TYPE, search, }); @@ -194,7 +227,7 @@ export class AgentsRepository implements AgentsRepositoryType { } const { saved_objects, total } = await this.soAdapter.find(user, { - type: 'agents', + type: SO_TYPE, page, perPage, filter: _joinFilters(filters), diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts b/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts index c6541681a50e6..6022a6873e3fd 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts @@ -19,10 +19,10 @@ export const RuntimeAgentType = t.union([ ]); const RuntimeAgentActionType = t.union([ + t.literal('POLICY_CHANGE'), t.literal('DATA_DUMP'), t.literal('RESUME'), t.literal('PAUSE'), - t.literal('UNENROLL'), ]); export type AgentActionType = t.TypeOf; @@ -141,6 +141,11 @@ export interface AgentsRepository { update(user: FrameworkUser, id: string, newData: Partial): Promise; + bulkUpdate( + user: FrameworkUser, + data: Array<{ id: string; newData: Partial }> + ): Promise; + findByMetadata( user: FrameworkUser, metadata: { local?: any; userProvided?: any } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/policies/default.ts b/x-pack/legacy/plugins/fleet/server/repositories/policies/default.ts index f6dfa02a019cc..555a4f8b6e12b 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/policies/default.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/policies/default.ts @@ -4,11 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IngestPlugin, PoliciesRepository as PoliciesRepositoryType } from './types'; +import { + IngestPolicyLib, + IngestOutputLib, + PoliciesRepository as PoliciesRepositoryType, +} from './types'; import { FrameworkUser } from '../../adapters/framework/adapter_types'; export class PoliciesRepository implements PoliciesRepositoryType { - constructor(private readonly plugin?: IngestPlugin) {} + constructor( + private readonly ingestPolicyLib?: IngestPolicyLib, + private readonly ingestOutputLib?: IngestOutputLib + ) {} /** * Return a full policy @@ -16,16 +23,26 @@ export class PoliciesRepository implements PoliciesRepositoryType { * @param id */ async getPolicyOutputByIDs(user: FrameworkUser, ids: string[]) { - if (this.plugin) { - return await this.plugin.getPolicyOutputByIDs(user, ids); + if (this.ingestOutputLib) { + return await this.ingestOutputLib.getByIDs( + { + kind: 'internal', + }, + ids + ); } return []; } async get(user: FrameworkUser, id: string) { - if (this.plugin) { - return await this.plugin.getPolicyById(user, id); + if (this.ingestPolicyLib) { + return await this.ingestPolicyLib.get( + { + kind: 'internal', + }, + id + ); } return null; diff --git a/x-pack/legacy/plugins/fleet/server/repositories/policies/types.ts b/x-pack/legacy/plugins/fleet/server/repositories/policies/types.ts index 6ba7242f8bd23..226ca993573fe 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/policies/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/policies/types.ts @@ -7,10 +7,11 @@ import * as t from 'io-ts'; import { FrameworkUser } from '../../adapters/framework/adapter_types'; import { Output, Policy } from '../../../../ingest/server/libs/adapters/policy/adapter_types'; -export interface IngestPlugin { - getPolicyOutputByIDs(user: FrameworkUser, ids: string[]): Promise; - getPolicyById(user: FrameworkUser, id: string): Promise; -} +import { PolicyLib } from '../../../../ingest/server/libs/policy'; +import { OutputsLib } from '../../../../ingest/server/libs/outputs'; + +export type IngestOutputLib = OutputsLib; +export type IngestPolicyLib = PolicyLib; export interface PoliciesRepository { getPolicyOutputByIDs(user: FrameworkUser, ids: string[]): Promise; diff --git a/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts b/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts index 4bdb0e2a79974..f0e1c20111732 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts @@ -50,6 +50,8 @@ export const createCheckinAgentsRoute = (libs: FleetServerLib) => ({ policy, actions: actions.map(a => ({ type: a.type, + data: a.data ? JSON.parse(a.data) : a.data, + id: a.id, })), }; }, diff --git a/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts b/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts index 28b39a0ff2ff9..41fe77cbde214 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts @@ -52,6 +52,14 @@ export const createEnrollAgentsRoute = (libs: FleetServerLib) => ({ sharedId ); + if (agent.policy_id) { + await libs.agentsPolicy.updateAgentForPolicyId( + { kind: 'internal' }, + agent.policy_id, + agent.id + ); + } + return { action: 'created', success: true, diff --git a/x-pack/legacy/plugins/ingest/server/kibana.index.ts b/x-pack/legacy/plugins/ingest/server/kibana.index.ts index d629ffe7c8cae..698f33b07663d 100644 --- a/x-pack/legacy/plugins/ingest/server/kibana.index.ts +++ b/x-pack/legacy/plugins/ingest/server/kibana.index.ts @@ -12,6 +12,7 @@ export const initServerWithKibana = (hapiServer: any) => { libs.framework.log('Ingest is composed -- debug message'); libs.framework.expose('policy', libs.policy); + libs.framework.expose('outputs', libs.outputs); initRestApi(hapiServer, libs); }; diff --git a/x-pack/legacy/plugins/ingest/server/libs/outputs.ts b/x-pack/legacy/plugins/ingest/server/libs/outputs.ts index 60cf81c622ac4..0816de5b21f15 100644 --- a/x-pack/legacy/plugins/ingest/server/libs/outputs.ts +++ b/x-pack/legacy/plugins/ingest/server/libs/outputs.ts @@ -14,7 +14,7 @@ export class OutputsLib { } ) {} public async getByIDs(_user: FrameworkUser, ids: string[]): Promise { - if (ids.length > 0 || ids[0] !== 'default') { + if (ids.length > 0 && ids[0] !== 'default') { throw new Error('Currently, only a default output is supported'); } From c9c7ffea854719394cecedca5f4e3e8b819056b8 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Mon, 2 Dec 2019 13:44:13 -0500 Subject: [PATCH 2/5] Fix tests --- .../plugins/fleet/scripts/dev_agent/script.ts | 2 +- .../agent.contract.test.slap_snap | 581 ++++---- .../agent_policy.contract.test.slap_snap | 1215 +++++++++++++++++ .../api_keys.contract.test.slap_snap | 556 +------- .../libs/__snapshots__/policy.test.ts.snap | 1 + .../server/libs/agent_policy.contract.test.ts | 11 +- 6 files changed, 1513 insertions(+), 853 deletions(-) create mode 100644 x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap diff --git a/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts b/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts index 5c4964e727e13..88de888d16200 100644 --- a/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts @@ -83,7 +83,7 @@ async function checkin(kibanaURL: string, agent: Agent, log: ToolingLog) { } const json = await res.json(); - log.info('checkin', JSON.stringify(json, null, 2)); + log.info('checkin', json); } async function enroll(kibanaURL: string, apiKey: string, log: ToolingLog): Promise { diff --git a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent.contract.test.slap_snap index 86901084a3a8c..bb6067c27ee73 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent.contract.test.slap_snap @@ -29,28 +29,28 @@ exports['Agent lib Enroll Should enroll a new PERMANENT agent - find:"agents" (2 exports['Agent lib Enroll Should enroll a new PERMANENT agent - create:agents (3)'] = { "results": { "type": "agents", - "id": "938be600-1062-11ea-9b88-0f163d773341", + "id": "674a4f20-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "policy_id": "policyId", "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:36:55.646Z", + "enrolled_at": "2019-12-02T18:41:50.865Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [] }, "references": [], - "updated_at": "2019-11-26T15:36:55.647Z", + "updated_at": "2019-12-02T18:41:50.866Z", "version": "WzIsMV0=" } } exports['Agent lib Enroll Should enroll a new PERMANENT agent - update:agents (4)'] = { "results": { - "id": "938be600-1062-11ea-9b88-0f163d773341", + "id": "674a4f20-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:36:55.786Z", + "updated_at": "2019-12-02T18:41:51.428Z", "version": "WzMsMV0=", "attributes": { "access_api_key_id": "mock-access-api-key-id-1" @@ -66,20 +66,20 @@ exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if "saved_objects": [ { "type": "agents", - "id": "938be600-1062-11ea-9b88-0f163d773341", + "id": "674a4f20-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "policy_id": "policyId", "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:36:55.646Z", + "enrolled_at": "2019-12-02T18:41:50.865Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-1" }, "references": [], - "updated_at": "2019-11-26T15:36:55.786Z", + "updated_at": "2019-12-02T18:41:51.428Z", "version": "WzMsMV0=" } ] @@ -102,27 +102,27 @@ exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if this agent is active - create:agents (4)'] = { "results": { "type": "agents", - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:36:57.840Z", + "enrolled_at": "2019-12-02T18:41:53.482Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [] }, "references": [], - "updated_at": "2019-11-26T15:36:57.841Z", + "updated_at": "2019-12-02T18:41:53.483Z", "version": "WzUsMV0=" } } exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if this agent is active - update:agents (5)'] = { "results": { - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:36:58.860Z", + "updated_at": "2019-12-02T18:41:54.490Z", "version": "WzYsMV0=", "attributes": { "access_api_key_id": "mock-access-api-key-id-1" @@ -132,9 +132,9 @@ exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if this agent is active - update:agents (6)'] = { "results": { - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:36:59.883Z", + "updated_at": "2019-12-02T18:41:55.527Z", "version": "WzcsMV0=", "attributes": { "active": false @@ -150,19 +150,19 @@ exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if "saved_objects": [ { "type": "agents", - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": false, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:36:57.840Z", + "enrolled_at": "2019-12-02T18:41:53.482Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-1" }, "references": [], - "updated_at": "2019-11-26T15:36:59.883Z", + "updated_at": "2019-12-02T18:41:55.527Z", "version": "WzcsMV0=" } ] @@ -171,24 +171,24 @@ exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if this agent is active - update:agents (8)'] = { "results": { - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:00.915Z", + "updated_at": "2019-12-02T18:41:56.558Z", "version": "WzgsMV0=", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:37:00.913Z" + "enrolled_at": "2019-12-02T18:41:56.557Z" } } } exports['Agent lib Enroll Should allow to enroll a new PERMANENT agent again if this agent is active - update:agents (9)'] = { "results": { - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:01.942Z", + "updated_at": "2019-12-02T18:41:57.703Z", "version": "WzksMV0=", "attributes": { "access_api_key_id": "mock-access-api-key-id-2" @@ -204,19 +204,19 @@ exports['Agent lib Enroll Should not enroll a new PERMANENT agent if this agent "saved_objects": [ { "type": "agents", - "id": "94da8610-1062-11ea-9b88-0f163d773341", + "id": "68d9a1b0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:37:00.913Z", + "enrolled_at": "2019-12-02T18:41:56.557Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-2" }, "references": [], - "updated_at": "2019-11-26T15:37:01.942Z", + "updated_at": "2019-12-02T18:41:57.703Z", "version": "WzksMV0=" } ] @@ -239,27 +239,27 @@ exports['Agent lib Enroll Should not enroll a new PERMANENT agent if this agent exports['Agent lib Enroll Should not enroll a new PERMANENT agent if this agent is already active - create:agents (4)'] = { "results": { "type": "agents", - "id": "98865000-1062-11ea-9b88-0f163d773341", + "id": "6c979410-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:37:03.999Z", + "enrolled_at": "2019-12-02T18:41:59.760Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [] }, "references": [], - "updated_at": "2019-11-26T15:37:04.000Z", + "updated_at": "2019-12-02T18:41:59.761Z", "version": "WzExLDFd" } } exports['Agent lib Enroll Should not enroll a new PERMANENT agent if this agent is already active - update:agents (5)'] = { "results": { - "id": "98865000-1062-11ea-9b88-0f163d773341", + "id": "6c979410-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:05.023Z", + "updated_at": "2019-12-02T18:42:00.776Z", "version": "WzEyLDFd", "attributes": { "access_api_key_id": "mock-access-api-key-id-1" @@ -275,19 +275,19 @@ exports['Agent lib Enroll Should not enroll a new PERMANENT agent if this agent "saved_objects": [ { "type": "agents", - "id": "98865000-1062-11ea-9b88-0f163d773341", + "id": "6c979410-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:37:03.999Z", + "enrolled_at": "2019-12-02T18:41:59.760Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-1" }, "references": [], - "updated_at": "2019-11-26T15:37:05.023Z", + "updated_at": "2019-12-02T18:42:00.776Z", "version": "WzEyLDFd" } ] @@ -302,19 +302,19 @@ exports['Agent lib Enroll Should enroll a new EPHEMERAL agent - find:"agents" (1 "saved_objects": [ { "type": "agents", - "id": "98865000-1062-11ea-9b88-0f163d773341", + "id": "6c979410-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "shared_id": "agent-1", "active": true, "type": "PERMANENT", - "enrolled_at": "2019-11-26T15:37:03.999Z", + "enrolled_at": "2019-12-02T18:41:59.760Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-1" }, "references": [], - "updated_at": "2019-11-26T15:37:05.023Z", + "updated_at": "2019-12-02T18:42:00.776Z", "version": "WzEyLDFd" } ] @@ -328,27 +328,27 @@ exports['Agent lib Enroll Should enroll a new EPHEMERAL agent - delete (2)'] = { exports['Agent lib Enroll Should enroll a new EPHEMERAL agent - create:agents (3)'] = { "results": { "type": "agents", - "id": "9a659750-1062-11ea-9b88-0f163d773341", + "id": "6e6e28d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "active": true, "policy_id": "policyId", "type": "EPHEMERAL", - "enrolled_at": "2019-11-26T15:37:07.140Z", + "enrolled_at": "2019-12-02T18:42:02.844Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [] }, "references": [], - "updated_at": "2019-11-26T15:37:07.141Z", + "updated_at": "2019-12-02T18:42:02.845Z", "version": "WzE0LDFd" } } exports['Agent lib Enroll Should enroll a new EPHEMERAL agent - update:agents (4)'] = { "results": { - "id": "9a659750-1062-11ea-9b88-0f163d773341", + "id": "6e6e28d0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:08.163Z", + "updated_at": "2019-12-02T18:42:03.864Z", "version": "WzE1LDFd", "attributes": { "access_api_key_id": "mock-access-api-key-id-1" @@ -364,19 +364,19 @@ exports['Agent lib Delete should delete ephemeral instances - find:"agents" (1)' "saved_objects": [ { "type": "agents", - "id": "9a659750-1062-11ea-9b88-0f163d773341", + "id": "6e6e28d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "active": true, "policy_id": "policyId", "type": "EPHEMERAL", - "enrolled_at": "2019-11-26T15:37:07.140Z", + "enrolled_at": "2019-12-02T18:42:02.844Z", "user_provided_metadata": "{}", "local_metadata": "{}", "actions": [], "access_api_key_id": "mock-access-api-key-id-1" }, "references": [], - "updated_at": "2019-11-26T15:37:08.163Z", + "updated_at": "2019-12-02T18:42:03.864Z", "version": "WzE1LDFd" } ] @@ -390,7 +390,7 @@ exports['Agent lib Delete should delete ephemeral instances - delete (2)'] = { exports['Agent lib Delete should delete ephemeral instances - create:agents (3)'] = { "results": { "type": "agents", - "id": "9c3a3040-1062-11ea-9b88-0f163d773341", + "id": "704029b0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "EPHEMERAL", "active": true, @@ -398,7 +398,7 @@ exports['Agent lib Delete should delete ephemeral instances - create:agents (3)' "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:10.212Z", + "updated_at": "2019-12-02T18:42:05.899Z", "version": "WzE3LDFd" } } @@ -432,7 +432,7 @@ exports['Agent lib Delete should desactivate other agent - find:"agents" (1)'] = exports['Agent lib Delete should desactivate other agent - create:agents (2)'] = { "results": { "type": "agents", - "id": "9d759670-1062-11ea-9b88-0f163d773341", + "id": "717945f0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -440,16 +440,16 @@ exports['Agent lib Delete should desactivate other agent - create:agents (2)'] = "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:12.279Z", + "updated_at": "2019-12-02T18:42:07.951Z", "version": "WzE5LDFd" } } exports['Agent lib Delete should desactivate other agent - update:agents (3)'] = { "results": { - "id": "9d759670-1062-11ea-9b88-0f163d773341", + "id": "717945f0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:13.279Z", + "updated_at": "2019-12-02T18:42:08.959Z", "version": "WzIwLDFd", "attributes": { "active": false @@ -459,9 +459,9 @@ exports['Agent lib Delete should desactivate other agent - update:agents (3)'] = exports['Agent lib Delete should desactivate other agent - get:agents (4)'] = { "results": { - "id": "9d759670-1062-11ea-9b88-0f163d773341", + "id": "717945f0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:13.279Z", + "updated_at": "2019-12-02T18:42:08.959Z", "version": "WzIwLDFd", "attributes": { "type": "PERMANENT", @@ -481,7 +481,7 @@ exports['Agent lib list should return all agents - find:"agents" (1)'] = { "saved_objects": [ { "type": "agents", - "id": "9d759670-1062-11ea-9b88-0f163d773341", + "id": "717945f0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": false, @@ -489,7 +489,7 @@ exports['Agent lib list should return all agents - find:"agents" (1)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:13.279Z", + "updated_at": "2019-12-02T18:42:08.959Z", "version": "WzIwLDFd" } ] @@ -503,7 +503,7 @@ exports['Agent lib list should return all agents - delete (2)'] = { exports['Agent lib list should return all agents - create:agents (3)'] = { "results": { "type": "agents", - "id": "9f491df0-1062-11ea-9b88-0f163d773341", + "id": "734c0a20-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -511,7 +511,7 @@ exports['Agent lib list should return all agents - create:agents (3)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:15.342Z", + "updated_at": "2019-12-02T18:42:11.010Z", "version": "WzIyLDFd" } } @@ -519,7 +519,7 @@ exports['Agent lib list should return all agents - create:agents (3)'] = { exports['Agent lib list should return all agents - create:agents (4)'] = { "results": { "type": "agents", - "id": "9fe4e8c0-1062-11ea-9b88-0f163d773341", + "id": "73e87130-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -527,7 +527,7 @@ exports['Agent lib list should return all agents - create:agents (4)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:16.364Z", + "updated_at": "2019-12-02T18:42:12.035Z", "version": "WzIzLDFd" } } @@ -540,7 +540,7 @@ exports['Agent lib list should return all agents - find:"agents" (5)'] = { "saved_objects": [ { "type": "agents", - "id": "9f491df0-1062-11ea-9b88-0f163d773341", + "id": "734c0a20-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -548,12 +548,12 @@ exports['Agent lib list should return all agents - find:"agents" (5)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:15.342Z", + "updated_at": "2019-12-02T18:42:11.010Z", "version": "WzIyLDFd" }, { "type": "agents", - "id": "9fe4e8c0-1062-11ea-9b88-0f163d773341", + "id": "73e87130-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -561,7 +561,7 @@ exports['Agent lib list should return all agents - find:"agents" (5)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:16.364Z", + "updated_at": "2019-12-02T18:42:12.035Z", "version": "WzIzLDFd" } ] @@ -576,7 +576,7 @@ exports['Agent lib checkin should throw if the agens do not exists - find:"agent "saved_objects": [ { "type": "agents", - "id": "9f491df0-1062-11ea-9b88-0f163d773341", + "id": "734c0a20-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -584,12 +584,12 @@ exports['Agent lib checkin should throw if the agens do not exists - find:"agent "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:15.342Z", + "updated_at": "2019-12-02T18:42:11.010Z", "version": "WzIyLDFd" }, { "type": "agents", - "id": "9fe4e8c0-1062-11ea-9b88-0f163d773341", + "id": "73e87130-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -597,7 +597,7 @@ exports['Agent lib checkin should throw if the agens do not exists - find:"agent "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:16.364Z", + "updated_at": "2019-12-02T18:42:12.035Z", "version": "WzIzLDFd" } ] @@ -633,7 +633,7 @@ exports['Agent lib checkin should throw is the agent is not active - find:"agent exports['Agent lib checkin should throw is the agent is not active - create:agents (2)'] = { "results": { "type": "agents", - "id": "a1bb0850-1062-11ea-9b88-0f163d773341", + "id": "75be90c0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": false, @@ -643,7 +643,7 @@ exports['Agent lib checkin should throw is the agent is not active - create:agen "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:19.445Z", + "updated_at": "2019-12-02T18:42:15.116Z", "version": "WzI2LDFd" } } @@ -656,7 +656,7 @@ exports['Agent lib checkin should throw is the agent is not active - find:"agent "saved_objects": [ { "type": "agents", - "id": "a1bb0850-1062-11ea-9b88-0f163d773341", + "id": "75be90c0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": false, @@ -666,7 +666,7 @@ exports['Agent lib checkin should throw is the agent is not active - find:"agent "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:19.445Z", + "updated_at": "2019-12-02T18:42:15.116Z", "version": "WzI2LDFd" } ] @@ -681,7 +681,7 @@ exports['Agent lib checkin should persist new events - find:"agents" (1)'] = { "saved_objects": [ { "type": "agents", - "id": "a1bb0850-1062-11ea-9b88-0f163d773341", + "id": "75be90c0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": false, @@ -691,7 +691,7 @@ exports['Agent lib checkin should persist new events - find:"agents" (1)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:19.445Z", + "updated_at": "2019-12-02T18:42:15.116Z", "version": "WzI2LDFd" } ] @@ -705,7 +705,7 @@ exports['Agent lib checkin should persist new events - delete (2)'] = { exports['Agent lib checkin should persist new events - create:agents (3)'] = { "results": { "type": "agents", - "id": "a2ed94e0-1062-11ea-9b88-0f163d773341", + "id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": true, @@ -715,7 +715,7 @@ exports['Agent lib checkin should persist new events - create:agents (3)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:21.454Z", + "updated_at": "2019-12-02T18:42:17.138Z", "version": "WzI4LDFd" } } @@ -728,7 +728,7 @@ exports['Agent lib checkin should persist new events - find:"agents" (4)'] = { "saved_objects": [ { "type": "agents", - "id": "a2ed94e0-1062-11ea-9b88-0f163d773341", + "id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": true, @@ -738,36 +738,23 @@ exports['Agent lib checkin should persist new events - find:"agents" (4)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:21.454Z", + "updated_at": "2019-12-02T18:42:17.138Z", "version": "WzI4LDFd" } ] } } -exports['Agent lib checkin should persist new events - update:agents (5)'] = { - "results": { - "id": "a2ed94e0-1062-11ea-9b88-0f163d773341", - "type": "agents", - "updated_at": "2019-11-26T15:37:22.478Z", - "version": "WzI5LDFd", - "attributes": { - "last_checkin": "2019-11-26T15:37:22.477Z", - "actions": [] - } - } -} - -exports['Agent lib checkin should persist new events - bulkCreate (6)'] = { +exports['Agent lib checkin should persist new events - bulkCreate (5)'] = { "results": { "saved_objects": [ { - "id": "agent_events:a424dc60-1062-11ea-9b88-0f163d773341", + "id": "agent_events:778f8030-1533-11ea-a3c9-5b99a65c0d97", "type": "agent_events", - "updated_at": "2019-11-26T15:37:23.493Z", - "version": "WzMwLDFd", + "updated_at": "2019-12-02T18:42:18.162Z", + "version": "WzI5LDFd", "attributes": { - "agent_id": "a2ed94e0-1062-11ea-9b88-0f163d773341", + "agent_id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", "timestamp": "2019-09-05T15:41:26+0000", "type": "STATE", "subtype": "STARTING", @@ -779,6 +766,19 @@ exports['Agent lib checkin should persist new events - bulkCreate (6)'] = { } } +exports['Agent lib checkin should persist new events - update:agents (6)'] = { + "results": { + "id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", + "type": "agents", + "updated_at": "2019-12-02T18:42:19.177Z", + "version": "WzMwLDFd", + "attributes": { + "last_checkin": "2019-12-02T18:42:18.160Z", + "actions": [] + } + } +} + exports['Agent lib checkin should persist new events - find:"agent_events" (7)'] = { "results": { "page": 1, @@ -787,17 +787,17 @@ exports['Agent lib checkin should persist new events - find:"agent_events" (7)'] "saved_objects": [ { "type": "agent_events", - "id": "a424dc60-1062-11ea-9b88-0f163d773341", + "id": "778f8030-1533-11ea-a3c9-5b99a65c0d97", "attributes": { - "agent_id": "a2ed94e0-1062-11ea-9b88-0f163d773341", + "agent_id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", "timestamp": "2019-09-05T15:41:26+0000", "type": "STATE", "subtype": "STARTING", "message": "State changed from PAUSE to STARTING" }, "references": [], - "updated_at": "2019-11-26T15:37:23.493Z", - "version": "WzMwLDFd" + "updated_at": "2019-12-02T18:42:18.162Z", + "version": "WzI5LDFd" } ] } @@ -811,7 +811,7 @@ exports['Agent lib checkin should not update agent metadata if none are provided "saved_objects": [ { "type": "agents", - "id": "a2ed94e0-1062-11ea-9b88-0f163d773341", + "id": "76f31920-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "actions": [], "active": true, @@ -819,11 +819,11 @@ exports['Agent lib checkin should not update agent metadata if none are provided "access_api_key_id": "key1", "local_metadata": "{}", "user_provided_metadata": "{}", - "last_checkin": "2019-11-26T15:37:22.477Z" + "last_checkin": "2019-12-02T18:42:18.160Z" }, "references": [], - "updated_at": "2019-11-26T15:37:22.478Z", - "version": "WzI5LDFd" + "updated_at": "2019-12-02T18:42:19.177Z", + "version": "WzMwLDFd" } ] } @@ -836,7 +836,7 @@ exports['Agent lib checkin should not update agent metadata if none are provided exports['Agent lib checkin should not update agent metadata if none are provided - create:agents (3)'] = { "results": { "type": "agents", - "id": "a55e6dd0-1062-11ea-9b88-0f163d773341", + "id": "796355d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -846,7 +846,7 @@ exports['Agent lib checkin should not update agent metadata if none are provided "access_api_key_id": "key1" }, "references": [], - "updated_at": "2019-11-26T15:37:25.549Z", + "updated_at": "2019-12-02T18:42:21.229Z", "version": "WzMyLDFd" } } @@ -859,7 +859,7 @@ exports['Agent lib checkin should not update agent metadata if none are provided "saved_objects": [ { "type": "agents", - "id": "a55e6dd0-1062-11ea-9b88-0f163d773341", + "id": "796355d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -869,7 +869,7 @@ exports['Agent lib checkin should not update agent metadata if none are provided "access_api_key_id": "key1" }, "references": [], - "updated_at": "2019-11-26T15:37:25.549Z", + "updated_at": "2019-12-02T18:42:21.229Z", "version": "WzMyLDFd" } ] @@ -878,22 +878,21 @@ exports['Agent lib checkin should not update agent metadata if none are provided exports['Agent lib checkin should not update agent metadata if none are provided - update:agents (5)'] = { "results": { - "id": "a55e6dd0-1062-11ea-9b88-0f163d773341", + "id": "796355d0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:26.573Z", + "updated_at": "2019-12-02T18:42:22.255Z", "version": "WzMzLDFd", "attributes": { - "last_checkin": "2019-11-26T15:37:26.572Z", - "actions": [] + "last_checkin": "2019-12-02T18:42:22.253Z" } } } exports['Agent lib checkin should not update agent metadata if none are provided - get:agents (6)'] = { "results": { - "id": "a55e6dd0-1062-11ea-9b88-0f163d773341", + "id": "796355d0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:26.573Z", + "updated_at": "2019-12-02T18:42:22.255Z", "version": "WzMzLDFd", "attributes": { "local_metadata": "{\"key\":\"local1\"}", @@ -902,98 +901,12 @@ exports['Agent lib checkin should not update agent metadata if none are provided "active": true, "policy_id": "policy:1", "access_api_key_id": "key1", - "last_checkin": "2019-11-26T15:37:26.572Z" + "last_checkin": "2019-12-02T18:42:22.253Z" }, "references": [] } } -exports['Agent lib checkin should return the full policy for this agent - find:"agents" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 1, - "saved_objects": [ - { - "type": "agents", - "id": "a55e6dd0-1062-11ea-9b88-0f163d773341", - "attributes": { - "local_metadata": "{\"key\":\"local1\"}", - "user_provided_metadata": "{\"key\":\"user1\"}", - "actions": [], - "active": true, - "policy_id": "policy:1", - "access_api_key_id": "key1", - "last_checkin": "2019-11-26T15:37:26.572Z" - }, - "references": [], - "updated_at": "2019-11-26T15:37:26.573Z", - "version": "WzMzLDFd" - } - ] - } -} - -exports['Agent lib checkin should return the full policy for this agent - delete (2)'] = { - "results": {} -} - -exports['Agent lib checkin should return the full policy for this agent - create:agents (3)'] = { - "results": { - "type": "agents", - "id": "a74ad480-1062-11ea-9b88-0f163d773341", - "attributes": { - "local_metadata": "{\"key\":\"local1\"}", - "user_provided_metadata": "{\"key\":\"user1\"}", - "actions": [], - "active": true, - "policy_id": "policy:1", - "access_api_key_id": "key1" - }, - "references": [], - "updated_at": "2019-11-26T15:37:28.776Z", - "version": "WzM1LDFd" - } -} - -exports['Agent lib checkin should return the full policy for this agent - find:"agents" (4)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 1, - "saved_objects": [ - { - "type": "agents", - "id": "a74ad480-1062-11ea-9b88-0f163d773341", - "attributes": { - "local_metadata": "{\"key\":\"local1\"}", - "user_provided_metadata": "{\"key\":\"user1\"}", - "actions": [], - "active": true, - "policy_id": "policy:1", - "access_api_key_id": "key1" - }, - "references": [], - "updated_at": "2019-11-26T15:37:28.776Z", - "version": "WzM1LDFd" - } - ] - } -} - -exports['Agent lib checkin should return the full policy for this agent - update:agents (5)'] = { - "results": { - "id": "a74ad480-1062-11ea-9b88-0f163d773341", - "type": "agents", - "updated_at": "2019-11-26T15:37:29.804Z", - "version": "WzM2LDFd", - "attributes": { - "last_checkin": "2019-11-26T15:37:29.802Z", - "actions": [] - } - } -} - exports['Agent lib checkin should update agent metadata if provided - find:"agents" (1)'] = { "results": { "page": 1, @@ -1002,7 +915,7 @@ exports['Agent lib checkin should update agent metadata if provided - find:"agen "saved_objects": [ { "type": "agents", - "id": "a74ad480-1062-11ea-9b88-0f163d773341", + "id": "796355d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1010,11 +923,11 @@ exports['Agent lib checkin should update agent metadata if provided - find:"agen "active": true, "policy_id": "policy:1", "access_api_key_id": "key1", - "last_checkin": "2019-11-26T15:37:29.802Z" + "last_checkin": "2019-12-02T18:42:22.253Z" }, "references": [], - "updated_at": "2019-11-26T15:37:29.804Z", - "version": "WzM2LDFd" + "updated_at": "2019-12-02T18:42:22.255Z", + "version": "WzMzLDFd" } ] } @@ -1027,7 +940,7 @@ exports['Agent lib checkin should update agent metadata if provided - delete (2) exports['Agent lib checkin should update agent metadata if provided - create:agents (3)'] = { "results": { "type": "agents", - "id": "a91c8740-1062-11ea-9b88-0f163d773341", + "id": "7b366820-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1037,8 +950,8 @@ exports['Agent lib checkin should update agent metadata if provided - create:age "access_api_key_id": "key1" }, "references": [], - "updated_at": "2019-11-26T15:37:31.828Z", - "version": "WzM4LDFd" + "updated_at": "2019-12-02T18:42:24.290Z", + "version": "WzM1LDFd" } } @@ -1050,7 +963,7 @@ exports['Agent lib checkin should update agent metadata if provided - find:"agen "saved_objects": [ { "type": "agents", - "id": "a91c8740-1062-11ea-9b88-0f163d773341", + "id": "7b366820-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1060,8 +973,8 @@ exports['Agent lib checkin should update agent metadata if provided - find:"agen "access_api_key_id": "key1" }, "references": [], - "updated_at": "2019-11-26T15:37:31.828Z", - "version": "WzM4LDFd" + "updated_at": "2019-12-02T18:42:24.290Z", + "version": "WzM1LDFd" } ] } @@ -1069,13 +982,12 @@ exports['Agent lib checkin should update agent metadata if provided - find:"agen exports['Agent lib checkin should update agent metadata if provided - update:agents (5)'] = { "results": { - "id": "a91c8740-1062-11ea-9b88-0f163d773341", + "id": "7b366820-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:32.856Z", - "version": "WzM5LDFd", + "updated_at": "2019-12-02T18:42:25.318Z", + "version": "WzM2LDFd", "attributes": { - "last_checkin": "2019-11-26T15:37:32.854Z", - "actions": [], + "last_checkin": "2019-12-02T18:42:25.317Z", "local_metadata": "{\"key\":\"local2\"}" } } @@ -1083,10 +995,10 @@ exports['Agent lib checkin should update agent metadata if provided - update:age exports['Agent lib checkin should update agent metadata if provided - get:agents (6)'] = { "results": { - "id": "a91c8740-1062-11ea-9b88-0f163d773341", + "id": "7b366820-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:32.856Z", - "version": "WzM5LDFd", + "updated_at": "2019-12-02T18:42:25.318Z", + "version": "WzM2LDFd", "attributes": { "local_metadata": "{\"key\":\"local2\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1094,7 +1006,7 @@ exports['Agent lib checkin should update agent metadata if provided - get:agents "active": true, "policy_id": "policy:1", "access_api_key_id": "key1", - "last_checkin": "2019-11-26T15:37:32.854Z" + "last_checkin": "2019-12-02T18:42:25.317Z" }, "references": [] } @@ -1108,7 +1020,7 @@ exports['Agent lib checkin should return new actions - find:"agents" (1)'] = { "saved_objects": [ { "type": "agents", - "id": "a91c8740-1062-11ea-9b88-0f163d773341", + "id": "7b366820-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local2\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1116,11 +1028,11 @@ exports['Agent lib checkin should return new actions - find:"agents" (1)'] = { "active": true, "policy_id": "policy:1", "access_api_key_id": "key1", - "last_checkin": "2019-11-26T15:37:32.854Z" + "last_checkin": "2019-12-02T18:42:25.317Z" }, "references": [], - "updated_at": "2019-11-26T15:37:32.856Z", - "version": "WzM5LDFd" + "updated_at": "2019-12-02T18:42:25.318Z", + "version": "WzM2LDFd" } ] } @@ -1133,7 +1045,7 @@ exports['Agent lib checkin should return new actions - delete (2)'] = { exports['Agent lib checkin should return new actions - create:agents (3)'] = { "results": { "type": "agents", - "id": "aaf1e380-1062-11ea-9b88-0f163d773341", + "id": "7d095360-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "active": true, "policy_id": "policy:1", @@ -1155,8 +1067,8 @@ exports['Agent lib checkin should return new actions - create:agents (3)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:34.904Z", - "version": "WzQxLDFd" + "updated_at": "2019-12-02T18:42:27.350Z", + "version": "WzM4LDFd" } } @@ -1168,7 +1080,7 @@ exports['Agent lib checkin should return new actions - find:"agents" (4)'] = { "saved_objects": [ { "type": "agents", - "id": "aaf1e380-1062-11ea-9b88-0f163d773341", + "id": "7d095360-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "active": true, "policy_id": "policy:1", @@ -1190,8 +1102,8 @@ exports['Agent lib checkin should return new actions - find:"agents" (4)'] = { "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:34.904Z", - "version": "WzQxLDFd" + "updated_at": "2019-12-02T18:42:27.350Z", + "version": "WzM4LDFd" } ] } @@ -1199,20 +1111,12 @@ exports['Agent lib checkin should return new actions - find:"agents" (4)'] = { exports['Agent lib checkin should return new actions - update:agents (5)'] = { "results": { - "id": "aaf1e380-1062-11ea-9b88-0f163d773341", + "id": "7d095360-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:35.924Z", - "version": "WzQyLDFd", + "updated_at": "2019-12-02T18:42:28.383Z", + "version": "WzM5LDFd", "attributes": { - "last_checkin": "2019-11-26T15:37:35.922Z", - "actions": [ - { - "created_at": "2019-09-05T15:43:26+0000", - "type": "PAUSE", - "id": "this-a-unique-id", - "sent_at": "2019-11-26T15:37:35.922Z" - } - ] + "last_checkin": "2019-12-02T18:42:28.381Z" } } } @@ -1225,26 +1129,31 @@ exports['Agent lib unenroll should set the list of agents as inactive - find:"ag "saved_objects": [ { "type": "agents", - "id": "aaf1e380-1062-11ea-9b88-0f163d773341", + "id": "7d095360-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "active": true, "policy_id": "policy:1", "access_api_key_id": "key1", "actions": [ { - "sent_at": "2019-11-26T15:37:35.922Z", "created_at": "2019-09-05T15:43:26+0000", - "id": "this-a-unique-id", - "type": "PAUSE" + "type": "PAUSE", + "id": "this-a-unique-id" + }, + { + "created_at": "2019-09-05T15:41:26+0000", + "type": "PAUSE", + "sent_at": "2019-09-05T15:42:26+0000", + "id": "this-a-unique-id-already-sent" } ], "local_metadata": "{}", "user_provided_metadata": "{}", - "last_checkin": "2019-11-26T15:37:35.922Z" + "last_checkin": "2019-12-02T18:42:28.381Z" }, "references": [], - "updated_at": "2019-11-26T15:37:35.924Z", - "version": "WzQyLDFd" + "updated_at": "2019-12-02T18:42:28.383Z", + "version": "WzM5LDFd" } ] } @@ -1257,7 +1166,7 @@ exports['Agent lib unenroll should set the list of agents as inactive - delete ( exports['Agent lib unenroll should set the list of agents as inactive - create:agents (3)'] = { "results": { "type": "agents", - "id": "acc39640-1062-11ea-9b88-0f163d773341", + "id": "7edf24d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1266,15 +1175,15 @@ exports['Agent lib unenroll should set the list of agents as inactive - create:a "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:37.956Z", - "version": "WzQ0LDFd" + "updated_at": "2019-12-02T18:42:30.429Z", + "version": "WzQxLDFd" } } exports['Agent lib unenroll should set the list of agents as inactive - create:agents (4)'] = { "results": { "type": "agents", - "id": "ad784040-1062-11ea-9b88-0f163d773341", + "id": "7f7aa180-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1283,17 +1192,17 @@ exports['Agent lib unenroll should set the list of agents as inactive - create:a "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:39.140Z", - "version": "WzQ1LDFd" + "updated_at": "2019-12-02T18:42:31.448Z", + "version": "WzQyLDFd" } } exports['Agent lib unenroll should set the list of agents as inactive - update:agents (5)'] = { "results": { - "id": "acc39640-1062-11ea-9b88-0f163d773341", + "id": "7edf24d0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:40.163Z", - "version": "WzQ2LDFd", + "updated_at": "2019-12-02T18:42:32.466Z", + "version": "WzQzLDFd", "attributes": { "active": false } @@ -1302,10 +1211,10 @@ exports['Agent lib unenroll should set the list of agents as inactive - update:a exports['Agent lib unenroll should set the list of agents as inactive - update:agents (6)'] = { "results": { - "id": "ad784040-1062-11ea-9b88-0f163d773341", + "id": "7f7aa180-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:41.196Z", - "version": "WzQ3LDFd", + "updated_at": "2019-12-02T18:42:33.485Z", + "version": "WzQ0LDFd", "attributes": { "active": false } @@ -1314,10 +1223,10 @@ exports['Agent lib unenroll should set the list of agents as inactive - update:a exports['Agent lib unenroll should set the list of agents as inactive - get:agents (7)'] = { "results": { - "id": "acc39640-1062-11ea-9b88-0f163d773341", + "id": "7edf24d0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:40.163Z", - "version": "WzQ2LDFd", + "updated_at": "2019-12-02T18:42:32.466Z", + "version": "WzQzLDFd", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1331,10 +1240,10 @@ exports['Agent lib unenroll should set the list of agents as inactive - get:agen exports['Agent lib unenroll should set the list of agents as inactive - get:agents (8)'] = { "results": { - "id": "ad784040-1062-11ea-9b88-0f163d773341", + "id": "7f7aa180-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:41.196Z", - "version": "WzQ3LDFd", + "updated_at": "2019-12-02T18:42:33.485Z", + "version": "WzQ0LDFd", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1354,7 +1263,7 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "saved_objects": [ { "type": "agents", - "id": "acc39640-1062-11ea-9b88-0f163d773341", + "id": "7edf24d0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1363,12 +1272,12 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:40.163Z", - "version": "WzQ2LDFd" + "updated_at": "2019-12-02T18:42:32.466Z", + "version": "WzQzLDFd" }, { "type": "agents", - "id": "ad784040-1062-11ea-9b88-0f163d773341", + "id": "7f7aa180-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1377,8 +1286,8 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:41.196Z", - "version": "WzQ3LDFd" + "updated_at": "2019-12-02T18:42:33.485Z", + "version": "WzQ0LDFd" } ] } @@ -1395,7 +1304,7 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - create:agents (4)'] = { "results": { "type": "agents", - "id": "b0850b10-1062-11ea-9b88-0f163d773341", + "id": "8282ff80-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1404,15 +1313,15 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:44.257Z", - "version": "WzUwLDFd" + "updated_at": "2019-12-02T18:42:36.536Z", + "version": "WzQ3LDFd" } } exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - create:agents (5)'] = { "results": { "type": "agents", - "id": "b11fc470-1062-11ea-9b88-0f163d773341", + "id": "831f8da0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1421,8 +1330,8 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:45.271Z", - "version": "WzUxLDFd" + "updated_at": "2019-12-02T18:42:37.562Z", + "version": "WzQ4LDFd" } } @@ -1434,7 +1343,7 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "saved_objects": [ { "type": "agents", - "id": "b0850b10-1062-11ea-9b88-0f163d773341", + "id": "8282ff80-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1443,12 +1352,12 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:44.257Z", - "version": "WzUwLDFd" + "updated_at": "2019-12-02T18:42:36.536Z", + "version": "WzQ3LDFd" }, { "type": "agents", - "id": "b11fc470-1062-11ea-9b88-0f163d773341", + "id": "831f8da0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1457,8 +1366,8 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:45.271Z", - "version": "WzUxLDFd" + "updated_at": "2019-12-02T18:42:37.562Z", + "version": "WzQ4LDFd" } ] } @@ -1466,10 +1375,10 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - update:agents (7)'] = { "results": { - "id": "b0850b10-1062-11ea-9b88-0f163d773341", + "id": "8282ff80-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:46.344Z", - "version": "WzUyLDFd", + "updated_at": "2019-12-02T18:42:38.643Z", + "version": "WzQ5LDFd", "attributes": { "active": false } @@ -1478,10 +1387,10 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - update:agents (8)'] = { "results": { - "id": "b11fc470-1062-11ea-9b88-0f163d773341", + "id": "831f8da0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:47.322Z", - "version": "WzUzLDFd", + "updated_at": "2019-12-02T18:42:39.629Z", + "version": "WzUwLDFd", "attributes": { "active": false } @@ -1499,10 +1408,10 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - get:agents (10)'] = { "results": { - "id": "b0850b10-1062-11ea-9b88-0f163d773341", + "id": "8282ff80-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:46.344Z", - "version": "WzUyLDFd", + "updated_at": "2019-12-02T18:42:38.643Z", + "version": "WzQ5LDFd", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1516,10 +1425,10 @@ exports['Agent lib unenrollForPolicy should set all the of agents for this polic exports['Agent lib unenrollForPolicy should set all the of agents for this policy as inactive - get:agents (11)'] = { "results": { - "id": "b11fc470-1062-11ea-9b88-0f163d773341", + "id": "831f8da0-1533-11ea-a3c9-5b99a65c0d97", "type": "agents", - "updated_at": "2019-11-26T15:37:47.322Z", - "version": "WzUzLDFd", + "updated_at": "2019-12-02T18:42:39.629Z", + "version": "WzUwLDFd", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1539,7 +1448,7 @@ exports['Agent lib addAction should throw if the agent do not exists - find:"age "saved_objects": [ { "type": "agents", - "id": "b0850b10-1062-11ea-9b88-0f163d773341", + "id": "8282ff80-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1548,12 +1457,12 @@ exports['Agent lib addAction should throw if the agent do not exists - find:"age "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:46.344Z", - "version": "WzUyLDFd" + "updated_at": "2019-12-02T18:42:38.643Z", + "version": "WzQ5LDFd" }, { "type": "agents", - "id": "b11fc470-1062-11ea-9b88-0f163d773341", + "id": "831f8da0-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "local_metadata": "{\"key\":\"local1\"}", "user_provided_metadata": "{\"key\":\"user1\"}", @@ -1562,8 +1471,8 @@ exports['Agent lib addAction should throw if the agent do not exists - find:"age "policy_id": "policy:1" }, "references": [], - "updated_at": "2019-11-26T15:37:47.322Z", - "version": "WzUzLDFd" + "updated_at": "2019-12-02T18:42:39.629Z", + "version": "WzUwLDFd" } ] } @@ -1593,7 +1502,7 @@ exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"age exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (2)'] = { "results": { "type": "agents", - "id": "b4312320-1062-11ea-9b88-0f163d773341", + "id": "862ea260-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -1602,15 +1511,15 @@ exports['Agent lib getAgentsStatusForPolicy should return all agents - create:ag "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:50.418Z", - "version": "WzU2LDFd" + "updated_at": "2019-12-02T18:42:42.694Z", + "version": "WzUzLDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (3)'] = { "results": { "type": "agents", - "id": "b4c9b9a0-1062-11ea-9b88-0f163d773341", + "id": "86cabb50-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, @@ -1619,15 +1528,15 @@ exports['Agent lib getAgentsStatusForPolicy should return all agents - create:ag "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:51.418Z", - "version": "WzU3LDFd" + "updated_at": "2019-12-02T18:42:43.717Z", + "version": "WzU0LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (4)'] = { "results": { "type": "agents", - "id": "b56891b0-1062-11ea-9b88-0f163d773341", + "id": "8766ad30-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "TEMPORARY", "active": true, @@ -1636,120 +1545,120 @@ exports['Agent lib getAgentsStatusForPolicy should return all agents - create:ag "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:52.459Z", - "version": "WzU4LDFd" + "updated_at": "2019-12-02T18:42:44.739Z", + "version": "WzU1LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (5)'] = { "results": { "type": "agents", - "id": "b60239a0-1062-11ea-9b88-0f163d773341", + "id": "88016690-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, "policy_id": "policy:1", - "last_checkin": "2019-11-26T15:32:50.415Z", + "last_checkin": "2019-12-02T18:37:42.692Z", "local_metadata": "{}", "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:53.466Z", - "version": "WzU5LDFd" + "updated_at": "2019-12-02T18:42:45.753Z", + "version": "WzU2LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (6)'] = { "results": { "type": "agents", - "id": "b69e2b80-1062-11ea-9b88-0f163d773341", + "id": "889b0e80-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, "policy_id": "policy:1", - "last_checkin": "2019-11-26T15:37:50.415Z", + "last_checkin": "2019-12-02T18:42:42.692Z", "local_metadata": "{}", "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:54.488Z", - "version": "WzYwLDFd" + "updated_at": "2019-12-02T18:42:46.760Z", + "version": "WzU3LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (7)'] = { "results": { "type": "agents", - "id": "b739a830-1062-11ea-9b88-0f163d773341", + "id": "8939bf80-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "PERMANENT", "active": true, "policy_id": "policy:1", - "last_checkin": "2019-11-26T15:37:50.415Z", + "last_checkin": "2019-12-02T18:42:42.692Z", "local_metadata": "{}", "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:55.506Z", - "version": "WzYxLDFd" + "updated_at": "2019-12-02T18:42:47.800Z", + "version": "WzU4LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (8)'] = { "results": { "type": "agents", - "id": "b7d4fdd0-1062-11ea-9b88-0f163d773341", + "id": "89d31950-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "TEMPORARY", "active": true, "policy_id": "policy:1", - "last_checkin": "2019-11-26T15:32:50.415Z", + "last_checkin": "2019-12-02T18:37:42.692Z", "local_metadata": "{}", "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:56.525Z", - "version": "WzYyLDFd" + "updated_at": "2019-12-02T18:42:48.805Z", + "version": "WzU5LDFd" } } exports['Agent lib getAgentsStatusForPolicy should return all agents - create:agents (9)'] = { "results": { "type": "agents", - "id": "b86fb730-1062-11ea-9b88-0f163d773341", + "id": "8a6f8060-1533-11ea-a3c9-5b99a65c0d97", "attributes": { "type": "TEMPORARY", "active": true, "policy_id": "policy:1", - "last_checkin": "2019-11-26T15:37:50.415Z", + "last_checkin": "2019-12-02T18:42:42.692Z", "local_metadata": "{}", "user_provided_metadata": "{}" }, "references": [], - "updated_at": "2019-11-26T15:37:57.539Z", - "version": "WzYzLDFd" + "updated_at": "2019-12-02T18:42:49.830Z", + "version": "WzYwLDFd" } } -exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (12)'] = { +exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (10)'] = { "results": { "page": 1, "per_page": 0, - "total": 1, + "total": 5, "saved_objects": [] } } -exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (10)'] = { +exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (11)'] = { "results": { "page": 1, "per_page": 0, - "total": 5, + "total": 1, "saved_objects": [] } } -exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (11)'] = { +exports['Agent lib getAgentsStatusForPolicy should return all agents - find:"agents" (12)'] = { "results": { "page": 1, "per_page": 0, diff --git a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap new file mode 100644 index 0000000000000..5455747b252f2 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap @@ -0,0 +1,1215 @@ + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "e669efa0-150a-11ea-8ad9-d10bed68f7b3", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}" + }, + "references": [], + "updated_at": "2019-12-02T13:51:54.778Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "7cff2bf0-150c-11ea-836d-474a0a44645c", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}" + }, + "references": [], + "updated_at": "2019-12-02T14:03:16.911Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "7cff2bf0-150c-11ea-836d-474a0a44645c", + "type": "agents", + "updated_at": "2019-12-02T14:03:16.911Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}" + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:09:34.421Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", + "type": "agents", + "updated_at": "2019-12-02T14:09:34.421Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", + "type": "agents", + "updated_at": "2019-12-02T14:09:35.350Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "1f742219-4d96-45cf-b275-9201ff3c83a4", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T14:09:35.348Z", + "data": "{\"policy\":{\"id\":\"default\",\"outputs\":{},\"streams\":[],\"name\":\"Policy 1\",\"updated_by\":\"johndoe\",\"updated_on\":\"2019-09-23T20:46:42+0000\",\"version\":0,\"created_by\":\"johndoe\",\"created_on\":\"2019-09-23T20:46:42+0000\"}}" + } + ] + } + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", + "type": "agents", + "updated_at": "2019-12-02T14:09:35.350Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"id\":\"default\",\"outputs\":{},\"streams\":[],\"name\":\"Policy 1\",\"updated_by\":\"johndoe\",\"updated_on\":\"2019-09-23T20:46:42+0000\",\"version\":0,\"created_by\":\"johndoe\",\"created_on\":\"2019-09-23T20:46:42+0000\"}}", + "created_at": "2019-12-02T14:09:35.348Z", + "id": "1f742219-4d96-45cf-b275-9201ff3c83a4", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:33:55.907Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", + "type": "agents", + "updated_at": "2019-12-02T14:33:55.907Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", + "type": "agents", + "updated_at": "2019-12-02T14:33:56.725Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "ce67857d-53ab-4db0-b5c7-e1e1834d3b56", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T14:33:56.724Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", + "type": "agents", + "updated_at": "2019-12-02T14:33:56.725Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:33:56.724Z", + "id": "ce67857d-53ab-4db0-b5c7-e1e1834d3b56", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "286b00f0-1511-11ea-a27e-2717661c3dab", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:36:42.495Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "286b00f0-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:42.495Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "286b00f0-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:42.745Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "7e5c256a-1f12-47e3-a0ac-dcda013a6462", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T14:36:42.743Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "286b00f0-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:42.745Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:36:42.743Z", + "id": "7e5c256a-1f12-47e3-a0ac-dcda013a6462", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "292ddbc0-1511-11ea-a27e-2717661c3dab", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:36:43.772Z", + "version": "WzQsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { + "results": { + "type": "agents", + "id": "29c69950-1511-11ea-a27e-2717661c3dab", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:36:44.773Z", + "version": "WzUsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { + "results": { + "type": "agents", + "id": "2a65e690-1511-11ea-a27e-2717661c3dab", + "attributes": { + "policy_id": "policy2", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:36:45.817Z", + "version": "WzYsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { + "results": { + "page": 1, + "per_page": 100, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { + "results": { + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (7)'] = { + "results": { + "id": "292ddbc0-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:43.772Z", + "version": "WzQsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (8)'] = { + "results": { + "id": "29c69950-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:44.773Z", + "version": "WzUsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { + "results": { + "id": "2a65e690-1511-11ea-a27e-2717661c3dab", + "type": "agents", + "updated_at": "2019-12-02T14:36:45.817Z", + "version": "WzYsMV0=", + "attributes": { + "policy_id": "policy2", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "6852b6e0-1511-11ea-a155-519330227ea0", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:38:29.709Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "6852b6e0-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:29.709Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "6852b6e0-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:30.027Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "44adbc65-4b99-4aef-a620-fa99016b5a0f", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T14:38:30.024Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "6852b6e0-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:30.027Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:38:30.024Z", + "id": "44adbc65-4b99-4aef-a620-fa99016b5a0f", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "691f55b0-1511-11ea-a155-519330227ea0", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:38:31.051Z", + "version": "WzQsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { + "results": { + "type": "agents", + "id": "69b83a50-1511-11ea-a155-519330227ea0", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:38:32.053Z", + "version": "WzUsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { + "results": { + "type": "agents", + "id": "6a5341d0-1511-11ea-a155-519330227ea0", + "attributes": { + "policy_id": "policy2", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:38:33.068Z", + "version": "WzYsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { + "results": { + "page": 1, + "per_page": 100, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { + "results": { + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (7)'] = { + "results": { + "id": "691f55b0-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:31.051Z", + "version": "WzQsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (8)'] = { + "results": { + "id": "69b83a50-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:32.053Z", + "version": "WzUsMV0=", + "attributes": { + "policy_id": "default", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { + "results": { + "id": "6a5341d0-1511-11ea-a155-519330227ea0", + "type": "agents", + "updated_at": "2019-12-02T14:38:33.068Z", + "version": "WzYsMV0=", + "attributes": { + "policy_id": "policy2", + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:44.888Z", + "version": "WzIsMV0=" + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:44.888Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:45.862Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T14:41:45.859Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } + } +} + +exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:45.862Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:41:45.859Z", + "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:46.904Z", + "version": "WzQsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { + "results": { + "type": "agents", + "id": "de755440-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:47.907Z", + "version": "WzUsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { + "results": { + "type": "agents", + "id": "df12a5b0-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "policy2", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:48.939Z", + "version": "WzYsMV0=" + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { + "results": { + "page": 1, + "per_page": 100, + "total": 3, + "saved_objects": [ + { + "type": "agents", + "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:41:45.859Z", + "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [], + "updated_at": "2019-12-02T14:41:45.862Z", + "version": "WzMsMV0=" + }, + { + "type": "agents", + "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:46.904Z", + "version": "WzQsMV0=" + }, + { + "type": "agents", + "id": "de755440-1511-11ea-9f34-65c55b2d70d9", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T14:41:47.907Z", + "version": "WzUsMV0=" + } + ] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (7)'] = { + "results": { + "page": 2, + "per_page": 100, + "total": 3, + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (8)'] = { + "results": { + "saved_objects": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { + "results": { + "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:50.094Z", + "version": "WzgsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:41:50.043Z", + "id": "0754c11b-74c9-47dc-ad30-c7bbef7508d1", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (10)'] = { + "results": { + "id": "de755440-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:50.094Z", + "version": "WzksMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T14:41:50.044Z", + "id": "cf6733f7-5482-4928-970b-992124a6ee07", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (11)'] = { + "results": { + "id": "df12a5b0-1511-11ea-9f34-65c55b2d70d9", + "type": "agents", + "updated_at": "2019-12-02T14:41:48.939Z", + "version": "WzYsMV0=", + "attributes": { + "policy_id": "policy2", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { + "thrownError": "{\"msg\":\"unknown error\",\"path\":\"/_bulk\",\"query\":{\"refresh\":\"wait_for\"},\"body\":\"{\\\"update\\\":{\\\"_id\\\":\\\"agents:dca8aa90-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:45.859Z\\\",\\\"id\\\":\\\"3b265219-71cc-4f26-ba87-90417066dc02\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\"},{\\\"id\\\":\\\"21e05485-c488-4504-8a81-72a56839755a\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.043Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:dddc2180-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"0754c11b-74c9-47dc-ad30-c7bbef7508d1\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.043Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:de755440-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"cf6733f7-5482-4928-970b-992124a6ee07\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.044Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n\",\"statusCode\":0}", + "results": null +} + +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:25.622Z", + "version": "WzIsMV0=" + } +} + +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { + "results": { + "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:25.622Z", + "version": "WzIsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { + "results": { + "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:25.986Z", + "version": "WzMsMV0=", + "attributes": { + "actions": [ + { + "id": "46f35c21-d60c-458a-be45-4682d9126906", + "type": "POLICY_CHANGE", + "created_at": "2019-12-02T20:48:25.984Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } + } +} + +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { + "results": { + "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:25.986Z", + "version": "WzMsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T20:48:25.984Z", + "id": "46f35c21-d60c-458a-be45-4682d9126906", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { + "results": { + "type": "agents", + "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:27.011Z", + "version": "WzQsMV0=" + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { + "results": { + "type": "agents", + "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:28.008Z", + "version": "WzUsMV0=" + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { + "results": { + "type": "agents", + "id": "182499c0-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "policy2", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:29.020Z", + "version": "WzYsMV0=" + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { + "results": { + "page": 1, + "per_page": 100, + "total": 3, + "saved_objects": [ + { + "type": "agents", + "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T20:48:25.984Z", + "id": "46f35c21-d60c-458a-be45-4682d9126906", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [], + "updated_at": "2019-12-02T20:48:25.986Z", + "version": "WzMsMV0=" + }, + { + "type": "agents", + "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:27.011Z", + "version": "WzQsMV0=" + }, + { + "type": "agents", + "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [], + "updated_at": "2019-12-02T20:48:28.008Z", + "version": "WzUsMV0=" + } + ] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (7)'] = { + "results": { + "page": 2, + "per_page": 100, + "total": 3, + "saved_objects": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (8)'] = { + "results": { + "saved_objects": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { + "results": { + "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:30.149Z", + "version": "WzgsMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T20:48:30.109Z", + "id": "519cf0f3-398c-4534-b732-63f28b6ea465", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (10)'] = { + "results": { + "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:30.149Z", + "version": "WzksMV0=", + "attributes": { + "policy_id": "default", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [ + { + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", + "created_at": "2019-12-02T20:48:30.109Z", + "id": "509d6a9d-60a2-4b77-8e66-22db9efdec91", + "type": "POLICY_CHANGE" + } + ] + }, + "references": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (11)'] = { + "results": { + "id": "182499c0-1545-11ea-8a4c-d782b3e0e16c", + "type": "agents", + "updated_at": "2019-12-02T20:48:29.020Z", + "version": "WzYsMV0=", + "attributes": { + "policy_id": "policy2", + "active": true, + "local_metadata": "{}", + "user_provided_metadata": "{}", + "actions": [] + }, + "references": [] + } +} + +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { + "thrownError": "{\"msg\":\"unknown error\",\"path\":\"/_bulk\",\"query\":{\"refresh\":\"wait_for\"},\"body\":\"{\\\"update\\\":{\\\"_id\\\":\\\"agents:161e1b60-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:25.984Z\\\",\\\"id\\\":\\\"46f35c21-d60c-458a-be45-4682d9126906\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\"},{\\\"id\\\":\\\"db1f1263-2e31-4ffe-b509-833e4e6f5b47\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:16f20d30-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"519cf0f3-398c-4534-b732-63f28b6ea465\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:178a2e80-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"509d6a9d-60a2-4b77-8e66-22db9efdec91\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n\",\"statusCode\":0}", + "results": null +} diff --git a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/api_keys.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/api_keys.contract.test.slap_snap index 975eb6b86cd7d..a5dded392aa02 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/api_keys.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/api_keys.contract.test.slap_snap @@ -10,9 +10,9 @@ exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - find:"en exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - createApiKey (2)'] = { "results": { - "id": "r7NDZW4B4KwD6w8o_-VN", - "name": "TEST API KEY: 4aae3a09-e9d1-4a12-8a57-0206ba925049", - "api_key": "xO4Ms-OZRWWtE61N8MWqLw" + "id": "MwfYx24BHcAAABHLmCzN", + "name": "TEST API KEY: eecae6e3-333c-47b0-ad3d-27bfe1f9597e", + "api_key": "hqjPotvsSfmJx4QljPuPoA" } } @@ -62,478 +62,22 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - find exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - createApiKey (2)'] = { "results": { - "id": "sLNEZW4B4KwD6w8oAeXf", - "name": "TEST API KEY: cac73ad9-e757-49e2-9bd9-40fbdce6bf99", - "api_key": "77eOdCJnRWOegQ1iIjGnDg" + "id": "NAfYx24BHcAAABHLmizj", + "name": "TEST API KEY: 5e00e45e-e865-46f7-beb4-1e475fd884e7", + "api_key": "QV11wsIfRQeQ1gj-_NqBxg" } } exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - create:enrollment_api_keys (3)'] = { "results": { "type": "enrollment_api_keys", - "id": "6850373a-bb23-4f02-bb21-c0acbafcd3d8", + "id": "f6ef5088-027a-4198-80b5-228dc712c84c", "attributes": { "active": true, - "api_key_id": "sLNEZW4B4KwD6w8oAeXf" + "api_key_id": "NAfYx24BHcAAABHLmizj" }, "references": [], - "updated_at": "2019-11-13T14:56:27.037Z", - "version": "WzMxMiwxXQ==" - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - authenticate (4)'] = { - "results": { - "username": "elastic", - "roles": [], - "full_name": null, - "email": null, - "metadata": { - "_reserved": true - }, - "enabled": true, - "authentication_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - }, - "lookup_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - } - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - find:"enrollment_api_keys" (5)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 1, - "saved_objects": [ - { - "type": "enrollment_api_keys", - "id": "6850373a-bb23-4f02-bb21-c0acbafcd3d8", - "attributes": { - "active": true, - "api_key_id": "sLNEZW4B4KwD6w8oAeXf", - "api_key": "y7Zz4tVm3miSfv1W1rd9zAROGpHBVtGKScnQvnDikCWUo1X3DUFTNnOI99B0H4gngrSvq1U8DKofCF7hP0jrGSJqLmuntGss5hES2DvO7/5djsCVf3kva+uTwW18gGsWTP707l7TCMfewDCETNtKBIwxt8w4/j/FfOXxusi1W1PebmiQFspZZTQ30dWKXZ9yzjs6VXqwpIF3Sw==" - }, - "references": [], - "updated_at": "2019-11-13T14:56:27.037Z", - "version": "WzMxMiwxXQ==" - } - ] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - getDecryptedAsInternalUser:enrollment_api_keys:6850373a-bb23-4f02-bb21-c0acbafcd3d8 (6)'] = { - "results": { - "id": "6850373a-bb23-4f02-bb21-c0acbafcd3d8", - "type": "enrollment_api_keys", - "updated_at": "2019-11-13T14:56:27.037Z", - "version": "WzMxMiwxXQ==", - "attributes": { - "active": true, - "api_key_id": "sLNEZW4B4KwD6w8oAeXf", - "api_key": "c0xORVpXNEI0S3dENnc4b0FlWGY6NzdlT2RDSm5SV09lZ1ExaUlqR25EZw==" - }, - "references": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 1, - "saved_objects": [ - { - "type": "enrollment_api_keys", - "id": "6850373a-bb23-4f02-bb21-c0acbafcd3d8", - "attributes": { - "active": true, - "api_key_id": "sLNEZW4B4KwD6w8oAeXf" - }, - "references": [], - "updated_at": "2019-11-13T14:56:27.037Z", - "version": "WzMxMiwxXQ==" - } - ] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - delete (2)'] = { - "results": {} -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - createApiKey (3)'] = { - "results": { - "id": "sbNEZW4B4KwD6w8oDOXF", - "name": "TEST API KEY: c0120d29-ef06-45e8-9649-431939f26e59", - "api_key": "m07xSOsSSk6qroc-hM0gnw" - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - create:enrollment_api_keys (4)'] = { - "results": { - "type": "enrollment_api_keys", - "id": "340f1199-6036-47e0-9b94-a69516fe4629", - "attributes": { - "active": false, - "api_key_id": "sbNEZW4B4KwD6w8oDOXF" - }, - "references": [], - "updated_at": "2019-11-13T14:56:29.059Z", - "version": "WzMxNCwxXQ==" - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - authenticate (5)'] = { - "results": { - "username": "elastic", - "roles": [], - "full_name": null, - "email": null, - "metadata": { - "_reserved": true - }, - "enabled": true, - "authentication_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - }, - "lookup_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - } - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - find:"enrollment_api_keys" (6)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 1, - "saved_objects": [ - { - "type": "enrollment_api_keys", - "id": "340f1199-6036-47e0-9b94-a69516fe4629", - "attributes": { - "active": false, - "api_key_id": "sbNEZW4B4KwD6w8oDOXF", - "api_key": "5y+RPHiBwUF0Kt8g/uJXlZ8OzR2oQSju6Btm+yv5px5CrhjA1575pQpSW+2kW/MZdmkev9fY+8VMLaGsM4pGoYQfh0PlbkZQ3XQW+mvFvrhMvFX+gZfvS+0AQE27dhRm6qvj091N/gmDGkfm4JZD8kE9CznyZSEmnmNtTeqt/XnuHTRg609J5EPkGtyw8WpA2DohNtzQUiFGiQ==" - }, - "references": [], - "updated_at": "2019-11-13T14:56:29.059Z", - "version": "WzMxNCwxXQ==" - } - ] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - getDecryptedAsInternalUser:enrollment_api_keys:340f1199-6036-47e0-9b94-a69516fe4629 (7)'] = { - "results": { - "id": "340f1199-6036-47e0-9b94-a69516fe4629", - "type": "enrollment_api_keys", - "updated_at": "2019-11-13T14:56:29.059Z", - "version": "WzMxNCwxXQ==", - "attributes": { - "active": false, - "api_key_id": "sbNEZW4B4KwD6w8oDOXF", - "api_key": "c2JORVpXNEI0S3dENnc4b0RPWEY6bTA3eFNPc1NTazZxcm9jLWhNMGdudw==" - }, - "references": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 1, - "saved_objects": [ - { - "type": "enrollment_api_keys", - "id": "340f1199-6036-47e0-9b94-a69516fe4629", - "attributes": { - "active": false, - "api_key_id": "sbNEZW4B4KwD6w8oDOXF" - }, - "references": [], - "updated_at": "2019-11-13T14:56:29.059Z", - "version": "WzMxNCwxXQ==" - } - ] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - delete (2)'] = { - "results": {} -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - createApiKey (3)'] = { - "results": { - "id": "srNEZW4B4KwD6w8oFOWo", - "name": "TEST API KEY: d7b015ad-ed9e-4bdc-a4e7-db6449d69f44", - "api_key": "rfo24UgTQ9ecyZZ-erxfkQ" - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - authenticate (4)'] = { - "results": { - "username": "elastic", - "roles": [], - "full_name": null, - "email": null, - "metadata": { - "_reserved": true - }, - "enabled": true, - "authentication_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - }, - "lookup_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - } - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - find:"enrollment_api_keys" (5)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify invalid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify invalid ApiKey - authenticate (2)'] = { - "thrownError": "{\"msg\":\"[security_exception] missing authentication credentials for REST request [/_security/_authenticate], with { header={ WWW-Authenticate={ 0=\\\"ApiKey\\\" & 1=\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\" } } }\",\"path\":\"/_security/_authenticate\",\"statusCode\":401,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":[\\\"ApiKey\\\",\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"]}}],\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":[\\\"ApiKey\\\",\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"]}},\\\"status\\\":401}\",\"wwwAuthenticateDirective\":\"ApiKey, Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\"}", - "results": null -} - -exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - createApiKey (2)'] = { - "results": { - "id": "s7NEZW4B4KwD6w8oFeVt", - "name": "Fleet:EnrollmentApiKey:294002ed-c668-4970-9fcf-f516341673fa:policy1", - "api_key": "9sWTYpGNTCilNbYkl9lNFg" - } -} - -exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - create:enrollment_api_keys (3)'] = { - "results": { - "type": "enrollment_api_keys", - "id": "dca6bb47-53d6-4317-99e5-30760483bbbe", - "attributes": { - "created_at": "2019-11-13T14:56:32.063Z", - "api_key_id": "s7NEZW4B4KwD6w8oFeVt", - "policy_id": "policy1", - "active": true, - "enrollment_rules": [], - "name": "Fleet:EnrollmentApiKey:294002ed-c668-4970-9fcf-f516341673fa:policy1" - }, - "references": [], - "updated_at": "2019-11-13T14:56:32.078Z", - "version": "WzMxNiwxXQ==" - } -} - -exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - createApiKey (2)'] = { - "thrownError": "{\"msg\":\"[illegal_state_exception] api keys are not enabled\",\"path\":\"/_security/api_key\",\"body\":\"{\\\"name\\\":\\\"TEST API KEY: 400ef296-d069-4fd4-b7b4-94163e1f889f\\\"}\",\"statusCode\":500,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"}],\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"},\\\"status\\\":500}\"}", - "results": null -} - -exports['ApiKeys Lib verifyAccessApiKey should not verify invalid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyAccessApiKey should not verify invalid ApiKey - authenticate (2)'] = { - "thrownError": "{\"msg\":\"[security_exception] missing authentication credentials for REST request [/_security/_authenticate], with { header={ WWW-Authenticate=\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\" } }\",\"path\":\"/_security/_authenticate\",\"statusCode\":401,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}}],\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}},\\\"status\\\":401}\",\"wwwAuthenticateDirective\":\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\"}", - "results": null -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - createApiKey (2)'] = { - "thrownError": "{\"msg\":\"[illegal_state_exception] api keys are not enabled\",\"path\":\"/_security/api_key\",\"body\":\"{\\\"name\\\":\\\"TEST API KEY: 6f7189a3-2c0e-4823-97d9-e48889d348d3\\\"}\",\"statusCode\":500,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"}],\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"},\\\"status\\\":500}\"}", - "results": null -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - createApiKey (2)'] = { - "thrownError": "{\"msg\":\"[illegal_state_exception] api keys are not enabled\",\"path\":\"/_security/api_key\",\"body\":\"{\\\"name\\\":\\\"TEST API KEY: 6b3b071b-7a0f-4ad2-b390-f43258861944\\\"}\",\"statusCode\":500,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"}],\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"},\\\"status\\\":500}\"}", - "results": null -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - createApiKey (2)'] = { - "thrownError": "{\"msg\":\"[illegal_state_exception] api keys are not enabled\",\"path\":\"/_security/api_key\",\"body\":\"{\\\"name\\\":\\\"TEST API KEY: df703156-fdb0-43e1-95b0-b358e8834b05\\\"}\",\"statusCode\":500,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"}],\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"},\\\"status\\\":500}\"}", - "results": null -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify invalid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify invalid ApiKey - authenticate (2)'] = { - "thrownError": "{\"msg\":\"[security_exception] missing authentication credentials for REST request [/_security/_authenticate], with { header={ WWW-Authenticate=\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\" } }\",\"path\":\"/_security/_authenticate\",\"statusCode\":401,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}}],\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}},\\\"status\\\":401}\",\"wwwAuthenticateDirective\":\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\"}", - "results": null -} - -exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - createApiKey (2)'] = { - "thrownError": "{\"msg\":\"[illegal_state_exception] api keys are not enabled\",\"path\":\"/_security/api_key\",\"body\":\"{\\\"name\\\":\\\"Fleet:EnrollmentApiKey:5696dc78-4271-4ab9-8282-a47820d97177:policy1\\\"}\",\"statusCode\":500,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"}],\\\"type\\\":\\\"illegal_state_exception\\\",\\\"reason\\\":\\\"api keys are not enabled\\\"},\\\"status\\\":500}\"}", - "results": null -} - -exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - createApiKey (2)'] = { - "results": { - "id": "Qc__o24B7IgcxoUvG13b", - "name": "TEST API KEY: 85ea84b5-99d8-4263-98fd-25072f78b22f", - "api_key": "TS3_RkaERR-u519WFhzR9Q" - } -} - -exports['ApiKeys Lib verifyAccessApiKey should verify a valid api key - authenticate (3)'] = { - "results": { - "username": "elastic", - "roles": [], - "full_name": null, - "email": null, - "metadata": { - "_reserved": true - }, - "enabled": true, - "authentication_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - }, - "lookup_realm": { - "name": "_es_api_key", - "type": "_es_api_key" - } - } -} - -exports['ApiKeys Lib verifyAccessApiKey should not verify invalid ApiKey - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyAccessApiKey should not verify invalid ApiKey - authenticate (2)'] = { - "thrownError": "{\"msg\":\"[security_exception] missing authentication credentials for REST request [/_security/_authenticate], with { header={ WWW-Authenticate={ 0=\\\"ApiKey\\\" & 1=\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\" } } }\",\"path\":\"/_security/_authenticate\",\"statusCode\":401,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":[\\\"ApiKey\\\",\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"]}}],\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_security/_authenticate]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":[\\\"ApiKey\\\",\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"]}},\\\"status\\\":401}\",\"wwwAuthenticateDirective\":\"ApiKey, Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\"}", - "results": null -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - createApiKey (2)'] = { - "results": { - "id": "Qs__o24B7IgcxoUvHF3-", - "name": "TEST API KEY: 121af0b2-e3a4-4733-806e-8a14c9ad829b", - "api_key": "DzZDlabpSEiMFMhZRXBudQ" - } -} - -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - create:enrollment_api_keys (3)'] = { - "results": { - "type": "enrollment_api_keys", - "id": "ea7c8201-3ca3-4d0c-8e11-3a605d51080f", - "attributes": { - "active": true, - "api_key_id": "Qs__o24B7IgcxoUvHF3-" - }, - "references": [], - "updated_at": "2019-11-25T19:17:16.596Z", + "updated_at": "2019-12-02T18:21:32.671Z", "version": "WzIsMV0=" } } @@ -567,30 +111,30 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - find "saved_objects": [ { "type": "enrollment_api_keys", - "id": "ea7c8201-3ca3-4d0c-8e11-3a605d51080f", + "id": "f6ef5088-027a-4198-80b5-228dc712c84c", "attributes": { "active": true, - "api_key_id": "Qs__o24B7IgcxoUvHF3-", - "api_key": "j3nnMvEwvFnMq87sOWCLHsYYrC9od+GuTPVSO0K45ZFXydGRvxejKE0vE74hid3F1rEewEJ13n3tVAWVhdHRTkBH3Jo+rrxjouA8rjBBrkKr+i90fHFv7s247hOJaCIN049o6XEF6n2XHftWU6zjp/PCKC70BIarH9l6je9qW+g464Cw5axFoKvkMt/cY03LNlPkIwPPztFA8w==" + "api_key_id": "NAfYx24BHcAAABHLmizj", + "api_key": "uH8vwvTWND7hNnH3603dLVY9GHZisAVx2wKeiZKud6L1x4MRQB68So/EFP4PlAwV5MguQJDs+u/LrzSXVZi54jVtsNdwdT8F+YT+FON3I2uw2/LGlwuqrU13r8b7j02uxL8a7I3E2Nw2nIxdFfds9t9vEg/nshnR3yIFzpUBypM5LHYVk11lXty6ABLgML3Wcm9xmxL/fE2JuQ==" }, "references": [], - "updated_at": "2019-11-25T19:17:16.596Z", + "updated_at": "2019-12-02T18:21:32.671Z", "version": "WzIsMV0=" } ] } } -exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - getDecryptedAsInternalUser:enrollment_api_keys:ea7c8201-3ca3-4d0c-8e11-3a605d51080f (6)'] = { +exports['ApiKeys Lib verifyEnrollmentApiKey should verify a valid api key - getDecryptedAsInternalUser:enrollment_api_keys:f6ef5088-027a-4198-80b5-228dc712c84c (6)'] = { "results": { - "id": "ea7c8201-3ca3-4d0c-8e11-3a605d51080f", + "id": "f6ef5088-027a-4198-80b5-228dc712c84c", "type": "enrollment_api_keys", - "updated_at": "2019-11-25T19:17:16.596Z", + "updated_at": "2019-12-02T18:21:32.671Z", "version": "WzIsMV0=", "attributes": { "active": true, - "api_key_id": "Qs__o24B7IgcxoUvHF3-", - "api_key": "UXNfX28yNEI3SWdjeG9VdkhGMy06RHpaRGxhYnBTRWlNRk1oWlJYQnVkUQ==" + "api_key_id": "NAfYx24BHcAAABHLmizj", + "api_key": "TkFmWXgyNEJIY0FBQUJITG1pemo6UVYxMXdzSWZSUWVRMWdqLV9OcUJ4Zw==" }, "references": [] } @@ -604,13 +148,13 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrolle "saved_objects": [ { "type": "enrollment_api_keys", - "id": "ea7c8201-3ca3-4d0c-8e11-3a605d51080f", + "id": "f6ef5088-027a-4198-80b5-228dc712c84c", "attributes": { "active": true, - "api_key_id": "Qs__o24B7IgcxoUvHF3-" + "api_key_id": "NAfYx24BHcAAABHLmizj" }, "references": [], - "updated_at": "2019-11-25T19:17:16.596Z", + "updated_at": "2019-12-02T18:21:32.671Z", "version": "WzIsMV0=" } ] @@ -623,22 +167,22 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrolle exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - createApiKey (3)'] = { "results": { - "id": "Q8__o24B7IgcxoUvJl07", - "name": "TEST API KEY: 9af30b98-15f3-43e9-90c8-f18a78557aa6", - "api_key": "L9b16RB2TOKAHLYfem2Nuw" + "id": "NQfYx24BHcAAABHLoizJ", + "name": "TEST API KEY: 926dcc43-476b-4be7-9882-0d3a257a426f", + "api_key": "QYuBI5gvSDuvnUUpFV7HwQ" } } exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - create:enrollment_api_keys (4)'] = { "results": { "type": "enrollment_api_keys", - "id": "fb272aba-237d-46bc-8fb2-55afd210cdf9", + "id": "50e62ce1-3307-4877-8864-4f7f5623d57b", "attributes": { "active": false, - "api_key_id": "Q8__o24B7IgcxoUvJl07" + "api_key_id": "NQfYx24BHcAAABHLoizJ" }, "references": [], - "updated_at": "2019-11-25T19:17:18.618Z", + "updated_at": "2019-12-02T18:21:34.699Z", "version": "WzQsMV0=" } } @@ -672,30 +216,30 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrolle "saved_objects": [ { "type": "enrollment_api_keys", - "id": "fb272aba-237d-46bc-8fb2-55afd210cdf9", + "id": "50e62ce1-3307-4877-8864-4f7f5623d57b", "attributes": { "active": false, - "api_key_id": "Q8__o24B7IgcxoUvJl07", - "api_key": "zdzGDZpkO2GjnHdVuvoCM4OnpKgB4sBSkZVyDHqBGTwsP8cIlfBlEaL+fKxTu3g10FTWlJRAuHA9bfxHZ0npV51PjGJzh+oeIEF2o4oEEtdKEidmsHmFiSw8Nl3czUZe3t6h3Fex3IEGN1Hb5f9UgNrEITjCsiu7RBgmurbGyO/BvTtGhPYoSHrbmicfapGPI2IT8+uywJNCag==" + "api_key_id": "NQfYx24BHcAAABHLoizJ", + "api_key": "+cenCs4Yw1KRNZ1a8xKnD33Mt6BTcDwswZCP5M+0IGTeiruJhxozMv2/Cux6r5oUrqBeDFhOmkNxM9iyB8SxsLV2m/vv8g6VgyCTVQIvPGaRwCDNKoSsCEFtGkG5T45tkbeSsJ1u6syossAl9vmvbTYNUepSLxLBCGEAR1+2LLrHEExnf43Byvaok1qN24/sRgVXxhuwjzSHGQ==" }, "references": [], - "updated_at": "2019-11-25T19:17:18.618Z", + "updated_at": "2019-12-02T18:21:34.699Z", "version": "WzQsMV0=" } ] } } -exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - getDecryptedAsInternalUser:enrollment_api_keys:fb272aba-237d-46bc-8fb2-55afd210cdf9 (7)'] = { +exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive enrollemnt api key - getDecryptedAsInternalUser:enrollment_api_keys:50e62ce1-3307-4877-8864-4f7f5623d57b (7)'] = { "results": { - "id": "fb272aba-237d-46bc-8fb2-55afd210cdf9", + "id": "50e62ce1-3307-4877-8864-4f7f5623d57b", "type": "enrollment_api_keys", - "updated_at": "2019-11-25T19:17:18.618Z", + "updated_at": "2019-12-02T18:21:34.699Z", "version": "WzQsMV0=", "attributes": { "active": false, - "api_key_id": "Q8__o24B7IgcxoUvJl07", - "api_key": "UThfX28yNEI3SWdjeG9VdkpsMDc6TDliMTZSQjJUT0tBSExZZmVtMk51dw==" + "api_key_id": "NQfYx24BHcAAABHLoizJ", + "api_key": "TlFmWXgyNEJIY0FBQUJITG9peko6UVl1Qkk1Z3ZTRHV2blVVcEZWN0h3UQ==" }, "references": [] } @@ -709,13 +253,13 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enro "saved_objects": [ { "type": "enrollment_api_keys", - "id": "fb272aba-237d-46bc-8fb2-55afd210cdf9", + "id": "50e62ce1-3307-4877-8864-4f7f5623d57b", "attributes": { "active": false, - "api_key_id": "Q8__o24B7IgcxoUvJl07" + "api_key_id": "NQfYx24BHcAAABHLoizJ" }, "references": [], - "updated_at": "2019-11-25T19:17:18.618Z", + "updated_at": "2019-12-02T18:21:34.699Z", "version": "WzQsMV0=" } ] @@ -728,9 +272,9 @@ exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enro exports['ApiKeys Lib verifyEnrollmentApiKey should not verify a inactive an enrollemnt api key not persisted - createApiKey (3)'] = { "results": { - "id": "RM__o24B7IgcxoUvLl0n", - "name": "TEST API KEY: 907726c7-483e-4668-8b87-266e9dd02b2c", - "api_key": "iOCKY7WaQ-a--vO4VHlGnw" + "id": "NgfYx24BHcAAABHLqiy3", + "name": "TEST API KEY: 4999e798-9bd6-4f01-8906-d788004bf2e3", + "api_key": "LRhSoquWQ5qdeIokYOAt5Q" } } @@ -789,26 +333,26 @@ exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - f exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - createApiKey (2)'] = { "results": { - "id": "Rc__o24B7IgcxoUvMF20", - "name": "Fleet:EnrollmentApiKey:4ba8f45d-405b-40a5-8f62-0e9fc3b5a0fa:policy1", - "api_key": "pZWRxpnoS3qUmxyUAW4xhA" + "id": "NwfYx24BHcAAABHLrix5", + "name": "87fdfc0c-71e3-4fa9-afa2-45566940eaa5", + "api_key": "DusvTWfGTGufWX_sZU4tDA" } } exports['ApiKeys Lib generateEnrollmentApiKey should generate a valid ApiKey - create:enrollment_api_keys (3)'] = { "results": { "type": "enrollment_api_keys", - "id": "e4908759-71c7-4bea-a4c7-e2000137faae", + "id": "c65148fd-772a-483b-a589-54560d5bbb25", "attributes": { - "created_at": "2019-11-25T19:17:21.645Z", - "api_key_id": "Rc__o24B7IgcxoUvMF20", + "created_at": "2019-12-02T18:21:37.721Z", + "api_key_id": "NwfYx24BHcAAABHLrix5", "policy_id": "policy1", "active": true, "enrollment_rules": [], - "name": "Fleet:EnrollmentApiKey:4ba8f45d-405b-40a5-8f62-0e9fc3b5a0fa:policy1" + "name": "87fdfc0c-71e3-4fa9-afa2-45566940eaa5" }, "references": [], - "updated_at": "2019-11-25T19:17:21.661Z", + "updated_at": "2019-12-02T18:21:37.734Z", "version": "WzYsMV0=" } } diff --git a/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap b/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap index 78d00662fe0ae..17ac01da211ae 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap +++ b/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap @@ -2,6 +2,7 @@ exports[`Policies Lib getWithAgentFormating Should return a policy with all datasource, formatted for agent 1`] = ` Object { + "id": "policy_example", "outputs": Object { "default": Object { "api_token": "slfhsdlfhjjkshfkjh:sdfsdfsdfsdf", diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts index 80c3d702041e2..8ee50728e59d7 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.contract.test.ts @@ -16,8 +16,6 @@ import { MemorizeSODatabaseAdapter } from '../adapters/saved_objects_database/me import { SODatabaseAdapter } from '../adapters/saved_objects_database/default'; import { FleetServerLib } from './types'; import { compose } from './compose/memorized'; -import { MemorizedElasticsearchAdapter } from '../adapters/elasticsearch/memorize_adapter'; -import { ElasticsearchAdapter } from '../adapters/elasticsearch/default'; import { Agent } from '../repositories/agents/types'; jest.mock('./framework'); @@ -61,10 +59,9 @@ function getUser(): FrameworkUser { } as unknown) as FrameworkUser; } -describe('ApiKeys Lib', () => { +describe('AgentPolicy Lib', () => { let servers: any; let soAdapter: MemorizeSODatabaseAdapter; - let esAdapter: MemorizedElasticsearchAdapter; let libs: FleetServerLib; async function getAgentById(agentId: string) { @@ -106,9 +103,6 @@ describe('ApiKeys Lib', () => { servers = await createKibanaServer({ security: { enabled: false }, }); - esAdapter = new MemorizedElasticsearchAdapter( - new ElasticsearchAdapter(servers.kbnServer.plugins.elasticsearch) - ); soAdapter = new MemorizeSODatabaseAdapter( new SODatabaseAdapter( servers.kbnServer.savedObjects, @@ -120,9 +114,6 @@ describe('ApiKeys Lib', () => { if (!soAdapter) { soAdapter = new MemorizeSODatabaseAdapter(); } - if (!esAdapter) { - esAdapter = new MemorizedElasticsearchAdapter(); - } }); afterAll(async () => { From f9daf2c4123c2c37cd3f41d01d8171a82d407ca6 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 3 Dec 2019 11:00:45 -0500 Subject: [PATCH 3/5] Fix after merge --- .../agent_list/components/agent_enrollment.tsx | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx b/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx index a1ee5707ef848..8682371abdfbd 100644 --- a/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx +++ b/x-pack/legacy/plugins/fleet/public/pages/agent_list/components/agent_enrollment.tsx @@ -131,21 +131,6 @@ export const AgentEnrollmentFlyout: React.FC = ({ onClose, policies )} - - - } - > - ({ value: p.id, inputDisplay: p.name }))} - valueOfSelected={selectedPolicy || ''} - onChange={value => setSelectedPolicy(value)} - /> - ); From 6aeef00824d245a1dd7078119f7a264253e743b4 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 3 Dec 2019 14:23:11 -0500 Subject: [PATCH 4/5] Fix after review and more doc --- .../fleet/dev_docs/actions_and_events.md | 66 +++++++++++++++++++ .../fleet/dev_docs/api/agents_checkin.md | 2 - .../legacy/plugins/fleet/server/libs/agent.ts | 45 ++++--------- .../plugins/fleet/server/libs/agent_event.ts | 51 ++++++++++++++ .../plugins/fleet/server/libs/agent_policy.ts | 1 + .../fleet/server/libs/compose/kibana.ts | 6 +- .../fleet/server/libs/compose/memorized.ts | 5 +- .../legacy/plugins/fleet/server/libs/types.ts | 2 + .../server/repositories/agent_events/types.ts | 6 +- .../fleet/server/routes/agents/events.ts | 2 +- 10 files changed, 146 insertions(+), 40 deletions(-) create mode 100644 x-pack/legacy/plugins/fleet/dev_docs/actions_and_events.md create mode 100644 x-pack/legacy/plugins/fleet/server/libs/agent_event.ts diff --git a/x-pack/legacy/plugins/fleet/dev_docs/actions_and_events.md b/x-pack/legacy/plugins/fleet/dev_docs/actions_and_events.md new file mode 100644 index 0000000000000..1f1b59788613a --- /dev/null +++ b/x-pack/legacy/plugins/fleet/dev_docs/actions_and_events.md @@ -0,0 +1,66 @@ +## Agent Fleet: actions protocol + +Agent is using `actions` and `events` to comunicate with fleet during checkin. + +## Actions + +Action are returned to the agent during the checkin [see](./api/agents_checkin) +Agent should aknowledge the fact they received an action for that they can send one of this two events during checkin: + +```js +{ + "events": [{ + { + "type": "ACTION", + "subtype": "ACKNOWLEDGED" + "message": "acknowledge action : 1", + "action_id": "action_id_1" , + "timestamp": "2018-01-02T.." + }, { + "type": "ACTION", + "subtype": "UNKNOWN" + "message": "Unsupported action : 2", + "action_id": "action_id_2" , + "timestamp": "2018-01-02T.." + }] +} +``` + +### POLICY_CHANGE + +This action is send when a new policy is available, the policy is available under the `data` field. + +```js +{ + "type": "POLICY_CHANGE", + "id": "action_id_1", + "data": { + "policy": { + "id": "policy_id", + "outputs": { + "default": { + "api_key": "slfhsdlfhjjkshfkjh:sdfsdfsdfsdf", + "id": "default", + "name": "Default", + "type": "elasticsearch", + "url": "https://localhost:9200", + } + }, + "streams": [ + { + "metricsets": [ + "container", + "cpu" + ], + "id": "string", + "type": "etc", + "output": { + "use_output": "default" + } + } + ] + } + } + }] +} +``` diff --git a/x-pack/legacy/plugins/fleet/dev_docs/api/agents_checkin.md b/x-pack/legacy/plugins/fleet/dev_docs/api/agents_checkin.md index ae74d150e504e..f5949de8bc536 100644 --- a/x-pack/legacy/plugins/fleet/dev_docs/api/agents_checkin.md +++ b/x-pack/legacy/plugins/fleet/dev_docs/api/agents_checkin.md @@ -42,8 +42,6 @@ Authorization: ApiKey VALID_ACCESS_API_KEY { "action": "checkin", "success": true, - "policy": { - }, "actions": [] } ``` diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent.ts b/x-pack/legacy/plugins/fleet/server/libs/agent.ts index befd6344e1592..7110a4efd0602 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent.ts @@ -16,20 +16,17 @@ import { NewAgent, SortOptions, } from '../repositories/agents/types'; -import { AgentEvent, AgentEventsRepository } from '../repositories/agent_events/types'; +import { AgentEvent } from '../repositories/agent_events/types'; import { AgentPolicy } from '../repositories/policies/types'; import { ApiKeyLib } from './api_keys'; -import { PolicyLib } from './policy'; import { AgentStatusHelper } from './agent_status_helper'; +import { AgentEventLib } from './agent_event'; export class AgentLib { constructor( private readonly agentsRepository: AgentsRepository, - private readonly agentEventsRepository: AgentEventsRepository, private readonly apiKeys: ApiKeyLib, - // TODO remove will be used later - // @ts-ignore - private readonly policies: PolicyLib + private readonly agentEvents: AgentEventLib ) {} /** @@ -166,7 +163,7 @@ export class AgentLib { */ public async delete(user: FrameworkUser, agent: Agent) { if (agent.type === 'EPHEMERAL') { - await this.agentEventsRepository.deleteEventsForAgent(user, agent.id); + await this.agentEvents.deleteEventsForAgent(user, agent.id); return await this.agentsRepository.delete(user, agent); } @@ -180,23 +177,6 @@ export class AgentLib { return await this.agentsRepository.getById(user, id); } - /** - * Get events for a given agent - */ - public async getEventsById( - user: FrameworkUser, - agentId: string, - search?: string, - page: number = 1, - perPage: number = 25 - ): Promise<{ items: AgentEvent[]; total: number }> { - return await this.agentEventsRepository.getEventsForAgent(user, agentId, { - search, - page, - perPage, - }); - } - /** * Agent checkin, update events, get new actions to perfomed. * @param agent @@ -235,19 +215,18 @@ export class AgentLib { updateData.local_metadata = localMetadata; } - if (events.length > 0) { - // TODO move this to an AgentEvent lib https://github.com/elastic/kibana/issues/51976 - const acknowledgedActions = events - .filter(e => e.type === 'ACTION' && e.subtype === 'ACKNOWLEDGE') - .map(e => e.action_id); - + const { acknowledgedActionIds } = await this.agentEvents.processEventsForCheckin( + internalUser, + agent.id, + events + ); + if (acknowledgedActionIds.length > 0) { const updatedActions = actions.map(a => { - return { ...a, sent_at: acknowledgedActions.indexOf(a.id) >= 0 ? now : undefined }; + return { ...a, sent_at: acknowledgedActionIds.indexOf(a.id) >= 0 ? now : undefined }; }); updateData.actions = updatedActions; - - await this.agentEventsRepository.createEventsForAgent(internalUser, agent.id, events); } + await this.agentsRepository.update(internalUser, agent.id, updateData); return { actions: updateData.actions || actions, policy: null }; diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_event.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_event.ts new file mode 100644 index 0000000000000..100539ab66f03 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_event.ts @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FrameworkUser } from '../adapters/framework/adapter_types'; +import { AgentEventsRepository } from '../repositories/agent_events/default'; +import { AgentEvent } from '../repositories/agent_events/types'; + +/** + * This is the server lib to manage everything related to policies and agents + */ +export class AgentEventLib { + constructor(private readonly agentEventsRepository: AgentEventsRepository) {} + + public async processEventsForCheckin(user: FrameworkUser, agentId: string, events: AgentEvent[]) { + let acknowledgedActionIds: string[] = []; + if (events.length > 0) { + acknowledgedActionIds = events + .filter( + e => e.type === 'ACTION' && (e.subtype === 'ACKNOWLEDGED' || e.subtype === 'UNKNOWN') + ) + .map(e => e.action_id as string); + + await this.agentEventsRepository.createEventsForAgent(user, agentId, events); + } + + return { + acknowledgedActionIds, + }; + } + + public async deleteEventsForAgent(user: FrameworkUser, agentId: string) { + await this.agentEventsRepository.deleteEventsForAgent(user, agentId); + } + + public async getEventsById( + user: FrameworkUser, + agentId: string, + search?: string, + page: number = 1, + perPage: number = 25 + ): Promise<{ items: AgentEvent[]; total: number }> { + return await this.agentEventsRepository.getEventsForAgent(user, agentId, { + search, + page, + perPage, + }); + } +} diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts index 0dca3d3492831..5d3725997b34b 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts @@ -42,6 +42,7 @@ export class AgentPolicyLib { }); if (agents.length === 0) { hasMore = false; + break; } const agentUpdate = agents.map(agent => { diff --git a/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts b/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts index 0188fd3891aad..21bc6e9e94209 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts @@ -23,6 +23,7 @@ import { AgentEventsRepository } from '../../repositories/agent_events/default'; import { InstallLib } from '../install'; import { ElasticsearchAdapter } from '../../adapters/elasticsearch/default'; import { AgentPolicyLib } from '../agent_policy'; +import { AgentEventLib } from '../agent_event'; export function compose(server: any): FleetServerLib { const frameworkAdapter = new FrameworkAdapter(server); @@ -49,9 +50,9 @@ export function compose(server: any): FleetServerLib { const policies = new PolicyLib(policyAdapter); const apiKeys = new ApiKeyLib(enrollmentApiKeysRepository, esAdapter, framework); - const agents = new AgentLib(agentsRepository, agentEventsRepository, apiKeys, policies); - const agentsPolicy = new AgentPolicyLib(agentsRepository, policies); + const agentEvents = new AgentEventLib(agentEventsRepository); + const agents = new AgentLib(agentsRepository, apiKeys, agentEvents); const artifactRepository = new FileSystemArtifactRepository(os.tmpdir()); const artifacts = new ArtifactLib(artifactRepository, new HttpAdapter()); @@ -61,6 +62,7 @@ export function compose(server: any): FleetServerLib { return { agents, agentsPolicy, + agentEvents, apiKeys, policies, artifacts, diff --git a/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts b/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts index a9c4818eaaff4..37c7be67e9084 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/compose/memorized.ts @@ -26,6 +26,7 @@ import { MemorizeSODatabaseAdapter } from '../../adapters/saved_objects_database import { MemorizedElasticsearchAdapter } from '../../adapters/elasticsearch/memorize_adapter'; import { MemorizeEncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/memorize_adapter'; import { AgentPolicyLib } from '../agent_policy'; +import { AgentEventLib } from '../agent_event'; export function compose(server?: any): FleetServerLib { const frameworkAdapter = new FrameworkAdapter(server); @@ -55,7 +56,8 @@ export function compose(server?: any): FleetServerLib { const policies = new PolicyLib(policyRepository); const apiKeys = new ApiKeyLib(enrollmentApiKeysRepository, esAdapter, framework); - const agents = new AgentLib(agentsRepository, agentEventsRepository, apiKeys, policies); + const agentEvents = new AgentEventLib(agentEventsRepository); + const agents = new AgentLib(agentsRepository, apiKeys, agentEvents); const artifactRepository = new FileSystemArtifactRepository(os.tmpdir()); const artifacts = new ArtifactLib(artifactRepository, new HttpAdapter()); @@ -64,6 +66,7 @@ export function compose(server?: any): FleetServerLib { return { agents, + agentEvents, apiKeys, policies, artifacts, diff --git a/x-pack/legacy/plugins/fleet/server/libs/types.ts b/x-pack/legacy/plugins/fleet/server/libs/types.ts index b2abc431cb081..4bb5810109555 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/types.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/types.ts @@ -11,6 +11,7 @@ import { ArtifactLib } from './artifact'; import { InstallLib } from './install'; import { FrameworkLib } from './framework'; import { AgentPolicyLib } from './agent_policy'; +import { AgentEventLib } from './agent_event'; export interface FleetServerLib { apiKeys: ApiKeyLib; @@ -20,4 +21,5 @@ export interface FleetServerLib { install: InstallLib; framework: FrameworkLib; agentsPolicy: AgentPolicyLib; + agentEvents: AgentEventLib; } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts index 4d11bd63883ba..d3b85fe19d5e8 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/types.ts @@ -15,14 +15,18 @@ export const RuntimeAgentEventType = t.union([ ]); export const RuntimeAgentEventSubtype = t.union([ + // State t.literal('RUNNING'), t.literal('STARTING'), t.literal('IN_PROGRESS'), t.literal('CONFIG'), t.literal('FAILED'), t.literal('STOPPED'), + // Action results t.literal('DATA_DUMP'), - t.literal('ACKNOWLEDGE'), + // Actions + t.literal('ACKNOWLEDGED'), + t.literal('UNKNOWN'), ]); export const RuntimeAgentEvent = t.intersection( diff --git a/x-pack/legacy/plugins/fleet/server/routes/agents/events.ts b/x-pack/legacy/plugins/fleet/server/routes/agents/events.ts index 70824f6cd9800..f2d6c2a492fa9 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/agents/events.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/agents/events.ts @@ -40,7 +40,7 @@ export const createGETAgentEventsRoute = (libs: FleetServerLib) => ({ const page = parseInt(request.query.page, 10); const perPage = parseInt(request.query.per_page, 10); - const { items, total } = await libs.agents.getEventsById( + const { items, total } = await libs.agentEvents.getEventsById( request.user, request.params.agentId, request.query.kuery, From b612ab4bbf9385b7d18b520b3ce2b31a8472ee12 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 3 Dec 2019 15:49:30 -0500 Subject: [PATCH 5/5] Fix missings slaspshot --- .../agent_policy.contract.test.slap_snap | 1047 ++--------------- .../plugins/fleet/server/libs/agent_policy.ts | 2 +- 2 files changed, 87 insertions(+), 962 deletions(-) diff --git a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap index 5455747b252f2..bd247d9c6185d 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/libs/__memorize_snapshots__/agent_policy.contract.test.slap_snap @@ -1,640 +1,5 @@ -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "e669efa0-150a-11ea-8ad9-d10bed68f7b3", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}" - }, - "references": [], - "updated_at": "2019-12-02T13:51:54.778Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "7cff2bf0-150c-11ea-836d-474a0a44645c", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}" - }, - "references": [], - "updated_at": "2019-12-02T14:03:16.911Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "7cff2bf0-150c-11ea-836d-474a0a44645c", - "type": "agents", - "updated_at": "2019-12-02T14:03:16.911Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}" - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:09:34.421Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", - "type": "agents", - "updated_at": "2019-12-02T14:09:34.421Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { - "results": { - "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", - "type": "agents", - "updated_at": "2019-12-02T14:09:35.350Z", - "version": "WzMsMV0=", - "attributes": { - "actions": [ - { - "id": "1f742219-4d96-45cf-b275-9201ff3c83a4", - "type": "POLICY_CHANGE", - "created_at": "2019-12-02T14:09:35.348Z", - "data": "{\"policy\":{\"id\":\"default\",\"outputs\":{},\"streams\":[],\"name\":\"Policy 1\",\"updated_by\":\"johndoe\",\"updated_on\":\"2019-09-23T20:46:42+0000\",\"version\":0,\"created_by\":\"johndoe\",\"created_on\":\"2019-09-23T20:46:42+0000\"}}" - } - ] - } - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { - "results": { - "id": "5e02c760-150d-11ea-976f-3b5d44ae2d6d", - "type": "agents", - "updated_at": "2019-12-02T14:09:35.350Z", - "version": "WzMsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"id\":\"default\",\"outputs\":{},\"streams\":[],\"name\":\"Policy 1\",\"updated_by\":\"johndoe\",\"updated_on\":\"2019-09-23T20:46:42+0000\",\"version\":0,\"created_by\":\"johndoe\",\"created_on\":\"2019-09-23T20:46:42+0000\"}}", - "created_at": "2019-12-02T14:09:35.348Z", - "id": "1f742219-4d96-45cf-b275-9201ff3c83a4", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:33:55.907Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", - "type": "agents", - "updated_at": "2019-12-02T14:33:55.907Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { - "results": { - "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", - "type": "agents", - "updated_at": "2019-12-02T14:33:56.725Z", - "version": "WzMsMV0=", - "attributes": { - "actions": [ - { - "id": "ce67857d-53ab-4db0-b5c7-e1e1834d3b56", - "type": "POLICY_CHANGE", - "created_at": "2019-12-02T14:33:56.724Z", - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" - } - ] - } - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { - "results": { - "id": "c51fb130-1510-11ea-bcd5-b59bad6abd3f", - "type": "agents", - "updated_at": "2019-12-02T14:33:56.725Z", - "version": "WzMsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:33:56.724Z", - "id": "ce67857d-53ab-4db0-b5c7-e1e1834d3b56", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "286b00f0-1511-11ea-a27e-2717661c3dab", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:36:42.495Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "286b00f0-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:42.495Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { - "results": { - "id": "286b00f0-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:42.745Z", - "version": "WzMsMV0=", - "attributes": { - "actions": [ - { - "id": "7e5c256a-1f12-47e3-a0ac-dcda013a6462", - "type": "POLICY_CHANGE", - "created_at": "2019-12-02T14:36:42.743Z", - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" - } - ] - } - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { - "results": { - "id": "286b00f0-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:42.745Z", - "version": "WzMsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:36:42.743Z", - "id": "7e5c256a-1f12-47e3-a0ac-dcda013a6462", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "292ddbc0-1511-11ea-a27e-2717661c3dab", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:36:43.772Z", - "version": "WzQsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { - "results": { - "type": "agents", - "id": "29c69950-1511-11ea-a27e-2717661c3dab", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:36:44.773Z", - "version": "WzUsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { - "results": { - "type": "agents", - "id": "2a65e690-1511-11ea-a27e-2717661c3dab", - "attributes": { - "policy_id": "policy2", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:36:45.817Z", - "version": "WzYsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { - "results": { - "page": 1, - "per_page": 100, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { - "results": { - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (7)'] = { - "results": { - "id": "292ddbc0-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:43.772Z", - "version": "WzQsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (8)'] = { - "results": { - "id": "29c69950-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:44.773Z", - "version": "WzUsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { - "results": { - "id": "2a65e690-1511-11ea-a27e-2717661c3dab", - "type": "agents", - "updated_at": "2019-12-02T14:36:45.817Z", - "version": "WzYsMV0=", - "attributes": { - "policy_id": "policy2", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "6852b6e0-1511-11ea-a155-519330227ea0", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:38:29.709Z", - "version": "WzIsMV0=" - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "6852b6e0-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:29.709Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { - "results": { - "id": "6852b6e0-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:30.027Z", - "version": "WzMsMV0=", - "attributes": { - "actions": [ - { - "id": "44adbc65-4b99-4aef-a620-fa99016b5a0f", - "type": "POLICY_CHANGE", - "created_at": "2019-12-02T14:38:30.024Z", - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" - } - ] - } - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { - "results": { - "id": "6852b6e0-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:30.027Z", - "version": "WzMsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:38:30.024Z", - "id": "44adbc65-4b99-4aef-a620-fa99016b5a0f", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "691f55b0-1511-11ea-a155-519330227ea0", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:38:31.051Z", - "version": "WzQsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { - "results": { - "type": "agents", - "id": "69b83a50-1511-11ea-a155-519330227ea0", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:38:32.053Z", - "version": "WzUsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { - "results": { - "type": "agents", - "id": "6a5341d0-1511-11ea-a155-519330227ea0", - "attributes": { - "policy_id": "policy2", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T14:38:33.068Z", - "version": "WzYsMV0=" - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { - "results": { - "page": 1, - "per_page": 100, - "total": 0, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { - "results": { - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (7)'] = { - "results": { - "id": "691f55b0-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:31.051Z", - "version": "WzQsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (8)'] = { - "results": { - "id": "69b83a50-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:32.053Z", - "version": "WzUsMV0=", - "attributes": { - "policy_id": "default", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { - "results": { - "id": "6a5341d0-1511-11ea-a155-519330227ea0", - "type": "agents", - "updated_at": "2019-12-02T14:38:33.068Z", - "version": "WzYsMV0=", - "attributes": { - "policy_id": "policy2", - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { "results": { "page": 1, "per_page": 1000, @@ -643,10 +8,10 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new } } -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { "results": { "type": "agents", - "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -655,16 +20,16 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:44.888Z", + "updated_at": "2019-12-03T20:46:48.861Z", "version": "WzIsMV0=" } } -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { "results": { - "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T14:41:44.888Z", + "updated_at": "2019-12-03T20:46:48.861Z", "version": "WzIsMV0=", "attributes": { "policy_id": "default", @@ -677,18 +42,18 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new } } -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { "results": { - "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T14:41:45.862Z", + "updated_at": "2019-12-03T20:46:49.451Z", "version": "WzMsMV0=", "attributes": { "actions": [ { - "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "id": "b89e5542-f40e-4f4c-810f-d9b3f8322f14", "type": "POLICY_CHANGE", - "created_at": "2019-12-02T14:41:45.859Z", + "created_at": "2019-12-03T20:46:49.450Z", "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" } ] @@ -696,11 +61,11 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new } } -exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { +exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { "results": { - "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T14:41:45.862Z", + "updated_at": "2019-12-03T20:46:49.451Z", "version": "WzMsMV0=", "attributes": { "policy_id": "default", @@ -710,8 +75,8 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new "actions": [ { "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:41:45.859Z", - "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "created_at": "2019-12-03T20:46:49.450Z", + "id": "b89e5542-f40e-4f4c-810f-d9b3f8322f14", "type": "POLICY_CHANGE" } ] @@ -720,7 +85,7 @@ exports['ApiKeys Lib updateAgentForPolicyId Should update the agent with the new } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { "results": { "page": 1, "per_page": 1000, @@ -729,10 +94,10 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { "results": { "type": "agents", - "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", + "id": "07d2f340-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -741,15 +106,15 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:46.904Z", + "updated_at": "2019-12-03T20:46:50.484Z", "version": "WzQsMV0=" } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { "results": { "type": "agents", - "id": "de755440-1511-11ea-9f34-65c55b2d70d9", + "id": "086a9f60-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -758,15 +123,15 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:47.907Z", + "updated_at": "2019-12-03T20:46:51.478Z", "version": "WzUsMV0=" } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { "results": { "type": "agents", - "id": "df12a5b0-1511-11ea-9f34-65c55b2d70d9", + "id": "0906b850-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "policy2", "active": true, @@ -775,12 +140,12 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:48.939Z", + "updated_at": "2019-12-03T20:46:52.501Z", "version": "WzYsMV0=" } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { "results": { "page": 1, "per_page": 100, @@ -788,7 +153,7 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "saved_objects": [ { "type": "agents", - "id": "dca8aa90-1511-11ea-9f34-65c55b2d70d9", + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -797,19 +162,19 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [ { "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:41:45.859Z", - "id": "3b265219-71cc-4f26-ba87-90417066dc02", + "created_at": "2019-12-03T20:46:49.450Z", + "id": "b89e5542-f40e-4f4c-810f-d9b3f8322f14", "type": "POLICY_CHANGE" } ] }, "references": [], - "updated_at": "2019-12-02T14:41:45.862Z", + "updated_at": "2019-12-03T20:46:49.451Z", "version": "WzMsMV0=" }, { "type": "agents", - "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", + "id": "07d2f340-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -818,12 +183,12 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:46.904Z", + "updated_at": "2019-12-03T20:46:50.484Z", "version": "WzQsMV0=" }, { "type": "agents", - "id": "de755440-1511-11ea-9f34-65c55b2d70d9", + "id": "086a9f60-160e-11ea-989f-e12ac0a7162a", "attributes": { "policy_id": "default", "active": true, @@ -832,298 +197,69 @@ exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the "actions": [] }, "references": [], - "updated_at": "2019-12-02T14:41:47.907Z", + "updated_at": "2019-12-03T20:46:51.478Z", "version": "WzUsMV0=" } ] } } -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (7)'] = { - "results": { - "page": 2, - "per_page": 100, - "total": 3, - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (8)'] = { - "results": { - "saved_objects": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { - "results": { - "id": "dddc2180-1511-11ea-9f34-65c55b2d70d9", - "type": "agents", - "updated_at": "2019-12-02T14:41:50.094Z", - "version": "WzgsMV0=", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:41:50.043Z", - "id": "0754c11b-74c9-47dc-ad30-c7bbef7508d1", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (10)'] = { - "results": { - "id": "de755440-1511-11ea-9f34-65c55b2d70d9", - "type": "agents", - "updated_at": "2019-12-02T14:41:50.094Z", - "version": "WzksMV0=", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T14:41:50.044Z", - "id": "cf6733f7-5482-4928-970b-992124a6ee07", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (11)'] = { - "results": { - "id": "df12a5b0-1511-11ea-9f34-65c55b2d70d9", - "type": "agents", - "updated_at": "2019-12-02T14:41:48.939Z", - "version": "WzYsMV0=", - "attributes": { - "policy_id": "policy2", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['ApiKeys Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { - "thrownError": "{\"msg\":\"unknown error\",\"path\":\"/_bulk\",\"query\":{\"refresh\":\"wait_for\"},\"body\":\"{\\\"update\\\":{\\\"_id\\\":\\\"agents:dca8aa90-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:45.859Z\\\",\\\"id\\\":\\\"3b265219-71cc-4f26-ba87-90417066dc02\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\"},{\\\"id\\\":\\\"21e05485-c488-4504-8a81-72a56839755a\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.043Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:dddc2180-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"0754c11b-74c9-47dc-ad30-c7bbef7508d1\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.043Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:de755440-1511-11ea-9f34-65c55b2d70d9\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"cf6733f7-5482-4928-970b-992124a6ee07\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T14:41:50.044Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T14:41:50.094Z\\\"}}\\n\",\"statusCode\":0}", - "results": null -} - -exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:25.622Z", - "version": "WzIsMV0=" - } -} - -exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (3)'] = { - "results": { - "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", - "type": "agents", - "updated_at": "2019-12-02T20:48:25.622Z", - "version": "WzIsMV0=", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [] - } -} - -exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - update:agents (4)'] = { - "results": { - "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", - "type": "agents", - "updated_at": "2019-12-02T20:48:25.986Z", - "version": "WzMsMV0=", - "attributes": { - "actions": [ - { - "id": "46f35c21-d60c-458a-be45-4682d9126906", - "type": "POLICY_CHANGE", - "created_at": "2019-12-02T20:48:25.984Z", - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" - } - ] - } - } -} - -exports['AgentPolicy Lib updateAgentForPolicyId Should update the agent with the new policy - get:agents (5)'] = { - "results": { - "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", - "type": "agents", - "updated_at": "2019-12-02T20:48:25.986Z", - "version": "WzMsMV0=", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [ - { - "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T20:48:25.984Z", - "id": "46f35c21-d60c-458a-be45-4682d9126906", - "type": "POLICY_CHANGE" - } - ] - }, - "references": [] - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"enrollment_api_keys" (1)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (2)'] = { - "results": { - "type": "agents", - "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:27.011Z", - "version": "WzQsMV0=" - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (3)'] = { - "results": { - "type": "agents", - "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", - "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:28.008Z", - "version": "WzUsMV0=" - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - create:agents (4)'] = { - "results": { - "type": "agents", - "id": "182499c0-1545-11ea-8a4c-d782b3e0e16c", - "attributes": { - "policy_id": "policy2", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:29.020Z", - "version": "WzYsMV0=" - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - find:"agents" (5)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { "results": { - "page": 1, - "per_page": 100, - "total": 3, "saved_objects": [ { + "id": "06db4cd0-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "id": "161e1b60-1545-11ea-8a4c-d782b3e0e16c", + "updated_at": "2019-12-03T20:46:53.571Z", + "version": "WzcsMV0=", "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", "actions": [ { "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T20:48:25.984Z", - "id": "46f35c21-d60c-458a-be45-4682d9126906", + "created_at": "2019-12-03T20:46:49.450Z", + "id": "b89e5542-f40e-4f4c-810f-d9b3f8322f14", "type": "POLICY_CHANGE" + }, + { + "id": "57d10e58-be39-4d60-b946-e638750fc688", + "type": "POLICY_CHANGE", + "created_at": "2019-12-03T20:46:53.567Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" } ] - }, - "references": [], - "updated_at": "2019-12-02T20:48:25.986Z", - "version": "WzMsMV0=" + } }, { + "id": "07d2f340-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", + "updated_at": "2019-12-03T20:46:53.571Z", + "version": "WzgsMV0=", "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:27.011Z", - "version": "WzQsMV0=" + "actions": [ + { + "id": "4b7fa740-4b30-47cd-8a41-5391fbbb235c", + "type": "POLICY_CHANGE", + "created_at": "2019-12-03T20:46:53.567Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } }, { + "id": "086a9f60-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", + "updated_at": "2019-12-03T20:46:53.571Z", + "version": "WzksMV0=", "attributes": { - "policy_id": "default", - "active": true, - "local_metadata": "{}", - "user_provided_metadata": "{}", - "actions": [] - }, - "references": [], - "updated_at": "2019-12-02T20:48:28.008Z", - "version": "WzUsMV0=" + "actions": [ + { + "id": "f15986fa-fa64-4bca-981f-968fc37ae014", + "type": "POLICY_CHANGE", + "created_at": "2019-12-03T20:46:53.567Z", + "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}" + } + ] + } } ] } @@ -1138,17 +274,11 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with } } -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (8)'] = { - "results": { - "saved_objects": [] - } -} - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (8)'] = { "results": { - "id": "16f20d30-1545-11ea-8a4c-d782b3e0e16c", + "id": "07d2f340-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T20:48:30.149Z", + "updated_at": "2019-12-03T20:46:53.571Z", "version": "WzgsMV0=", "attributes": { "policy_id": "default", @@ -1158,8 +288,8 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with "actions": [ { "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T20:48:30.109Z", - "id": "519cf0f3-398c-4534-b732-63f28b6ea465", + "created_at": "2019-12-03T20:46:53.567Z", + "id": "4b7fa740-4b30-47cd-8a41-5391fbbb235c", "type": "POLICY_CHANGE" } ] @@ -1168,11 +298,11 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with } } -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (10)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (9)'] = { "results": { - "id": "178a2e80-1545-11ea-8a4c-d782b3e0e16c", + "id": "086a9f60-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T20:48:30.149Z", + "updated_at": "2019-12-03T20:46:53.571Z", "version": "WzksMV0=", "attributes": { "policy_id": "default", @@ -1182,8 +312,8 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with "actions": [ { "data": "{\"policy\":{\"outputs\":{\"default\":{\"api_token\":\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\",\"id\":\"default\",\"name\":\"Default\",\"type\":\"elasticsearch\",\"url\":\"https://localhost:9200\",\"tlsCert\":\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\"}},\"streams\":[{\"metricsets\":[\"container\",\"cpu\"],\"id\":\"string\",\"type\":\"etc\",\"output\":{\"use_output\":\"default\"}}]}}", - "created_at": "2019-12-02T20:48:30.109Z", - "id": "509d6a9d-60a2-4b77-8e66-22db9efdec91", + "created_at": "2019-12-03T20:46:53.567Z", + "id": "f15986fa-fa64-4bca-981f-968fc37ae014", "type": "POLICY_CHANGE" } ] @@ -1192,11 +322,11 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with } } -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (11)'] = { +exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - get:agents (10)'] = { "results": { - "id": "182499c0-1545-11ea-8a4c-d782b3e0e16c", + "id": "0906b850-160e-11ea-989f-e12ac0a7162a", "type": "agents", - "updated_at": "2019-12-02T20:48:29.020Z", + "updated_at": "2019-12-03T20:46:52.501Z", "version": "WzYsMV0=", "attributes": { "policy_id": "policy2", @@ -1208,8 +338,3 @@ exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with "references": [] } } - -exports['AgentPolicy Lib updateAgentsForPolicyId Should updates all agents with the new policy - bulkUpdate (6)'] = { - "thrownError": "{\"msg\":\"unknown error\",\"path\":\"/_bulk\",\"query\":{\"refresh\":\"wait_for\"},\"body\":\"{\\\"update\\\":{\\\"_id\\\":\\\"agents:161e1b60-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:25.984Z\\\",\\\"id\\\":\\\"46f35c21-d60c-458a-be45-4682d9126906\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\"},{\\\"id\\\":\\\"db1f1263-2e31-4ffe-b509-833e4e6f5b47\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:16f20d30-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"519cf0f3-398c-4534-b732-63f28b6ea465\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n{\\\"update\\\":{\\\"_id\\\":\\\"agents:178a2e80-1545-11ea-8a4c-d782b3e0e16c\\\",\\\"_index\\\":\\\".kibana\\\"}}\\n{\\\"doc\\\":{\\\"agents\\\":{\\\"actions\\\":[{\\\"id\\\":\\\"509d6a9d-60a2-4b77-8e66-22db9efdec91\\\",\\\"type\\\":\\\"POLICY_CHANGE\\\",\\\"created_at\\\":\\\"2019-12-02T20:48:30.109Z\\\",\\\"data\\\":\\\"{\\\\\\\"policy\\\\\\\":{\\\\\\\"outputs\\\\\\\":{\\\\\\\"default\\\\\\\":{\\\\\\\"api_token\\\\\\\":\\\\\\\"slfhsdlfhjjkshfkjh:sdfsdfsdfsdf\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"default\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"Default\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"elasticsearch\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://localhost:9200\\\\\\\",\\\\\\\"tlsCert\\\\\\\":\\\\\\\"ldsjfldsjfljsdalkfjl;ksadh;kjsdha;kjhslgkjhsdalkghasdkgh\\\\\\\"}},\\\\\\\"streams\\\\\\\":[{\\\\\\\"metricsets\\\\\\\":[\\\\\\\"container\\\\\\\",\\\\\\\"cpu\\\\\\\"],\\\\\\\"id\\\\\\\":\\\\\\\"string\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"etc\\\\\\\",\\\\\\\"output\\\\\\\":{\\\\\\\"use_output\\\\\\\":\\\\\\\"default\\\\\\\"}}]}}\\\"}]},\\\"updated_at\\\":\\\"2019-12-02T20:48:30.149Z\\\"}}\\n\",\"statusCode\":0}", - "results": null -} diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts index 5d3725997b34b..ef7da2cd06380 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent_policy.ts @@ -52,7 +52,7 @@ export class AgentPolicyLib { }; }); - this.agentsRepository.bulkUpdate(user, agentUpdate); + await this.agentsRepository.bulkUpdate(user, agentUpdate); } }