From 3612b98b5541fdb7de5ada6f213025358cfa8e35 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Mon, 11 Nov 2019 18:29:11 -0500 Subject: [PATCH] [Fleet] Use ES api keys for agent authentication (#49639) --- src/test_utils/kbn_server.ts | 2 +- .../plugins/fleet/common/constants/index.ts | 2 + .../plugins/fleet/common/return_types.ts | 2 +- .../plugins/fleet/common/types/domain_data.ts | 3 + .../fleet/dev_docs/api/agents_checkin.md | 3 +- .../fleet/dev_docs/api/agents_enroll.md | 11 +- x-pack/legacy/plugins/fleet/index.ts | 14 +- .../components/metadata_form.tsx | 5 +- .../public/pages/agent_details/index.tsx | 25 +- .../fleet/public/pages/agent_list/index.tsx | 5 +- .../plugins/fleet/scripts/dev_agent/script.ts | 20 +- .../fleet/scripts/dev_env_setup/script.ts | 54 +- x-pack/legacy/plugins/fleet/scripts/readme.md | 4 +- .../default.contract.test.slap_snap | 18 + .../adapters/elasticsearch/adapter_types.ts | 15 + .../elasticsearch/default.contract.test.ts | 61 + .../server/adapters/elasticsearch/default.ts | 59 + .../adapters/elasticsearch/in_memory.ts | 47 + .../elasticsearch/memorize_adapter.ts | 53 + .../encrypted_saved_objects/default.ts | 4 +- .../default.contract.test.slap_snap | 5 - .../default.contract.test.ts.snap | 25 - .../plugins/fleet/server/kibana.index.ts | 6 + .../fleet/server/libs/__mocks__/api_keys.ts | 141 + .../fleet/server/libs/__mocks__/framework.ts | 6 + .../fleet/server/libs/__mocks__/token.ts | 31 - .../plugins/fleet/server/libs/agent.test.ts | 239 +- .../legacy/plugins/fleet/server/libs/agent.ts | 52 +- .../fleet/server/libs/api_keys.test.ts | 142 + .../plugins/fleet/server/libs/api_keys.ts | 310 ++ .../fleet/server/libs/compose/kibana.ts | 21 +- .../plugins/fleet/server/libs/framework.ts | 7 + .../plugins/fleet/server/libs/token.test.ts | 186 -- .../legacy/plugins/fleet/server/libs/token.ts | 246 -- .../legacy/plugins/fleet/server/libs/types.ts | 4 +- .../legacy/plugins/fleet/server/mappings.ts | 10 +- .../default.contract.test.slap_snap | 258 +- .../default.contract.test.slap_snap | 2662 ++++++++--------- .../agents/default.contract.test.ts | 32 +- .../server/repositories/agents/default.ts | 35 +- .../server/repositories/agents/in_memory.ts | 13 +- .../fleet/server/repositories/agents/types.ts | 11 +- .../default.contract.test.slap_snap | 338 +++ .../default.contract.test.ts | 200 ++ .../enrollment_api_keys/default.ts | 159 + .../enrollment_api_keys/memory.ts | 99 + .../{tokens => enrollment_api_keys}/types.ts | 76 +- .../default.contract.test.slap_snap | 642 ---- .../tokens/default.contract.test.ts | 233 -- .../server/repositories/tokens/default.ts | 123 - .../server/repositories/tokens/memory.ts | 68 - .../fleet/server/routes/agents/checkin.ts | 23 +- .../fleet/server/routes/agents/enroll.ts | 13 +- .../routes/enrollment_api_keys/index.ts | 119 + .../{policy => enrollment_api_keys}/rules.ts | 36 +- .../plugins/fleet/server/routes/init_api.ts | 22 +- .../fleet/server/routes/policy/tokens.ts | 41 - .../{agent_actions.ts => agents/actions.ts} | 6 +- .../{agent_checkin.ts => agents/checkin.ts} | 55 +- .../{enroll_agent.ts => agents/enroll.ts} | 57 +- .../{agent_events.ts => agents/events.ts} | 4 +- .../apis/fleet/agents/services.ts | 19 + .../apis/fleet/enrollment_api_keys/crud.ts | 81 + .../rules.ts} | 18 +- .../apis/fleet/get_enrollment_token.ts | 41 - .../test/api_integration/apis/fleet/index.js | 13 +- x-pack/test/api_integration/config.js | 7 +- .../es_archives/fleet/agents/data.json | 19 +- .../es_archives/fleet/agents/mappings.json | 1369 ++++++++- .../test_utils/jest/contract_tests/servers.ts | 8 +- 70 files changed, 5051 insertions(+), 3687 deletions(-) create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/__memorize_snapshots__/default.contract.test.slap_snap create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/adapter_types.ts create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.contract.test.ts create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.ts create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/in_memory.ts create mode 100644 x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/memorize_adapter.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.ts.snap create mode 100644 x-pack/legacy/plugins/fleet/server/libs/__mocks__/api_keys.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/libs/__mocks__/token.ts create mode 100644 x-pack/legacy/plugins/fleet/server/libs/api_keys.test.ts create mode 100644 x-pack/legacy/plugins/fleet/server/libs/api_keys.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/libs/token.test.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/libs/token.ts create mode 100644 x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap create mode 100644 x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.contract.test.ts create mode 100644 x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.ts create mode 100644 x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/memory.ts rename x-pack/legacy/plugins/fleet/server/repositories/{tokens => enrollment_api_keys}/types.ts (54%) delete mode 100644 x-pack/legacy/plugins/fleet/server/repositories/tokens/__memorize_snapshots__/default.contract.test.slap_snap delete mode 100644 x-pack/legacy/plugins/fleet/server/repositories/tokens/default.contract.test.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/repositories/tokens/default.ts delete mode 100644 x-pack/legacy/plugins/fleet/server/repositories/tokens/memory.ts create mode 100644 x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/index.ts rename x-pack/legacy/plugins/fleet/server/routes/{policy => enrollment_api_keys}/rules.ts (58%) delete mode 100644 x-pack/legacy/plugins/fleet/server/routes/policy/tokens.ts rename x-pack/test/api_integration/apis/fleet/{agent_actions.ts => agents/actions.ts} (95%) rename x-pack/test/api_integration/apis/fleet/{agent_checkin.ts => agents/checkin.ts} (56%) rename x-pack/test/api_integration/apis/fleet/{enroll_agent.ts => agents/enroll.ts} (53%) rename x-pack/test/api_integration/apis/fleet/{agent_events.ts => agents/events.ts} (91%) create mode 100644 x-pack/test/api_integration/apis/fleet/agents/services.ts create mode 100644 x-pack/test/api_integration/apis/fleet/enrollment_api_keys/crud.ts rename x-pack/test/api_integration/apis/fleet/{enrollment_rules.ts => enrollment_api_keys/rules.ts} (65%) delete mode 100644 x-pack/test/api_integration/apis/fleet/get_enrollment_token.ts diff --git a/src/test_utils/kbn_server.ts b/src/test_utils/kbn_server.ts index 1494c01166e20..8217eafe79eef 100644 --- a/src/test_utils/kbn_server.ts +++ b/src/test_utils/kbn_server.ts @@ -252,7 +252,7 @@ export function createTestServers({ return { startES: async () => { - await es.start(); + await es.start(get(settings, 'es.esArgs', [])); if (['gold', 'trial'].includes(license)) { await setupUsers({ diff --git a/x-pack/legacy/plugins/fleet/common/constants/index.ts b/x-pack/legacy/plugins/fleet/common/constants/index.ts index d783bdb664d60..c18d67f38dbf9 100644 --- a/x-pack/legacy/plugins/fleet/common/constants/index.ts +++ b/x-pack/legacy/plugins/fleet/common/constants/index.ts @@ -8,3 +8,5 @@ export { INDEX_NAMES } from './index_names'; export { PLUGIN } from './plugin'; export * from './agent'; export const BASE_PATH = '/fleet'; + +export const DEFAULT_POLICY_ID = 'default'; diff --git a/x-pack/legacy/plugins/fleet/common/return_types.ts b/x-pack/legacy/plugins/fleet/common/return_types.ts index 9f7f0f95a2e82..2d3efaf96535b 100644 --- a/x-pack/legacy/plugins/fleet/common/return_types.ts +++ b/x-pack/legacy/plugins/fleet/common/return_types.ts @@ -45,7 +45,7 @@ export interface ReturnTypeCheckin extends BaseReturnType { type: string; data?: object; }>; - policy: { [k: string]: any }; + policy: { [k: string]: any } | null; } export interface ReturnTypeBulkDelete extends BaseReturnType { diff --git a/x-pack/legacy/plugins/fleet/common/types/domain_data.ts b/x-pack/legacy/plugins/fleet/common/types/domain_data.ts index cddff3516077a..b7ec451d1428c 100644 --- a/x-pack/legacy/plugins/fleet/common/types/domain_data.ts +++ b/x-pack/legacy/plugins/fleet/common/types/domain_data.ts @@ -6,6 +6,7 @@ import * as t from 'io-ts'; import { RuntimeAgent, RuntimeAgentAction } from '../../server/repositories/agents/types'; import { RuntimeAgentEvent } from '../../server/repositories/agent_events/types'; +import { EnrollmentApiKey } from '../../server/repositories/enrollment_api_keys/types'; // Here we create the runtime check for a generic, unknown beat config type. // We can also pass in optional params to create spacific runtime checks that @@ -35,6 +36,8 @@ export type Agent = t.TypeOf; export type AgentAction = t.TypeOf; export type AgentEvent = t.TypeOf; +export type EnrollmentApiKey = EnrollmentApiKey; + export type PolicyUpdatedEvent = | { type: 'created'; 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 1c33feef6cc12..ae74d150e504e 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 @@ -9,7 +9,7 @@ Report current state of a Fleet agent. ## Headers -- `kbn-fleet-access-token` (Required, string) A fleet agent access token. +- `Authorization` (Required, string) A valid fleet access api key.. ## Request body @@ -25,6 +25,7 @@ Report current state of a Fleet agent. ```js POST /api/fleet/agents/a4937110-e53e-11e9-934f-47a8e38a522c/checkin +Authorization: ApiKey VALID_ACCESS_API_KEY { "events": [{ "type": "STATE", diff --git a/x-pack/legacy/plugins/fleet/dev_docs/api/agents_enroll.md b/x-pack/legacy/plugins/fleet/dev_docs/api/agents_enroll.md index fff42cf3273af..977b3029371ba 100644 --- a/x-pack/legacy/plugins/fleet/dev_docs/api/agents_enroll.md +++ b/x-pack/legacy/plugins/fleet/dev_docs/api/agents_enroll.md @@ -8,7 +8,7 @@ Enroll agent ## Headers -- `kbn-fleet-enrollment-token` (Required, string) A fleet enrollment token. +- `Authorization` (Required, string) a valid enrollemnt api key. ## Request body @@ -20,12 +20,13 @@ Enroll agent `200` Indicates a successful call. `400` For an invalid request. -`401` For an invalid kbn-fleet-enrollment-token. +`401` For an invalid api key. ## Example ```js POST /api/fleet/agents/enroll +Authorization: ApiKey VALID_API_KEY { "type": "PERMANENT", "metadata": { @@ -50,20 +51,20 @@ The API returns the following: "user_provided_metadata": {}, "local_metadata": {}, "actions": [], - "access_token": "ACCESS_TOKEN" + "access_api_key": "ACCESS_API_KEY" } } ``` ## Expected errors -The API will return a response with a `401` status code and an error if the enrollment token is invalid like this: +The API will return a response with a `401` status code and an error if the enrollment apiKey is invalid like this: ```js { "statusCode": 401, "error": "Unauthorized", - "message": "Enrollment token is not valid: invalid token" + "message": "Enrollment apiKey is not valid: Enrollement api key does not exists or is not active" } ``` diff --git a/x-pack/legacy/plugins/fleet/index.ts b/x-pack/legacy/plugins/fleet/index.ts index 4d356736ee3e5..8af32cac2a7b7 100644 --- a/x-pack/legacy/plugins/fleet/index.ts +++ b/x-pack/legacy/plugins/fleet/index.ts @@ -20,7 +20,7 @@ export const config = Joi.object({ export function fleet(kibana: any) { return new kibana.Plugin({ id: PLUGIN.ID, - require: ['kibana', 'elasticsearch', 'xpack_main', 'encrypted_saved_objects', 'ingest'], + require: ['kibana', 'elasticsearch', 'xpack_main', 'encryptedSavedObjects', 'ingest'], publicDir: resolve(__dirname, 'public'), uiExports: { // app: { @@ -46,7 +46,7 @@ export function fleet(kibana: any) { // TODO https://github.com/elastic/kibana/issues/46373 // indexPattern: INDEX_NAMES.EVENT, }, - tokens: { + enrollment_api_keys: { isNamespaceAgnostic: true, // TODO https://github.com/elastic/kibana/issues/46373 // indexPattern: INDEX_NAMES.FLEET, @@ -57,9 +57,9 @@ export function fleet(kibana: any) { config: () => config, configPrefix: CONFIG_PREFIX, init(server: any) { - server.plugins.encrypted_saved_objects.registerType({ - type: 'tokens', - attributesToEncrypt: new Set(['token']), + server.newPlatform.setup.plugins.encryptedSavedObjects.registerType({ + type: 'enrollment_api_keys', + attributesToEncrypt: new Set(['api_key']), attributesToExcludeFromAAD: new Set(['enrollment_rules']), }); server.plugins.xpack_main.registerFeature({ @@ -70,7 +70,7 @@ export function fleet(kibana: any) { privileges: { all: { savedObject: { - all: ['agents', 'events', 'tokens'], + all: ['agents', 'events', 'enrollment_api_keys'], read: [], }, ui: ['read', 'write'], @@ -79,7 +79,7 @@ export function fleet(kibana: any) { read: { savedObject: { all: [], - read: ['agents', 'events', 'tokens'], + read: ['agents', 'events', 'enrollment_api_keys'], }, ui: ['read'], api: ['fleet-read'], diff --git a/x-pack/legacy/plugins/fleet/public/pages/agent_details/components/metadata_form.tsx b/x-pack/legacy/plugins/fleet/public/pages/agent_details/components/metadata_form.tsx index 95cd02fdf3466..6df53cd0ec1d7 100644 --- a/x-pack/legacy/plugins/fleet/public/pages/agent_details/components/metadata_form.tsx +++ b/x-pack/legacy/plugins/fleet/public/pages/agent_details/components/metadata_form.tsx @@ -57,10 +57,7 @@ function useAddMetadataForm(agent: Agent, done: () => void) { function setError(error: AxiosError) { setState({ isLoading: false, - error: - error.isAxiosError && error.response && error.response.data - ? error.response.data.message - : error.message, + error: error.response && error.response.data ? error.response.data.message : error.message, }); } diff --git a/x-pack/legacy/plugins/fleet/public/pages/agent_details/index.tsx b/x-pack/legacy/plugins/fleet/public/pages/agent_details/index.tsx index 4564e6db204e5..81aa6d5b41383 100644 --- a/x-pack/legacy/plugins/fleet/public/pages/agent_details/index.tsx +++ b/x-pack/legacy/plugins/fleet/public/pages/agent_details/index.tsx @@ -6,16 +6,7 @@ import React, { SFC } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { - EuiFlexGroup, - EuiFlexItem, - EuiHorizontalRule, - EuiPageBody, - EuiPageContent, - EuiCallOut, - EuiText, - EuiSpacer, -} from '@elastic/eui'; +import { EuiPageBody, EuiPageContent, EuiCallOut, EuiText, EuiSpacer } from '@elastic/eui'; import { RouteComponentProps } from 'react-router-dom'; import { Loading } from '../../components/loading'; import { AgentEventsTable } from './components/agent_events_table'; @@ -78,20 +69,6 @@ export const AgentDetailsPage: SFC = ({ - - - - - - - - - - - - - - ); diff --git a/x-pack/legacy/plugins/fleet/public/pages/agent_list/index.tsx b/x-pack/legacy/plugins/fleet/public/pages/agent_list/index.tsx index d7d7c7d9e69fb..67ac84e4157d8 100644 --- a/x-pack/legacy/plugins/fleet/public/pages/agent_list/index.tsx +++ b/x-pack/legacy/plugins/fleet/public/pages/agent_list/index.tsx @@ -106,9 +106,8 @@ export const AgentListPage: React.SFC<{}> = () => { setIsPoliciesLoading(false); }; - // Load initial list of agents + // Load initial list of policies useEffect(() => { - fetchAgents(); fetchPolicies(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [showInactive]); @@ -118,7 +117,7 @@ export const AgentListPage: React.SFC<{}> = () => { fetchAgents(); setAreAllAgentsSelected(false); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [pagination, search, selectedPolicies]); + }, [pagination, search, showInactive, selectedPolicies]); // Poll for agents on interval useInterval(() => { 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 9cf195aba2190..88de888d16200 100644 --- a/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/legacy/plugins/fleet/scripts/dev_agent/script.ts @@ -12,7 +12,7 @@ const CHECKIN_INTERVAL = 3000; // 3 seconds interface Agent { id: string; - access_token: string; + access_api_key: string; } let closing = false; @@ -27,11 +27,11 @@ run( throw createFlagError('please provide a single --path flag'); } - if (!flags.enrollmentToken || typeof flags.enrollmentToken !== 'string') { - throw createFlagError('please provide a single --path flag'); + if (!flags.enrollmentApiKey || typeof flags.enrollmentApiKey !== 'string') { + throw createFlagError('please provide a single --enrollmentApiKey flag'); } const kibanaUrl: string = (flags.kibanaUrl as string) || 'http://localhost:5601'; - const agent = await enroll(kibanaUrl, flags.enrollmentToken as string, log); + const agent = await enroll(kibanaUrl, flags.enrollmentApiKey as string, log); log.info('Enrolled with sucess', agent); @@ -46,10 +46,10 @@ run( Run a fleet development agent. `, flags: { - string: ['kibanaUrl', 'enrollmentToken'], + string: ['kibanaUrl', 'enrollmentApiKey'], help: ` --kibanaUrl kibanaURL to run the fleet agent - --enrollmentToken enrollment token + --enrollmentApiKey enrollment api key `, }, } @@ -72,7 +72,7 @@ async function checkin(kibanaURL: string, agent: Agent, log: ToolingLog) { }), headers: { 'kbn-xsrf': 'xxx', - 'kbn-fleet-access-token': agent.access_token, + Authorization: `ApiKey ${agent.access_api_key}`, }, }); @@ -86,7 +86,7 @@ async function checkin(kibanaURL: string, agent: Agent, log: ToolingLog) { log.info('checkin', json); } -async function enroll(kibanaURL: string, token: string, log: ToolingLog): Promise { +async function enroll(kibanaURL: string, apiKey: string, log: ToolingLog): Promise { const res = await fetch(`${kibanaURL}/api/fleet/agents/enroll`, { method: 'POST', body: JSON.stringify({ @@ -106,7 +106,7 @@ async function enroll(kibanaURL: string, token: string, log: ToolingLog): Promis }), headers: { 'kbn-xsrf': 'xxx', - 'kbn-fleet-enrollment-token': token, + Authorization: `ApiKey ${apiKey}`, }, }); const json = await res.json(); @@ -118,6 +118,6 @@ async function enroll(kibanaURL: string, token: string, log: ToolingLog): Promis return { id: json.item.id, - access_token: json.item.access_token, + access_api_key: json.item.access_api_key, }; } diff --git a/x-pack/legacy/plugins/fleet/scripts/dev_env_setup/script.ts b/x-pack/legacy/plugins/fleet/scripts/dev_env_setup/script.ts index 22bd1d10faa23..d6aec090c9935 100644 --- a/x-pack/legacy/plugins/fleet/scripts/dev_env_setup/script.ts +++ b/x-pack/legacy/plugins/fleet/scripts/dev_env_setup/script.ts @@ -7,10 +7,6 @@ import { createFlagError, run } from '@kbn/dev-utils'; import fetch from 'node-fetch'; -interface Policy { - id: string; -} - run( async ({ flags, log }) => { const kibanaUrl = flags.kibanaUrl || 'http://localhost:5601'; @@ -28,14 +24,12 @@ run( throw createFlagError('please provide a single --kibanaPassword flag'); } - const policy = await createPolicy(kibanaUrl, kibanaUser, kibanaPassword); - log.info('Policy created', policy); - const token = await getEnrollmentToken(kibanaUrl, kibanaUser, kibanaPassword, policy.id); - log.info('Enrollment token', token); + const apiKey = await createEnrollmentApiKey(kibanaUrl, kibanaUser, kibanaPassword); + log.info('Enrollment API Key', apiKey); }, { description: ` - Setup a fleet test policy and generate an enrollment token. + Setup a fleet enrollment API Key. `, flags: { string: ['kibanaUrl', 'kibanaUser', 'kibanaPassword'], @@ -48,48 +42,24 @@ run( } ); -async function createPolicy( +async function createEnrollmentApiKey( kibanaURL: string, kibanaUser: string, - kibanaPassword: string -): Promise { - const res = await fetch(`${kibanaURL}/api/ingest/policies`, { + kibanaPassword: string, + policyId?: string +): Promise { + const res = await fetch(`${kibanaURL}/api/fleet/enrollment-api-keys`, { method: 'POST', + body: JSON.stringify({ + policy_id: policyId, + }), headers: { 'kbn-xsrf': 'xsrf', 'content-type': 'application/json', authorization: `Basic ${Buffer.from(`${kibanaUser}:${kibanaPassword}`).toString('base64')}`, }, - body: JSON.stringify({ - name: 'Dev policy', - }), }); const json = await res.json(); - - return { - id: json.item.id, - }; -} - -async function getEnrollmentToken( - kibanaURL: string, - kibanaUser: string, - kibanaPassword: string, - policyId: string -): Promise { - const res = await fetch( - `${kibanaURL}/api/fleet/policies/${policyId}/enrollment-tokens?regenerate=true`, - { - method: 'GET', - headers: { - 'kbn-xsrf': 'xsrf', - 'content-type': 'application/json', - authorization: `Basic ${Buffer.from(`${kibanaUser}:${kibanaPassword}`).toString('base64')}`, - }, - } - ); - - const json = await res.json(); - return json.item.token; + return json.item.api_key; } diff --git a/x-pack/legacy/plugins/fleet/scripts/readme.md b/x-pack/legacy/plugins/fleet/scripts/readme.md index 32a4c2811742e..a4da2e3767e24 100644 --- a/x-pack/legacy/plugins/fleet/scripts/readme.md +++ b/x-pack/legacy/plugins/fleet/scripts/readme.md @@ -4,10 +4,10 @@ You can run a development fleet agent that is going to enroll and checkin every For this you can run the following command in the fleet pluging directory. ``` -node scripts/dev_agent --enrollmentToken= --kibanaUrl=http://localhost:5603/qed +node scripts/dev_agent --enrollmentApiKey= --kibanaUrl=http://localhost:5603/qed ``` -To generate a dummy config and an enrollment token you can use this script +To generate a dummy config and an enrollment enrollmentApiKey you can use this script ``` node scripts/dev_env_setup --kibanaUrl=http://localhost:5603/qed --kibanaUser=elastic --kibanaPassword=changeme diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/__memorize_snapshots__/default.contract.test.slap_snap new file mode 100644 index 0000000000000..80c9da08df23d --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/__memorize_snapshots__/default.contract.test.slap_snap @@ -0,0 +1,18 @@ + +exports['AgentsEventsRepository Api Keys allow to create and delete an api key - createApiKey (1)'] = { + "results": { + "id": "xnomHW4BOCe18YaxW5t6", + "name": "test api key", + "api_key": "HSIY-8YbQCuVOy1lTUSJsg" + } +} + +exports['AgentsEventsRepository Api Keys allow to create and delete an api key - deleteApiKey (2)'] = { + "results": { + "invalidated_api_keys": [ + "xnomHW4BOCe18YaxW5t6" + ], + "previously_invalidated_api_keys": [], + "error_count": 0 + } +} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/adapter_types.ts b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/adapter_types.ts new file mode 100644 index 0000000000000..0c57ee408c58b --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/adapter_types.ts @@ -0,0 +1,15 @@ +/* + * 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 '../framework/adapter_types'; + +export interface ElasticsearchAdapter { + authenticate(user: FrameworkUser): Promise; + createApiKey( + user: FrameworkUser, + data: { name: string; expiration?: any; role_descriptors?: any } + ): Promise<{ id: string; api_key: string }>; + deleteApiKey(user: FrameworkUser, data: { id: string }): Promise; +} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.contract.test.ts b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.contract.test.ts new file mode 100644 index 0000000000000..0dac8aa0ab519 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.contract.test.ts @@ -0,0 +1,61 @@ +/* + * 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 } from '../../adapters/framework/adapter_types'; +import { MemorizedElasticsearchAdapter } from './memorize_adapter'; +import { ElasticsearchAdapter } from './default'; +import { ElasticsearchAdapter as ElasticsearchAdapterType } from './adapter_types'; + +describe('AgentsEventsRepository', () => { + let servers: any; + + let esAdapter: ElasticsearchAdapterType; + + function getUser(): FrameworkUser { + return ({ + kind: 'internal', + } as unknown) as FrameworkUser; + } + + 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) + ); + }); + + if (!esAdapter) { + esAdapter = new MemorizedElasticsearchAdapter(); + } + }); + + afterAll(async () => { + if (servers) { + await servers.shutdown; + } + }); + + describe('Api Keys', () => { + it('allow to create and delete an api key', async () => { + const key = await esAdapter.createApiKey(getUser(), { + name: 'test api key', + }); + expect(key).toHaveProperty('id'); + expect(key).toHaveProperty('api_key'); + await esAdapter.deleteApiKey(getUser(), { + id: key.id, + }); + }); + }); +}); diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.ts b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.ts new file mode 100644 index 0000000000000..8beea99db0e85 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/default.ts @@ -0,0 +1,59 @@ +/* + * 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 { ElasticsearchPlugin } from 'src/legacy/core_plugins/elasticsearch'; +import { ElasticsearchAdapter as ElasticsearchAdapterType } from './adapter_types'; +import { FrameworkUser, internalAuthData } from '../framework/adapter_types'; + +export class ElasticsearchAdapter implements ElasticsearchAdapterType { + constructor(private readonly elasticsearch: ElasticsearchPlugin) {} + + public async createApiKey( + user: FrameworkUser, + data: { name: string; expiration?: any; role_descriptors?: any } + ) { + const options = { + method: 'POST', + path: '/_security/api_key', + body: data, + }; + return await this._call(user, 'transport.request', options); + } + + public async deleteApiKey(user: FrameworkUser, data: { id: string }) { + const options = { + method: 'DELETE', + path: '/_security/api_key', + body: data, + }; + return await this._call(user, 'transport.request', options); + } + + public async authenticate(user: FrameworkUser) { + if (user.kind !== 'authenticated') { + throw new Error('Not supported'); + } + const options = { + method: 'GET', + path: '/_security/_authenticate', + }; + return await this._call(user, 'transport.request', options); + } + + private async _call(user: FrameworkUser, endpoint: any, params: any): Promise { + const { callWithInternalUser, callWithRequest } = this.elasticsearch.getCluster('admin'); + if (user.kind === 'internal') { + return await callWithInternalUser(endpoint, params); + throw new Error('Elastic search call is only implemented for internal user'); + } + + if (user.kind === 'authenticated') { + return await callWithRequest({ headers: user[internalAuthData] }, endpoint, params); + } + + throw new Error('Elastic search call is not implemented for unauthenticated user'); + } +} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/in_memory.ts b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/in_memory.ts new file mode 100644 index 0000000000000..cb5bfb78dbcdd --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/in_memory.ts @@ -0,0 +1,47 @@ +/* + * 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 { ElasticsearchAdapter as ElasticsearchAdapterType } from './adapter_types'; +import { FrameworkUser } from '../framework/adapter_types'; + +/** + * In memory fake elastic search adapter for tests purpose only + */ +export class InMemoryElasticsearchAdapter implements ElasticsearchAdapterType { + public apiKeys: { + [k: string]: { + api_key: string; + id: string; + }; + } = {}; + + private keyId = 1; + + public async createApiKey( + user: FrameworkUser, + data: { name: string; expiration?: any; role_descriptors?: any } + ) { + const id = `api-key-${this.keyId++}`; + const key = Buffer.from(`${id}:VALID_API_KEY`).toString('base64'); + + const apiKey = { + id, + api_key: key, + }; + + this.apiKeys[apiKey.id] = apiKey; + + return this.apiKeys[apiKey.id]; + } + + public async deleteApiKey(user: FrameworkUser, data: { id: string }) { + delete this.apiKeys[data.id]; + } + + public async authenticate(user: FrameworkUser) { + return; + } +} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/memorize_adapter.ts b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/memorize_adapter.ts new file mode 100644 index 0000000000000..e6fe00c9ae6ad --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/adapters/elasticsearch/memorize_adapter.ts @@ -0,0 +1,53 @@ +/* + * 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 { ElasticsearchAdapter } from './adapter_types'; +import { FrameworkUser } from '../framework/adapter_types'; + +export class MemorizedElasticsearchAdapter implements ElasticsearchAdapter { + constructor(private readonly esAdapter?: ElasticsearchAdapter) {} + public async authenticate(user: FrameworkUser): Promise { + return Slapshot.memorize( + `authenticate`, + async () => { + if (!this.esAdapter) { + throw new Error('An adapter must be provided when running tests online'); + } + return await this.esAdapter.authenticate(user); + }, + { pure: false } + ); + } + public async createApiKey( + user: FrameworkUser, + data: { name: string; expiration?: any; role_descriptors?: any } + ): Promise<{ id: string; api_key: string }> { + return Slapshot.memorize( + `createApiKey`, + async () => { + if (!this.esAdapter) { + throw new Error('An adapter must be provided when running tests online'); + } + return await this.esAdapter.createApiKey(user, data); + }, + { pure: false } + ); + } + + public async deleteApiKey(user: FrameworkUser, data: { id: string }): Promise { + return Slapshot.memorize( + `deleteApiKey`, + async () => { + if (!this.esAdapter) { + throw new Error('An adapter must be provided when running tests online'); + } + return await this.esAdapter.deleteApiKey(user, data); + }, + { pure: false } + ); + } +} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/encrypted_saved_objects/default.ts b/x-pack/legacy/plugins/fleet/server/adapters/encrypted_saved_objects/default.ts index 46dc4fcb8fa85..56791cdf7a56e 100644 --- a/x-pack/legacy/plugins/fleet/server/adapters/encrypted_saved_objects/default.ts +++ b/x-pack/legacy/plugins/fleet/server/adapters/encrypted_saved_objects/default.ts @@ -5,10 +5,10 @@ */ import { SavedObjectsBaseOptions, SavedObjectAttributes, SavedObject } from 'src/core/server'; -import { EncryptedSavedObjectsPlugin } from '../../../../encrypted_saved_objects'; +import { PluginStartContract } from '../../../../../../plugins/encrypted_saved_objects/server'; export class EncryptedSavedObjects { - constructor(private readonly plugin: EncryptedSavedObjectsPlugin) {} + constructor(private readonly plugin: PluginStartContract) {} public async getDecryptedAsInternalUser( type: string, diff --git a/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.slap_snap index 665db27159d51..319adc2839696 100644 --- a/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.slap_snap @@ -3,8 +3,3 @@ exports['Agent Adapter getSetting Work - getSetting'] = { "results": "xpack_fleet_default_encryptionKey", "thrownError": null } - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} diff --git a/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.ts.snap b/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.ts.snap deleted file mode 100644 index 05dfabc9b6ba2..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/adapters/framework/__memorize_snapshots__/default.contract.test.ts.snap +++ /dev/null @@ -1,25 +0,0 @@ - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} - -exports['Agent Adapter getSetting Work - getSetting'] = { - "results": "xpack_fleet_default_encryptionKey", - "thrownError": null -} diff --git a/x-pack/legacy/plugins/fleet/server/kibana.index.ts b/x-pack/legacy/plugins/fleet/server/kibana.index.ts index 92acae45cff87..9da5a91f3d62d 100644 --- a/x-pack/legacy/plugins/fleet/server/kibana.index.ts +++ b/x-pack/legacy/plugins/fleet/server/kibana.index.ts @@ -19,8 +19,14 @@ export const initServerWithKibana = (hapiServer: any) => { kind: 'internal', } ) { + if (event.type === 'created') { + await libs.apiKeys.generateEnrollmentApiKey(user, { + policyId: 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/__mocks__/api_keys.ts b/x-pack/legacy/plugins/fleet/server/libs/__mocks__/api_keys.ts new file mode 100644 index 0000000000000..8fc1dc6d9abd6 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/__mocks__/api_keys.ts @@ -0,0 +1,141 @@ +/* + * 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 { + EnrollmentApiKeyVerificationResponse, + AccessApiKeyVerificationResponse, + EnrollmentApiKey, + EnrollmentRuleData, + EnrollmentRule, +} from '../../repositories/enrollment_api_keys/types'; +import { FrameworkUser, internalAuthData } from '../../adapters/framework/adapter_types'; +import { ApiKeyLib as ApiKeyLibType } from '../api_keys'; + +type Interface = { + [P in keyof T]: T[P]; +}; + +export class ApiKeyLib implements Interface { + private accessApiKeyId = 1; + + public listEnrollmentApiKeys( + user: FrameworkUser, + options: { + page?: number | undefined; + perPage?: number | undefined; + kuery?: string | undefined; + showInactive?: boolean | undefined; + } + ): Promise<{ items: any; total: any; page: any; perPage: any }> { + throw new Error('Method not implemented.'); + } + + public async deleteEnrollmentApiKey(user: FrameworkUser, id: string) { + throw new Error('Method not implemented.'); + } + + public async deleteEnrollmentApiKeyForPolicyId(user: FrameworkUser, policyId: string) { + throw new Error('Method not implemented.'); + } + + public async getEnrollmentApiKey( + user: FrameworkUser, + keyId: string + ): Promise { + throw new Error('Method not implemented.'); + } + public async verifyEnrollmentApiKey( + user: FrameworkUser + ): Promise { + if (user.kind === 'authenticated') { + const apiKeyHeader = user[internalAuthData].authorization.split(' ')[1]; + const apiKey = Buffer.from(apiKeyHeader, 'base64') + .toString('utf8') + .split(':')[1]; + if (apiKey === 'VALID_KEY_WITH_POLICY') { + return { + valid: true, + enrollmentApiKey: { + policy_id: 'policyId', + } as EnrollmentApiKey, + }; + } + if (apiKey === 'VALID_KEY') { + return { valid: true, enrollmentApiKey: {} as EnrollmentApiKey }; + } + } + return { + valid: false, + reason: 'Not a valid api key', + }; + } + public async verifyAccessApiKey( + user: FrameworkUser + ): Promise { + if (user.kind === 'authenticated') { + const apiKeyHeader = user[internalAuthData].authorization.split(' ')[1]; + const [apiKeyId, apiKey] = Buffer.from(apiKeyHeader, 'base64') + .toString('utf8') + .split(':'); + + if (apiKey === 'VALID_KEY') { + return { valid: true, accessApiKeyId: apiKeyId }; + } + } + return { + valid: false, + reason: 'Not a valid api key', + }; + } + public async generateAccessApiKey( + agentId: string, + policyId?: string | undefined + ): Promise<{ key: string; id: string }> { + const id = this.accessApiKeyId++; + return { + id: `mock-access-api-key-id-${id}`, + key: `mock-access-api-key-${id}`, + }; + } + public generateEnrollmentApiKey( + user: FrameworkUser, + data: { + name?: string | undefined; + policyId?: string | undefined; + expiration?: string | undefined; + } + ): Promise { + throw new Error('Method not implemented.'); + } + public addEnrollmentRule( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleData: EnrollmentRuleData + ): Promise { + throw new Error('Method not implemented.'); + } + public updateEnrollmentRuleForPolicy( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleId: string, + ruleData: EnrollmentRuleData + ): Promise { + throw new Error('Method not implemented.'); + } + public deleteEnrollmentRule( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleId: string + ): Promise { + throw new Error('Method not implemented.'); + } + public deleteAllEnrollmentRules( + user: FrameworkUser, + enrollmentApiKeyId: string + ): Promise { + throw new Error('Method not implemented.'); + } +} diff --git a/x-pack/legacy/plugins/fleet/server/libs/__mocks__/framework.ts b/x-pack/legacy/plugins/fleet/server/libs/__mocks__/framework.ts index cd9f2a693f745..74701a1888a3a 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__mocks__/framework.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/__mocks__/framework.ts @@ -4,8 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ +import { FrameworkUser } from '../../adapters/framework/adapter_types'; + export class FrameworkLib { public getSetting(setting: 'encryptionKey'): string { return 'mockedEncryptionKey'; } + + public getInternalUser(): FrameworkUser { + return { kind: 'internal' }; + } } diff --git a/x-pack/legacy/plugins/fleet/server/libs/__mocks__/token.ts b/x-pack/legacy/plugins/fleet/server/libs/__mocks__/token.ts deleted file mode 100644 index 719ce4da0a029..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/libs/__mocks__/token.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 { TokenVerificationResponse, TokenType } from '../../repositories/tokens/types'; -import { FrameworkUser } from '../../adapters/framework/adapter_types'; - -export class TokenLib { - private accessTokenId = 1; - constructor() {} - public async verify(user: FrameworkUser, token: any): Promise { - switch (token) { - case 'valid-enrollment-token': { - return { - valid: true, - type: TokenType.ENROLLMENT_TOKEN, - token: { policy_id: 'policyId' }, - }; - } - default: { - return { valid: false, reason: 'token does not exists' }; - } - } - } - - public async generateAccessToken(user: FrameworkUser, token: any): Promise { - return `mock-access-token-${this.accessTokenId++}`; - } -} diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent.test.ts b/x-pack/legacy/plugins/fleet/server/libs/agent.test.ts index 2594bb00db321..3eed31bcdf998 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent.test.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent.test.ts @@ -5,58 +5,70 @@ */ import { AgentLib } from './agent'; -import { TokenLib } from './token'; +import { ApiKeyLib } from './api_keys'; import { PolicyLib } from './policy'; import { InMemoryAgentsRepository } from '../repositories/agents/in_memory'; import { Agent } from '../repositories/agents/types'; -import { TokensRepository } from '../repositories/tokens/types'; -import { FrameworkLib } from './framework'; import { PoliciesRepository } from '../repositories/policies/default'; -import { FrameworkUser } from '../adapters/framework/adapter_types'; +import { FrameworkUser, internalAuthData } from '../adapters/framework/adapter_types'; import { InMemoryAgentEventsRepository } from '../repositories/agent_events/in_memory'; -jest.mock('./token'); +jest.mock('./api_keys'); jest.mock('./policy'); -describe('Agent lib', () => { - function getUser() { - return ({} as unknown) as FrameworkUser; +function getMockedApiKeyLib() { + // @ts-ignore + return new ApiKeyLib(); +} + +function compose() { + const apiKeyLib = getMockedApiKeyLib(); + const policy = new PolicyLib({} as PoliciesRepository); + const agentsRepository = new InMemoryAgentsRepository(); + const agentsEventsRepository = new InMemoryAgentEventsRepository(); + const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, apiKeyLib, policy); + + return { + agentLib, + agentsRepository, + agentsEventsRepository, + }; +} + +function getUser(apiKey?: string, apiKeyId?: string) { + if (!apiKey) { + return {} as FrameworkUser; } - describe('Enroll', () => { - it('Should throw if the enrollment token is not valid', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsRepository = new InMemoryAgentsRepository(); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + return ({ + kind: 'authenticated', + [internalAuthData]: { + authorization: `ApiKey ${Buffer.from(`${apiKeyId || 'key_id'}:${apiKey}`).toString( + 'base64' + )}`, + }, + } as unknown) as FrameworkUser; +} +describe('Agent lib', () => { + describe('Enroll', () => { + it('Should throw if the enrollment api key is not valid', async () => { + const { agentLib } = compose(); let error: Error | null = null; try { - await agentLib.enroll( - getUser(), - 'not-a-valid-enrollment-token', - 'PERMANENT', - undefined, - 'agent-1' - ); + await agentLib.enroll(getUser('INVALID_KEY'), 'PERMANENT', undefined, 'agent-1'); } catch (err) { error = err; } expect(error).toBeDefined(); - expect((error as Error).message).toBe('Enrollment token is not valid: token does not exists'); + expect((error as Error).message).toBe('Enrollment apiKey is not valid: Not a valid api key'); }); it('Should enroll a new PERMANENT agent', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + const { agentLib } = compose(); const agent = await agentLib.enroll( - getUser(), - 'valid-enrollment-token', + getUser('VALID_KEY_WITH_POLICY'), 'PERMANENT', undefined, 'agent-1' @@ -64,61 +76,35 @@ describe('Agent lib', () => { expect(agent).toBeDefined(); expect(agent).toMatchObject({ - access_token: 'mock-access-token-1', + access_api_key: 'mock-access-api-key-1', policy_id: 'policyId', }); }); it('Should allow to enroll a new PERMANENT agent again if this agent is active', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + const { agentLib, agentsRepository } = compose(); - const agent1 = await agentLib.enroll( - getUser(), - 'valid-enrollment-token', - 'PERMANENT', - undefined, - 'agent-1' - ); + const agent1 = await agentLib.enroll(getUser('VALID_KEY'), 'PERMANENT', undefined, 'agent-1'); // Desactivate this agent agentsRepository.agents[agent1.id].active = false; - const agent2 = await agentLib.enroll( - getUser(), - 'valid-enrollment-token', - 'PERMANENT', - undefined, - 'agent-1' - ); + const agent2 = await agentLib.enroll(getUser('VALID_KEY'), 'PERMANENT', undefined, 'agent-1'); expect(agent2).toBeDefined(); expect(agent2).toMatchObject({ - access_token: 'mock-access-token-2', + access_api_key: 'mock-access-api-key-2', }); }); it('Should not enroll a new PERMANENT agent if this agent is already active', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + const { agentLib } = compose(); - await agentLib.enroll(getUser(), 'valid-enrollment-token', 'PERMANENT', undefined, 'agent-1'); + await agentLib.enroll(getUser('VALID_KEY'), 'PERMANENT', undefined, 'agent-1'); let error: Error | null = null; try { - await agentLib.enroll( - getUser(), - 'valid-enrollment-token', - 'PERMANENT', - undefined, - 'agent-1' - ); + await agentLib.enroll(getUser('VALID_KEY'), 'PERMANENT', undefined, 'agent-1'); } catch (err) { error = err; } @@ -128,22 +114,13 @@ describe('Agent lib', () => { }); it('Should enroll a new EPHEMERAL agent', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + const { agentLib } = compose(); - const agent = await agentLib.enroll( - getUser(), - 'valid-enrollment-token', - 'EPHEMERAL', - undefined - ); + const agent = await agentLib.enroll(getUser('VALID_KEY_WITH_POLICY'), 'EPHEMERAL', undefined); expect(agent).toBeDefined(); expect(agent).toMatchObject({ - access_token: 'mock-access-token-1', + access_api_key: 'mock-access-api-key-1', policy_id: 'policyId', }); }); @@ -151,12 +128,8 @@ describe('Agent lib', () => { describe('Delete', () => { it('should delete ephemeral instances', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.delete = jest.fn(async () => {}); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); await agentLib.delete(getUser(), { id: 'agent:1', @@ -167,12 +140,8 @@ describe('Agent lib', () => { }); it('should desactivate other agent', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.update = jest.fn(async () => {}); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); await agentLib.delete(getUser(), { id: 'agent:1', @@ -187,15 +156,10 @@ describe('Agent lib', () => { describe('list', () => { it('should return all agents', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = { id: 'agent:1' } as Agent; agentsRepository.agents['agent:2'] = { id: 'agent:2' } as Agent; - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); - const res = await agentLib.list(getUser()); expect(res).toBeDefined(); @@ -206,14 +170,10 @@ describe('Agent lib', () => { describe('checkin', () => { it('should throw if the agens do not exists', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); + const { agentLib } = compose(); await expect( - agentLib.checkin(getUser(), 'agent:1', [ + agentLib.checkin(getUser('VALID_KEY'), [ { timestamp: '2019-09-05T15:41:26+0000', type: 'STATE', @@ -225,37 +185,31 @@ describe('Agent lib', () => { }); it('should throw is the agent is not active', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsRepository = new InMemoryAgentsRepository(); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', actions: [], active: false, policy_id: 'policy:1', + access_api_key_id: 'key1', } as unknown) as Agent; - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); - await expect(agentLib.checkin(getUser(), 'agent:1', [])).rejects.toThrowError( + await expect(agentLib.checkin(getUser('VALID_KEY', 'key1'), [])).rejects.toThrowError( /Agent inactive/ ); }); it('should persist new events', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policy = new PolicyLib({} as PoliciesRepository); - const agentsRepository = new InMemoryAgentsRepository(); - const agentsEventsRepository = new InMemoryAgentEventsRepository(); + const { agentLib, agentsRepository, agentsEventsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', actions: [], active: true, policy_id: 'policy:1', + access_api_key_id: 'key1', } as unknown) as Agent; - const agentLib = new AgentLib(agentsRepository, agentsEventsRepository, token, policy); - await agentLib.checkin(getUser(), 'agent:1', [ + await agentLib.checkin(getUser('VALID_KEY', 'key1'), [ { timestamp: '2019-09-05T15:41:26+0000', type: 'STATE', @@ -278,11 +232,8 @@ describe('Agent lib', () => { }); it('should not update agent metadata if none are provided', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policy = new PolicyLib({} as PoliciesRepository); - const agentEventsRepository = new InMemoryAgentEventsRepository(); - const agentRepository = new InMemoryAgentsRepository(); - agentRepository.agents['agent:1'] = ({ + const { agentLib, agentsRepository } = compose(); + agentsRepository.agents['agent:1'] = ({ id: 'agent:1', local_metadata: { key: 'local1' }, user_provided_metadata: { key: 'user1' }, @@ -290,21 +241,19 @@ describe('Agent lib', () => { events: [], active: true, policy_id: 'policy:1', + access_api_key_id: 'key1', } as unknown) as Agent; - const agentLib = new AgentLib(agentRepository, agentEventsRepository, token, policy); - await agentLib.checkin(getUser(), 'agent:1', []); + await agentLib.checkin(getUser('VALID_KEY', 'key1'), []); - const refreshAgent = (await agentRepository.getById(getUser(), 'agent:1')) as Agent; + const refreshAgent = (await agentsRepository.getById(getUser(), 'agent:1')) as Agent; expect(refreshAgent.local_metadata).toMatchObject({ key: 'local1', }); }); it('should return the full policy for this agent', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const policyLib = new PolicyLib({} as PoliciesRepository); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', local_metadata: { key: 'local1' }, @@ -313,11 +262,10 @@ describe('Agent lib', () => { events: [], active: true, policy_id: 'policy:1', + access_api_key_id: 'key1', } as unknown) as Agent; - const agentEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policyLib); - const { policy } = await agentLib.checkin(getUser(), 'agent:1', []); + const { policy } = await agentLib.checkin(getUser('VALID_KEY', 'key1'), []); expect(policy).toMatchObject({ id: 'policy:1', @@ -325,9 +273,7 @@ describe('Agent lib', () => { }); it('should update agent metadata if provided', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const agentEventsRepository = new InMemoryAgentEventsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', local_metadata: { key: 'local1' }, @@ -336,11 +282,10 @@ describe('Agent lib', () => { events: [], active: true, policy_id: 'policy:1', + access_api_key_id: 'key1', } as unknown) as Agent; - const policy = new PolicyLib({} as PoliciesRepository); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); - await agentLib.checkin(getUser(), 'agent:1', [], { key: 'local2' }); + await agentLib.checkin(getUser('VALID_KEY', 'key1'), [], { key: 'local2' }); const refreshAgent = (await agentsRepository.getById(getUser(), 'agent:1')) as Agent; expect(refreshAgent.local_metadata).toMatchObject({ @@ -349,13 +294,12 @@ describe('Agent lib', () => { }); it('should return new actions', async () => { - const policy = new PolicyLib({} as PoliciesRepository); - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', active: true, policy_id: 'policy:1', + access_api_key_id: 'key1', actions: [ { created_at: '2019-09-05T15:43:26+0000', @@ -371,9 +315,7 @@ describe('Agent lib', () => { ], events: [], } as unknown) as Agent; - const agentEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); - const { actions } = await agentLib.checkin(getUser(), 'agent:1', []); + const { actions } = await agentLib.checkin(getUser('VALID_KEY', 'key1'), []); expect(actions).toHaveLength(1); expect(actions[0]).toMatchObject({ @@ -388,9 +330,7 @@ describe('Agent lib', () => { describe('unenroll', () => { it('should set the list of agents as inactive', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const agentEventsRepository = new InMemoryAgentEventsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', local_metadata: { key: 'local1' }, @@ -409,8 +349,6 @@ describe('Agent lib', () => { active: true, policy_id: 'policy:1', } as unknown) as Agent; - const policy = new PolicyLib({} as PoliciesRepository); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); await agentLib.unenroll(getUser(), ['agent:1', 'agent:2']); @@ -424,9 +362,7 @@ describe('Agent lib', () => { describe('unenrollForPolicy', () => { it('should set all the of agents for this policy as inactive', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const agentEventsRepository = new InMemoryAgentEventsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = ({ id: 'agent:1', local_metadata: { key: 'local1' }, @@ -445,8 +381,6 @@ describe('Agent lib', () => { active: true, policy_id: 'policy:1', } as unknown) as Agent; - const policy = new PolicyLib({} as PoliciesRepository); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); await agentLib.unenrollForPolicy(getUser(), 'policy:1'); @@ -460,11 +394,7 @@ describe('Agent lib', () => { describe('addAction', () => { it('should throw if the agent do not exists', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); - const policy = new PolicyLib({} as PoliciesRepository); - const agentEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); + const { agentLib } = compose(); await expect( agentLib.addAction(getUser(), 'agent:1', { @@ -474,8 +404,7 @@ describe('Agent lib', () => { }); it('should add the action', async () => { - const token = new TokenLib({} as TokensRepository, {} as FrameworkLib); - const agentsRepository = new InMemoryAgentsRepository(); + const { agentLib, agentsRepository } = compose(); agentsRepository.agents['agent:1'] = { id: 'agent:1', actions: [], @@ -485,10 +414,6 @@ describe('Agent lib', () => { }; const spy = jest.spyOn(agentsRepository, 'update'); - const policy = new PolicyLib({} as PoliciesRepository); - const agentEventsRepository = new InMemoryAgentEventsRepository(); - const agentLib = new AgentLib(agentsRepository, agentEventsRepository, token, policy); - const action = await agentLib.addAction(getUser(), 'agent:1', { type: 'PAUSE', }); diff --git a/x-pack/legacy/plugins/fleet/server/libs/agent.ts b/x-pack/legacy/plugins/fleet/server/libs/agent.ts index 47ce7f27967c1..b2f7dcb7eef5d 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/agent.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/agent.ts @@ -15,7 +15,7 @@ import { AgentAction, AgentActionType, } from '../repositories/agents/types'; -import { TokenLib } from './token'; +import { ApiKeyLib } from './api_keys'; import { PolicyLib } from './policy'; import { FullPolicyFile } from '../repositories/policies/types'; import { FrameworkUser } from '../adapters/framework/adapter_types'; @@ -25,29 +25,29 @@ export class AgentLib { constructor( private readonly agentsRepository: AgentsRepository, private readonly agentEventsRepository: AgentEventsRepository, - private readonly tokens: TokenLib, - private readonly policy: PolicyLib + private readonly apiKeys: ApiKeyLib, + private readonly policies: PolicyLib ) {} /** - * Enroll a new token into elastic fleet + * Enroll a new agent into elastic fleet */ public async enroll( user: FrameworkUser, - token: any, type: AgentType, metadata?: { local: any; userProvided: any }, sharedId?: string ): Promise { - const verifyResponse = await this.tokens.verify(user, token); + const internalUser = this._getInternalUser(); + const verifyResponse = await this.apiKeys.verifyEnrollmentApiKey(user); if (!verifyResponse.valid) { - throw Boom.unauthorized(`Enrollment token is not valid: ${verifyResponse.reason}`); + throw Boom.unauthorized(`Enrollment apiKey is not valid: ${verifyResponse.reason}`); } - const policyId = verifyResponse.token.policy_id; + const policyId = verifyResponse.enrollmentApiKey.policy_id; const existingAgent = sharedId - ? await this.agentsRepository.getBySharedId(user, sharedId) + ? await this.agentsRepository.getBySharedId(internalUser, sharedId) : null; if (existingAgent && existingAgent.active === true) { @@ -68,22 +68,22 @@ export class AgentLib { let agent; if (existingAgent) { - await this.agentsRepository.update(user, existingAgent.id, agentData); + await this.agentsRepository.update(internalUser, existingAgent.id, agentData); agent = { ...existingAgent, ...agentData, }; } else { - agent = await this.agentsRepository.create(user, agentData); + agent = await this.agentsRepository.create(internalUser, agentData); } - const accessToken = await this.tokens.generateAccessToken(agent.id, policyId); + const accessApiKey = await this.apiKeys.generateAccessApiKey(agent.id, policyId); await this.agentsRepository.update(user, agent.id, { - access_token: accessToken, + access_api_key_id: accessApiKey.id, }); - return { ...agent, access_token: accessToken }; + return { ...agent, access_api_key: accessApiKey.key }; } public async unenrollForPolicy(user: FrameworkUser, policyId: string) { @@ -199,16 +199,20 @@ export class AgentLib { */ public async checkin( user: FrameworkUser, - agentId: string, events: AgentEvent[], localMetadata?: any - ): Promise<{ actions: AgentAction[]; policy: FullPolicyFile }> { - const agent = await this.agentsRepository.getById(user, agentId); + ): Promise<{ actions: AgentAction[]; policy: FullPolicyFile | null }> { + const res = await this.apiKeys.verifyAccessApiKey(user); + if (!res.valid) { + throw Boom.unauthorized('Invalid apiKey'); + } + + const internalUser = this._getInternalUser(); + const agent = await this.agentsRepository.getByAccessApiKeyId(internalUser, res.accessApiKeyId); if (!agent) { throw Boom.notFound('Agent not found or inactive'); } - if (!agent.active) { throw Boom.forbidden('Agent inactive'); } @@ -229,10 +233,10 @@ export class AgentLib { updateData.local_metadata = localMetadata; } - const policy = await this.policy.getFullPolicy(agent.policy_id); - await this.agentsRepository.update(user, agent.id, updateData); + const policy = agent.policy_id ? await this.policies.getFullPolicy(agent.policy_id) : null; + await this.agentsRepository.update(internalUser, agent.id, updateData); if (events.length > 0) { - await this.agentEventsRepository.createEventsForAgent(user, agent.id, events); + await this.agentEventsRepository.createEventsForAgent(internalUser, agent.id, events); } return { actions, policy }; @@ -288,4 +292,10 @@ export class AgentLib { public _filterActionsForCheckin(agent: Agent): AgentAction[] { return agent.actions.filter(a => !a.sent_at); } + + private _getInternalUser(): FrameworkUser { + return { + kind: 'internal', + }; + } } diff --git a/x-pack/legacy/plugins/fleet/server/libs/api_keys.test.ts b/x-pack/legacy/plugins/fleet/server/libs/api_keys.test.ts new file mode 100644 index 0000000000000..0f28dcd6e3ef8 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/api_keys.test.ts @@ -0,0 +1,142 @@ +/* + * 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 { ApiKeyLib } from './api_keys'; +import { FrameworkLib } from './framework'; +import { MemoryEnrollmentApiKeysRepository } from '../repositories/enrollment_api_keys/memory'; +import { FrameworkAdapter } from '../adapters/framework/default'; +import { FrameworkUser, internalAuthData } from '../adapters/framework/adapter_types'; +import { InMemoryElasticsearchAdapter } from '../adapters/elasticsearch/in_memory'; + +jest.mock('./framework'); + +function getUser() { + return {} as FrameworkUser; +} + +function getUserForApiKey(apiKey: string) { + return { + kind: 'authenticated', + [internalAuthData]: { + authorization: `ApiKey ${apiKey}`, + }, + } as FrameworkUser; +} + +function compose() { + const enrollmentApiKeyRepository = new MemoryEnrollmentApiKeysRepository(); + const esAdapter = new InMemoryElasticsearchAdapter(); + const apiKeys = new ApiKeyLib( + enrollmentApiKeyRepository, + esAdapter, + new FrameworkLib({} as FrameworkAdapter) + ); + + return { apiKeys, enrollmentApiKeyRepository, esAdapter }; +} + +describe('ApiKeys Lib', () => { + describe('verifyAccessApiKey', () => { + it('should verify a valid api key', async () => { + const { apiKeys, esAdapter } = compose(); + const apiKey = await esAdapter.createApiKey(getUser(), { + name: 'test-api-key', + }); + + const res = await apiKeys.verifyAccessApiKey(getUserForApiKey(apiKey.api_key)); + + expect(res).toMatchObject({ + valid: true, + }); + }); + it('should not verify invalid ApiKey', async () => { + const { apiKeys, esAdapter } = compose(); + esAdapter.authenticate = () => { + throw new Error('ApiKey not valid'); + }; + const res = await apiKeys.verifyAccessApiKey(getUserForApiKey('NOT_A_VALID_API_KEY')); + expect(res).toMatchObject({ + valid: false, + reason: 'ApiKey not valid', + }); + }); + }); + describe('verifyEnrollmentApiKey', () => { + it('should verify a valid api key', async () => { + const { apiKeys, esAdapter, enrollmentApiKeyRepository } = compose(); + const apiKey = await esAdapter.createApiKey(getUser(), { + name: 'test-api-key', + }); + enrollmentApiKeyRepository.create(getUser(), { + active: true, + apiKeyId: apiKey.id, + apiKey: apiKey.api_key, + }); + + const res = await apiKeys.verifyEnrollmentApiKey(getUserForApiKey(apiKey.api_key)); + + expect(res).toMatchObject({ + valid: true, + }); + }); + + it('should not verify a inactive enrollemnt api key', async () => { + const { apiKeys, esAdapter, enrollmentApiKeyRepository } = compose(); + const apiKey = await esAdapter.createApiKey(getUser(), { + name: 'test-api-key', + }); + enrollmentApiKeyRepository.create(getUser(), { + active: false, + apiKeyId: apiKey.id, + apiKey: apiKey.api_key, + }); + + const res = await apiKeys.verifyEnrollmentApiKey(getUserForApiKey(apiKey.api_key)); + + expect(res).toMatchObject({ + valid: false, + reason: 'Enrollement api key does not exists or is not active', + }); + }); + + it('should not verify a inactive an enrollemnt api key not persisted', async () => { + const { apiKeys, esAdapter } = compose(); + const apiKey = await esAdapter.createApiKey(getUser(), { + name: 'test-api-key', + }); + const res = await apiKeys.verifyEnrollmentApiKey(getUserForApiKey(apiKey.api_key)); + + expect(res).toMatchObject({ + valid: false, + reason: 'Enrollement api key does not exists or is not active', + }); + }); + + it('should not verify invalid ApiKey', async () => { + const { apiKeys, esAdapter } = compose(); + esAdapter.authenticate = () => { + throw new Error('ApiKey not valid'); + }; + const res = await apiKeys.verifyEnrollmentApiKey(getUserForApiKey('NOT_A_VALID_API_KEY')); + expect(res).toMatchObject({ + valid: false, + reason: 'ApiKey not valid', + }); + }); + }); + + describe('generateEnrollmentApiKey', () => { + it('should generate a valid ApiKey', async () => { + const { apiKeys } = compose(); + + const apiKey = await apiKeys.generateEnrollmentApiKey(getUser(), { + policyId: 'policy1', + }); + + expect(apiKey).toBeDefined(); + }); + }); +}); diff --git a/x-pack/legacy/plugins/fleet/server/libs/api_keys.ts b/x-pack/legacy/plugins/fleet/server/libs/api_keys.ts new file mode 100644 index 0000000000000..1ff633d65f3a8 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/libs/api_keys.ts @@ -0,0 +1,310 @@ +/* + * 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 * as _ from 'lodash'; +import Boom from 'boom'; +import uuid from 'uuid/v4'; +import { + EnrollmentApiKeyVerificationResponse, + EnrollmentApiKey, + EnrollmentRuleData, + EnrollmentApiKeysRepository, + AccessApiKeyVerificationResponse, + EnrollmentRule, +} from '../repositories/enrollment_api_keys/types'; +import { FrameworkLib } from './framework'; +import { FrameworkUser, internalAuthData } from '../adapters/framework/adapter_types'; +import { ElasticsearchAdapter } from '../adapters/elasticsearch/adapter_types'; +import { DEFAULT_POLICY_ID } from '../../common/constants'; + +export class ApiKeyLib { + constructor( + private readonly enrollmentApiKeysRepository: EnrollmentApiKeysRepository, + private readonly esAdapter: ElasticsearchAdapter, + private readonly frameworkLib: FrameworkLib + ) {} + + public async getEnrollmentApiKey(user: FrameworkUser, keyId: string) { + return await this.enrollmentApiKeysRepository.getById(user, keyId); + } + + public async listEnrollmentApiKeys( + user: FrameworkUser, + options: { page?: number; perPage?: number; kuery?: string; showInactive?: boolean } + ): Promise<{ items: any; total: any; page: any; perPage: any }> { + return await this.enrollmentApiKeysRepository.list(user, options); + } + + /** + * Verify if an an enrollment api key is valid and active + */ + public async verifyEnrollmentApiKey( + user: FrameworkUser + ): Promise { + try { + const { apiKeyId } = this._parseApiKey(user); + + await this.esAdapter.authenticate(user); + const enrollmentApiKey = await this.enrollmentApiKeysRepository.getByApiKeyId( + this.frameworkLib.getInternalUser(), + apiKeyId + ); + if (!enrollmentApiKey || !enrollmentApiKey.active) { + throw new Error('Enrollement api key does not exists or is not active'); + } + + return { + valid: true, + enrollmentApiKey, + }; + } catch (error) { + return { + valid: false, + reason: error.message, + }; + } + } + + /** + * Verify if an an enrollment api key is valid and active + */ + public async verifyAccessApiKey(user: FrameworkUser): Promise { + try { + const { apiKeyId } = this._parseApiKey(user); + + await this.esAdapter.authenticate(user); + + return { + valid: true, + accessApiKeyId: apiKeyId, + }; + } catch (error) { + return { + valid: false, + reason: error.message, + }; + } + } + + public async generateAccessApiKey( + agentId: string, + policyId?: string + ): Promise<{ key: string; id: string }> { + const name = this._getAccesstApiKeyName(agentId); + + const key = await this.esAdapter.createApiKey(this.frameworkLib.getInternalUser(), { + name, + + role_descriptors: { + 'fleet-agent': { + index: [ + { + names: ['logs-*', 'metrics-*'], + privileges: ['write'], + }, + ], + }, + }, + }); + + return { id: key.id, key: Buffer.from(`${key.id}:${key.api_key}`).toString('base64') }; + } + + /** + * Generate a new enrollment api key + */ + public async generateEnrollmentApiKey( + user: FrameworkUser, + data: { + name?: string; + policyId?: string; + expiration?: string; + } + ): Promise { + const id = uuid(); + const { name: providedKeyName, policyId = DEFAULT_POLICY_ID, expiration } = data; + + const name = this._getEnrollmentApiKeyName(id, providedKeyName, policyId); + + const key = await this.esAdapter.createApiKey(this.frameworkLib.getInternalUser(), { + name, + expiration, + }); + + const apiKey = Buffer.from(`${key.id}:${key.api_key}`).toString('base64'); + + return await this.enrollmentApiKeysRepository.create(user, { + active: true, + apiKeyId: key.id, + apiKey, + name, + policyId, + }); + } + + public async deleteEnrollmentApiKeyForPolicyId(user: FrameworkUser, policyId: string) { + let hasMore = true; + let page = 1; + while (hasMore) { + const { items } = await this.enrollmentApiKeysRepository.list(user, { + page: page++, + perPage: 100, + kuery: `enrollment_api_keys.policy_id:${policyId}`, + }); + + if (items.length === 0) { + hasMore = false; + } + + for (const apiKey of items) { + await this.deleteEnrollmentApiKey(user, apiKey.id); + } + } + } + + public async deleteEnrollmentApiKey(user: FrameworkUser, id: string) { + const enrollmentApiKey = await this.enrollmentApiKeysRepository.getById(user, id); + if (!enrollmentApiKey) { + throw Boom.notFound('Enrollment Api Key not found'); + } + + await this.esAdapter.deleteApiKey(this.frameworkLib.getInternalUser(), { + id: enrollmentApiKey.api_key_id, + }); + + await this.enrollmentApiKeysRepository.delete(user, id); + } + + private _parseApiKey(user: FrameworkUser) { + if (user.kind !== 'authenticated') { + throw new Error('Error must provide an authenticated user'); + } + + const authorizationHeader = user[internalAuthData].authorization; + + if (!authorizationHeader) { + throw new Error('Authorization header must be set'); + } + + if (!authorizationHeader.startsWith('ApiKey ')) { + throw new Error('Authorization header is malformed'); + } + + const apiKey = authorizationHeader.split(' ')[1]; + if (!apiKey) { + throw new Error('Authorization header is malformed'); + } + const apiKeyId = Buffer.from(apiKey, 'base64') + .toString('utf8') + .split(':')[0]; + + return { + apiKey, + apiKeyId, + }; + } + + private _getEnrollmentApiKeyName(id: string, name?: string, policyId?: string): string { + const generatedName = `Fleet:EnrollmentApiKey:${id}${policyId ? `:${policyId}` : ''}`; + + return name ? `${name} (${generatedName})` : generatedName; + } + + private _getAccesstApiKeyName(agentId: string): string { + return `Fleet:AccessApiKey:${agentId}`; + } + + public async addEnrollmentRule( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleData: EnrollmentRuleData + ) { + const enrollmentApiKey = await this.enrollmentApiKeysRepository.getById( + user, + enrollmentApiKeyId + ); + if (!enrollmentApiKey) { + throw Boom.notFound('Enrollment api key not found.'); + } + + const rule = { + ...ruleData, + id: uuid(), + created_at: new Date().toISOString(), + }; + + await this.enrollmentApiKeysRepository.update(user, enrollmentApiKey.id, { + enrollment_rules: enrollmentApiKey.enrollment_rules.concat([rule]), + }); + + return rule; + } + + public async updateEnrollmentRuleForPolicy( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleId: string, + ruleData: EnrollmentRuleData + ): Promise { + const enrollmentApiKey = await this._getEnrollemntApiKeyByIdOrThrow(user, enrollmentApiKeyId); + + const ruleToUpdate = enrollmentApiKey.enrollment_rules.find(rule => rule.id === ruleId); + if (!ruleToUpdate) { + throw Boom.notFound(`Rule not found: ${ruleId}`); + } + const ruleIndex = enrollmentApiKey.enrollment_rules.indexOf(ruleToUpdate); + + const rule = { + ...ruleToUpdate, + ...ruleData, + updated_at: new Date().toISOString(), + }; + + await this.enrollmentApiKeysRepository.update(user, enrollmentApiKey.id, { + enrollment_rules: [ + ...enrollmentApiKey.enrollment_rules.slice(0, ruleIndex), + rule, + ...enrollmentApiKey.enrollment_rules.slice(ruleIndex + 1), + ], + }); + + return rule; + } + + public async deleteEnrollmentRule( + user: FrameworkUser, + enrollmentApiKeyId: string, + ruleId: string + ) { + const enrollmentApiKey = await this._getEnrollemntApiKeyByIdOrThrow(user, enrollmentApiKeyId); + const ruleIndex = enrollmentApiKey.enrollment_rules.findIndex(rule => rule.id === ruleId); + if (ruleIndex < 0) { + throw Boom.notFound(`Rule not found: ${ruleId}`); + } + + await this.enrollmentApiKeysRepository.update(user, enrollmentApiKey.id, { + enrollment_rules: [ + ...enrollmentApiKey.enrollment_rules.slice(0, ruleIndex), + ...enrollmentApiKey.enrollment_rules.slice(ruleIndex + 1), + ], + }); + } + + public async deleteAllEnrollmentRules(user: FrameworkUser, enrollmentApiKeyId: string) { + const enrollmentApiKey = await this._getEnrollemntApiKeyByIdOrThrow(user, enrollmentApiKeyId); + await this.enrollmentApiKeysRepository.update(user, enrollmentApiKey.id, { + enrollment_rules: [], + }); + } + + private async _getEnrollemntApiKeyByIdOrThrow(user: FrameworkUser, id: string) { + const apiKey = await this.enrollmentApiKeysRepository.getById(user, id); + if (!apiKey) { + throw Boom.notFound(`No enrollment api key found`); + } + return apiKey; + } +} 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 503b846c09541..0f42515ab50a6 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/compose/kibana.ts @@ -5,12 +5,12 @@ */ import os from 'os'; -import { TokenLib } from '../token'; +import { ApiKeyLib } from '../api_keys'; import { AgentLib } from '../agent'; import { FrameworkLib } from '../framework'; import { AgentsRepository } from '../../repositories/agents/default'; import { SODatabaseAdapter } from '../../adapters/saved_objects_database/default'; -import { TokensRepository } from '../../repositories/tokens/default'; +import { EnrollmentApiKeysRepository } from '../../repositories/enrollment_api_keys/default'; import { FrameworkAdapter } from '../../adapters/framework/default'; import { PolicyLib } from '../policy'; import { EncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/default'; @@ -21,6 +21,7 @@ import { FileSystemArtifactRepository } from '../../repositories/artifacts/file_ import { HttpAdapter } from '../../adapters/http_adapter/default'; import { AgentEventsRepository } from '../../repositories/agent_events/default'; import { InstallLib } from '../install'; +import { ElasticsearchAdapter } from '../../adapters/elasticsearch/default'; export function compose(server: any): FleetServerLib { const frameworkAdapter = new FrameworkAdapter(server); @@ -31,14 +32,20 @@ export function compose(server: any): FleetServerLib { server.savedObjects, server.plugins.elasticsearch ); - const encryptedObjectAdapter = new EncryptedSavedObjects(server.plugins.encrypted_saved_objects); + const esAdapter = new ElasticsearchAdapter(server.plugins.elasticsearch); + const encryptedObjectAdapter = new EncryptedSavedObjects( + server.newPlatform.start.plugins.encryptedSavedObjects + ); const agentsRepository = new AgentsRepository(soDatabaseAdapter); const agentEventsRepository = new AgentEventsRepository(soDatabaseAdapter); - const tokensRepository = new TokensRepository(soDatabaseAdapter, encryptedObjectAdapter); + const enrollmentApiKeysRepository = new EnrollmentApiKeysRepository( + soDatabaseAdapter, + encryptedObjectAdapter + ); const policies = new PolicyLib(policyAdapter); - const tokens = new TokenLib(tokensRepository, framework); - const agents = new AgentLib(agentsRepository, agentEventsRepository, tokens, policies); + 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()); @@ -47,7 +54,7 @@ export function compose(server: any): FleetServerLib { return { agents, - tokens, + apiKeys, policies, artifacts, install, diff --git a/x-pack/legacy/plugins/fleet/server/libs/framework.ts b/x-pack/legacy/plugins/fleet/server/libs/framework.ts index e270496dcbf9f..4ce246367643d 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/framework.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/framework.ts @@ -5,6 +5,7 @@ */ import { FrameworkAdapter } from '../adapters/framework/default'; +import { FrameworkUser } from '../adapters/framework/adapter_types'; export class FrameworkLib { constructor(private readonly adapter: FrameworkAdapter) {} @@ -25,4 +26,10 @@ export class FrameworkLib { basePath: this.adapter.getSetting('server.basePath'), }; } + + public getInternalUser(): FrameworkUser { + return { + kind: 'internal', + }; + } } diff --git a/x-pack/legacy/plugins/fleet/server/libs/token.test.ts b/x-pack/legacy/plugins/fleet/server/libs/token.test.ts deleted file mode 100644 index 3be5c1d6d4098..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/libs/token.test.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 { sign } from 'jsonwebtoken'; -import { createHmac } from 'crypto'; -import { TokenLib } from './token'; -import { FrameworkLib } from './framework'; -import { MemoryTokensRepository } from '../repositories/tokens/memory'; -import { FrameworkAdapter } from '../adapters/framework/default'; -import { TokenType, Token } from '../repositories/tokens/types'; -import { FrameworkUser } from '../adapters/framework/adapter_types'; - -jest.mock('./framework'); - -function generateJWTToken(): string { - return sign( - { - policy: { - id: 'policyId', - }, - type: TokenType.ENROLLMENT_TOKEN, - }, - 'mockedEncryptionKey' - ); -} - -function hashJWTToken(token: string) { - return createHmac('sha512', 'mockedEncryptionKey') - .update(token) - .digest('hex'); -} - -function getUser() { - return {} as FrameworkUser; -} - -describe('Token Lib', () => { - describe('verify', () => { - it('should verify a valid token', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const token = generateJWTToken(); - const tokenHash = hashJWTToken(token); - tokenAdapter.create(getUser(), { - type: TokenType.ENROLLMENT_TOKEN, - active: true, - tokenHash, - token, - policyId: 'policyId', - }); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const res = await tokens.verify(getUser(), token); - - expect(res).toMatchObject({ - valid: true, - }); - }); - - it('should not verify a inactive token', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const token = generateJWTToken(); - const tokenHash = hashJWTToken(token); - tokenAdapter.create(getUser(), { - type: TokenType.ENROLLMENT_TOKEN, - active: false, - token, - tokenHash, - policyId: 'policyId', - }); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const res = await tokens.verify(getUser(), token); - - expect(res).toMatchObject({ - valid: false, - reason: 'Token is not active', - }); - }); - - it('should not verify a token not persisted', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const token = generateJWTToken(); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const res = await tokens.verify(getUser(), token); - - expect(res).toMatchObject({ - valid: false, - reason: 'Token not found', - }); - }); - - it('should not verify invalid token', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const res = await tokens.verify(getUser(), 'iamnotavalidtoken'); - expect(res).toMatchObject({ - valid: false, - reason: 'jwt malformed', - }); - }); - }); - - describe('generateEnrolmentToken', () => { - it('should generate a valid token', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const token = await tokens.generateEnrolmentToken(getUser(), 'policy_id'); - - expect(token).toBeDefined(); - }); - - it('should persit the generated token', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const token = await tokens.generateEnrolmentToken(getUser(), 'policy_id'); - - const tokenHash = hashJWTToken(token); - const persistedToken = await tokenAdapter.getByTokenHash(getUser(), tokenHash); - - expect(persistedToken).toMatchObject({ - tokenHash, - policy_id: 'policy_id', - }); - }); - }); - - describe('getEnrollmentTokenForPolicy', () => { - it('should return null if there is no token for that policy', async () => { - const tokenAdapter = new MemoryTokensRepository(); - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const token = await tokens.getEnrollmentTokenForPolicy(getUser(), 'policy:do-not-exists'); - - expect(token).toBeNull(); - }); - - it('should return the token for a given policy', async () => { - const tokenAdapter = new MemoryTokensRepository(); - tokenAdapter.tokens['token:1'] = { - id: 'token:1', - policy_id: 'policy:1', - active: true, - tokenHash: 'asdasd', - token: '{}', - type: TokenType.ENROLLMENT_TOKEN, - created_at: '2019-09-12T12:48:42+0000', - enrollment_rules: [], - }; - - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const token = await tokens.getEnrollmentTokenForPolicy(getUser(), 'policy:1'); - - expect(token).toBeDefined(); - expect((token as Token).id).toBe('token:1'); - }); - - it('should regenerate a token for a given policy if the regenerate flag is true', async () => { - const tokenAdapter = new MemoryTokensRepository(); - tokenAdapter.tokens['tokens-0'] = { - id: 'tokens-0', - policy_id: 'policy:1', - active: true, - token: '', - tokenHash: 'asdasd', - type: TokenType.ENROLLMENT_TOKEN, - created_at: '2019-09-12T12:48:42+0000', - enrollment_rules: [], - }; - - const tokens = new TokenLib(tokenAdapter, new FrameworkLib({} as FrameworkAdapter)); - - const token = await tokens.getEnrollmentTokenForPolicy(getUser(), 'policy:1', true); - - expect(token).toBeDefined(); - expect((token as Token).id).toBe('tokens-1'); - }); - }); -}); diff --git a/x-pack/legacy/plugins/fleet/server/libs/token.ts b/x-pack/legacy/plugins/fleet/server/libs/token.ts deleted file mode 100644 index ce897a66d5acc..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/libs/token.ts +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 { sign as signToken, verify as verifyToken } from 'jsonwebtoken'; -import { createHmac } from 'crypto'; -import * as _ from 'lodash'; -import Boom from 'boom'; -import uuid from 'uuid/v4'; -import { - TokenVerificationResponse, - TokenType, - Token, - EnrollmentRuleData, - TokensRepository, -} from '../repositories/tokens/types'; -import { FrameworkLib } from './framework'; -import { FrameworkUser } from '../adapters/framework/adapter_types'; - -interface JWTToken { - policy_id: string; - type: TokenType; -} - -export class TokenLib { - constructor( - private readonly tokensRepository: TokensRepository, - private readonly frameworkLib: FrameworkLib - ) {} - - /** - * Verify if a token is valid - * @param token - */ - public async verify(user: FrameworkUser, token: string): Promise { - try { - const decodedToken = this._verifyJWTToken(token); - - if (decodedToken.type === TokenType.ENROLLMENT_TOKEN) { - await this._verifyPersistedToken(user, token); - } - - return { - valid: true, - type: decodedToken.type, - token: { - policy_id: decodedToken.policy_id, - }, - }; - } catch (error) { - return { - valid: false, - reason: error.message, - }; - } - } - - public async generateAccessToken(agentId: string, policyId: string): Promise { - const encryptionKey = this.frameworkLib.getSetting('encryptionKey'); - const token = signToken( - { - type: TokenType.ACCESS_TOKEN, - agentId, - policy_id: policyId, - }, - encryptionKey - ); - - return token; - } - - /** - * Generate a new enrolment token for a policy - */ - public async generateEnrolmentToken( - user: FrameworkUser, - policyId: string, - expire?: string - ): Promise { - const encryptionKey = this.frameworkLib.getSetting('encryptionKey'); - - const token = signToken( - { - type: TokenType.ENROLLMENT_TOKEN, - policy_id: policyId, - }, - encryptionKey, - expire - ? { - expiresIn: expire, - } - : undefined - ); - const tokenHash = await this.hashToken(token); - - await this.tokensRepository.create(user, { - active: true, - type: TokenType.ENROLLMENT_TOKEN, - tokenHash, - token, - policyId, - }); - - return token; - } - - public async getEnrollmentTokenForPolicy( - user: FrameworkUser, - policyId: string, - regenerate?: boolean - ): Promise { - let token = await this.tokensRepository.getByPolicyId(user, policyId); - - if (regenerate) { - if (token) { - await this.tokensRepository.delete(user, token.id); - } - await this.generateEnrolmentToken(user, policyId); - token = await this.tokensRepository.getByPolicyId(user, policyId); - } - - return token; - } - - public async addEnrollmentRuleForPolicy( - user: FrameworkUser, - policyId: string, - ruleData: EnrollmentRuleData - ) { - const token = await this.tokensRepository.getByPolicyId(user, policyId); - if (!token) { - throw Boom.notFound(`No token found for policy: ${policyId}`); - } - - const rule = { - ...ruleData, - id: uuid(), - created_at: new Date().toISOString(), - }; - - await this.tokensRepository.update(user, token.id, { - enrollment_rules: token.enrollment_rules.concat([rule]), - }); - - return rule; - } - - public async updateEnrollmentRuleForPolicy( - user: FrameworkUser, - policyId: string, - ruleId: string, - ruleData: EnrollmentRuleData - ) { - const token = await this._getTokenByPolicyIdOrThrow(user, policyId); - - const ruleToUpdate = token.enrollment_rules.find(rule => rule.id === ruleId); - if (!ruleToUpdate) { - throw Boom.notFound(`Rule not found: ${ruleId}`); - } - const ruleIndex = token.enrollment_rules.indexOf(ruleToUpdate); - - const rule = { - ...ruleToUpdate, - ...ruleData, - updated_at: new Date().toISOString(), - }; - - await this.tokensRepository.update(user, token.id, { - enrollment_rules: [ - ...token.enrollment_rules.slice(0, ruleIndex), - rule, - ...token.enrollment_rules.slice(ruleIndex + 1), - ], - }); - - return rule; - } - - public async deleteEnrollmentRuleForPolicy( - user: FrameworkUser, - policyId: string, - ruleId: string - ) { - const token = await this._getTokenByPolicyIdOrThrow(user, policyId); - const ruleIndex = token.enrollment_rules.findIndex(rule => rule.id === ruleId); - if (ruleIndex < 0) { - throw Boom.notFound(`Rule not found: ${ruleId}`); - } - - await this.tokensRepository.update(user, token.id, { - enrollment_rules: [ - ...token.enrollment_rules.slice(0, ruleIndex), - ...token.enrollment_rules.slice(ruleIndex + 1), - ], - }); - } - - public async deleteAllEnrollmentRulesForPolicy(user: FrameworkUser, policyId: string) { - const token = await this._getTokenByPolicyIdOrThrow(user, policyId); - await this.tokensRepository.update(user, token.id, { - enrollment_rules: [], - }); - } - - public async hashToken(token: string): Promise { - const encryptionKey = this.frameworkLib.getSetting('encryptionKey'); - - const hmac = createHmac('sha512', encryptionKey); - - return hmac.update(token).digest('hex'); - } - - /** - * Get the token for a given policy. - * @param user - * @param policyId - */ - private async _getTokenByPolicyIdOrThrow(user: FrameworkUser, policyId: string) { - const token = await this.tokensRepository.getByPolicyId(user, policyId); - if (!token) { - throw Boom.notFound(`No token found for policy: ${policyId}`); - } - return token; - } - - private _verifyJWTToken(token: string): JWTToken { - const encryptionKey = this.frameworkLib.getSetting('encryptionKey'); - const decodedToken = verifyToken(token, encryptionKey) as JWTToken; - - return decodedToken; - } - - private async _verifyPersistedToken(user: FrameworkUser, token: string) { - const tokenHash = await this.hashToken(token); - const persistedToken = await this.tokensRepository.getByTokenHash(user, tokenHash); - if (!persistedToken) { - throw new Error('Token not found'); - } - - if (persistedToken.active === false) { - throw new Error('Token is not active'); - } - } -} diff --git a/x-pack/legacy/plugins/fleet/server/libs/types.ts b/x-pack/legacy/plugins/fleet/server/libs/types.ts index f06e0e38d539c..56e771d96935e 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/types.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/types.ts @@ -5,15 +5,15 @@ */ import { AgentLib } from './agent'; -import { TokenLib } from './token'; +import { ApiKeyLib } from './api_keys'; import { PolicyLib } from './policy'; import { ArtifactLib } from './artifact'; import { InstallLib } from './install'; import { FrameworkLib } from './framework'; export interface FleetServerLib { + apiKeys: ApiKeyLib; agents: AgentLib; - tokens: TokenLib; policies: PolicyLib; artifacts: ArtifactLib; install: InstallLib; diff --git a/x-pack/legacy/plugins/fleet/server/mappings.ts b/x-pack/legacy/plugins/fleet/server/mappings.ts index e989083cea626..0a4b9c461e7c7 100644 --- a/x-pack/legacy/plugins/fleet/server/mappings.ts +++ b/x-pack/legacy/plugins/fleet/server/mappings.ts @@ -19,7 +19,7 @@ export const mappings = { enrolled_at: { type: 'date', }, - access_token: { + access_api_key_id: { type: 'keyword', }, version: { @@ -55,15 +55,15 @@ export const mappings = { }, }, }, - tokens: { + enrollment_api_keys: { properties: { - type: { + name: { type: 'keyword', }, - token: { + api_key: { type: 'binary', }, - tokenHash: { + api_key_id: { type: 'keyword', }, policy_id: { diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/__memorize_snapshots__/default.contract.test.slap_snap index 38ebe7ab793e7..c0d06c08c313d 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agent_events/__memorize_snapshots__/default.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/repositories/agent_events/__memorize_snapshots__/default.contract.test.slap_snap @@ -2,7 +2,7 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent - create:agent_events (1)'] = { "results": { "type": "agent_events", - "id": "36eebaa0-f06c-11e9-adc1-97816634f461", + "id": "de47c380-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -11,8 +11,8 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:18.026Z", - "version": "WzMwOTUsMV0=" + "updated_at": "2019-10-29T14:10:31.992Z", + "version": "WzMsMV0=" } } @@ -20,10 +20,10 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "results": { "saved_objects": [ { - "id": "agent_events:37632750-f06c-11e9-adc1-97816634f461", + "id": "agent_events:decd4730-fa55-11e9-a4c5-8377241f6276", "type": "agent_events", - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTYsMV0=", + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzQsMV0=", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -34,10 +34,10 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "references": [] }, { - "id": "agent_events:37632751-f06c-11e9-adc1-97816634f461", + "id": "agent_events:decd4731-fa55-11e9-a4c5-8377241f6276", "type": "agent_events", - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTcsMV0=", + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzUsMV0=", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -59,7 +59,7 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "saved_objects": [ { "type": "agent_events", - "id": "36eebaa0-f06c-11e9-adc1-97816634f461", + "id": "de47c380-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -68,12 +68,12 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:18.026Z", - "version": "WzMwOTUsMV0=" + "updated_at": "2019-10-29T14:10:31.992Z", + "version": "WzMsMV0=" }, { "type": "agent_events", - "id": "37632750-f06c-11e9-adc1-97816634f461", + "id": "decd4730-fa55-11e9-a4c5-8377241f6276", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -82,12 +82,12 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "message": "..." }, "references": [], - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTYsMV0=" + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzQsMV0=" }, { "type": "agent_events", - "id": "37632751-f06c-11e9-adc1-97816634f461", + "id": "decd4731-fa55-11e9-a4c5-8377241f6276", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -96,8 +96,8 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "message": "..." }, "references": [], - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTcsMV0=" + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzUsMV0=" } ] } @@ -111,7 +111,7 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "saved_objects": [ { "type": "agent_events", - "id": "36eebaa0-f06c-11e9-adc1-97816634f461", + "id": "de47c380-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -120,12 +120,12 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:18.026Z", - "version": "WzMwOTUsMV0=" + "updated_at": "2019-10-29T14:10:31.992Z", + "version": "WzMsMV0=" }, { "type": "agent_events", - "id": "37632750-f06c-11e9-adc1-97816634f461", + "id": "decd4730-fa55-11e9-a4c5-8377241f6276", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -134,12 +134,12 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "message": "..." }, "references": [], - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTYsMV0=" + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzQsMV0=" }, { "type": "agent_events", - "id": "37632751-f06c-11e9-adc1-97816634f461", + "id": "decd4731-fa55-11e9-a4c5-8377241f6276", "attributes": { "agent_id": "agent:1", "type": "STATE", @@ -148,29 +148,29 @@ exports['AgentsEventsRepository createEventsForAgent Create events for an agent "message": "..." }, "references": [], - "updated_at": "2019-10-16T23:25:18.788Z", - "version": "WzMwOTcsMV0=" + "updated_at": "2019-10-29T14:10:32.866Z", + "version": "WzUsMV0=" } ] } } -exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:36eebaa0-f06c-11e9-adc1-97816634f461:{} (5)'] = { +exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:de47c380-fa55-11e9-a4c5-8377241f6276:{} (5)'] = { "results": {} } -exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:37632750-f06c-11e9-adc1-97816634f461:{} (6)'] = { +exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:decd4730-fa55-11e9-a4c5-8377241f6276:{} (6)'] = { "results": {} } -exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:37632751-f06c-11e9-adc1-97816634f461:{} (7)'] = { +exports['AgentsEventsRepository createEventsForAgent Create events for an agent - delete:agent_events:decd4731-fa55-11e9-a4c5-8377241f6276:{} (7)'] = { "results": {} } exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - create:agent_events (1)'] = { "results": { "type": "agent_events", - "id": "39cb26a0-f06c-11e9-adc1-97816634f461", + "id": "e13805a0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -179,15 +179,15 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:22.826Z", - "version": "WzMxMDEsMV0=" + "updated_at": "2019-10-29T14:10:36.922Z", + "version": "WzksMV0=" } } exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - create:agent_events (2)'] = { "results": { "type": "agent_events", - "id": "3a6802e0-f06c-11e9-adc1-97816634f461", + "id": "e1d3f780-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -196,15 +196,15 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:23.854Z", - "version": "WzMxMDIsMV0=" + "updated_at": "2019-10-29T14:10:37.944Z", + "version": "WzEwLDFd" } } exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - create:agent_events (3)'] = { "results": { "type": "agent_events", - "id": "3b02e350-f06c-11e9-adc1-97816634f461", + "id": "e26f9b40-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -213,15 +213,15 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:24.869Z", - "version": "WzMxMDMsMV0=" + "updated_at": "2019-10-29T14:10:38.964Z", + "version": "WzExLDFd" } } exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - create:agent_events (4)'] = { "results": { "type": "agent_events", - "id": "3b9d75a0-f06c-11e9-adc1-97816634f461", + "id": "e30aa2c0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -230,8 +230,8 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:25.882Z", - "version": "WzMxMDQsMV0=" + "updated_at": "2019-10-29T14:10:39.980Z", + "version": "WzEyLDFd" } } @@ -243,38 +243,38 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "saved_objects": [ { "type": "agent_events", - "id": "39cb26a0-f06c-11e9-adc1-97816634f461", + "id": "e13805a0-fa55-11e9-a4c5-8377241f6276", "references": [], - "updated_at": "2019-10-16T23:25:22.826Z", - "version": "WzMxMDEsMV0=" + "updated_at": "2019-10-29T14:10:36.922Z", + "version": "WzksMV0=" }, { "type": "agent_events", - "id": "3a6802e0-f06c-11e9-adc1-97816634f461", + "id": "e1d3f780-fa55-11e9-a4c5-8377241f6276", "references": [], - "updated_at": "2019-10-16T23:25:23.854Z", - "version": "WzMxMDIsMV0=" + "updated_at": "2019-10-29T14:10:37.944Z", + "version": "WzEwLDFd" }, { "type": "agent_events", - "id": "3b02e350-f06c-11e9-adc1-97816634f461", + "id": "e26f9b40-fa55-11e9-a4c5-8377241f6276", "references": [], - "updated_at": "2019-10-16T23:25:24.869Z", - "version": "WzMxMDMsMV0=" + "updated_at": "2019-10-29T14:10:38.964Z", + "version": "WzExLDFd" } ] } } -exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:39cb26a0-f06c-11e9-adc1-97816634f461:{} (6)'] = { +exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:e13805a0-fa55-11e9-a4c5-8377241f6276:{} (6)'] = { "results": {} } -exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:3a6802e0-f06c-11e9-adc1-97816634f461:{} (7)'] = { +exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:e1d3f780-fa55-11e9-a4c5-8377241f6276:{} (7)'] = { "results": {} } -exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:3b02e350-f06c-11e9-adc1-97816634f461:{} (8)'] = { +exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:e26f9b40-fa55-11e9-a4c5-8377241f6276:{} (8)'] = { "results": {} } @@ -295,7 +295,7 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "saved_objects": [ { "type": "agent_events", - "id": "3b9d75a0-f06c-11e9-adc1-97816634f461", + "id": "e30aa2c0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -304,8 +304,8 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:25.882Z", - "version": "WzMxMDQsMV0=" + "updated_at": "2019-10-29T14:10:39.980Z", + "version": "WzEyLDFd" } ] } @@ -319,7 +319,7 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "saved_objects": [ { "type": "agent_events", - "id": "3b9d75a0-f06c-11e9-adc1-97816634f461", + "id": "e30aa2c0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -328,21 +328,21 @@ exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:25.882Z", - "version": "WzMxMDQsMV0=" + "updated_at": "2019-10-29T14:10:39.980Z", + "version": "WzEyLDFd" } ] } } -exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:3b9d75a0-f06c-11e9-adc1-97816634f461:{} (12)'] = { +exports['AgentsEventsRepository deleteEventsForAgent Delete correctly all events for the agent - delete:agent_events:e30aa2c0-fa55-11e9-a4c5-8377241f6276:{} (12)'] = { "results": {} } exports['AgentsEventsRepository getEventsForAgent Get events for the agent - create:agent_events (1)'] = { "results": { "type": "agent_events", - "id": "3ea29f50-f06c-11e9-adc1-97816634f461", + "id": "e611c840-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -353,15 +353,15 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - cre "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:30.949Z", - "version": "WzMxMDksMV0=" + "updated_at": "2019-10-29T14:10:45.060Z", + "version": "WzE3LDFd" } } exports['AgentsEventsRepository getEventsForAgent Get events for the agent - create:agent_events (2)'] = { "results": { "type": "agent_events", - "id": "3f3bab00-f06c-11e9-adc1-97816634f461", + "id": "e6accfc0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -370,15 +370,15 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - cre "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:31.952Z", - "version": "WzMxMTAsMV0=" + "updated_at": "2019-10-29T14:10:46.076Z", + "version": "WzE4LDFd" } } exports['AgentsEventsRepository getEventsForAgent Get events for the agent - create:agent_events (3)'] = { "results": { "type": "agent_events", - "id": "3fd83920-f06c-11e9-adc1-97816634f461", + "id": "e7476210-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -387,15 +387,15 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - cre "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:32.978Z", - "version": "WzMxMTEsMV0=" + "updated_at": "2019-10-29T14:10:47.088Z", + "version": "WzE5LDFd" } } exports['AgentsEventsRepository getEventsForAgent Get events for the agent - create:agent_events (4)'] = { "results": { "type": "agent_events", - "id": "40725640-f06c-11e9-adc1-97816634f461", + "id": "e7dfd180-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -404,8 +404,8 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - cre "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:33.988Z", - "version": "WzMxMTIsMV0=" + "updated_at": "2019-10-29T14:10:48.088Z", + "version": "WzIwLDFd" } } @@ -417,7 +417,7 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "saved_objects": [ { "type": "agent_events", - "id": "3fd83920-f06c-11e9-adc1-97816634f461", + "id": "e7476210-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -426,12 +426,12 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:32.978Z", - "version": "WzMxMTEsMV0=" + "updated_at": "2019-10-29T14:10:47.088Z", + "version": "WzE5LDFd" }, { "type": "agent_events", - "id": "3f3bab00-f06c-11e9-adc1-97816634f461", + "id": "e6accfc0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -440,12 +440,12 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:31.952Z", - "version": "WzMxMTAsMV0=" + "updated_at": "2019-10-29T14:10:46.076Z", + "version": "WzE4LDFd" }, { "type": "agent_events", - "id": "3ea29f50-f06c-11e9-adc1-97816634f461", + "id": "e611c840-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -456,8 +456,8 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:30.949Z", - "version": "WzMxMDksMV0=" + "updated_at": "2019-10-29T14:10:45.060Z", + "version": "WzE3LDFd" } ] } @@ -471,7 +471,7 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "saved_objects": [ { "type": "agent_events", - "id": "3ea29f50-f06c-11e9-adc1-97816634f461", + "id": "e611c840-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -482,12 +482,12 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:30.949Z", - "version": "WzMxMDksMV0=" + "updated_at": "2019-10-29T14:10:45.060Z", + "version": "WzE3LDFd" }, { "type": "agent_events", - "id": "3f3bab00-f06c-11e9-adc1-97816634f461", + "id": "e6accfc0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -496,12 +496,12 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:31.952Z", - "version": "WzMxMTAsMV0=" + "updated_at": "2019-10-29T14:10:46.076Z", + "version": "WzE4LDFd" }, { "type": "agent_events", - "id": "3fd83920-f06c-11e9-adc1-97816634f461", + "id": "e7476210-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -510,12 +510,12 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:32.978Z", - "version": "WzMxMTEsMV0=" + "updated_at": "2019-10-29T14:10:47.088Z", + "version": "WzE5LDFd" }, { "type": "agent_events", - "id": "40725640-f06c-11e9-adc1-97816634f461", + "id": "e7dfd180-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -524,33 +524,33 @@ exports['AgentsEventsRepository getEventsForAgent Get events for the agent - fin "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:33.988Z", - "version": "WzMxMTIsMV0=" + "updated_at": "2019-10-29T14:10:48.088Z", + "version": "WzIwLDFd" } ] } } -exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:3ea29f50-f06c-11e9-adc1-97816634f461:{} (7)'] = { +exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:e611c840-fa55-11e9-a4c5-8377241f6276:{} (7)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:3f3bab00-f06c-11e9-adc1-97816634f461:{} (8)'] = { +exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:e6accfc0-fa55-11e9-a4c5-8377241f6276:{} (8)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:3fd83920-f06c-11e9-adc1-97816634f461:{} (9)'] = { +exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:e7476210-fa55-11e9-a4c5-8377241f6276:{} (9)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:40725640-f06c-11e9-adc1-97816634f461:{} (10)'] = { +exports['AgentsEventsRepository getEventsForAgent Get events for the agent - delete:agent_events:e7dfd180-fa55-11e9-a4c5-8377241f6276:{} (10)'] = { "results": {} } exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - create:agent_events (1)'] = { "results": { "type": "agent_events", - "id": "4377a700-f06c-11e9-adc1-97816634f461", + "id": "eae8a4b0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -561,15 +561,15 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - cr "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:39.056Z", - "version": "WzMxMTcsMV0=" + "updated_at": "2019-10-29T14:10:53.179Z", + "version": "WzI1LDFd" } } exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - create:agent_events (2)'] = { "results": { "type": "agent_events", - "id": "44114ef0-f06c-11e9-adc1-97816634f461", + "id": "eb830ff0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -578,15 +578,15 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - cr "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:40.063Z", - "version": "WzMxMTgsMV0=" + "updated_at": "2019-10-29T14:10:54.191Z", + "version": "WzI2LDFd" } } exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - create:agent_events (3)'] = { "results": { "type": "agent_events", - "id": "44ab4500-f06c-11e9-adc1-97816634f461", + "id": "ec1d7b30-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -595,15 +595,15 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - cr "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:41.071Z", - "version": "WzMxMTksMV0=" + "updated_at": "2019-10-29T14:10:55.203Z", + "version": "WzI3LDFd" } } exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - create:agent_events (4)'] = { "results": { "type": "agent_events", - "id": "4547fa30-f06c-11e9-adc1-97816634f461", + "id": "ecb80d80-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -612,8 +612,8 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - cr "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:42.099Z", - "version": "WzMxMjAsMV0=" + "updated_at": "2019-10-29T14:10:56.216Z", + "version": "WzI4LDFd" } } @@ -625,7 +625,7 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "saved_objects": [ { "type": "agent_events", - "id": "44114ef0-f06c-11e9-adc1-97816634f461", + "id": "eb830ff0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -634,8 +634,8 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:40.063Z", - "version": "WzMxMTgsMV0=" + "updated_at": "2019-10-29T14:10:54.191Z", + "version": "WzI2LDFd" } ] } @@ -649,7 +649,7 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "saved_objects": [ { "type": "agent_events", - "id": "4377a700-f06c-11e9-adc1-97816634f461", + "id": "eae8a4b0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -660,12 +660,12 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:39.056Z", - "version": "WzMxMTcsMV0=" + "updated_at": "2019-10-29T14:10:53.179Z", + "version": "WzI1LDFd" }, { "type": "agent_events", - "id": "44114ef0-f06c-11e9-adc1-97816634f461", + "id": "eb830ff0-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STOPPED", @@ -674,12 +674,12 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:40.063Z", - "version": "WzMxMTgsMV0=" + "updated_at": "2019-10-29T14:10:54.191Z", + "version": "WzI2LDFd" }, { "type": "agent_events", - "id": "44ab4500-f06c-11e9-adc1-97816634f461", + "id": "ec1d7b30-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -688,12 +688,12 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "agent_id": "agent:1" }, "references": [], - "updated_at": "2019-10-16T23:25:41.071Z", - "version": "WzMxMTksMV0=" + "updated_at": "2019-10-29T14:10:55.203Z", + "version": "WzI3LDFd" }, { "type": "agent_events", - "id": "4547fa30-f06c-11e9-adc1-97816634f461", + "id": "ecb80d80-fa55-11e9-a4c5-8377241f6276", "attributes": { "type": "STATE", "subtype": "STARTING", @@ -702,25 +702,25 @@ exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - fi "agent_id": "agent:2" }, "references": [], - "updated_at": "2019-10-16T23:25:42.099Z", - "version": "WzMxMjAsMV0=" + "updated_at": "2019-10-29T14:10:56.216Z", + "version": "WzI4LDFd" } ] } } -exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:4377a700-f06c-11e9-adc1-97816634f461:{} (7)'] = { +exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:eae8a4b0-fa55-11e9-a4c5-8377241f6276:{} (7)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:44114ef0-f06c-11e9-adc1-97816634f461:{} (8)'] = { +exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:eb830ff0-fa55-11e9-a4c5-8377241f6276:{} (8)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:44ab4500-f06c-11e9-adc1-97816634f461:{} (9)'] = { +exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:ec1d7b30-fa55-11e9-a4c5-8377241f6276:{} (9)'] = { "results": {} } -exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:4547fa30-f06c-11e9-adc1-97816634f461:{} (10)'] = { +exports['AgentsEventsRepository getEventsForAgent allow to filter using KQL - delete:agent_events:ecb80d80-fa55-11e9-a4c5-8377241f6276:{} (10)'] = { "results": {} } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agents/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/repositories/agents/__memorize_snapshots__/default.contract.test.slap_snap index 94a5e80207481..041c6e540e6f2 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/__memorize_snapshots__/default.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/__memorize_snapshots__/default.contract.test.slap_snap @@ -2,11 +2,11 @@ exports['AgentsRepository create should create a new agent - create:agents (1)'] = { "results": { "type": "agents", - "id": "97294be0-f104-11e9-9e96-810494679327", + "id": "f81fab60-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -16,8 +16,8 @@ exports['AgentsRepository create should create a new agent - create:agents (1)'] "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:02.974Z", - "version": "WzIsMV0=" + "updated_at": "2019-10-29T14:11:15.350Z", + "version": "WzMzLDFd" } } @@ -29,11 +29,11 @@ exports['AgentsRepository create should create a new agent - find:"agents" (2)'] "saved_objects": [ { "type": "agents", - "id": "97294be0-f104-11e9-9e96-810494679327", + "id": "f81fab60-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -43,14 +43,14 @@ exports['AgentsRepository create should create a new agent - find:"agents" (2)'] "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:02.974Z", - "version": "WzIsMV0=" + "updated_at": "2019-10-29T14:11:15.350Z", + "version": "WzMzLDFd" } ] } } -exports['AgentsRepository create should create a new agent - delete:agents:97294be0-f104-11e9-9e96-810494679327:{} (3)'] = { +exports['AgentsRepository create should create a new agent - delete:agents:f81fab60-fa55-11e9-8237-65a0c5e0a0f7:{} (3)'] = { "results": {} } @@ -61,7 +61,7 @@ exports['AgentsRepository create should create a new agent with the specified id "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -71,8 +71,8 @@ exports['AgentsRepository create should create a new agent with the specified id "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:04.735Z", - "version": "WzUsMV0=" + "updated_at": "2019-10-29T14:11:17.342Z", + "version": "WzM1LDFd" } } @@ -88,7 +88,7 @@ exports['AgentsRepository create should create a new agent with the specified id "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -98,8 +98,8 @@ exports['AgentsRepository create should create a new agent with the specified id "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:04.735Z", - "version": "WzUsMV0=" + "updated_at": "2019-10-29T14:11:17.342Z", + "version": "WzM1LDFd" } ] } @@ -116,7 +116,7 @@ exports['AgentsRepository create should allow to create a new agent with the sam "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -126,8 +126,8 @@ exports['AgentsRepository create should allow to create a new agent with the sam "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:06.773Z", - "version": "WzcsMV0=" + "updated_at": "2019-10-29T14:11:19.367Z", + "version": "WzM3LDFd" } } @@ -138,7 +138,7 @@ exports['AgentsRepository create should allow to create a new agent with the sam "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -148,8 +148,8 @@ exports['AgentsRepository create should allow to create a new agent with the sam "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:07.793Z", - "version": "WzgsMV0=" + "updated_at": "2019-10-29T14:11:20.381Z", + "version": "WzM4LDFd" } } @@ -165,7 +165,7 @@ exports['AgentsRepository create should allow to create a new agent with the sam "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -175,8 +175,8 @@ exports['AgentsRepository create should allow to create a new agent with the sam "actions": [] }, "references": [], - "updated_at": "2019-10-17T17:36:07.793Z", - "version": "WzgsMV0=" + "updated_at": "2019-10-29T14:11:20.381Z", + "version": "WzM4LDFd" } ] } @@ -189,11 +189,11 @@ exports['AgentsRepository create should allow to create a new agent with the sam exports['AgentsRepository create should allow to create a new agent with the same id two time if override is true - create:agents (5)'] = { "results": { "type": "agents", - "id": "9b3e37e0-f104-11e9-9e96-810494679327", + "id": "fc55db00-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -202,33 +202,33 @@ exports['AgentsRepository create should allow to create a new agent with the sam "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:09.822Z", - "version": "WzEwLDFd" + "updated_at": "2019-10-29T14:11:22.415Z", + "version": "WzQwLDFd" } } -exports['AgentsRepository update should allow to update an agent - get:agents:9b3e37e0-f104-11e9-9e96-810494679327:{"active":true}:{} (1)'] = { +exports['AgentsRepository update should allow to update an agent - get:agents:fc55db00-fa55-11e9-8237-65a0c5e0a0f7:{"active":true}:{} (1)'] = { "results": { - "id": "9b3e37e0-f104-11e9-9e96-810494679327", + "id": "fc55db00-fa55-11e9-8237-65a0c5e0a0f7", "type": "agents", - "updated_at": "2019-10-17T17:36:10.843Z", - "version": "WzExLDFd", + "updated_at": "2019-10-29T14:11:23.425Z", + "version": "WzQxLDFd", "attributes": { "active": true } } } -exports['AgentsRepository update should allow to update an agent - get:agents:9b3e37e0-f104-11e9-9e96-810494679327:{} (2)'] = { +exports['AgentsRepository update should allow to update an agent - get:agents:fc55db00-fa55-11e9-8237-65a0c5e0a0f7:{} (2)'] = { "results": { - "id": "9b3e37e0-f104-11e9-9e96-810494679327", + "id": "fc55db00-fa55-11e9-8237-65a0c5e0a0f7", "type": "agents", - "updated_at": "2019-10-17T17:36:10.843Z", - "version": "WzExLDFd", + "updated_at": "2019-10-29T14:11:23.425Z", + "version": "WzQxLDFd", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -248,11 +248,11 @@ exports['AgentsRepository update should allow to update an agent - find:"agents" "saved_objects": [ { "type": "agents", - "id": "9b3e37e0-f104-11e9-9e96-810494679327", + "id": "fc55db00-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -261,25 +261,25 @@ exports['AgentsRepository update should allow to update an agent - find:"agents" "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:10.843Z", - "version": "WzExLDFd" + "updated_at": "2019-10-29T14:11:23.425Z", + "version": "WzQxLDFd" } ] } } -exports['AgentsRepository update should allow to update an agent - delete:agents:9b3e37e0-f104-11e9-9e96-810494679327:{} (4)'] = { +exports['AgentsRepository update should allow to update an agent - delete:agents:fc55db00-fa55-11e9-8237-65a0c5e0a0f7:{} (4)'] = { "results": {} } exports['AgentsRepository update should allow to update an agent - create:agents (5)'] = { "results": { "type": "agents", - "id": "9d114a30-f104-11e9-9e96-810494679327", + "id": "fe24cea0-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -288,16 +288,16 @@ exports['AgentsRepository update should allow to update an agent - create:agents "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:12.882Z", - "version": "WzEzLDFd" + "updated_at": "2019-10-29T14:11:25.450Z", + "version": "WzQzLDFd" } } -exports['AgentsRepository delete should delete an agent - delete:agents:9d114a30-f104-11e9-9e96-810494679327:{} (1)'] = { +exports['AgentsRepository delete should delete an agent - delete:agents:fe24cea0-fa55-11e9-8237-65a0c5e0a0f7:{} (1)'] = { "results": {} } -exports['AgentsRepository delete should delete an agent - get:agents:9d114a30-f104-11e9-9e96-810494679327:{} (2)'] = { +exports['AgentsRepository delete should delete an agent - get:agents:fe24cea0-fa55-11e9-8237-65a0c5e0a0f7:{} (2)'] = { "results": null } @@ -313,11 +313,11 @@ exports['AgentsRepository delete should delete an agent - find:"agents" (3)'] = exports['AgentsRepository list should list all active agents - create:agents (1)'] = { "results": { "type": "agents", - "id": "9e49ca30-f104-11e9-9e96-810494679327", + "id": "ff5bc800-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -326,19 +326,19 @@ exports['AgentsRepository list should list all active agents - create:agents (1) "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:14.931Z", - "version": "WzE1LDFd" + "updated_at": "2019-10-29T14:11:27.488Z", + "version": "WzQ1LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (2)'] = { "results": { "type": "agents", - "id": "9ee260b0-f104-11e9-9e96-810494679327", + "id": "fff4d3b0-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -347,19 +347,19 @@ exports['AgentsRepository list should list all active agents - create:agents (2) "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:15.931Z", - "version": "WzE2LDFd" + "updated_at": "2019-10-29T14:11:28.491Z", + "version": "WzQ2LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (3)'] = { "results": { "type": "agents", - "id": "9f802750-f104-11e9-9e96-810494679327", + "id": "008f8d10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -368,19 +368,19 @@ exports['AgentsRepository list should list all active agents - create:agents (3) "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:16.965Z", - "version": "WzE3LDFd" + "updated_at": "2019-10-29T14:11:29.505Z", + "version": "WzQ3LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (4)'] = { "results": { "type": "agents", - "id": "a01b2ed0-f104-11e9-9e96-810494679327", + "id": "012898c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -389,19 +389,19 @@ exports['AgentsRepository list should list all active agents - create:agents (4) "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:17.980Z", - "version": "WzE4LDFd" + "updated_at": "2019-10-29T14:11:30.508Z", + "version": "WzQ4LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (5)'] = { "results": { "type": "agents", - "id": "a0b60f40-f104-11e9-9e96-810494679327", + "id": "01c770d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -410,19 +410,19 @@ exports['AgentsRepository list should list all active agents - create:agents (5) "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:18.996Z", - "version": "WzE5LDFd" + "updated_at": "2019-10-29T14:11:31.549Z", + "version": "WzQ5LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (6)'] = { "results": { "type": "agents", - "id": "a151b300-f104-11e9-9e96-810494679327", + "id": "02622a30-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -431,19 +431,19 @@ exports['AgentsRepository list should list all active agents - create:agents (6) "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:20.016Z", - "version": "WzIwLDFd" + "updated_at": "2019-10-29T14:11:32.563Z", + "version": "WzUwLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (7)'] = { "results": { "type": "agents", - "id": "a1ebd020-f104-11e9-9e96-810494679327", + "id": "02fd31b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -452,19 +452,19 @@ exports['AgentsRepository list should list all active agents - create:agents (7) "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:21.026Z", - "version": "WzIxLDFd" + "updated_at": "2019-10-29T14:11:33.579Z", + "version": "WzUxLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (8)'] = { "results": { "type": "agents", - "id": "a285ed40-f104-11e9-9e96-810494679327", + "id": "03979cf0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -473,19 +473,19 @@ exports['AgentsRepository list should list all active agents - create:agents (8) "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:22.036Z", - "version": "WzIyLDFd" + "updated_at": "2019-10-29T14:11:34.591Z", + "version": "WzUyLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (9)'] = { "results": { "type": "agents", - "id": "a3238cd0-f104-11e9-9e96-810494679327", + "id": "04325650-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -494,19 +494,19 @@ exports['AgentsRepository list should list all active agents - create:agents (9) "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:23.069Z", - "version": "WzIzLDFd" + "updated_at": "2019-10-29T14:11:35.605Z", + "version": "WzUzLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (10)'] = { "results": { "type": "agents", - "id": "a3bdd100-f104-11e9-9e96-810494679327", + "id": "04cc7370-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -515,19 +515,19 @@ exports['AgentsRepository list should list all active agents - create:agents (10 "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:24.080Z", - "version": "WzI0LDFd" + "updated_at": "2019-10-29T14:11:36.615Z", + "version": "WzU0LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (11)'] = { "results": { "type": "agents", - "id": "a458d880-f104-11e9-9e96-810494679327", + "id": "056705c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -536,19 +536,19 @@ exports['AgentsRepository list should list all active agents - create:agents (11 "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:25.096Z", - "version": "WzI1LDFd" + "updated_at": "2019-10-29T14:11:37.628Z", + "version": "WzU1LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (12)'] = { "results": { "type": "agents", - "id": "a4f343c0-f104-11e9-9e96-810494679327", + "id": "06019810-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -557,19 +557,19 @@ exports['AgentsRepository list should list all active agents - create:agents (12 "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:26.108Z", - "version": "WzI2LDFd" + "updated_at": "2019-10-29T14:11:38.641Z", + "version": "WzU2LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (13)'] = { "results": { "type": "agents", - "id": "a58c7680-f104-11e9-9e96-810494679327", + "id": "069c0350-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -578,19 +578,19 @@ exports['AgentsRepository list should list all active agents - create:agents (13 "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:27.112Z", - "version": "WzI3LDFd" + "updated_at": "2019-10-29T14:11:39.652Z", + "version": "WzU3LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (14)'] = { "results": { "type": "agents", - "id": "a628dd90-f104-11e9-9e96-810494679327", + "id": "073731e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -599,19 +599,19 @@ exports['AgentsRepository list should list all active agents - create:agents (14 "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:28.137Z", - "version": "WzI4LDFd" + "updated_at": "2019-10-29T14:11:40.670Z", + "version": "WzU4LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (15)'] = { "results": { "type": "agents", - "id": "a6c396f0-f104-11e9-9e96-810494679327", + "id": "07d19d20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -620,19 +620,19 @@ exports['AgentsRepository list should list all active agents - create:agents (15 "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:29.151Z", - "version": "WzI5LDFd" + "updated_at": "2019-10-29T14:11:41.682Z", + "version": "WzU5LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (16)'] = { "results": { "type": "agents", - "id": "a75f88d0-f104-11e9-9e96-810494679327", + "id": "086c5680-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -641,19 +641,19 @@ exports['AgentsRepository list should list all active agents - create:agents (16 "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:30.173Z", - "version": "WzMwLDFd" + "updated_at": "2019-10-29T14:11:42.696Z", + "version": "WzYwLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (17)'] = { "results": { "type": "agents", - "id": "a7f84660-f104-11e9-9e96-810494679327", + "id": "09075e00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -662,19 +662,19 @@ exports['AgentsRepository list should list all active agents - create:agents (17 "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:31.174Z", - "version": "WzMxLDFd" + "updated_at": "2019-10-29T14:11:43.712Z", + "version": "WzYxLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (18)'] = { "results": { "type": "agents", - "id": "a89570c0-f104-11e9-9e96-810494679327", + "id": "09a23e70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -683,19 +683,19 @@ exports['AgentsRepository list should list all active agents - create:agents (18 "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:32.204Z", - "version": "WzMyLDFd" + "updated_at": "2019-10-29T14:11:44.727Z", + "version": "WzYyLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (19)'] = { "results": { "type": "agents", - "id": "a9311480-f104-11e9-9e96-810494679327", + "id": "0a3d45f0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -704,19 +704,19 @@ exports['AgentsRepository list should list all active agents - create:agents (19 "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:33.224Z", - "version": "WzMzLDFd" + "updated_at": "2019-10-29T14:11:45.743Z", + "version": "WzYzLDFd" } } exports['AgentsRepository list should list all active agents - create:agents (20)'] = { "results": { "type": "agents", - "id": "a9cbf4f0-f104-11e9-9e96-810494679327", + "id": "0ad78a20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -725,19 +725,19 @@ exports['AgentsRepository list should list all active agents - create:agents (20 "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:34.239Z", - "version": "WzM0LDFd" + "updated_at": "2019-10-29T14:11:46.754Z", + "version": "WzY0LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (21)'] = { "results": { "type": "agents", - "id": "aa668740-f104-11e9-9e96-810494679327", + "id": "0b718030-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -746,52 +746,52 @@ exports['AgentsRepository list should list all active agents - create:agents (21 "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:35.252Z", - "version": "WzM1LDFd" + "updated_at": "2019-10-29T14:11:47.763Z", + "version": "WzY1LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (22)'] = { "results": { "type": "agents", - "id": "ab0167b0-f104-11e9-9e96-810494679327", + "id": "0c0beb70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:36:14.930Z", + "last_checkin": "2019-10-27T14:11:27.486Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:36.267Z", - "version": "WzM2LDFd" + "updated_at": "2019-10-29T14:11:48.775Z", + "version": "WzY2LDFd" } } exports['AgentsRepository list should list all active agents - create:agents (23)'] = { "results": { "type": "agents", - "id": "ab9c2110-f104-11e9-9e96-810494679327", + "id": "0ca87990-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:36:14.929Z", + "last_checkin": "2019-10-29T14:11:27.486Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:37.281Z", - "version": "WzM3LDFd" + "updated_at": "2019-10-29T14:11:49.801Z", + "version": "WzY3LDFd" } } @@ -803,11 +803,11 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "saved_objects": [ { "type": "agents", - "id": "a9cbf4f0-f104-11e9-9e96-810494679327", + "id": "0ad78a20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -816,16 +816,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:34.239Z", - "version": "WzM0LDFd" + "updated_at": "2019-10-29T14:11:46.754Z", + "version": "WzY0LDFd" }, { "type": "agents", - "id": "a9311480-f104-11e9-9e96-810494679327", + "id": "0a3d45f0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -834,16 +834,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:33.224Z", - "version": "WzMzLDFd" + "updated_at": "2019-10-29T14:11:45.743Z", + "version": "WzYzLDFd" }, { "type": "agents", - "id": "a89570c0-f104-11e9-9e96-810494679327", + "id": "09a23e70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -852,16 +852,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:32.204Z", - "version": "WzMyLDFd" + "updated_at": "2019-10-29T14:11:44.727Z", + "version": "WzYyLDFd" }, { "type": "agents", - "id": "a7f84660-f104-11e9-9e96-810494679327", + "id": "09075e00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -870,16 +870,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:31.174Z", - "version": "WzMxLDFd" + "updated_at": "2019-10-29T14:11:43.712Z", + "version": "WzYxLDFd" }, { "type": "agents", - "id": "a75f88d0-f104-11e9-9e96-810494679327", + "id": "086c5680-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -888,16 +888,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:30.173Z", - "version": "WzMwLDFd" + "updated_at": "2019-10-29T14:11:42.696Z", + "version": "WzYwLDFd" }, { "type": "agents", - "id": "a6c396f0-f104-11e9-9e96-810494679327", + "id": "07d19d20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -906,16 +906,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:29.151Z", - "version": "WzI5LDFd" + "updated_at": "2019-10-29T14:11:41.682Z", + "version": "WzU5LDFd" }, { "type": "agents", - "id": "a628dd90-f104-11e9-9e96-810494679327", + "id": "073731e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -924,16 +924,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:28.137Z", - "version": "WzI4LDFd" + "updated_at": "2019-10-29T14:11:40.670Z", + "version": "WzU4LDFd" }, { "type": "agents", - "id": "a58c7680-f104-11e9-9e96-810494679327", + "id": "069c0350-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -942,16 +942,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:27.112Z", - "version": "WzI3LDFd" + "updated_at": "2019-10-29T14:11:39.652Z", + "version": "WzU3LDFd" }, { "type": "agents", - "id": "a4f343c0-f104-11e9-9e96-810494679327", + "id": "06019810-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -960,16 +960,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:26.108Z", - "version": "WzI2LDFd" + "updated_at": "2019-10-29T14:11:38.641Z", + "version": "WzU2LDFd" }, { "type": "agents", - "id": "a458d880-f104-11e9-9e96-810494679327", + "id": "056705c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -978,16 +978,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:25.096Z", - "version": "WzI1LDFd" + "updated_at": "2019-10-29T14:11:37.628Z", + "version": "WzU1LDFd" }, { "type": "agents", - "id": "a3bdd100-f104-11e9-9e96-810494679327", + "id": "04cc7370-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -996,16 +996,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:24.080Z", - "version": "WzI0LDFd" + "updated_at": "2019-10-29T14:11:36.615Z", + "version": "WzU0LDFd" }, { "type": "agents", - "id": "a3238cd0-f104-11e9-9e96-810494679327", + "id": "04325650-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1014,16 +1014,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:23.069Z", - "version": "WzIzLDFd" + "updated_at": "2019-10-29T14:11:35.605Z", + "version": "WzUzLDFd" }, { "type": "agents", - "id": "a285ed40-f104-11e9-9e96-810494679327", + "id": "03979cf0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1032,16 +1032,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:22.036Z", - "version": "WzIyLDFd" + "updated_at": "2019-10-29T14:11:34.591Z", + "version": "WzUyLDFd" }, { "type": "agents", - "id": "a1ebd020-f104-11e9-9e96-810494679327", + "id": "02fd31b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1050,16 +1050,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:21.026Z", - "version": "WzIxLDFd" + "updated_at": "2019-10-29T14:11:33.579Z", + "version": "WzUxLDFd" }, { "type": "agents", - "id": "a151b300-f104-11e9-9e96-810494679327", + "id": "02622a30-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1068,16 +1068,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:20.016Z", - "version": "WzIwLDFd" + "updated_at": "2019-10-29T14:11:32.563Z", + "version": "WzUwLDFd" }, { "type": "agents", - "id": "a0b60f40-f104-11e9-9e96-810494679327", + "id": "01c770d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1086,16 +1086,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:18.996Z", - "version": "WzE5LDFd" + "updated_at": "2019-10-29T14:11:31.549Z", + "version": "WzQ5LDFd" }, { "type": "agents", - "id": "a01b2ed0-f104-11e9-9e96-810494679327", + "id": "012898c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1104,16 +1104,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:17.980Z", - "version": "WzE4LDFd" + "updated_at": "2019-10-29T14:11:30.508Z", + "version": "WzQ4LDFd" }, { "type": "agents", - "id": "9f802750-f104-11e9-9e96-810494679327", + "id": "008f8d10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1122,16 +1122,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:16.965Z", - "version": "WzE3LDFd" + "updated_at": "2019-10-29T14:11:29.505Z", + "version": "WzQ3LDFd" }, { "type": "agents", - "id": "9ee260b0-f104-11e9-9e96-810494679327", + "id": "fff4d3b0-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1140,16 +1140,16 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:15.931Z", - "version": "WzE2LDFd" + "updated_at": "2019-10-29T14:11:28.491Z", + "version": "WzQ2LDFd" }, { "type": "agents", - "id": "9e49ca30-f104-11e9-9e96-810494679327", + "id": "ff5bc800-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1158,27 +1158,27 @@ exports['AgentsRepository list should list all active agents - find:"agents" (24 "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:14.931Z", - "version": "WzE1LDFd" + "updated_at": "2019-10-29T14:11:27.488Z", + "version": "WzQ1LDFd" }, { "type": "agents", - "id": "ab9c2110-f104-11e9-9e96-810494679327", + "id": "0ca87990-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:36:14.929Z", + "last_checkin": "2019-10-29T14:11:27.486Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:37.281Z", - "version": "WzM3LDFd" + "updated_at": "2019-10-29T14:11:49.801Z", + "version": "WzY3LDFd" } ] } @@ -1192,524 +1192,524 @@ exports['AgentsRepository list should list all active agents - find:"agents" (25 "saved_objects": [ { "type": "agents", - "id": "9f802750-f104-11e9-9e96-810494679327", + "id": "ff5bc800-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent2", + "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-09T19:35:14.861Z" + "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:16.965Z", - "version": "WzE3LDFd" + "updated_at": "2019-10-29T14:11:27.488Z", + "version": "WzQ1LDFd" }, { "type": "agents", - "id": "a01b2ed0-f104-11e9-9e96-810494679327", + "id": "008f8d10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent3", + "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-10T19:35:14.861Z" + "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:17.980Z", - "version": "WzE4LDFd" + "updated_at": "2019-10-29T14:11:29.505Z", + "version": "WzQ3LDFd" }, { "type": "agents", - "id": "a0b60f40-f104-11e9-9e96-810494679327", + "id": "fff4d3b0-fa55-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent4", + "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-11T19:35:14.861Z" + "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:18.996Z", - "version": "WzE5LDFd" + "updated_at": "2019-10-29T14:11:28.491Z", + "version": "WzQ2LDFd" }, { "type": "agents", - "id": "a151b300-f104-11e9-9e96-810494679327", + "id": "056705c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent5", + "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-12T19:35:14.861Z" + "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:20.016Z", - "version": "WzIwLDFd" + "updated_at": "2019-10-29T14:11:37.628Z", + "version": "WzU1LDFd" }, { "type": "agents", - "id": "a1ebd020-f104-11e9-9e96-810494679327", + "id": "06019810-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent6", + "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-13T19:35:14.861Z" + "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:21.026Z", - "version": "WzIxLDFd" + "updated_at": "2019-10-29T14:11:38.641Z", + "version": "WzU2LDFd" }, { "type": "agents", - "id": "9ee260b0-f104-11e9-9e96-810494679327", + "id": "012898c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent1", + "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-08T19:35:14.861Z" + "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:15.931Z", - "version": "WzE2LDFd" + "updated_at": "2019-10-29T14:11:30.508Z", + "version": "WzQ4LDFd" }, { "type": "agents", - "id": "9e49ca30-f104-11e9-9e96-810494679327", + "id": "01c770d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent0", + "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-07T19:35:14.861Z" + "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:14.931Z", - "version": "WzE1LDFd" + "updated_at": "2019-10-29T14:11:31.549Z", + "version": "WzQ5LDFd" }, { "type": "agents", - "id": "a58c7680-f104-11e9-9e96-810494679327", + "id": "02622a30-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent12", + "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-19T19:35:14.861Z" + "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:27.112Z", - "version": "WzI3LDFd" + "updated_at": "2019-10-29T14:11:32.563Z", + "version": "WzUwLDFd" }, { "type": "agents", - "id": "a628dd90-f104-11e9-9e96-810494679327", + "id": "02fd31b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent13", + "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-20T19:35:14.861Z" + "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:28.137Z", - "version": "WzI4LDFd" + "updated_at": "2019-10-29T14:11:33.579Z", + "version": "WzUxLDFd" }, { "type": "agents", - "id": "a6c396f0-f104-11e9-9e96-810494679327", + "id": "03979cf0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent14", + "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-21T19:35:14.861Z" + "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:29.151Z", - "version": "WzI5LDFd" + "updated_at": "2019-10-29T14:11:34.591Z", + "version": "WzUyLDFd" }, { "type": "agents", - "id": "a75f88d0-f104-11e9-9e96-810494679327", + "id": "04325650-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent15", + "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-22T19:35:14.861Z" + "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:30.173Z", - "version": "WzMwLDFd" + "updated_at": "2019-10-29T14:11:35.605Z", + "version": "WzUzLDFd" }, { "type": "agents", - "id": "a4f343c0-f104-11e9-9e96-810494679327", + "id": "04cc7370-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent11", + "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-18T19:35:14.861Z" + "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:26.108Z", - "version": "WzI2LDFd" + "updated_at": "2019-10-29T14:11:36.615Z", + "version": "WzU0LDFd" }, { "type": "agents", - "id": "a458d880-f104-11e9-9e96-810494679327", + "id": "0b718030-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent10", - "active": true, - "access_token": "TOKEN_1", + "shared_id": "inactive_agent_1", + "active": false, + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-17T19:35:14.861Z" + "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:25.096Z", - "version": "WzI1LDFd" + "updated_at": "2019-10-29T14:11:47.763Z", + "version": "WzY1LDFd" }, { "type": "agents", - "id": "a285ed40-f104-11e9-9e96-810494679327", + "id": "069c0350-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent7", + "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-14T19:35:14.861Z" + "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:22.036Z", - "version": "WzIyLDFd" + "updated_at": "2019-10-29T14:11:39.652Z", + "version": "WzU3LDFd" }, { "type": "agents", - "id": "a3238cd0-f104-11e9-9e96-810494679327", + "id": "073731e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent8", + "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-15T19:35:14.861Z" + "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:23.069Z", - "version": "WzIzLDFd" + "updated_at": "2019-10-29T14:11:40.670Z", + "version": "WzU4LDFd" }, { "type": "agents", - "id": "a3bdd100-f104-11e9-9e96-810494679327", + "id": "07d19d20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent9", + "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-16T19:35:14.861Z" + "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:24.080Z", - "version": "WzI0LDFd" + "updated_at": "2019-10-29T14:11:41.682Z", + "version": "WzU5LDFd" }, { "type": "agents", - "id": "a7f84660-f104-11e9-9e96-810494679327", + "id": "086c5680-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent16", + "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-23T19:35:14.861Z" + "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:31.174Z", - "version": "WzMxLDFd" + "updated_at": "2019-10-29T14:11:42.696Z", + "version": "WzYwLDFd" }, { "type": "agents", - "id": "a89570c0-f104-11e9-9e96-810494679327", + "id": "09075e00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent17", + "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-24T19:35:14.861Z" + "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:32.204Z", - "version": "WzMyLDFd" + "updated_at": "2019-10-29T14:11:43.712Z", + "version": "WzYxLDFd" }, { "type": "agents", - "id": "a9311480-f104-11e9-9e96-810494679327", + "id": "09a23e70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent18", + "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-25T19:35:14.861Z" + "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:33.224Z", - "version": "WzMzLDFd" + "updated_at": "2019-10-29T14:11:44.727Z", + "version": "WzYyLDFd" }, { "type": "agents", - "id": "a9cbf4f0-f104-11e9-9e96-810494679327", + "id": "0a3d45f0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent19", + "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-26T19:35:14.861Z" + "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:34.239Z", - "version": "WzM0LDFd" + "updated_at": "2019-10-29T14:11:45.743Z", + "version": "WzYzLDFd" }, { "type": "agents", - "id": "aa668740-f104-11e9-9e96-810494679327", + "id": "0ad78a20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "inactive_agent_1", - "active": false, - "access_token": "TOKEN_1", + "shared_id": "agent19", + "active": true, + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-11-13T20:35:14.861Z" + "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:35.252Z", - "version": "WzM1LDFd" + "updated_at": "2019-10-29T14:11:46.754Z", + "version": "WzY0LDFd" }, { "type": "agents", - "id": "ab0167b0-f104-11e9-9e96-810494679327", + "id": "0c0beb70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:36:14.930Z", + "last_checkin": "2019-10-27T14:11:27.486Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:36.267Z", - "version": "WzM2LDFd" + "updated_at": "2019-10-29T14:11:48.775Z", + "version": "WzY2LDFd" }, { "type": "agents", - "id": "ab9c2110-f104-11e9-9e96-810494679327", + "id": "0ca87990-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:36:14.929Z", + "last_checkin": "2019-10-29T14:11:27.486Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:36:37.281Z", - "version": "WzM3LDFd" + "updated_at": "2019-10-29T14:11:49.801Z", + "version": "WzY3LDFd" } ] } } -exports['AgentsRepository list should list all active agents - delete:agents:9f802750-f104-11e9-9e96-810494679327:{} (26)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:ff5bc800-fa55-11e9-8237-65a0c5e0a0f7:{} (26)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a01b2ed0-f104-11e9-9e96-810494679327:{} (27)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:008f8d10-fa56-11e9-8237-65a0c5e0a0f7:{} (27)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a0b60f40-f104-11e9-9e96-810494679327:{} (28)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:fff4d3b0-fa55-11e9-8237-65a0c5e0a0f7:{} (28)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a151b300-f104-11e9-9e96-810494679327:{} (29)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:056705c0-fa56-11e9-8237-65a0c5e0a0f7:{} (29)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a1ebd020-f104-11e9-9e96-810494679327:{} (30)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:06019810-fa56-11e9-8237-65a0c5e0a0f7:{} (30)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:9ee260b0-f104-11e9-9e96-810494679327:{} (31)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:012898c0-fa56-11e9-8237-65a0c5e0a0f7:{} (31)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:9e49ca30-f104-11e9-9e96-810494679327:{} (32)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:01c770d0-fa56-11e9-8237-65a0c5e0a0f7:{} (32)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a58c7680-f104-11e9-9e96-810494679327:{} (33)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:02622a30-fa56-11e9-8237-65a0c5e0a0f7:{} (33)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a628dd90-f104-11e9-9e96-810494679327:{} (34)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:02fd31b0-fa56-11e9-8237-65a0c5e0a0f7:{} (34)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a6c396f0-f104-11e9-9e96-810494679327:{} (35)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:03979cf0-fa56-11e9-8237-65a0c5e0a0f7:{} (35)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a75f88d0-f104-11e9-9e96-810494679327:{} (36)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:04325650-fa56-11e9-8237-65a0c5e0a0f7:{} (36)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a4f343c0-f104-11e9-9e96-810494679327:{} (37)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:04cc7370-fa56-11e9-8237-65a0c5e0a0f7:{} (37)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a458d880-f104-11e9-9e96-810494679327:{} (38)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:0b718030-fa56-11e9-8237-65a0c5e0a0f7:{} (38)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a285ed40-f104-11e9-9e96-810494679327:{} (39)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:069c0350-fa56-11e9-8237-65a0c5e0a0f7:{} (39)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a3238cd0-f104-11e9-9e96-810494679327:{} (40)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:073731e0-fa56-11e9-8237-65a0c5e0a0f7:{} (40)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a3bdd100-f104-11e9-9e96-810494679327:{} (41)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:07d19d20-fa56-11e9-8237-65a0c5e0a0f7:{} (41)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a7f84660-f104-11e9-9e96-810494679327:{} (42)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:086c5680-fa56-11e9-8237-65a0c5e0a0f7:{} (42)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a89570c0-f104-11e9-9e96-810494679327:{} (43)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:09075e00-fa56-11e9-8237-65a0c5e0a0f7:{} (43)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a9311480-f104-11e9-9e96-810494679327:{} (44)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:09a23e70-fa56-11e9-8237-65a0c5e0a0f7:{} (44)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:a9cbf4f0-f104-11e9-9e96-810494679327:{} (45)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:0a3d45f0-fa56-11e9-8237-65a0c5e0a0f7:{} (45)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:aa668740-f104-11e9-9e96-810494679327:{} (46)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:0ad78a20-fa56-11e9-8237-65a0c5e0a0f7:{} (46)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:ab0167b0-f104-11e9-9e96-810494679327:{} (47)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:0c0beb70-fa56-11e9-8237-65a0c5e0a0f7:{} (47)'] = { "results": {} } -exports['AgentsRepository list should list all active agents - delete:agents:ab9c2110-f104-11e9-9e96-810494679327:{} (48)'] = { +exports['AgentsRepository list should list all active agents - delete:agents:0ca87990-fa56-11e9-8237-65a0c5e0a0f7:{} (48)'] = { "results": {} } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (1)'] = { "results": { "type": "agents", - "id": "ba23c3a0-f104-11e9-9e96-810494679327", + "id": "1b26f460-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1718,19 +1718,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:01.658Z", - "version": "WzYxLDFd" + "updated_at": "2019-10-29T14:12:14.118Z", + "version": "WzkxLDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (2)'] = { "results": { "type": "agents", - "id": "babe55f0-f104-11e9-9e96-810494679327", + "id": "1bc186b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1739,19 +1739,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:02.671Z", - "version": "WzYyLDFd" + "updated_at": "2019-10-29T14:12:15.131Z", + "version": "WzkyLDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (3)'] = { "results": { "type": "agents", - "id": "bb57fde0-f104-11e9-9e96-810494679327", + "id": "1c5b55b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1760,19 +1760,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:03.678Z", - "version": "WzYzLDFd" + "updated_at": "2019-10-29T14:12:16.138Z", + "version": "WzkzLDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (4)'] = { "results": { "type": "agents", - "id": "bbf464f0-f104-11e9-9e96-810494679327", + "id": "1cf7e3d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1781,19 +1781,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:04.703Z", - "version": "WzY0LDFd" + "updated_at": "2019-10-29T14:12:17.165Z", + "version": "Wzk0LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (5)'] = { "results": { "type": "agents", - "id": "bc8ef740-f104-11e9-9e96-810494679327", + "id": "1d90c870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1802,19 +1802,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:05.716Z", - "version": "WzY1LDFd" + "updated_at": "2019-10-29T14:12:18.167Z", + "version": "Wzk1LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (6)'] = { "results": { "type": "agents", - "id": "bd29fec0-f104-11e9-9e96-810494679327", + "id": "1e2d0870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1823,19 +1823,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:06.732Z", - "version": "WzY2LDFd" + "updated_at": "2019-10-29T14:12:19.191Z", + "version": "Wzk2LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (7)'] = { "results": { "type": "agents", - "id": "bdc5c990-f104-11e9-9e96-810494679327", + "id": "1ec74ca0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1844,19 +1844,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:07.753Z", - "version": "WzY3LDFd" + "updated_at": "2019-10-29T14:12:20.202Z", + "version": "Wzk3LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (8)'] = { "results": { "type": "agents", - "id": "be60d110-f104-11e9-9e96-810494679327", + "id": "1f607f60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1865,19 +1865,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:08.769Z", - "version": "WzY4LDFd" + "updated_at": "2019-10-29T14:12:21.205Z", + "version": "Wzk4LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (9)'] = { "results": { "type": "agents", - "id": "befc26b0-f104-11e9-9e96-810494679327", + "id": "1ffbd500-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1886,19 +1886,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:09.787Z", - "version": "WzY5LDFd" + "updated_at": "2019-10-29T14:12:22.224Z", + "version": "Wzk5LDFd" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (10)'] = { "results": { "type": "agents", - "id": "bf958080-f104-11e9-9e96-810494679327", + "id": "20964040-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1907,19 +1907,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:10.792Z", - "version": "WzcwLDFd" + "updated_at": "2019-10-29T14:12:23.236Z", + "version": "WzEwMCwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (11)'] = { "results": { "type": "agents", - "id": "c03012d0-f104-11e9-9e96-810494679327", + "id": "2130d290-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1928,19 +1928,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:11.805Z", - "version": "WzcxLDFd" + "updated_at": "2019-10-29T14:12:24.249Z", + "version": "WzEwMSwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (12)'] = { "results": { "type": "agents", - "id": "c0ca2ff0-f104-11e9-9e96-810494679327", + "id": "21cbda10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1949,19 +1949,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:12.815Z", - "version": "WzcyLDFd" + "updated_at": "2019-10-29T14:12:25.265Z", + "version": "WzEwMiwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (13)'] = { "results": { "type": "agents", - "id": "c1642600-f104-11e9-9e96-810494679327", + "id": "22677dd0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1970,19 +1970,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:13.824Z", - "version": "WzczLDFd" + "updated_at": "2019-10-29T14:12:26.285Z", + "version": "WzEwMywxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (14)'] = { "results": { "type": "agents", - "id": "c1fd7fd0-f104-11e9-9e96-810494679327", + "id": "23023730-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -1991,19 +1991,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:14.828Z", - "version": "Wzc0LDFd" + "updated_at": "2019-10-29T14:12:27.299Z", + "version": "WzEwNCwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (15)'] = { "results": { "type": "agents", - "id": "c299bfd0-f104-11e9-9e96-810494679327", + "id": "239d17a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2012,19 +2012,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:15.853Z", - "version": "Wzc1LDFd" + "updated_at": "2019-10-29T14:12:28.314Z", + "version": "WzEwNSwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (16)'] = { "results": { "type": "agents", - "id": "c332f290-f104-11e9-9e96-810494679327", + "id": "24381f20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2033,19 +2033,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:16.857Z", - "version": "Wzc2LDFd" + "updated_at": "2019-10-29T14:12:29.330Z", + "version": "WzEwNiwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (17)'] = { "results": { "type": "agents", - "id": "c3cf0b80-f104-11e9-9e96-810494679327", + "id": "24d2b170-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2054,19 +2054,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:17.880Z", - "version": "Wzc3LDFd" + "updated_at": "2019-10-29T14:12:30.343Z", + "version": "WzEwNywxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (18)'] = { "results": { "type": "agents", - "id": "c469ebf0-f104-11e9-9e96-810494679327", + "id": "256d91e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2075,19 +2075,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:18.895Z", - "version": "Wzc4LDFd" + "updated_at": "2019-10-29T14:12:31.357Z", + "version": "WzEwOCwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (19)'] = { "results": { "type": "agents", - "id": "c5045730-f104-11e9-9e96-810494679327", + "id": "260760e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2096,19 +2096,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:19.907Z", - "version": "Wzc5LDFd" + "updated_at": "2019-10-29T14:12:32.365Z", + "version": "WzEwOSwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (20)'] = { "results": { "type": "agents", - "id": "c59f37a0-f104-11e9-9e96-810494679327", + "id": "26a21a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2117,19 +2117,19 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:20.922Z", - "version": "WzgwLDFd" + "updated_at": "2019-10-29T14:12:33.380Z", + "version": "WzExMCwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (21)'] = { "results": { "type": "agents", - "id": "c6381c40-f104-11e9-9e96-810494679327", + "id": "273c3760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2138,52 +2138,52 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:21.924Z", - "version": "WzgxLDFd" + "updated_at": "2019-10-29T14:12:34.390Z", + "version": "WzExMSwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (22)'] = { "results": { "type": "agents", - "id": "c6d34ad0-f104-11e9-9e96-810494679327", + "id": "27d988d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:37:01.653Z", + "last_checkin": "2019-10-27T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:22.941Z", - "version": "WzgyLDFd" + "updated_at": "2019-10-29T14:12:35.421Z", + "version": "WzExMiwxXQ==" } } exports['AgentsRepository list should list all agents with showInactive set to true - create:agents (23)'] = { "results": { "type": "agents", - "id": "c76e0430-f104-11e9-9e96-810494679327", + "id": "2873cd00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:01.653Z", + "last_checkin": "2019-10-29T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:23.955Z", - "version": "WzgzLDFd" + "updated_at": "2019-10-29T14:12:36.432Z", + "version": "WzExMywxXQ==" } } @@ -2195,11 +2195,11 @@ exports['AgentsRepository list should list all agents with showInactive set to t "saved_objects": [ { "type": "agents", - "id": "c6381c40-f104-11e9-9e96-810494679327", + "id": "273c3760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2208,16 +2208,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:21.924Z", - "version": "WzgxLDFd" + "updated_at": "2019-10-29T14:12:34.390Z", + "version": "WzExMSwxXQ==" }, { "type": "agents", - "id": "c59f37a0-f104-11e9-9e96-810494679327", + "id": "26a21a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2226,16 +2226,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:20.922Z", - "version": "WzgwLDFd" + "updated_at": "2019-10-29T14:12:33.380Z", + "version": "WzExMCwxXQ==" }, { "type": "agents", - "id": "c5045730-f104-11e9-9e96-810494679327", + "id": "260760e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2244,16 +2244,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:19.907Z", - "version": "Wzc5LDFd" + "updated_at": "2019-10-29T14:12:32.365Z", + "version": "WzEwOSwxXQ==" }, { "type": "agents", - "id": "c469ebf0-f104-11e9-9e96-810494679327", + "id": "256d91e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2262,16 +2262,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:18.895Z", - "version": "Wzc4LDFd" + "updated_at": "2019-10-29T14:12:31.357Z", + "version": "WzEwOCwxXQ==" }, { "type": "agents", - "id": "c3cf0b80-f104-11e9-9e96-810494679327", + "id": "24d2b170-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2280,16 +2280,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:17.880Z", - "version": "Wzc3LDFd" + "updated_at": "2019-10-29T14:12:30.343Z", + "version": "WzEwNywxXQ==" }, { "type": "agents", - "id": "c332f290-f104-11e9-9e96-810494679327", + "id": "24381f20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2298,16 +2298,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:16.857Z", - "version": "Wzc2LDFd" + "updated_at": "2019-10-29T14:12:29.330Z", + "version": "WzEwNiwxXQ==" }, { "type": "agents", - "id": "c299bfd0-f104-11e9-9e96-810494679327", + "id": "239d17a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2316,16 +2316,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:15.853Z", - "version": "Wzc1LDFd" + "updated_at": "2019-10-29T14:12:28.314Z", + "version": "WzEwNSwxXQ==" }, { "type": "agents", - "id": "c1fd7fd0-f104-11e9-9e96-810494679327", + "id": "23023730-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2334,16 +2334,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:14.828Z", - "version": "Wzc0LDFd" + "updated_at": "2019-10-29T14:12:27.299Z", + "version": "WzEwNCwxXQ==" }, { "type": "agents", - "id": "c1642600-f104-11e9-9e96-810494679327", + "id": "22677dd0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2352,16 +2352,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:13.824Z", - "version": "WzczLDFd" + "updated_at": "2019-10-29T14:12:26.285Z", + "version": "WzEwMywxXQ==" }, { "type": "agents", - "id": "c0ca2ff0-f104-11e9-9e96-810494679327", + "id": "21cbda10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2370,16 +2370,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:12.815Z", - "version": "WzcyLDFd" + "updated_at": "2019-10-29T14:12:25.265Z", + "version": "WzEwMiwxXQ==" }, { "type": "agents", - "id": "c03012d0-f104-11e9-9e96-810494679327", + "id": "2130d290-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2388,16 +2388,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:11.805Z", - "version": "WzcxLDFd" + "updated_at": "2019-10-29T14:12:24.249Z", + "version": "WzEwMSwxXQ==" }, { "type": "agents", - "id": "bf958080-f104-11e9-9e96-810494679327", + "id": "20964040-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2406,16 +2406,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:10.792Z", - "version": "WzcwLDFd" + "updated_at": "2019-10-29T14:12:23.236Z", + "version": "WzEwMCwxXQ==" }, { "type": "agents", - "id": "befc26b0-f104-11e9-9e96-810494679327", + "id": "1ffbd500-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2424,16 +2424,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:09.787Z", - "version": "WzY5LDFd" + "updated_at": "2019-10-29T14:12:22.224Z", + "version": "Wzk5LDFd" }, { "type": "agents", - "id": "be60d110-f104-11e9-9e96-810494679327", + "id": "1f607f60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2442,16 +2442,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:08.769Z", - "version": "WzY4LDFd" + "updated_at": "2019-10-29T14:12:21.205Z", + "version": "Wzk4LDFd" }, { "type": "agents", - "id": "bdc5c990-f104-11e9-9e96-810494679327", + "id": "1ec74ca0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2460,16 +2460,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:07.753Z", - "version": "WzY3LDFd" + "updated_at": "2019-10-29T14:12:20.202Z", + "version": "Wzk3LDFd" }, { "type": "agents", - "id": "bd29fec0-f104-11e9-9e96-810494679327", + "id": "1e2d0870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2478,16 +2478,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:06.732Z", - "version": "WzY2LDFd" + "updated_at": "2019-10-29T14:12:19.191Z", + "version": "Wzk2LDFd" }, { "type": "agents", - "id": "bc8ef740-f104-11e9-9e96-810494679327", + "id": "1d90c870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2496,16 +2496,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:05.716Z", - "version": "WzY1LDFd" + "updated_at": "2019-10-29T14:12:18.167Z", + "version": "Wzk1LDFd" }, { "type": "agents", - "id": "bbf464f0-f104-11e9-9e96-810494679327", + "id": "1cf7e3d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2514,16 +2514,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:04.703Z", - "version": "WzY0LDFd" + "updated_at": "2019-10-29T14:12:17.165Z", + "version": "Wzk0LDFd" }, { "type": "agents", - "id": "bb57fde0-f104-11e9-9e96-810494679327", + "id": "1c5b55b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2532,16 +2532,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:03.678Z", - "version": "WzYzLDFd" + "updated_at": "2019-10-29T14:12:16.138Z", + "version": "WzkzLDFd" }, { "type": "agents", - "id": "babe55f0-f104-11e9-9e96-810494679327", + "id": "1bc186b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2550,16 +2550,16 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:02.671Z", - "version": "WzYyLDFd" + "updated_at": "2019-10-29T14:12:15.131Z", + "version": "WzkyLDFd" }, { "type": "agents", - "id": "ba23c3a0-f104-11e9-9e96-810494679327", + "id": "1b26f460-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2568,46 +2568,46 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:01.658Z", - "version": "WzYxLDFd" + "updated_at": "2019-10-29T14:12:14.118Z", + "version": "WzkxLDFd" }, { "type": "agents", - "id": "c6d34ad0-f104-11e9-9e96-810494679327", + "id": "27d988d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:37:01.653Z", + "last_checkin": "2019-10-27T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:22.941Z", - "version": "WzgyLDFd" + "updated_at": "2019-10-29T14:12:35.421Z", + "version": "WzExMiwxXQ==" }, { "type": "agents", - "id": "c76e0430-f104-11e9-9e96-810494679327", + "id": "2873cd00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:01.653Z", + "last_checkin": "2019-10-29T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:23.955Z", - "version": "WzgzLDFd" + "updated_at": "2019-10-29T14:12:36.432Z", + "version": "WzExMywxXQ==" } ] } @@ -2621,371 +2621,371 @@ exports['AgentsRepository list should list all agents with showInactive set to t "saved_objects": [ { "type": "agents", - "id": "ba23c3a0-f104-11e9-9e96-810494679327", + "id": "1bc186b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent0", + "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-07T19:35:14.861Z" + "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:01.658Z", - "version": "WzYxLDFd" + "updated_at": "2019-10-29T14:12:15.131Z", + "version": "WzkyLDFd" }, { "type": "agents", - "id": "bb57fde0-f104-11e9-9e96-810494679327", + "id": "1b26f460-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent2", + "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-09T19:35:14.861Z" + "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:03.678Z", - "version": "WzYzLDFd" + "updated_at": "2019-10-29T14:12:14.118Z", + "version": "WzkxLDFd" }, { "type": "agents", - "id": "bbf464f0-f104-11e9-9e96-810494679327", + "id": "2130d290-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent3", + "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-10T19:35:14.861Z" + "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:04.703Z", - "version": "WzY0LDFd" + "updated_at": "2019-10-29T14:12:24.249Z", + "version": "WzEwMSwxXQ==" }, { "type": "agents", - "id": "bc8ef740-f104-11e9-9e96-810494679327", + "id": "1c5b55b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent4", + "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-11T19:35:14.861Z" + "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:05.716Z", - "version": "WzY1LDFd" + "updated_at": "2019-10-29T14:12:16.138Z", + "version": "WzkzLDFd" }, { "type": "agents", - "id": "bd29fec0-f104-11e9-9e96-810494679327", + "id": "1cf7e3d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent5", + "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-12T19:35:14.861Z" + "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:06.732Z", - "version": "WzY2LDFd" + "updated_at": "2019-10-29T14:12:17.165Z", + "version": "Wzk0LDFd" }, { "type": "agents", - "id": "babe55f0-f104-11e9-9e96-810494679327", + "id": "1d90c870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent1", + "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-08T19:35:14.861Z" + "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:02.671Z", - "version": "WzYyLDFd" + "updated_at": "2019-10-29T14:12:18.167Z", + "version": "Wzk1LDFd" }, { "type": "agents", - "id": "c1642600-f104-11e9-9e96-810494679327", + "id": "1e2d0870-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent12", + "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-19T19:35:14.861Z" + "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:13.824Z", - "version": "WzczLDFd" + "updated_at": "2019-10-29T14:12:19.191Z", + "version": "Wzk2LDFd" }, { "type": "agents", - "id": "c299bfd0-f104-11e9-9e96-810494679327", + "id": "1ec74ca0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent14", + "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-21T19:35:14.861Z" + "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:15.853Z", - "version": "Wzc1LDFd" + "updated_at": "2019-10-29T14:12:20.202Z", + "version": "Wzk3LDFd" }, { "type": "agents", - "id": "c0ca2ff0-f104-11e9-9e96-810494679327", + "id": "1f607f60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent11", + "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-18T19:35:14.861Z" + "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:12.815Z", - "version": "WzcyLDFd" + "updated_at": "2019-10-29T14:12:21.205Z", + "version": "Wzk4LDFd" }, { "type": "agents", - "id": "c03012d0-f104-11e9-9e96-810494679327", + "id": "1ffbd500-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent10", + "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-17T19:35:14.861Z" + "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:11.805Z", - "version": "WzcxLDFd" + "updated_at": "2019-10-29T14:12:22.224Z", + "version": "Wzk5LDFd" }, { "type": "agents", - "id": "c1fd7fd0-f104-11e9-9e96-810494679327", + "id": "20964040-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent13", + "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-20T19:35:14.861Z" + "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:14.828Z", - "version": "Wzc0LDFd" + "updated_at": "2019-10-29T14:12:23.236Z", + "version": "WzEwMCwxXQ==" }, { "type": "agents", - "id": "bdc5c990-f104-11e9-9e96-810494679327", + "id": "22677dd0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent6", + "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-13T19:35:14.861Z" + "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:07.753Z", - "version": "WzY3LDFd" + "updated_at": "2019-10-29T14:12:26.285Z", + "version": "WzEwMywxXQ==" }, { "type": "agents", - "id": "be60d110-f104-11e9-9e96-810494679327", + "id": "23023730-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent7", + "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-14T19:35:14.861Z" + "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:08.769Z", - "version": "WzY4LDFd" + "updated_at": "2019-10-29T14:12:27.299Z", + "version": "WzEwNCwxXQ==" }, { "type": "agents", - "id": "befc26b0-f104-11e9-9e96-810494679327", + "id": "239d17a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent8", + "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-15T19:35:14.861Z" + "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:09.787Z", - "version": "WzY5LDFd" + "updated_at": "2019-10-29T14:12:28.314Z", + "version": "WzEwNSwxXQ==" }, { "type": "agents", - "id": "bf958080-f104-11e9-9e96-810494679327", + "id": "24381f20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent9", + "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-16T19:35:14.861Z" + "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:10.792Z", - "version": "WzcwLDFd" + "updated_at": "2019-10-29T14:12:29.330Z", + "version": "WzEwNiwxXQ==" }, { "type": "agents", - "id": "c332f290-f104-11e9-9e96-810494679327", + "id": "24d2b170-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent15", + "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-22T19:35:14.861Z" + "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:16.857Z", - "version": "Wzc2LDFd" + "updated_at": "2019-10-29T14:12:30.343Z", + "version": "WzEwNywxXQ==" }, { "type": "agents", - "id": "c3cf0b80-f104-11e9-9e96-810494679327", + "id": "256d91e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent16", + "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-23T19:35:14.861Z" + "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:17.880Z", - "version": "Wzc3LDFd" + "updated_at": "2019-10-29T14:12:31.357Z", + "version": "WzEwOCwxXQ==" }, { "type": "agents", - "id": "c469ebf0-f104-11e9-9e96-810494679327", + "id": "260760e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent17", + "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-24T19:35:14.861Z" + "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:18.895Z", - "version": "Wzc4LDFd" + "updated_at": "2019-10-29T14:12:32.365Z", + "version": "WzEwOSwxXQ==" }, { "type": "agents", - "id": "c5045730-f104-11e9-9e96-810494679327", + "id": "26a21a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent18", + "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-25T19:35:14.861Z" + "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:19.907Z", - "version": "Wzc5LDFd" + "updated_at": "2019-10-29T14:12:33.380Z", + "version": "WzExMCwxXQ==" }, { "type": "agents", - "id": "c59f37a0-f104-11e9-9e96-810494679327", + "id": "21cbda10-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent19", + "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-26T19:35:14.861Z" + "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:20.922Z", - "version": "WzgwLDFd" + "updated_at": "2019-10-29T14:12:25.265Z", + "version": "WzEwMiwxXQ==" }, { "type": "agents", - "id": "c6381c40-f104-11e9-9e96-810494679327", + "id": "273c3760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -2994,151 +2994,151 @@ exports['AgentsRepository list should list all agents with showInactive set to t "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:21.924Z", - "version": "WzgxLDFd" + "updated_at": "2019-10-29T14:12:34.390Z", + "version": "WzExMSwxXQ==" }, { "type": "agents", - "id": "c6d34ad0-f104-11e9-9e96-810494679327", + "id": "27d988d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:37:01.653Z", + "last_checkin": "2019-10-27T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:22.941Z", - "version": "WzgyLDFd" + "updated_at": "2019-10-29T14:12:35.421Z", + "version": "WzExMiwxXQ==" }, { "type": "agents", - "id": "c76e0430-f104-11e9-9e96-810494679327", + "id": "2873cd00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:01.653Z", + "last_checkin": "2019-10-29T14:12:14.115Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:23.955Z", - "version": "WzgzLDFd" + "updated_at": "2019-10-29T14:12:36.432Z", + "version": "WzExMywxXQ==" } ] } } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:ba23c3a0-f104-11e9-9e96-810494679327:{} (26)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1bc186b0-fa56-11e9-8237-65a0c5e0a0f7:{} (26)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bb57fde0-f104-11e9-9e96-810494679327:{} (27)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1b26f460-fa56-11e9-8237-65a0c5e0a0f7:{} (27)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bbf464f0-f104-11e9-9e96-810494679327:{} (28)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:2130d290-fa56-11e9-8237-65a0c5e0a0f7:{} (28)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bc8ef740-f104-11e9-9e96-810494679327:{} (29)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1c5b55b0-fa56-11e9-8237-65a0c5e0a0f7:{} (29)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bd29fec0-f104-11e9-9e96-810494679327:{} (30)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1cf7e3d0-fa56-11e9-8237-65a0c5e0a0f7:{} (30)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:babe55f0-f104-11e9-9e96-810494679327:{} (31)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1d90c870-fa56-11e9-8237-65a0c5e0a0f7:{} (31)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c1642600-f104-11e9-9e96-810494679327:{} (32)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1e2d0870-fa56-11e9-8237-65a0c5e0a0f7:{} (32)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c299bfd0-f104-11e9-9e96-810494679327:{} (33)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1ec74ca0-fa56-11e9-8237-65a0c5e0a0f7:{} (33)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c0ca2ff0-f104-11e9-9e96-810494679327:{} (34)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1f607f60-fa56-11e9-8237-65a0c5e0a0f7:{} (34)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c03012d0-f104-11e9-9e96-810494679327:{} (35)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:1ffbd500-fa56-11e9-8237-65a0c5e0a0f7:{} (35)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c1fd7fd0-f104-11e9-9e96-810494679327:{} (36)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:20964040-fa56-11e9-8237-65a0c5e0a0f7:{} (36)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bdc5c990-f104-11e9-9e96-810494679327:{} (37)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:22677dd0-fa56-11e9-8237-65a0c5e0a0f7:{} (37)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:be60d110-f104-11e9-9e96-810494679327:{} (38)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:23023730-fa56-11e9-8237-65a0c5e0a0f7:{} (38)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:befc26b0-f104-11e9-9e96-810494679327:{} (39)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:239d17a0-fa56-11e9-8237-65a0c5e0a0f7:{} (39)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:bf958080-f104-11e9-9e96-810494679327:{} (40)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:24381f20-fa56-11e9-8237-65a0c5e0a0f7:{} (40)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c332f290-f104-11e9-9e96-810494679327:{} (41)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:24d2b170-fa56-11e9-8237-65a0c5e0a0f7:{} (41)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c3cf0b80-f104-11e9-9e96-810494679327:{} (42)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:256d91e0-fa56-11e9-8237-65a0c5e0a0f7:{} (42)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c469ebf0-f104-11e9-9e96-810494679327:{} (43)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:260760e0-fa56-11e9-8237-65a0c5e0a0f7:{} (43)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c5045730-f104-11e9-9e96-810494679327:{} (44)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:26a21a40-fa56-11e9-8237-65a0c5e0a0f7:{} (44)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c59f37a0-f104-11e9-9e96-810494679327:{} (45)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:21cbda10-fa56-11e9-8237-65a0c5e0a0f7:{} (45)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c6381c40-f104-11e9-9e96-810494679327:{} (46)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:273c3760-fa56-11e9-8237-65a0c5e0a0f7:{} (46)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c6d34ad0-f104-11e9-9e96-810494679327:{} (47)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:27d988d0-fa56-11e9-8237-65a0c5e0a0f7:{} (47)'] = { "results": {} } -exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:c76e0430-f104-11e9-9e96-810494679327:{} (48)'] = { +exports['AgentsRepository list should list all agents with showInactive set to true - delete:agents:2873cd00-fa56-11e9-8237-65a0c5e0a0f7:{} (48)'] = { "results": {} } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (1)'] = { "results": { "type": "agents", - "id": "d5f383e0-f104-11e9-9e96-810494679327", + "id": "36f443a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3147,19 +3147,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:48.318Z", - "version": "WzEwNywxXQ==" + "updated_at": "2019-10-29T14:13:00.762Z", + "version": "WzEzNywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (2)'] = { "results": { "type": "agents", - "id": "d68e1630-f104-11e9-9e96-810494679327", + "id": "378dc480-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3168,19 +3168,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:49.331Z", - "version": "WzEwOCwxXQ==" + "updated_at": "2019-10-29T14:13:01.768Z", + "version": "WzEzOCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (3)'] = { "results": { "type": "agents", - "id": "d7291db0-f104-11e9-9e96-810494679327", + "id": "382a79b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3189,19 +3189,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:50.347Z", - "version": "WzEwOSwxXQ==" + "updated_at": "2019-10-29T14:13:02.795Z", + "version": "WzEzOSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (4)'] = { "results": { "type": "agents", - "id": "d7c33ad0-f104-11e9-9e96-810494679327", + "id": "38c46fc0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3210,19 +3210,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:51.356Z", - "version": "WzExMCwxXQ==" + "updated_at": "2019-10-29T14:13:03.804Z", + "version": "WzE0MCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (5)'] = { "results": { "type": "agents", - "id": "d85d30e0-f104-11e9-9e96-810494679327", + "id": "395fec70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3231,19 +3231,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:52.366Z", - "version": "WzExMSwxXQ==" + "updated_at": "2019-10-29T14:13:04.823Z", + "version": "WzE0MSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (6)'] = { "results": { "type": "agents", - "id": "d8f68ab0-f104-11e9-9e96-810494679327", + "id": "39fa57b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3252,19 +3252,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:53.371Z", - "version": "WzExMiwxXQ==" + "updated_at": "2019-10-29T14:13:05.834Z", + "version": "WzE0MiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (7)'] = { "results": { "type": "agents", - "id": "d9945150-f104-11e9-9e96-810494679327", + "id": "3a93ffa0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3273,19 +3273,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:54.405Z", - "version": "WzExMywxXQ==" + "updated_at": "2019-10-29T14:13:06.842Z", + "version": "WzE0MywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (8)'] = { "results": { "type": "agents", - "id": "da2e2050-f104-11e9-9e96-810494679327", + "id": "3b2e43d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3294,19 +3294,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:55.413Z", - "version": "WzExNCwxXQ==" + "updated_at": "2019-10-29T14:13:07.853Z", + "version": "WzE0NCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (9)'] = { "results": { "type": "agents", - "id": "dac88b90-f104-11e9-9e96-810494679327", + "id": "3bc88800-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3315,19 +3315,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:56.425Z", - "version": "WzExNSwxXQ==" + "updated_at": "2019-10-29T14:13:08.863Z", + "version": "WzE0NSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (10)'] = { "results": { "type": "agents", - "id": "db60fb00-f104-11e9-9e96-810494679327", + "id": "3c62cc30-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3336,19 +3336,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:57.424Z", - "version": "WzExNiwxXQ==" + "updated_at": "2019-10-29T14:13:09.875Z", + "version": "WzE0NiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (11)'] = { "results": { "type": "agents", - "id": "dbfd6210-f104-11e9-9e96-810494679327", + "id": "3cfbfef0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3357,19 +3357,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:58.449Z", - "version": "WzExNywxXQ==" + "updated_at": "2019-10-29T14:13:10.879Z", + "version": "WzE0NywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (12)'] = { "results": { "type": "agents", - "id": "dc97a640-f104-11e9-9e96-810494679327", + "id": "3d98b420-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3378,19 +3378,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:59.460Z", - "version": "WzExOCwxXQ==" + "updated_at": "2019-10-29T14:13:11.906Z", + "version": "WzE0OCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (13)'] = { "results": { "type": "agents", - "id": "dd317540-f104-11e9-9e96-810494679327", + "id": "3e331f60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3399,19 +3399,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:00.468Z", - "version": "WzExOSwxXQ==" + "updated_at": "2019-10-29T14:13:12.918Z", + "version": "WzE0OSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (14)'] = { "results": { "type": "agents", - "id": "ddcc55b0-f104-11e9-9e96-810494679327", + "id": "3ecd1570-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3420,19 +3420,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:01.483Z", - "version": "WzEyMCwxXQ==" + "updated_at": "2019-10-29T14:13:13.927Z", + "version": "WzE1MCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (15)'] = { "results": { "type": "agents", - "id": "de67ab50-f104-11e9-9e96-810494679327", + "id": "3f66bd60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3441,19 +3441,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:02.501Z", - "version": "WzEyMSwxXQ==" + "updated_at": "2019-10-29T14:13:14.934Z", + "version": "WzE1MSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (16)'] = { "results": { "type": "agents", - "id": "df02b2d0-f104-11e9-9e96-810494679327", + "id": "400128a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3462,19 +3462,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:03.517Z", - "version": "WzEyMiwxXQ==" + "updated_at": "2019-10-29T14:13:15.945Z", + "version": "WzE1MiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (17)'] = { "results": { "type": "agents", - "id": "df9d6c30-f104-11e9-9e96-810494679327", + "id": "409af7a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3483,19 +3483,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:04.531Z", - "version": "WzEyMywxXQ==" + "updated_at": "2019-10-29T14:13:16.954Z", + "version": "WzE1MywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (18)'] = { "results": { "type": "agents", - "id": "e037d770-f104-11e9-9e96-810494679327", + "id": "41336710-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3504,19 +3504,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:05.543Z", - "version": "WzEyNCwxXQ==" + "updated_at": "2019-10-29T14:13:17.953Z", + "version": "WzE1NCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (19)'] = { "results": { "type": "agents", - "id": "e0d4b3b0-f104-11e9-9e96-810494679327", + "id": "41d01c40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3525,19 +3525,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:06.571Z", - "version": "WzEyNSwxXQ==" + "updated_at": "2019-10-29T14:13:18.979Z", + "version": "WzE1NSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (20)'] = { "results": { "type": "agents", - "id": "e16e3490-f104-11e9-9e96-810494679327", + "id": "4269c430-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3546,19 +3546,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:07.577Z", - "version": "WzEyNiwxXQ==" + "updated_at": "2019-10-29T14:13:19.987Z", + "version": "WzE1NiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (21)'] = { "results": { "type": "agents", - "id": "e20878c0-f104-11e9-9e96-810494679327", + "id": "430540e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3567,52 +3567,52 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:08.588Z", - "version": "WzEyNywxXQ==" + "updated_at": "2019-10-29T14:13:21.005Z", + "version": "WzE1NywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (22)'] = { "results": { "type": "agents", - "id": "e2a3a750-f104-11e9-9e96-810494679327", + "id": "439f0fe0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:37:48.315Z", + "last_checkin": "2019-10-27T14:13:00.758Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:09.605Z", - "version": "WzEyOCwxXQ==" + "updated_at": "2019-10-29T14:13:22.014Z", + "version": "WzE1OCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date ASC - create:agents (23)'] = { "results": { "type": "agents", - "id": "e33cda10-f104-11e9-9e96-810494679327", + "id": "443a1760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:48.315Z", + "last_checkin": "2019-10-29T14:13:00.758Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:10.609Z", - "version": "WzEyOSwxXQ==" + "updated_at": "2019-10-29T14:13:23.030Z", + "version": "WzE1OSwxXQ==" } } @@ -3624,30 +3624,30 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "saved_objects": [ { "type": "agents", - "id": "e33cda10-f104-11e9-9e96-810494679327", + "id": "443a1760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:48.315Z", + "last_checkin": "2019-10-29T14:13:00.758Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:10.609Z", - "version": "WzEyOSwxXQ==" + "updated_at": "2019-10-29T14:13:23.030Z", + "version": "WzE1OSwxXQ==" }, { "type": "agents", - "id": "d5f383e0-f104-11e9-9e96-810494679327", + "id": "36f443a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3656,16 +3656,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:48.318Z", - "version": "WzEwNywxXQ==" + "updated_at": "2019-10-29T14:13:00.762Z", + "version": "WzEzNywxXQ==" }, { "type": "agents", - "id": "d68e1630-f104-11e9-9e96-810494679327", + "id": "378dc480-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3674,8 +3674,8 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:49.331Z", - "version": "WzEwOCwxXQ==" + "updated_at": "2019-10-29T14:13:01.768Z", + "version": "WzEzOCwxXQ==" } ] } @@ -3689,11 +3689,11 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "saved_objects": [ { "type": "agents", - "id": "d5f383e0-f104-11e9-9e96-810494679327", + "id": "36f443a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3702,16 +3702,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:48.318Z", - "version": "WzEwNywxXQ==" + "updated_at": "2019-10-29T14:13:00.762Z", + "version": "WzEzNywxXQ==" }, { "type": "agents", - "id": "d7291db0-f104-11e9-9e96-810494679327", + "id": "382a79b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3720,16 +3720,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:50.347Z", - "version": "WzEwOSwxXQ==" + "updated_at": "2019-10-29T14:13:02.795Z", + "version": "WzEzOSwxXQ==" }, { "type": "agents", - "id": "d7c33ad0-f104-11e9-9e96-810494679327", + "id": "38c46fc0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3738,16 +3738,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:51.356Z", - "version": "WzExMCwxXQ==" + "updated_at": "2019-10-29T14:13:03.804Z", + "version": "WzE0MCwxXQ==" }, { "type": "agents", - "id": "d85d30e0-f104-11e9-9e96-810494679327", + "id": "395fec70-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -3756,286 +3756,286 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:52.366Z", - "version": "WzExMSwxXQ==" + "updated_at": "2019-10-29T14:13:04.823Z", + "version": "WzE0MSwxXQ==" }, { "type": "agents", - "id": "d68e1630-f104-11e9-9e96-810494679327", + "id": "39fa57b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent1", + "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-08T19:35:14.861Z" + "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:49.331Z", - "version": "WzEwOCwxXQ==" + "updated_at": "2019-10-29T14:13:05.834Z", + "version": "WzE0MiwxXQ==" }, { "type": "agents", - "id": "dd317540-f104-11e9-9e96-810494679327", + "id": "3a93ffa0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent12", + "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-19T19:35:14.861Z" + "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:00.468Z", - "version": "WzExOSwxXQ==" + "updated_at": "2019-10-29T14:13:06.842Z", + "version": "WzE0MywxXQ==" }, { "type": "agents", - "id": "ddcc55b0-f104-11e9-9e96-810494679327", + "id": "3b2e43d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent13", + "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-20T19:35:14.861Z" + "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:01.483Z", - "version": "WzEyMCwxXQ==" + "updated_at": "2019-10-29T14:13:07.853Z", + "version": "WzE0NCwxXQ==" }, { "type": "agents", - "id": "dc97a640-f104-11e9-9e96-810494679327", + "id": "3bc88800-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent11", + "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-18T19:35:14.861Z" + "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:59.460Z", - "version": "WzExOCwxXQ==" + "updated_at": "2019-10-29T14:13:08.863Z", + "version": "WzE0NSwxXQ==" }, { "type": "agents", - "id": "dbfd6210-f104-11e9-9e96-810494679327", + "id": "3c62cc30-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent10", + "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-17T19:35:14.861Z" + "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:58.449Z", - "version": "WzExNywxXQ==" + "updated_at": "2019-10-29T14:13:09.875Z", + "version": "WzE0NiwxXQ==" }, { "type": "agents", - "id": "d8f68ab0-f104-11e9-9e96-810494679327", + "id": "378dc480-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent5", + "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-12T19:35:14.861Z" + "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:53.371Z", - "version": "WzExMiwxXQ==" + "updated_at": "2019-10-29T14:13:01.768Z", + "version": "WzEzOCwxXQ==" }, { "type": "agents", - "id": "d9945150-f104-11e9-9e96-810494679327", + "id": "3cfbfef0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent6", + "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-13T19:35:14.861Z" + "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:54.405Z", - "version": "WzExMywxXQ==" + "updated_at": "2019-10-29T14:13:10.879Z", + "version": "WzE0NywxXQ==" }, { "type": "agents", - "id": "da2e2050-f104-11e9-9e96-810494679327", + "id": "3e331f60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent7", + "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-14T19:35:14.861Z" + "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:55.413Z", - "version": "WzExNCwxXQ==" + "updated_at": "2019-10-29T14:13:12.918Z", + "version": "WzE0OSwxXQ==" }, { "type": "agents", - "id": "dac88b90-f104-11e9-9e96-810494679327", + "id": "3ecd1570-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent8", + "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-15T19:35:14.861Z" + "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:56.425Z", - "version": "WzExNSwxXQ==" + "updated_at": "2019-10-29T14:13:13.927Z", + "version": "WzE1MCwxXQ==" }, { "type": "agents", - "id": "db60fb00-f104-11e9-9e96-810494679327", + "id": "400128a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent9", + "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-16T19:35:14.861Z" + "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:37:57.424Z", - "version": "WzExNiwxXQ==" + "updated_at": "2019-10-29T14:13:15.945Z", + "version": "WzE1MiwxXQ==" }, { "type": "agents", - "id": "de67ab50-f104-11e9-9e96-810494679327", + "id": "409af7a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent14", + "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-21T19:35:14.861Z" + "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:02.501Z", - "version": "WzEyMSwxXQ==" + "updated_at": "2019-10-29T14:13:16.954Z", + "version": "WzE1MywxXQ==" }, { "type": "agents", - "id": "df02b2d0-f104-11e9-9e96-810494679327", + "id": "41336710-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent15", + "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-22T19:35:14.861Z" + "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:03.517Z", - "version": "WzEyMiwxXQ==" + "updated_at": "2019-10-29T14:13:17.953Z", + "version": "WzE1NCwxXQ==" }, { "type": "agents", - "id": "df9d6c30-f104-11e9-9e96-810494679327", + "id": "41d01c40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent16", + "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-23T19:35:14.861Z" + "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:04.531Z", - "version": "WzEyMywxXQ==" + "updated_at": "2019-10-29T14:13:18.979Z", + "version": "WzE1NSwxXQ==" }, { "type": "agents", - "id": "e037d770-f104-11e9-9e96-810494679327", + "id": "3d98b420-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent17", + "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-24T19:35:14.861Z" + "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:05.543Z", - "version": "WzEyNCwxXQ==" + "updated_at": "2019-10-29T14:13:11.906Z", + "version": "WzE0OCwxXQ==" }, { "type": "agents", - "id": "e0d4b3b0-f104-11e9-9e96-810494679327", + "id": "3f66bd60-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent18", + "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-25T19:35:14.861Z" + "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:06.571Z", - "version": "WzEyNSwxXQ==" + "updated_at": "2019-10-29T14:13:14.934Z", + "version": "WzE1MSwxXQ==" }, { "type": "agents", - "id": "e16e3490-f104-11e9-9e96-810494679327", + "id": "4269c430-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4044,16 +4044,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:07.577Z", - "version": "WzEyNiwxXQ==" + "updated_at": "2019-10-29T14:13:19.987Z", + "version": "WzE1NiwxXQ==" }, { "type": "agents", - "id": "e20878c0-f104-11e9-9e96-810494679327", + "id": "430540e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4062,151 +4062,151 @@ exports['AgentsRepository list should support to sort by enrolled_at date ASC - "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:08.588Z", - "version": "WzEyNywxXQ==" + "updated_at": "2019-10-29T14:13:21.005Z", + "version": "WzE1NywxXQ==" }, { "type": "agents", - "id": "e2a3a750-f104-11e9-9e96-810494679327", + "id": "439f0fe0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:37:48.315Z", + "last_checkin": "2019-10-27T14:13:00.758Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:09.605Z", - "version": "WzEyOCwxXQ==" + "updated_at": "2019-10-29T14:13:22.014Z", + "version": "WzE1OCwxXQ==" }, { "type": "agents", - "id": "e33cda10-f104-11e9-9e96-810494679327", + "id": "443a1760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:37:48.315Z", + "last_checkin": "2019-10-29T14:13:00.758Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:10.609Z", - "version": "WzEyOSwxXQ==" + "updated_at": "2019-10-29T14:13:23.030Z", + "version": "WzE1OSwxXQ==" } ] } } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d5f383e0-f104-11e9-9e96-810494679327:{} (26)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:36f443a0-fa56-11e9-8237-65a0c5e0a0f7:{} (26)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d7291db0-f104-11e9-9e96-810494679327:{} (27)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:382a79b0-fa56-11e9-8237-65a0c5e0a0f7:{} (27)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d7c33ad0-f104-11e9-9e96-810494679327:{} (28)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:38c46fc0-fa56-11e9-8237-65a0c5e0a0f7:{} (28)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d85d30e0-f104-11e9-9e96-810494679327:{} (29)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:395fec70-fa56-11e9-8237-65a0c5e0a0f7:{} (29)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d68e1630-f104-11e9-9e96-810494679327:{} (30)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:39fa57b0-fa56-11e9-8237-65a0c5e0a0f7:{} (30)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:dd317540-f104-11e9-9e96-810494679327:{} (31)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3a93ffa0-fa56-11e9-8237-65a0c5e0a0f7:{} (31)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:ddcc55b0-f104-11e9-9e96-810494679327:{} (32)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3b2e43d0-fa56-11e9-8237-65a0c5e0a0f7:{} (32)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:dc97a640-f104-11e9-9e96-810494679327:{} (33)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3bc88800-fa56-11e9-8237-65a0c5e0a0f7:{} (33)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:dbfd6210-f104-11e9-9e96-810494679327:{} (34)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3c62cc30-fa56-11e9-8237-65a0c5e0a0f7:{} (34)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d8f68ab0-f104-11e9-9e96-810494679327:{} (35)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:378dc480-fa56-11e9-8237-65a0c5e0a0f7:{} (35)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:d9945150-f104-11e9-9e96-810494679327:{} (36)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3cfbfef0-fa56-11e9-8237-65a0c5e0a0f7:{} (36)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:da2e2050-f104-11e9-9e96-810494679327:{} (37)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3e331f60-fa56-11e9-8237-65a0c5e0a0f7:{} (37)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:dac88b90-f104-11e9-9e96-810494679327:{} (38)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3ecd1570-fa56-11e9-8237-65a0c5e0a0f7:{} (38)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:db60fb00-f104-11e9-9e96-810494679327:{} (39)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:400128a0-fa56-11e9-8237-65a0c5e0a0f7:{} (39)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:de67ab50-f104-11e9-9e96-810494679327:{} (40)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:409af7a0-fa56-11e9-8237-65a0c5e0a0f7:{} (40)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:df02b2d0-f104-11e9-9e96-810494679327:{} (41)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:41336710-fa56-11e9-8237-65a0c5e0a0f7:{} (41)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:df9d6c30-f104-11e9-9e96-810494679327:{} (42)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:41d01c40-fa56-11e9-8237-65a0c5e0a0f7:{} (42)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e037d770-f104-11e9-9e96-810494679327:{} (43)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3d98b420-fa56-11e9-8237-65a0c5e0a0f7:{} (43)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e0d4b3b0-f104-11e9-9e96-810494679327:{} (44)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:3f66bd60-fa56-11e9-8237-65a0c5e0a0f7:{} (44)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e16e3490-f104-11e9-9e96-810494679327:{} (45)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:4269c430-fa56-11e9-8237-65a0c5e0a0f7:{} (45)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e20878c0-f104-11e9-9e96-810494679327:{} (46)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:430540e0-fa56-11e9-8237-65a0c5e0a0f7:{} (46)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e2a3a750-f104-11e9-9e96-810494679327:{} (47)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:439f0fe0-fa56-11e9-8237-65a0c5e0a0f7:{} (47)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:e33cda10-f104-11e9-9e96-810494679327:{} (48)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date ASC - delete:agents:443a1760-fa56-11e9-8237-65a0c5e0a0f7:{} (48)'] = { "results": {} } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (1)'] = { "results": { "type": "agents", - "id": "f1be1400-f104-11e9-9e96-810494679327", + "id": "52ba8e00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4215,19 +4215,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:34.944Z", - "version": "WzE1MywxXQ==" + "updated_at": "2019-10-29T14:13:47.360Z", + "version": "WzE4MywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (2)'] = { "results": { "type": "agents", - "id": "f2565c60-f104-11e9-9e96-810494679327", + "id": "535631c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4236,19 +4236,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:35.941Z", - "version": "WzE1NCwxXQ==" + "updated_at": "2019-10-29T14:13:48.380Z", + "version": "WzE4NCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (3)'] = { "results": { "type": "agents", - "id": "f2f163e0-f104-11e9-9e96-810494679327", + "id": "53f18760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4257,19 +4257,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:36.958Z", - "version": "WzE1NSwxXQ==" + "updated_at": "2019-10-29T14:13:49.398Z", + "version": "WzE4NSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (4)'] = { "results": { "type": "agents", - "id": "f38b0bd0-f104-11e9-9e96-810494679327", + "id": "548bcb90-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4278,19 +4278,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:37.964Z", - "version": "WzE1NiwxXQ==" + "updated_at": "2019-10-29T14:13:50.409Z", + "version": "WzE4NiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (5)'] = { "results": { "type": "agents", - "id": "f4257710-f104-11e9-9e96-810494679327", + "id": "5525c1a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4299,19 +4299,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:38.977Z", - "version": "WzE1NywxXQ==" + "updated_at": "2019-10-29T14:13:51.418Z", + "version": "WzE4NywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (6)'] = { "results": { "type": "agents", - "id": "f4c11ad0-f104-11e9-9e96-810494679327", + "id": "55c005d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4320,19 +4320,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:39.997Z", - "version": "WzE1OCwxXQ==" + "updated_at": "2019-10-29T14:13:52.429Z", + "version": "WzE4OCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (7)'] = { "results": { "type": "agents", - "id": "f55b5f00-f104-11e9-9e96-810494679327", + "id": "565a9820-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4341,19 +4341,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:41.008Z", - "version": "WzE1OSwxXQ==" + "updated_at": "2019-10-29T14:13:53.442Z", + "version": "WzE4OSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (8)'] = { "results": { "type": "agents", - "id": "f5f5f150-f104-11e9-9e96-810494679327", + "id": "56f44010-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4362,19 +4362,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:42.021Z", - "version": "WzE2MCwxXQ==" + "updated_at": "2019-10-29T14:13:54.448Z", + "version": "WzE5MCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (9)'] = { "results": { "type": "agents", - "id": "f68fe760-f104-11e9-9e96-810494679327", + "id": "578ed260-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4383,19 +4383,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:43.030Z", - "version": "WzE2MSwxXQ==" + "updated_at": "2019-10-29T14:13:55.462Z", + "version": "WzE5MSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (10)'] = { "results": { "type": "agents", - "id": "f72aeee0-f104-11e9-9e96-810494679327", + "id": "58280520-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4404,19 +4404,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:44.046Z", - "version": "WzE2MiwxXQ==" + "updated_at": "2019-10-29T14:13:56.466Z", + "version": "WzE5MiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (11)'] = { "results": { "type": "agents", - "id": "f7c6b9b0-f104-11e9-9e96-810494679327", + "id": "58c2be80-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4425,19 +4425,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:45.067Z", - "version": "WzE2MywxXQ==" + "updated_at": "2019-10-29T14:13:57.480Z", + "version": "WzE5MywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (12)'] = { "results": { "type": "agents", - "id": "f86061a0-f104-11e9-9e96-810494679327", + "id": "595e1420-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4446,19 +4446,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:46.074Z", - "version": "WzE2NCwxXQ==" + "updated_at": "2019-10-29T14:13:58.498Z", + "version": "WzE5NCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (13)'] = { "results": { "type": "agents", - "id": "f8fb4210-f104-11e9-9e96-810494679327", + "id": "59f8a670-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4467,19 +4467,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:47.089Z", - "version": "WzE2NSwxXQ==" + "updated_at": "2019-10-29T14:13:59.511Z", + "version": "WzE5NSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (14)'] = { "results": { "type": "agents", - "id": "f9962280-f104-11e9-9e96-810494679327", + "id": "5a92c390-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4488,19 +4488,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:48.104Z", - "version": "WzE2NiwxXQ==" + "updated_at": "2019-10-29T14:14:00.521Z", + "version": "WzE5NiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (15)'] = { "results": { "type": "agents", - "id": "fa3102f0-f104-11e9-9e96-810494679327", + "id": "5b2f9fd0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4509,19 +4509,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:49.119Z", - "version": "WzE2NywxXQ==" + "updated_at": "2019-10-29T14:14:01.549Z", + "version": "WzE5NywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (16)'] = { "results": { "type": "agents", - "id": "facbbc50-f104-11e9-9e96-810494679327", + "id": "5bc995e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4530,19 +4530,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:50.133Z", - "version": "WzE2OCwxXQ==" + "updated_at": "2019-10-29T14:14:02.558Z", + "version": "WzE5OCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (17)'] = { "results": { "type": "agents", - "id": "fb664ea0-f104-11e9-9e96-810494679327", + "id": "5c63b300-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent16", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4551,19 +4551,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:51.146Z", - "version": "WzE2OSwxXQ==" + "updated_at": "2019-10-29T14:14:03.568Z", + "version": "WzE5OSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (18)'] = { "results": { "type": "agents", - "id": "fc0092d0-f104-11e9-9e96-810494679327", + "id": "5cfe4550-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4572,19 +4572,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:52.157Z", - "version": "WzE3MCwxXQ==" + "updated_at": "2019-10-29T14:14:04.581Z", + "version": "WzIwMCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (19)'] = { "results": { "type": "agents", - "id": "fc9b4c30-f104-11e9-9e96-810494679327", + "id": "5d97c630-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4593,19 +4593,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:53.171Z", - "version": "WzE3MSwxXQ==" + "updated_at": "2019-10-29T14:14:05.587Z", + "version": "WzIwMSwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (20)'] = { "results": { "type": "agents", - "id": "fd35b770-f104-11e9-9e96-810494679327", + "id": "5e342d40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4614,19 +4614,19 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:54.182Z", - "version": "WzE3MiwxXQ==" + "updated_at": "2019-10-29T14:14:06.612Z", + "version": "WzIwMiwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (21)'] = { "results": { "type": "agents", - "id": "fdcf5f60-f104-11e9-9e96-810494679327", + "id": "5ecdae20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4635,52 +4635,52 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:55.189Z", - "version": "WzE3MywxXQ==" + "updated_at": "2019-10-29T14:14:07.617Z", + "version": "WzIwMywxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (22)'] = { "results": { "type": "agents", - "id": "fe695570-f104-11e9-9e96-810494679327", + "id": "5f688e90-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:38:34.939Z", + "last_checkin": "2019-10-27T14:13:47.356Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:56.199Z", - "version": "WzE3NCwxXQ==" + "updated_at": "2019-10-29T14:14:08.633Z", + "version": "WzIwNCwxXQ==" } } exports['AgentsRepository list should support to sort by enrolled_at date DESC - create:agents (23)'] = { "results": { "type": "agents", - "id": "ff014fb0-f104-11e9-9e96-810494679327", + "id": "6001e860-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:38:34.939Z", + "last_checkin": "2019-10-29T14:13:47.356Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:57.195Z", - "version": "WzE3NSwxXQ==" + "updated_at": "2019-10-29T14:14:09.638Z", + "version": "WzIwNSwxXQ==" } } @@ -4692,11 +4692,11 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "saved_objects": [ { "type": "agents", - "id": "fd35b770-f104-11e9-9e96-810494679327", + "id": "5e342d40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4705,16 +4705,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:54.182Z", - "version": "WzE3MiwxXQ==" + "updated_at": "2019-10-29T14:14:06.612Z", + "version": "WzIwMiwxXQ==" }, { "type": "agents", - "id": "fc9b4c30-f104-11e9-9e96-810494679327", + "id": "5d97c630-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4723,16 +4723,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:53.171Z", - "version": "WzE3MSwxXQ==" + "updated_at": "2019-10-29T14:14:05.587Z", + "version": "WzIwMSwxXQ==" }, { "type": "agents", - "id": "fc0092d0-f104-11e9-9e96-810494679327", + "id": "5cfe4550-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4741,8 +4741,8 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:52.157Z", - "version": "WzE3MCwxXQ==" + "updated_at": "2019-10-29T14:14:04.581Z", + "version": "WzIwMCwxXQ==" } ] } @@ -4756,11 +4756,11 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "saved_objects": [ { "type": "agents", - "id": "f1be1400-f104-11e9-9e96-810494679327", + "id": "52ba8e00-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent0", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4769,16 +4769,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-07T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:34.944Z", - "version": "WzE1MywxXQ==" + "updated_at": "2019-10-29T14:13:47.360Z", + "version": "WzE4MywxXQ==" }, { "type": "agents", - "id": "f2f163e0-f104-11e9-9e96-810494679327", + "id": "53f18760-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4787,16 +4787,16 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-09T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:36.958Z", - "version": "WzE1NSwxXQ==" + "updated_at": "2019-10-29T14:13:49.398Z", + "version": "WzE4NSwxXQ==" }, { "type": "agents", - "id": "f38b0bd0-f104-11e9-9e96-810494679327", + "id": "548bcb90-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", @@ -4805,475 +4805,475 @@ exports['AgentsRepository list should support to sort by enrolled_at date DESC - "enrolled_at": "2019-08-10T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:37.964Z", - "version": "WzE1NiwxXQ==" + "updated_at": "2019-10-29T14:13:50.409Z", + "version": "WzE4NiwxXQ==" }, { "type": "agents", - "id": "f2565c60-f104-11e9-9e96-810494679327", + "id": "5525c1a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent1", + "shared_id": "agent4", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-08T19:35:14.861Z" + "enrolled_at": "2019-08-11T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:35.941Z", - "version": "WzE1NCwxXQ==" + "updated_at": "2019-10-29T14:13:51.418Z", + "version": "WzE4NywxXQ==" }, { "type": "agents", - "id": "f8fb4210-f104-11e9-9e96-810494679327", + "id": "55c005d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent12", + "shared_id": "agent5", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-19T19:35:14.861Z" + "enrolled_at": "2019-08-12T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:47.089Z", - "version": "WzE2NSwxXQ==" + "updated_at": "2019-10-29T14:13:52.429Z", + "version": "WzE4OCwxXQ==" }, { "type": "agents", - "id": "f86061a0-f104-11e9-9e96-810494679327", + "id": "565a9820-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent11", + "shared_id": "agent6", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-18T19:35:14.861Z" + "enrolled_at": "2019-08-13T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:46.074Z", - "version": "WzE2NCwxXQ==" + "updated_at": "2019-10-29T14:13:53.442Z", + "version": "WzE4OSwxXQ==" }, { "type": "agents", - "id": "f7c6b9b0-f104-11e9-9e96-810494679327", + "id": "56f44010-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent10", + "shared_id": "agent7", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-17T19:35:14.861Z" + "enrolled_at": "2019-08-14T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:45.067Z", - "version": "WzE2MywxXQ==" + "updated_at": "2019-10-29T14:13:54.448Z", + "version": "WzE5MCwxXQ==" }, { "type": "agents", - "id": "f4257710-f104-11e9-9e96-810494679327", + "id": "578ed260-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent4", + "shared_id": "agent8", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-11T19:35:14.861Z" + "enrolled_at": "2019-08-15T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:38.977Z", - "version": "WzE1NywxXQ==" + "updated_at": "2019-10-29T14:13:55.462Z", + "version": "WzE5MSwxXQ==" }, { "type": "agents", - "id": "f4c11ad0-f104-11e9-9e96-810494679327", + "id": "535631c0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent5", + "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-12T19:35:14.861Z" + "enrolled_at": "2019-08-08T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:39.997Z", - "version": "WzE1OCwxXQ==" + "updated_at": "2019-10-29T14:13:48.380Z", + "version": "WzE4NCwxXQ==" }, { "type": "agents", - "id": "f55b5f00-f104-11e9-9e96-810494679327", + "id": "58c2be80-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent6", + "shared_id": "agent10", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-13T19:35:14.861Z" + "enrolled_at": "2019-08-17T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:41.008Z", - "version": "WzE1OSwxXQ==" + "updated_at": "2019-10-29T14:13:57.480Z", + "version": "WzE5MywxXQ==" }, { "type": "agents", - "id": "f5f5f150-f104-11e9-9e96-810494679327", + "id": "59f8a670-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent7", + "shared_id": "agent12", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-14T19:35:14.861Z" + "enrolled_at": "2019-08-19T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:42.021Z", - "version": "WzE2MCwxXQ==" + "updated_at": "2019-10-29T14:13:59.511Z", + "version": "WzE5NSwxXQ==" }, { "type": "agents", - "id": "f68fe760-f104-11e9-9e96-810494679327", + "id": "5a92c390-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent8", + "shared_id": "agent13", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-15T19:35:14.861Z" + "enrolled_at": "2019-08-20T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:43.030Z", - "version": "WzE2MSwxXQ==" + "updated_at": "2019-10-29T14:14:00.521Z", + "version": "WzE5NiwxXQ==" }, { "type": "agents", - "id": "f72aeee0-f104-11e9-9e96-810494679327", + "id": "5b2f9fd0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent9", + "shared_id": "agent14", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-16T19:35:14.861Z" + "enrolled_at": "2019-08-21T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:44.046Z", - "version": "WzE2MiwxXQ==" + "updated_at": "2019-10-29T14:14:01.549Z", + "version": "WzE5NywxXQ==" }, { "type": "agents", - "id": "fe695570-f104-11e9-9e96-810494679327", + "id": "5bc995e0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "inactive_agent_2", + "shared_id": "agent15", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", - "type": "EPHEMERAL", + "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-15T17:38:34.939Z", - "enrolled_at": "2019-08-05T19:35:14.861Z" + "enrolled_at": "2019-08-22T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:56.199Z", - "version": "WzE3NCwxXQ==" + "updated_at": "2019-10-29T14:14:02.558Z", + "version": "WzE5OCwxXQ==" }, { "type": "agents", - "id": "fdcf5f60-f104-11e9-9e96-810494679327", + "id": "5c63b300-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "inactive_agent_1", - "active": false, - "access_token": "TOKEN_1", + "shared_id": "agent16", + "active": true, + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-11-13T20:35:14.861Z" + "enrolled_at": "2019-08-23T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:55.189Z", - "version": "WzE3MywxXQ==" + "updated_at": "2019-10-29T14:14:03.568Z", + "version": "WzE5OSwxXQ==" }, { "type": "agents", - "id": "f9962280-f104-11e9-9e96-810494679327", + "id": "5cfe4550-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent13", + "shared_id": "agent17", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-20T19:35:14.861Z" + "enrolled_at": "2019-08-24T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:48.104Z", - "version": "WzE2NiwxXQ==" + "updated_at": "2019-10-29T14:14:04.581Z", + "version": "WzIwMCwxXQ==" }, { "type": "agents", - "id": "fa3102f0-f104-11e9-9e96-810494679327", + "id": "595e1420-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent14", + "shared_id": "agent11", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-21T19:35:14.861Z" + "enrolled_at": "2019-08-18T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:49.119Z", - "version": "WzE2NywxXQ==" + "updated_at": "2019-10-29T14:13:58.498Z", + "version": "WzE5NCwxXQ==" }, { "type": "agents", - "id": "facbbc50-f104-11e9-9e96-810494679327", + "id": "58280520-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent15", + "shared_id": "agent9", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-22T19:35:14.861Z" + "enrolled_at": "2019-08-16T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:50.133Z", - "version": "WzE2OCwxXQ==" + "updated_at": "2019-10-29T14:13:56.466Z", + "version": "WzE5MiwxXQ==" }, { "type": "agents", - "id": "fb664ea0-f104-11e9-9e96-810494679327", + "id": "5d97c630-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent16", + "shared_id": "agent18", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-23T19:35:14.861Z" + "enrolled_at": "2019-08-25T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:51.146Z", - "version": "WzE2OSwxXQ==" + "updated_at": "2019-10-29T14:14:05.587Z", + "version": "WzIwMSwxXQ==" }, { "type": "agents", - "id": "fc0092d0-f104-11e9-9e96-810494679327", + "id": "5e342d40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent17", + "shared_id": "agent19", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-24T19:35:14.861Z" + "enrolled_at": "2019-08-26T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:52.157Z", - "version": "WzE3MCwxXQ==" + "updated_at": "2019-10-29T14:14:06.612Z", + "version": "WzIwMiwxXQ==" }, { "type": "agents", - "id": "fc9b4c30-f104-11e9-9e96-810494679327", + "id": "5ecdae20-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent18", - "active": true, - "access_token": "TOKEN_1", + "shared_id": "inactive_agent_1", + "active": false, + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "PERMANENT", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-25T19:35:14.861Z" + "enrolled_at": "2019-11-13T20:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:53.171Z", - "version": "WzE3MSwxXQ==" + "updated_at": "2019-10-29T14:14:07.617Z", + "version": "WzIwMywxXQ==" }, { "type": "agents", - "id": "fd35b770-f104-11e9-9e96-810494679327", + "id": "5f688e90-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { - "shared_id": "agent19", + "shared_id": "inactive_agent_2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", - "type": "PERMANENT", + "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "enrolled_at": "2019-08-26T19:35:14.861Z" + "last_checkin": "2019-10-27T14:13:47.356Z", + "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:54.182Z", - "version": "WzE3MiwxXQ==" + "updated_at": "2019-10-29T14:14:08.633Z", + "version": "WzIwNCwxXQ==" }, { "type": "agents", - "id": "ff014fb0-f104-11e9-9e96-810494679327", + "id": "6001e860-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "ephemeral1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", "local_metadata": "{\"host\":\"test.fr\"}", "user_provided_metadata": "{\"color\":\"red\"}", - "last_checkin": "2019-10-17T17:38:34.939Z", + "last_checkin": "2019-10-29T14:13:47.356Z", "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:38:57.195Z", - "version": "WzE3NSwxXQ==" + "updated_at": "2019-10-29T14:14:09.638Z", + "version": "WzIwNSwxXQ==" } ] } } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f1be1400-f104-11e9-9e96-810494679327:{} (26)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:52ba8e00-fa56-11e9-8237-65a0c5e0a0f7:{} (26)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f2f163e0-f104-11e9-9e96-810494679327:{} (27)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:53f18760-fa56-11e9-8237-65a0c5e0a0f7:{} (27)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f38b0bd0-f104-11e9-9e96-810494679327:{} (28)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:548bcb90-fa56-11e9-8237-65a0c5e0a0f7:{} (28)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f2565c60-f104-11e9-9e96-810494679327:{} (29)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5525c1a0-fa56-11e9-8237-65a0c5e0a0f7:{} (29)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f8fb4210-f104-11e9-9e96-810494679327:{} (30)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:55c005d0-fa56-11e9-8237-65a0c5e0a0f7:{} (30)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f86061a0-f104-11e9-9e96-810494679327:{} (31)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:565a9820-fa56-11e9-8237-65a0c5e0a0f7:{} (31)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f7c6b9b0-f104-11e9-9e96-810494679327:{} (32)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:56f44010-fa56-11e9-8237-65a0c5e0a0f7:{} (32)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f4257710-f104-11e9-9e96-810494679327:{} (33)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:578ed260-fa56-11e9-8237-65a0c5e0a0f7:{} (33)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f4c11ad0-f104-11e9-9e96-810494679327:{} (34)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:535631c0-fa56-11e9-8237-65a0c5e0a0f7:{} (34)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f55b5f00-f104-11e9-9e96-810494679327:{} (35)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:58c2be80-fa56-11e9-8237-65a0c5e0a0f7:{} (35)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f5f5f150-f104-11e9-9e96-810494679327:{} (36)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:59f8a670-fa56-11e9-8237-65a0c5e0a0f7:{} (36)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f68fe760-f104-11e9-9e96-810494679327:{} (37)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5a92c390-fa56-11e9-8237-65a0c5e0a0f7:{} (37)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f72aeee0-f104-11e9-9e96-810494679327:{} (38)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5b2f9fd0-fa56-11e9-8237-65a0c5e0a0f7:{} (38)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fe695570-f104-11e9-9e96-810494679327:{} (39)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5bc995e0-fa56-11e9-8237-65a0c5e0a0f7:{} (39)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fdcf5f60-f104-11e9-9e96-810494679327:{} (40)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5c63b300-fa56-11e9-8237-65a0c5e0a0f7:{} (40)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:f9962280-f104-11e9-9e96-810494679327:{} (41)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5cfe4550-fa56-11e9-8237-65a0c5e0a0f7:{} (41)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fa3102f0-f104-11e9-9e96-810494679327:{} (42)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:595e1420-fa56-11e9-8237-65a0c5e0a0f7:{} (42)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:facbbc50-f104-11e9-9e96-810494679327:{} (43)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:58280520-fa56-11e9-8237-65a0c5e0a0f7:{} (43)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fb664ea0-f104-11e9-9e96-810494679327:{} (44)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5d97c630-fa56-11e9-8237-65a0c5e0a0f7:{} (44)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fc0092d0-f104-11e9-9e96-810494679327:{} (45)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5e342d40-fa56-11e9-8237-65a0c5e0a0f7:{} (45)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fc9b4c30-f104-11e9-9e96-810494679327:{} (46)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5ecdae20-fa56-11e9-8237-65a0c5e0a0f7:{} (46)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:fd35b770-f104-11e9-9e96-810494679327:{} (47)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:5f688e90-fa56-11e9-8237-65a0c5e0a0f7:{} (47)'] = { "results": {} } -exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:ff014fb0-f104-11e9-9e96-810494679327:{} (48)'] = { +exports['AgentsRepository list should support to sort by enrolled_at date DESC - delete:agents:6001e860-fa56-11e9-8237-65a0c5e0a0f7:{} (48)'] = { "results": {} } exports['AgentsRepository list for policy should allow to list agents for a policy - create:agents (1)'] = { "results": { "type": "agents", - "id": "0d812a10-f105-11e9-9e96-810494679327", + "id": "6e808a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5282,19 +5282,19 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:21.521Z", - "version": "WzE5OSwxXQ==" + "updated_at": "2019-10-29T14:14:33.956Z", + "version": "WzIyOSwxXQ==" } } exports['AgentsRepository list for policy should allow to list agents for a policy - create:agents (2)'] = { "results": { "type": "agents", - "id": "0e1ca6c0-f105-11e9-9e96-810494679327", + "id": "6f1b43a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5303,19 +5303,19 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:22.540Z", - "version": "WzIwMCwxXQ==" + "updated_at": "2019-10-29T14:14:34.970Z", + "version": "WzIzMCwxXQ==" } } exports['AgentsRepository list for policy should allow to list agents for a policy - create:agents (3)'] = { "results": { "type": "agents", - "id": "0eb6c3e0-f105-11e9-9e96-810494679327", + "id": "6fb539b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-2", "type": "PERMANENT", "version": "1", @@ -5324,8 +5324,8 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:23.550Z", - "version": "WzIwMSwxXQ==" + "updated_at": "2019-10-29T14:14:35.979Z", + "version": "WzIzMSwxXQ==" } } @@ -5337,11 +5337,11 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "saved_objects": [ { "type": "agents", - "id": "0d812a10-f105-11e9-9e96-810494679327", + "id": "6e808a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5350,16 +5350,16 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:21.521Z", - "version": "WzE5OSwxXQ==" + "updated_at": "2019-10-29T14:14:33.956Z", + "version": "WzIyOSwxXQ==" }, { "type": "agents", - "id": "0e1ca6c0-f105-11e9-9e96-810494679327", + "id": "6f1b43a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5368,8 +5368,8 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:22.540Z", - "version": "WzIwMCwxXQ==" + "updated_at": "2019-10-29T14:14:34.970Z", + "version": "WzIzMCwxXQ==" } ] } @@ -5383,11 +5383,11 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "saved_objects": [ { "type": "agents", - "id": "0d812a10-f105-11e9-9e96-810494679327", + "id": "6e808a40-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5396,16 +5396,16 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:21.521Z", - "version": "WzE5OSwxXQ==" + "updated_at": "2019-10-29T14:14:33.956Z", + "version": "WzIyOSwxXQ==" }, { "type": "agents", - "id": "0e1ca6c0-f105-11e9-9e96-810494679327", + "id": "6f1b43a0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-1", "type": "PERMANENT", "version": "1", @@ -5414,16 +5414,16 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:22.540Z", - "version": "WzIwMCwxXQ==" + "updated_at": "2019-10-29T14:14:34.970Z", + "version": "WzIzMCwxXQ==" }, { "type": "agents", - "id": "0eb6c3e0-f105-11e9-9e96-810494679327", + "id": "6fb539b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent3", "active": true, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy-id-2", "type": "PERMANENT", "version": "1", @@ -5432,33 +5432,33 @@ exports['AgentsRepository list for policy should allow to list agents for a poli "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:23.550Z", - "version": "WzIwMSwxXQ==" + "updated_at": "2019-10-29T14:14:35.979Z", + "version": "WzIzMSwxXQ==" } ] } } -exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:0d812a10-f105-11e9-9e96-810494679327:{} (6)'] = { +exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:6e808a40-fa56-11e9-8237-65a0c5e0a0f7:{} (6)'] = { "results": {} } -exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:0e1ca6c0-f105-11e9-9e96-810494679327:{} (7)'] = { +exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:6f1b43a0-fa56-11e9-8237-65a0c5e0a0f7:{} (7)'] = { "results": {} } -exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:0eb6c3e0-f105-11e9-9e96-810494679327:{} (8)'] = { +exports['AgentsRepository list for policy should allow to list agents for a policy - delete:agents:6fb539b0-fa56-11e9-8237-65a0c5e0a0f7:{} (8)'] = { "results": {} } exports['AgentsRepository findByMetadata should allow to find agents by local metadata - create:agents (1)'] = { "results": { "type": "agents", - "id": "111f5f70-f105-11e9-9e96-810494679327", + "id": "721f82f0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5467,19 +5467,19 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:27.591Z", - "version": "WzIwNSwxXQ==" + "updated_at": "2019-10-29T14:14:40.031Z", + "version": "WzIzNSwxXQ==" } } exports['AgentsRepository findByMetadata should allow to find agents by local metadata - create:agents (2)'] = { "results": { "type": "agents", - "id": "11bc3bb0-f105-11e9-9e96-810494679327", + "id": "72b903d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5488,8 +5488,8 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:28.618Z", - "version": "WzIwNiwxXQ==" + "updated_at": "2019-10-29T14:14:41.037Z", + "version": "WzIzNiwxXQ==" } } @@ -5501,11 +5501,11 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "saved_objects": [ { "type": "agents", - "id": "11bc3bb0-f105-11e9-9e96-810494679327", + "id": "72b903d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5514,8 +5514,8 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:28.618Z", - "version": "WzIwNiwxXQ==" + "updated_at": "2019-10-29T14:14:41.037Z", + "version": "WzIzNiwxXQ==" } ] } @@ -5529,11 +5529,11 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "saved_objects": [ { "type": "agents", - "id": "111f5f70-f105-11e9-9e96-810494679327", + "id": "721f82f0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5542,16 +5542,16 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:27.591Z", - "version": "WzIwNSwxXQ==" + "updated_at": "2019-10-29T14:14:40.031Z", + "version": "WzIzNSwxXQ==" }, { "type": "agents", - "id": "11bc3bb0-f105-11e9-9e96-810494679327", + "id": "72b903d0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5560,29 +5560,29 @@ exports['AgentsRepository findByMetadata should allow to find agents by local me "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:28.618Z", - "version": "WzIwNiwxXQ==" + "updated_at": "2019-10-29T14:14:41.037Z", + "version": "WzIzNiwxXQ==" } ] } } -exports['AgentsRepository findByMetadata should allow to find agents by local metadata - delete:agents:111f5f70-f105-11e9-9e96-810494679327:{} (5)'] = { +exports['AgentsRepository findByMetadata should allow to find agents by local metadata - delete:agents:721f82f0-fa56-11e9-8237-65a0c5e0a0f7:{} (5)'] = { "results": {} } -exports['AgentsRepository findByMetadata should allow to find agents by local metadata - delete:agents:11bc3bb0-f105-11e9-9e96-810494679327:{} (6)'] = { +exports['AgentsRepository findByMetadata should allow to find agents by local metadata - delete:agents:72b903d0-fa56-11e9-8237-65a0c5e0a0f7:{} (6)'] = { "results": {} } exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - create:agents (1)'] = { "results": { "type": "agents", - "id": "138ba480-f105-11e9-9e96-810494679327", + "id": "748b04b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5591,19 +5591,19 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:31.656Z", - "version": "WzIwOSwxXQ==" + "updated_at": "2019-10-29T14:14:44.090Z", + "version": "WzIzOSwxXQ==" } } exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - create:agents (2)'] = { "results": { "type": "agents", - "id": "14260fc0-f105-11e9-9e96-810494679327", + "id": "7524fac0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5612,8 +5612,8 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:32.668Z", - "version": "WzIxMCwxXQ==" + "updated_at": "2019-10-29T14:14:45.100Z", + "version": "WzI0MCwxXQ==" } } @@ -5625,11 +5625,11 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "saved_objects": [ { "type": "agents", - "id": "138ba480-f105-11e9-9e96-810494679327", + "id": "748b04b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5638,8 +5638,8 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:31.656Z", - "version": "WzIwOSwxXQ==" + "updated_at": "2019-10-29T14:14:44.090Z", + "version": "WzIzOSwxXQ==" } ] } @@ -5653,11 +5653,11 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "saved_objects": [ { "type": "agents", - "id": "138ba480-f105-11e9-9e96-810494679327", + "id": "748b04b0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent1", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5666,16 +5666,16 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:31.656Z", - "version": "WzIwOSwxXQ==" + "updated_at": "2019-10-29T14:14:44.090Z", + "version": "WzIzOSwxXQ==" }, { "type": "agents", - "id": "14260fc0-f105-11e9-9e96-810494679327", + "id": "7524fac0-fa56-11e9-8237-65a0c5e0a0f7", "attributes": { "shared_id": "agent2", "active": false, - "access_token": "TOKEN_1", + "access_api_key_id": "api_key_1", "policy_id": "policy_id_1", "type": "EPHEMERAL", "version": "1", @@ -5684,17 +5684,17 @@ exports['AgentsRepository findByMetadata should allow to find agents by user pro "enrolled_at": "2019-08-05T19:35:14.861Z" }, "references": [], - "updated_at": "2019-10-17T17:39:32.668Z", - "version": "WzIxMCwxXQ==" + "updated_at": "2019-10-29T14:14:45.100Z", + "version": "WzI0MCwxXQ==" } ] } } -exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - delete:agents:138ba480-f105-11e9-9e96-810494679327:{} (5)'] = { +exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - delete:agents:748b04b0-fa56-11e9-8237-65a0c5e0a0f7:{} (5)'] = { "results": {} } -exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - delete:agents:14260fc0-f105-11e9-9e96-810494679327:{} (6)'] = { +exports['AgentsRepository findByMetadata should allow to find agents by user provided metadata - delete:agents:7524fac0-fa56-11e9-8237-65a0c5e0a0f7:{} (6)'] = { "results": {} } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agents/default.contract.test.ts b/x-pack/legacy/plugins/fleet/server/repositories/agents/default.contract.test.ts index 77c8782dc510e..7e58643b60929 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/default.contract.test.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/default.contract.test.ts @@ -88,7 +88,7 @@ describe('AgentsRepository', () => { const agent = await adapter.create(getUser(), { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -104,7 +104,7 @@ describe('AgentsRepository', () => { expect(agent).toMatchObject({ shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -120,7 +120,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -145,7 +145,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -164,7 +164,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -191,7 +191,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -226,7 +226,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -257,7 +257,7 @@ describe('AgentsRepository', () => { return { shared_id: `agent${idx}`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'PERMANENT', version: '1', @@ -276,7 +276,7 @@ describe('AgentsRepository', () => { { shared_id: `ephemeral1`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -296,7 +296,7 @@ describe('AgentsRepository', () => { { shared_id: `inactive_agent_1`, active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'PERMANENT', version: '1', @@ -314,7 +314,7 @@ describe('AgentsRepository', () => { { shared_id: `inactive_agent_2`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -380,7 +380,7 @@ describe('AgentsRepository', () => { { shared_id: `agent1`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy-id-1', type: 'PERMANENT', version: '1', @@ -391,7 +391,7 @@ describe('AgentsRepository', () => { { shared_id: `agent2`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy-id-1', type: 'PERMANENT', version: '1', @@ -403,7 +403,7 @@ describe('AgentsRepository', () => { { shared_id: `agent3`, active: true, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy-id-2', type: 'PERMANENT', version: '1', @@ -430,7 +430,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent1', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', @@ -445,7 +445,7 @@ describe('AgentsRepository', () => { { shared_id: 'agent2', active: false, - access_token: 'TOKEN_1', + access_api_key_id: 'api_key_1', policy_id: 'policy_id_1', type: 'EPHEMERAL', version: '1', 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 6ec63eb47a3e7..3d5a75b408951 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/default.ts @@ -76,6 +76,22 @@ export class AgentsRepository implements AgentsRepositoryType { return this._savedObjectToAgent(response); } + public async getByAccessApiKeyId(user: FrameworkUser, apiKeyId: string): Promise { + const response = await this.soAdapter.find(user, { + type: 'agents', + searchFields: ['access_api_key_id'], + search: apiKeyId, + }); + + const agents = response.saved_objects.map(this._savedObjectToAgent); + + if (agents.length > 0) { + return agents[0]; + } + + return null; + } + /** * Get an agent by ES shared_id * @param agent @@ -207,25 +223,6 @@ export class AgentsRepository implements AgentsRepositoryType { }); } - /** - * Get an agent by ephemeral access token - * @param token - */ - public async getByEphemeralAccessToken(user: FrameworkUser, token: any): Promise { - const res = await this.soAdapter.find(user, { - type: 'agents', - search: token, - searchFields: ['access_token'], - }); - - const agents = res.saved_objects.map(this._savedObjectToAgent); - - if (agents.length < 0) { - return null; - } - - return agents[0]; - } private _savedObjectToAgent(so: SavedObject): Agent { if (so.error) { throw new Error(so.error.message); diff --git a/x-pack/legacy/plugins/fleet/server/repositories/agents/in_memory.ts b/x-pack/legacy/plugins/fleet/server/repositories/agents/in_memory.ts index 967e0dd4a9cf3..0cbccaf6bfc19 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/in_memory.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/in_memory.ts @@ -48,6 +48,15 @@ export class InMemoryAgentsRepository implements AgentsRepository { return agent || null; } + public async getByAccessApiKeyId( + user: FrameworkUser, + accessApiKeyId: string + ): Promise { + const agent = Object.values(this.agents).find(a => a.access_api_key_id === accessApiKeyId); + + return agent || null; + } + public async update(user: FrameworkUser, id: string, newData: Partial): Promise { if (this.agents[id]) { Object.assign(this.agents[id], newData); @@ -86,8 +95,4 @@ export class InMemoryAgentsRepository implements AgentsRepository { return { agents, total, page, perPage }; } - - public async getByEphemeralAccessToken(token: any): Promise { - return null; - } } 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 81230dc93c7f0..c6541681a50e6 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/agents/types.ts @@ -54,7 +54,6 @@ export type AgentType = t.TypeOf; const newAgentProperties = { type: RuntimeAgentType, active: t.boolean, - policy_id: t.string, }; const newAgentOptionalProperties = t.partial({ @@ -64,7 +63,9 @@ const newAgentOptionalProperties = t.partial({ user_provided_metadata: t.dictionary(t.string, t.string), local_metadata: t.dictionary(t.string, t.string), shared_id: t.string, - access_token: t.string, + access_api_key_id: t.string, + access_api_key: t.string, + policy_id: t.string, }); export const NewRuntimeAgent = t.intersection([ @@ -88,7 +89,7 @@ export const RuntimeAgent = t.intersection([ export const RuntimeSavedObjectAgentAttributes = t.intersection([ t.partial({ shared_id: t.string, - access_token: t.string, + access_api_key_id: t.string, last_updated: t.string, last_checkin: t.string, parent_id: t.string, @@ -132,6 +133,8 @@ export interface AgentsRepository { delete(user: FrameworkUser, agent: Agent): Promise; + getByAccessApiKeyId(user: FrameworkUser, apiKeyid: string): Promise; + getById(user: FrameworkUser, id: string): Promise; getBySharedId(user: FrameworkUser, sharedId: string): Promise; @@ -153,6 +156,4 @@ export interface AgentsRepository { policyId: string, options?: ListOptions ): Promise<{ agents: Agent[]; total: number; page: number; perPage: number }>; - - getByEphemeralAccessToken(user: FrameworkUser, token: any): Promise; } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap new file mode 100644 index 0000000000000..4f93ed1c96826 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap @@ -0,0 +1,338 @@ + +exports['Enrollment api key Repository create allow to create an enrollment api key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "98565dd9-e74f-45c2-a972-a1520e7cd91b", + "attributes": { + "created_at": "2019-10-29T14:14:55.616Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [], + "updated_at": "2019-10-29T14:14:55.636Z", + "version": "WzI0MywxXQ==" + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - get:enrollment_api_keys:98565dd9-e74f-45c2-a972-a1520e7cd91b:{} (2)'] = { + "results": { + "id": "98565dd9-e74f-45c2-a972-a1520e7cd91b", + "type": "enrollment_api_keys", + "updated_at": "2019-10-29T14:14:55.636Z", + "version": "WzI0MywxXQ==", + "attributes": { + "created_at": "2019-10-29T14:14:55.616Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [] + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "98565dd9-e74f-45c2-a972-a1520e7cd91b", + "attributes": { + "created_at": "2019-10-29T14:14:55.616Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [], + "updated_at": "2019-10-29T14:14:55.636Z", + "version": "WzI0MywxXQ==" + } + ] + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - delete:enrollment_api_keys:98565dd9-e74f-45c2-a972-a1520e7cd91b:{} (4)'] = { + "results": {} +} + +exports['Enrollment api key Repository update allow to update a key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "6ac9632a-295d-45f5-a2f5-79a27483ba77", + "attributes": { + "active": true, + "policy_id": "policyId" + }, + "references": [], + "updated_at": "2019-10-29T14:14:57.178Z", + "version": "WzI0NSwxXQ==" + } +} + +exports['Enrollment api key Repository update allow to update a key - get:enrollment_api_keys:6ac9632a-295d-45f5-a2f5-79a27483ba77:{"active":false,"api_key":"notencryptedapikey"}:{} (2)'] = { + "results": { + "id": "6ac9632a-295d-45f5-a2f5-79a27483ba77", + "type": "enrollment_api_keys", + "updated_at": "2019-10-29T14:14:58.185Z", + "version": "WzI0NiwxXQ==", + "attributes": { + "active": false + } + } +} + +exports['Enrollment api key Repository update allow to update a key - get:enrollment_api_keys:6ac9632a-295d-45f5-a2f5-79a27483ba77:{} (3)'] = { + "results": { + "id": "6ac9632a-295d-45f5-a2f5-79a27483ba77", + "type": "enrollment_api_keys", + "updated_at": "2019-10-29T14:14:58.185Z", + "version": "WzI0NiwxXQ==", + "attributes": { + "active": false, + "policy_id": "policyId" + }, + "references": [] + } +} + +exports['Enrollment api key Repository update allow to update a key - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "6ac9632a-295d-45f5-a2f5-79a27483ba77", + "attributes": { + "active": false, + "policy_id": "policyId" + }, + "references": [], + "updated_at": "2019-10-29T14:14:58.185Z", + "version": "WzI0NiwxXQ==" + } + ] + } +} + +exports['Enrollment api key Repository update allow to update a key - delete:enrollment_api_keys:6ac9632a-295d-45f5-a2f5-79a27483ba77:{} (5)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "5b943598-d218-4bd0-a5e9-ad2dd93d6031", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OCwxXQ==" + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - create:enrollment_api_keys (2)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "4ef59475-a86c-480e-8934-817ee67236c1", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OSwxXQ==" + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 20, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "4ef59475-a86c-480e-8934-817ee67236c1", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OSwxXQ==" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - getDecryptedAsInternalUser:enrollment_api_keys:4ef59475-a86c-480e-8934-817ee67236c1 (4)'] = { + "results": { + "id": "4ef59475-a86c-480e-8934-817ee67236c1", + "type": "enrollment_api_keys", + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OSwxXQ==", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - find:"enrollment_api_keys" (5)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 2, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "5b943598-d218-4bd0-a5e9-ad2dd93d6031", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OCwxXQ==" + }, + { + "type": "enrollment_api_keys", + "id": "4ef59475-a86c-480e-8934-817ee67236c1", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-10-29T14:15:00.207Z", + "version": "WzI0OSwxXQ==" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - delete:enrollment_api_keys:5b943598-d218-4bd0-a5e9-ad2dd93d6031:{} (6)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - delete:enrollment_api_keys:4ef59475-a86c-480e-8934-817ee67236c1:{} (7)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "79551426-5c54-4937-bc0d-baa25a209c12", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-10-29T14:15:03.244Z", + "version": "WzI1MiwxXQ==" + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - create:enrollment_api_keys (2)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "0aa92e81-eabf-4f63-a8c9-aca8dd1d426e", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-10-29T14:15:03.244Z", + "version": "WzI1MywxXQ==" + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 20, + "total": 0, + "saved_objects": [] + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 2, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "79551426-5c54-4937-bc0d-baa25a209c12", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-10-29T14:15:03.244Z", + "version": "WzI1MiwxXQ==" + }, + { + "type": "enrollment_api_keys", + "id": "0aa92e81-eabf-4f63-a8c9-aca8dd1d426e", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-10-29T14:15:03.244Z", + "version": "WzI1MywxXQ==" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - delete:enrollment_api_keys:79551426-5c54-4937-bc0d-baa25a209c12:{} (5)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - delete:enrollment_api_keys:0aa92e81-eabf-4f63-a8c9-aca8dd1d426e:{} (6)'] = { + "results": {} +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "8eea627e-dd8c-4ff9-b4a4-dc80f183ba9a", + "attributes": { + "active": true, + "api_key_id": "qwerty" + }, + "references": [], + "updated_at": "2019-10-29T14:15:06.272Z", + "version": "WzI1NiwxXQ==" + } +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - delete:enrollment_api_keys:8eea627e-dd8c-4ff9-b4a4-dc80f183ba9a:{} (2)'] = { + "results": {} +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - get:enrollment_api_keys:8eea627e-dd8c-4ff9-b4a4-dc80f183ba9a:{} (3)'] = { + "results": null +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +} diff --git a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.contract.test.ts b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.contract.test.ts new file mode 100644 index 0000000000000..d5375e8eac502 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.contract.test.ts @@ -0,0 +1,200 @@ +/* + * 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 { SavedObject } from 'src/core/server'; +import { EnrollmentApiKeysRepository } from './default'; +import { SODatabaseAdapter as SODatabaseAdapterType } from '../../adapters/saved_objects_database/adapter_types'; +import { SODatabaseAdapter } from '../../adapters/saved_objects_database/default'; +import { MemorizeSODatabaseAdapter } from '../../adapters/saved_objects_database/memorize_adapter'; +import { EnrollmentApiKey, SAVED_OBJECT_TYPE } from './types'; +import { EncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/default'; +import { MemorizeEncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/memorize_adapter'; +import { FrameworkUser, internalAuthData } from '../../adapters/framework/adapter_types'; + +describe('Enrollment api key Repository', () => { + let adapter: EnrollmentApiKeysRepository; + let soAdapter: SODatabaseAdapterType; + let encryptedSavedObject: EncryptedSavedObjects; + let servers: any; + + async function loadFixtures(keys: Array>): Promise { + return await Promise.all(keys.map(key => soAdapter.create(getUser(), SAVED_OBJECT_TYPE, key))); + } + + async function clearFixtures() { + const user = getUser(); + const { saved_objects: savedObjects } = await soAdapter.find(user, { + type: SAVED_OBJECT_TYPE, + perPage: 1000, + }); + for (const so of savedObjects) { + await soAdapter.delete(user, SAVED_OBJECT_TYPE, so.id); + } + } + + function getUser(): FrameworkUser { + return ({ + kind: 'authenticated', + [internalAuthData]: { + authorization: `Basic ${Buffer.from(`elastic:changeme`).toString('base64')}`, + }, + } as unknown) as FrameworkUser; + } + + beforeAll(async () => { + await Slapshot.callWhenOnline(async () => { + const { createKibanaServer } = await import( + '../../../../../../test_utils/jest/contract_tests/servers' + ); + servers = await createKibanaServer({ + security: { enabled: false }, + }); + const baseAdapter = new SODatabaseAdapter( + servers.kbnServer.savedObjects, + servers.kbnServer.plugins.elasticsearch + ); + soAdapter = new MemorizeSODatabaseAdapter(baseAdapter); + + const baseEncyrptedSOAdapter = new EncryptedSavedObjects( + servers.kbnServer.plugins.encrypted_saved_objects + ); + + encryptedSavedObject = (new MemorizeEncryptedSavedObjects( + baseEncyrptedSOAdapter + ) as unknown) as EncryptedSavedObjects; + }); + + if (!soAdapter) { + soAdapter = new MemorizeSODatabaseAdapter(); + } + if (!encryptedSavedObject) { + encryptedSavedObject = (new MemorizeEncryptedSavedObjects() as unknown) as EncryptedSavedObjects; + } + adapter = new EnrollmentApiKeysRepository(soAdapter, encryptedSavedObject); + }); + + afterAll(async () => { + if (servers) { + await servers.shutdown; + } + }); + + afterEach(clearFixtures); + + describe('create', () => { + it('allow to create an enrollment api key', async () => { + const user = getUser(); + const enrollmentApiKey = await adapter.create(user, { + active: true, + apiKey: 'notencryptedkey', + apiKeyId: 'key-id-123', + policyId: 'policyId', + }); + const savedEnrollmentApiKey = (await soAdapter.get( + user, + SAVED_OBJECT_TYPE, + enrollmentApiKey.id + )) as SavedObject; + expect(savedEnrollmentApiKey).toBeDefined(); + expect(enrollmentApiKey.id).toBeDefined(); + + expect(savedEnrollmentApiKey.attributes.apiKey !== 'notencryptedkey').toBe(true); + + expect(savedEnrollmentApiKey.attributes).toMatchObject({ + active: true, + policy_id: 'policyId', + api_key_id: 'key-id-123', + }); + }); + }); + + describe('update', () => { + let enrollmentApiKeyId: string; + beforeEach(async () => { + const keys = await loadFixtures([ + { + active: true, + api_key: 'qwerty', + policy_id: 'policyId', + }, + ]); + + enrollmentApiKeyId = keys[0].id; + }); + + it('allow to update a key', async () => { + const user = getUser(); + await adapter.update(user, enrollmentApiKeyId, { + active: false, + api_key: 'notencryptedapikey', + }); + + const soEnrollmentKey = (await soAdapter.get( + user, + SAVED_OBJECT_TYPE, + enrollmentApiKeyId + )) as SavedObject; + expect(soEnrollmentKey.attributes.api_key !== 'notencryptedapikey').toBe(true); + expect(soEnrollmentKey.attributes).toMatchObject({ + active: false, + }); + }); + }); + + describe('getByApiKeyId', () => { + beforeEach(async () => { + await loadFixtures([ + { + active: true, + api_key_id: 'api-key-1', + }, + { + active: true, + api_key_id: 'api-key-2', + }, + ]); + }); + + it('allow to find a key', async () => { + const user = getUser(); + const enrollmentApiKey = await adapter.getByApiKeyId(user, 'api-key-2'); + expect(enrollmentApiKey).toBeDefined(); + expect((enrollmentApiKey as EnrollmentApiKey).api_key_id).toBe('api-key-2'); + }); + + it('return null if the key does not exists', async () => { + const user = getUser(); + const enrollmentApiKey = await adapter.getByApiKeyId(user, 'idonotexists'); + expect(enrollmentApiKey).toBeNull(); + }); + }); + + describe('delete', () => { + let enrollmentApiKeyId: string; + beforeEach(async () => { + const keys = await loadFixtures([ + { + active: true, + api_key_id: 'qwerty', + }, + ]); + + enrollmentApiKeyId = keys[0].id; + }); + + it('allow to delete a enrollmentApiKey', async () => { + const user = getUser(); + await adapter.delete(user, enrollmentApiKeyId); + const soEnrollmentApiKey = await soAdapter.get( + user, + SAVED_OBJECT_TYPE, + enrollmentApiKeyId + ); + expect(soEnrollmentApiKey).toBeNull(); + }); + }); +}); diff --git a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.ts b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.ts new file mode 100644 index 0000000000000..f15ae6c645378 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/default.ts @@ -0,0 +1,159 @@ +/* + * 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 moment from 'moment'; +import { SavedObject } from 'src/core/server'; +import { SODatabaseAdapter } from '../../adapters/saved_objects_database/adapter_types'; +import { + EnrollmentApiKey, + EnrollmentApiKeysRepository as EnrollmentApiKeysRepositoryType, + SAVED_OBJECT_TYPE, +} from './types'; +import { EncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/default'; +import { FrameworkUser } from '../../adapters/framework/adapter_types'; + +function getFirstOrNull(list: T[]): T | null { + return list.length > 0 ? list[0] : null; +} + +/** + * EnrollmentApiKey repository that persist keys using saved objects + */ +export class EnrollmentApiKeysRepository implements EnrollmentApiKeysRepositoryType { + constructor( + private readonly soAdapter: SODatabaseAdapter, + private readonly encryptedSavedObject: EncryptedSavedObjects + ) {} + + public async list( + user: FrameworkUser, + options: { + page?: number; + perPage?: number; + kuery?: string; + showInactive?: boolean; + } + ): Promise<{ items: EnrollmentApiKey[]; total: any; page: any; perPage: any }> { + const { page = 1, perPage = 20, kuery } = options; + + const { saved_objects, total } = await this.soAdapter.find(user, { + type: SAVED_OBJECT_TYPE, + page, + perPage, + filter: + kuery && kuery !== '' + ? kuery.replace(/enrollment_api_keys\./g, 'enrollment_api_keys.attributes.') + : undefined, + }); + + const items = saved_objects.map(this._savedObjectToEnrollmentApiKey); + + return { + items, + total, + page, + perPage, + }; + } + + public async create( + user: FrameworkUser, + { + apiKeyId, + apiKey, + active, + policyId, + expire_at, + name, + }: { + apiKeyId: string; + apiKey: string; + active: boolean; + expire_at?: string; + policyId?: string; + name?: string; + } + ): Promise { + if (user.kind !== 'authenticated') { + throw new Error('Only authenticated user can create enrollment api keys.'); + } + const so = await this.soAdapter.create(user, SAVED_OBJECT_TYPE, { + created_at: moment().toISOString(), + api_key: apiKey, + api_key_id: apiKeyId, + policy_id: policyId, + expire_at, + active, + enrollment_rules: [], + name, + }); + + return { + id: so.id, + ...so.attributes, + api_key: apiKey, + }; + } + + public async getByApiKeyId( + user: FrameworkUser, + apiKeyId: string + ): Promise { + const res = await this.soAdapter.find(user, { + type: SAVED_OBJECT_TYPE, + searchFields: ['api_key_id'], + search: apiKeyId, + }); + + const keys = res.saved_objects.map(this._savedObjectToEnrollmentApiKey); + const key = getFirstOrNull(keys); + return key ? await this._getDecrypted(key.id) : null; + } + + public async getById(user: FrameworkUser, id: string): Promise { + return await this._getDecrypted(id); + } + + public async update( + user: FrameworkUser, + id: string, + newData: Partial + ): Promise { + if (user.kind !== 'authenticated') { + throw new Error('Only authenticated can update enrollment api keys'); + } + const { error } = await this.soAdapter.update(user, SAVED_OBJECT_TYPE, id, newData); + + if (error) { + throw new Error(error.message); + } + } + + public async delete(user: FrameworkUser, id: string): Promise { + await this.soAdapter.delete(user, SAVED_OBJECT_TYPE, id); + } + + private async _getDecrypted(id: string) { + return this._savedObjectToEnrollmentApiKey( + await this.encryptedSavedObject.getDecryptedAsInternalUser(SAVED_OBJECT_TYPE, id) + ); + } + + private _savedObjectToEnrollmentApiKey({ + error, + attributes, + id, + }: SavedObject): EnrollmentApiKey { + if (error) { + throw new Error(error.message); + } + + return { + id, + ...attributes, + }; + } +} diff --git a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/memory.ts b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/memory.ts new file mode 100644 index 0000000000000..6f0f4ac0e8691 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/memory.ts @@ -0,0 +1,99 @@ +/* + * 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 moment from 'moment'; +import { EnrollmentApiKey, EnrollmentApiKeysRepository } from './types'; +import { FrameworkUser } from '../../adapters/framework/adapter_types'; + +/** + * MemoryAdapter for persisting enrollmentApiKeys, for tests purposes only. + */ +export class MemoryEnrollmentApiKeysRepository implements EnrollmentApiKeysRepository { + public keys: { [k: string]: EnrollmentApiKey } = {}; + private keyId = 1; + public async create( + user: FrameworkUser, + { + apiKey, + apiKeyId, + active, + policyId, + expire_at, + name, + }: { + apiKey: string; + apiKeyId: string; + active: boolean; + policyId?: string; + expire_at?: string; + name?: string; + } + ): Promise { + const id = `enrollment-api-keys-${this.keyId++}`; + this.keys[id] = { + id, + active, + created_at: moment().toISOString(), + api_key: apiKey, + api_key_id: apiKeyId, + expire_at, + policy_id: policyId, + enrollment_rules: [], + name, + }; + + return this.keys[id]; + } + + public async list( + user: FrameworkUser, + options: { + page?: number; + perPage?: number; + kuery?: string; + showInactive?: boolean; + } + ): Promise<{ items: EnrollmentApiKey[]; total: any; page: any; perPage: any }> { + const { page = 1, perPage = 20 } = options; + + const keys = Object.values(this.keys); + const start = (page - 1) * perPage; + const items = keys.slice(start, start + perPage); + const total = items.length; + + return { + items, + total, + page, + perPage, + }; + } + + public async getByApiKeyId( + user: FrameworkUser, + apiKeyId: string + ): Promise { + return Object.values(this.keys).find(t => t.api_key_id === apiKeyId) || null; + } + + public async update( + user: FrameworkUser, + id: string, + newData: Partial + ): Promise { + const key = this.keys[id]; + + Object.assign(key, newData); + } + + public async getById(user: FrameworkUser, id: string) { + return Object.values(this.keys).find(t => t.id === id) || null; + } + + public async delete(user: FrameworkUser, id: string): Promise { + delete this.keys[id]; + } +} diff --git a/x-pack/legacy/plugins/fleet/server/repositories/tokens/types.ts b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/types.ts similarity index 54% rename from x-pack/legacy/plugins/fleet/server/repositories/tokens/types.ts rename to x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/types.ts index c98d23470a5e6..6564cf064d942 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/tokens/types.ts +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/types.ts @@ -8,13 +8,7 @@ import * as t from 'io-ts'; import { FrameworkUser } from '../../adapters/framework/adapter_types'; import { RuntimeAgentType } from '../agents/types'; -export interface EnrollmentTokenData { - policy_id: string; -} - -export interface AccessTokenData { - policy_id: string; -} +export const SAVED_OBJECT_TYPE = 'enrollment_api_keys'; export const RuntimeEnrollmentRuleData = t.partial( { @@ -39,74 +33,78 @@ export type EnrollmentRule = EnrollmentRuleData & { updated_at?: string; }; -export type TokenVerificationResponse = +export type EnrollmentApiKeyVerificationResponse = | { valid: true; - type: TokenType.ENROLLMENT_TOKEN; - token: EnrollmentTokenData; + enrollmentApiKey: EnrollmentApiKey; } + | { + valid: false; + reason: string; + }; + +export type AccessApiKeyVerificationResponse = | { valid: true; - type: TokenType.ACCESS_TOKEN; - token: AccessTokenData; + accessApiKeyId: string; } | { valid: false; reason: string; }; -export enum TokenType { - ENROLLMENT_TOKEN = 'ENROLLMENT_TOKEN', - ACCESS_TOKEN = 'ACCESS_TOKEN', -} - -export interface Token { +export interface EnrollmentApiKey { id: string; - type: TokenType; - token: string; - tokenHash: string; + api_key_id: string; + api_key: string; + name?: string; created_at: string; expire_at?: string; active: boolean; enrollment_rules: EnrollmentRule[]; - policy_id: string; + policy_id?: string; [k: string]: any; // allow to use it as saved object attributes type } -export interface TokensRepository { +export interface EnrollmentApiKeysRepository { + list( + user: FrameworkUser, + options: { + page?: number; + perPage?: number; + kuery?: string; + showInactive?: boolean; + } + ): Promise<{ items: EnrollmentApiKey[]; total: any; page: any; perPage: any }>; create( user: FrameworkUser, data: { - type: TokenType; - token: string; - tokenHash: string; + apiKeyId: string; + apiKey: string; active: boolean; - policyId: string; expire_at?: string; + policyId?: string; + name?: string; } - ): Promise; + ): Promise; /** - * Get a token by token. - * @param token + * Get a key for a given Id. */ - getByTokenHash(user: FrameworkUser, tokenHash: string): Promise; + getById(user: FrameworkUser, id: string): Promise; /** - * Get a token by token. - * @param token + * Get a key for a given apiKey Id. */ - getByPolicyId(user: FrameworkUser, policyId: string): Promise; + getByApiKeyId(user: FrameworkUser, apiKeyId: string): Promise; /** - * Update a token - * @param token + * Update an apiKey */ - update(user: FrameworkUser, id: string, newData: Partial): Promise; + update(user: FrameworkUser, id: string, newData: Partial): Promise; /** - * Delete a token - * @param token + * Delete an apiKey */ delete(user: FrameworkUser, id: string): Promise; } diff --git a/x-pack/legacy/plugins/fleet/server/repositories/tokens/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/repositories/tokens/__memorize_snapshots__/default.contract.test.slap_snap deleted file mode 100644 index 1d908c848fc16..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/repositories/tokens/__memorize_snapshots__/default.contract.test.slap_snap +++ /dev/null @@ -1,642 +0,0 @@ - -exports['Token Repository create allow to create a token - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "29eac571-7834-409b-8819-73a45ce695df", - "attributes": { - "created_at": "2019-10-16T23:24:49.431Z", - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId", - "active": true, - "enrollment_rules": [] - }, - "references": [], - "updated_at": "2019-10-16T23:24:49.480Z", - "version": "WzMwNjcsMV0=" - } -} - -exports['Token Repository create allow to create a token - get:tokens:29eac571-7834-409b-8819-73a45ce695df:{} (2)'] = { - "results": { - "id": "29eac571-7834-409b-8819-73a45ce695df", - "type": "tokens", - "updated_at": "2019-10-16T23:24:49.480Z", - "version": "WzMwNjcsMV0=", - "attributes": { - "created_at": "2019-10-16T23:24:49.431Z", - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId", - "active": true, - "enrollment_rules": [] - }, - "references": [] - } -} - -exports['Token Repository create allow to create a token - find:"tokens" (3)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 2, - "saved_objects": [ - { - "type": "tokens", - "id": "504372b9-67d0-4030-83b1-6112218e5c6a", - "attributes": { - "active": false, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId" - }, - "references": [], - "updated_at": "2019-10-16T23:24:06.323Z", - "version": "WzMwNjYsMV0=" - }, - { - "type": "tokens", - "id": "29eac571-7834-409b-8819-73a45ce695df", - "attributes": { - "created_at": "2019-10-16T23:24:49.431Z", - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId", - "active": true, - "enrollment_rules": [] - }, - "references": [], - "updated_at": "2019-10-16T23:24:49.480Z", - "version": "WzMwNjcsMV0=" - } - ] - } -} - -exports['Token Repository create allow to create a token - delete:tokens:504372b9-67d0-4030-83b1-6112218e5c6a:{} (4)'] = { - "results": {} -} - -exports['Token Repository create allow to create a token - delete:tokens:29eac571-7834-409b-8819-73a45ce695df:{} (5)'] = { - "results": {} -} - -exports['Token Repository update allow to update a token - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "8fbc5011-5c58-4235-aff6-cbbeab63bbab", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId" - }, - "references": [], - "updated_at": "2019-10-16T23:24:52.459Z", - "version": "WzMwNzAsMV0=" - } -} - -exports['Token Repository update allow to update a token - get:tokens:8fbc5011-5c58-4235-aff6-cbbeab63bbab:{"active":false,"token":"notencryptedtoken"}:{} (2)'] = { - "results": { - "id": "8fbc5011-5c58-4235-aff6-cbbeab63bbab", - "type": "tokens", - "updated_at": "2019-10-16T23:24:53.503Z", - "version": "WzMwNzEsMV0=", - "attributes": { - "active": false - } - } -} - -exports['Token Repository update allow to update a token - get:tokens:8fbc5011-5c58-4235-aff6-cbbeab63bbab:{} (3)'] = { - "results": { - "id": "8fbc5011-5c58-4235-aff6-cbbeab63bbab", - "type": "tokens", - "updated_at": "2019-10-16T23:24:53.503Z", - "version": "WzMwNzEsMV0=", - "attributes": { - "active": false, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId" - }, - "references": [] - } -} - -exports['Token Repository update allow to update a token - find:"tokens" (4)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 1, - "saved_objects": [ - { - "type": "tokens", - "id": "8fbc5011-5c58-4235-aff6-cbbeab63bbab", - "attributes": { - "active": false, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policyId" - }, - "references": [], - "updated_at": "2019-10-16T23:24:53.503Z", - "version": "WzMwNzEsMV0=" - } - ] - } -} - -exports['Token Repository update allow to update a token - delete:tokens:8fbc5011-5c58-4235-aff6-cbbeab63bbab:{} (5)'] = { - "results": {} -} - -exports['Token Repository getByTokenHash allow to find a token - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "d9376b90-aeff-4ba7-a07f-8632c98493b1", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzMsMV0=" - } -} - -exports['Token Repository getByTokenHash allow to find a token - create:tokens (2)'] = { - "results": { - "type": "tokens", - "id": "8925852c-b5a9-493b-bf42-02c537146bd2", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzQsMV0=" - } -} - -exports['Token Repository getByTokenHash allow to find a token - find:"tokens" (3)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 1, - "saved_objects": [ - { - "type": "tokens", - "id": "8925852c-b5a9-493b-bf42-02c537146bd2", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzQsMV0=" - } - ] - } -} - -exports['Token Repository getByTokenHash allow to find a token - getDecryptedAsInternalUser:tokens:8925852c-b5a9-493b-bf42-02c537146bd2 (4)'] = { - "results": { - "id": "8925852c-b5a9-493b-bf42-02c537146bd2", - "type": "tokens", - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzQsMV0=", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [] - } -} - -exports['Token Repository getByTokenHash allow to find a token - find:"tokens" (5)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 2, - "saved_objects": [ - { - "type": "tokens", - "id": "d9376b90-aeff-4ba7-a07f-8632c98493b1", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzMsMV0=" - }, - { - "type": "tokens", - "id": "8925852c-b5a9-493b-bf42-02c537146bd2", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:55.514Z", - "version": "WzMwNzQsMV0=" - } - ] - } -} - -exports['Token Repository getByTokenHash allow to find a token - delete:tokens:d9376b90-aeff-4ba7-a07f-8632c98493b1:{} (6)'] = { - "results": {} -} - -exports['Token Repository getByTokenHash allow to find a token - delete:tokens:8925852c-b5a9-493b-bf42-02c537146bd2:{} (7)'] = { - "results": {} -} - -exports['Token Repository getByTokenHash return null if the token does not exists - create:tokens (2)'] = { - "results": { - "type": "tokens", - "id": "d4a1422a-d420-4163-87d0-c6226d441f40", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:58.553Z", - "version": "WzMwNzgsMV0=" - } -} - -exports['Token Repository getByTokenHash return null if the token does not exists - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "a7e8b2e2-87de-4630-b93f-7a2a2f8ce66e", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:58.553Z", - "version": "WzMwNzcsMV0=" - } -} - -exports['Token Repository getByTokenHash return null if the token does not exists - find:"tokens" (3)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 0, - "saved_objects": [] - } -} - -exports['Token Repository getByTokenHash return null if the token does not exists - find:"tokens" (4)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 2, - "saved_objects": [ - { - "type": "tokens", - "id": "a7e8b2e2-87de-4630-b93f-7a2a2f8ce66e", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:58.553Z", - "version": "WzMwNzcsMV0=" - }, - { - "type": "tokens", - "id": "d4a1422a-d420-4163-87d0-c6226d441f40", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty" - }, - "references": [], - "updated_at": "2019-10-16T23:24:58.553Z", - "version": "WzMwNzgsMV0=" - } - ] - } -} - -exports['Token Repository getByTokenHash return null if the token does not exists - delete:tokens:a7e8b2e2-87de-4630-b93f-7a2a2f8ce66e:{} (5)'] = { - "results": {} -} - -exports['Token Repository getByTokenHash return null if the token does not exists - delete:tokens:d4a1422a-d420-4163-87d0-c6226d441f40:{} (6)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId allow to find a token - create:tokens (3)'] = { - "results": { - "type": "tokens", - "id": "e5eba5c0-1bd3-4ae1-9b3b-338d548320ce", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy123" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.606Z", - "version": "WzMwODEsMV0=" - } -} - -exports['Token Repository getByPolicyId allow to find a token - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "2d87ed62-d29b-4d76-b35c-bb061e250cb6", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policy1" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.606Z", - "version": "WzMwODIsMV0=" - } -} - -exports['Token Repository getByPolicyId allow to find a token - create:tokens (2)'] = { - "results": { - "type": "tokens", - "id": "3284c93d-4975-4e43-8309-a43442b8527b", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.618Z", - "version": "WzMwODMsMV0=" - } -} - -exports['Token Repository getByPolicyId allow to find a token - find:"tokens" (4)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 1, - "saved_objects": [ - { - "type": "tokens", - "id": "3284c93d-4975-4e43-8309-a43442b8527b", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.618Z", - "version": "WzMwODMsMV0=" - } - ] - } -} - -exports['Token Repository getByPolicyId allow to find a token - getDecryptedAsInternalUser:tokens:3284c93d-4975-4e43-8309-a43442b8527b (5)'] = { - "results": { - "id": "3284c93d-4975-4e43-8309-a43442b8527b", - "type": "tokens", - "updated_at": "2019-10-16T23:25:01.618Z", - "version": "WzMwODMsMV0=", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "token": "notencryptedtoken", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [] - } -} - -exports['Token Repository getByPolicyId allow to find a token - find:"tokens" (6)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 3, - "saved_objects": [ - { - "type": "tokens", - "id": "e5eba5c0-1bd3-4ae1-9b3b-338d548320ce", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy123" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.606Z", - "version": "WzMwODEsMV0=" - }, - { - "type": "tokens", - "id": "2d87ed62-d29b-4d76-b35c-bb061e250cb6", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policy1" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.606Z", - "version": "WzMwODIsMV0=" - }, - { - "type": "tokens", - "id": "3284c93d-4975-4e43-8309-a43442b8527b", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [], - "updated_at": "2019-10-16T23:25:01.618Z", - "version": "WzMwODMsMV0=" - } - ] - } -} - -exports['Token Repository getByPolicyId allow to find a token - delete:tokens:e5eba5c0-1bd3-4ae1-9b3b-338d548320ce:{} (7)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId allow to find a token - delete:tokens:2d87ed62-d29b-4d76-b35c-bb061e250cb6:{} (8)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId allow to find a token - delete:tokens:3284c93d-4975-4e43-8309-a43442b8527b:{} (9)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId return null if the token does not exists - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "76098317-808d-49d7-9dd2-bfdf0fc639ac", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policy1" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.667Z", - "version": "WzMwODgsMV0=" - } -} - -exports['Token Repository getByPolicyId return null if the token does not exists - create:tokens (3)'] = { - "results": { - "type": "tokens", - "id": "28a7ac76-f0d3-4ba7-8597-ed5a9f09555a", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy123" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.667Z", - "version": "WzMwODcsMV0=" - } -} - -exports['Token Repository getByPolicyId return null if the token does not exists - create:tokens (2)'] = { - "results": { - "type": "tokens", - "id": "b3ce6080-90f5-425a-a23b-2424955b592d", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.679Z", - "version": "WzMwODksMV0=" - } -} - -exports['Token Repository getByPolicyId return null if the token does not exists - find:"tokens" (4)'] = { - "results": { - "page": 1, - "per_page": 20, - "total": 0, - "saved_objects": [] - } -} - -exports['Token Repository getByPolicyId return null if the token does not exists - find:"tokens" (5)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 3, - "saved_objects": [ - { - "type": "tokens", - "id": "28a7ac76-f0d3-4ba7-8597-ed5a9f09555a", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy123" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.667Z", - "version": "WzMwODcsMV0=" - }, - { - "type": "tokens", - "id": "b3ce6080-90f5-425a-a23b-2424955b592d", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "azerty", - "policy_id": "policy12" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.679Z", - "version": "WzMwODksMV0=" - }, - { - "type": "tokens", - "id": "76098317-808d-49d7-9dd2-bfdf0fc639ac", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty", - "policy_id": "policy1" - }, - "references": [], - "updated_at": "2019-10-16T23:25:05.667Z", - "version": "WzMwODgsMV0=" - } - ] - } -} - -exports['Token Repository getByPolicyId return null if the token does not exists - delete:tokens:28a7ac76-f0d3-4ba7-8597-ed5a9f09555a:{} (6)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId return null if the token does not exists - delete:tokens:b3ce6080-90f5-425a-a23b-2424955b592d:{} (7)'] = { - "results": {} -} - -exports['Token Repository getByPolicyId return null if the token does not exists - delete:tokens:76098317-808d-49d7-9dd2-bfdf0fc639ac:{} (8)'] = { - "results": {} -} - -exports['Token Repository delete allow to update a token - create:tokens (1)'] = { - "results": { - "type": "tokens", - "id": "aaeee067-1d36-4204-85c6-6eb1fa4d63d9", - "attributes": { - "active": true, - "type": "ACCESS_TOKEN", - "tokenHash": "qwerty" - }, - "references": [], - "updated_at": "2019-10-16T23:25:09.733Z", - "version": "WzMwOTMsMV0=" - } -} - -exports['Token Repository delete allow to update a token - delete:tokens:aaeee067-1d36-4204-85c6-6eb1fa4d63d9:{} (2)'] = { - "results": {} -} - -exports['Token Repository delete allow to update a token - get:tokens:aaeee067-1d36-4204-85c6-6eb1fa4d63d9:{} (3)'] = { - "results": null -} - -exports['Token Repository delete allow to update a token - find:"tokens" (4)'] = { - "results": { - "page": 1, - "per_page": 1000, - "total": 0, - "saved_objects": [] - } -} diff --git a/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.contract.test.ts b/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.contract.test.ts deleted file mode 100644 index 919f8b3c2214b..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.contract.test.ts +++ /dev/null @@ -1,233 +0,0 @@ -/* - * 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 { SavedObject } from 'src/core/server'; -import { TokensRepository } from './default'; -import { SODatabaseAdapter as SODatabaseAdapterType } from '../../adapters/saved_objects_database/adapter_types'; -import { SODatabaseAdapter } from '../../adapters/saved_objects_database/default'; -import { MemorizeSODatabaseAdapter } from '../../adapters/saved_objects_database/memorize_adapter'; -import { Token, TokenType } from './types'; -import { EncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/default'; -import { MemorizeEncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/memorize_adapter'; -import { FrameworkUser, internalAuthData } from '../../adapters/framework/adapter_types'; - -describe('Token Repository', () => { - let adapter: TokensRepository; - let soAdapter: SODatabaseAdapterType; - let encryptedSavedObject: EncryptedSavedObjects; - let servers: any; - - async function loadFixtures(tokens: any[]): Promise { - return await Promise.all(tokens.map(token => soAdapter.create(getUser(), 'tokens', token))); - } - - async function clearFixtures() { - const user = getUser(); - const { saved_objects: savedObjects } = await soAdapter.find(user, { - type: 'tokens', - perPage: 1000, - }); - for (const so of savedObjects) { - await soAdapter.delete(user, 'tokens', so.id); - } - } - - function getUser(): FrameworkUser { - return ({ - kind: 'authenticated', - [internalAuthData]: { - authorization: `Basic ${Buffer.from(`elastic:changeme`).toString('base64')}`, - }, - } as unknown) as FrameworkUser; - } - - beforeAll(async () => { - await Slapshot.callWhenOnline(async () => { - const { createKibanaServer } = await import( - '../../../../../../test_utils/jest/contract_tests/servers' - ); - servers = await createKibanaServer({ - security: { enabled: false }, - }); - const baseAdapter = new SODatabaseAdapter( - servers.kbnServer.savedObjects, - servers.kbnServer.plugins.elasticsearch - ); - soAdapter = new MemorizeSODatabaseAdapter(baseAdapter); - - const baseEncyrptedSOAdapter = new EncryptedSavedObjects( - servers.kbnServer.plugins.encrypted_saved_objects - ); - - encryptedSavedObject = (new MemorizeEncryptedSavedObjects( - baseEncyrptedSOAdapter - ) as unknown) as EncryptedSavedObjects; - }); - - if (!soAdapter) { - soAdapter = new MemorizeSODatabaseAdapter(); - } - if (!encryptedSavedObject) { - encryptedSavedObject = (new MemorizeEncryptedSavedObjects() as unknown) as EncryptedSavedObjects; - } - adapter = new TokensRepository(soAdapter, encryptedSavedObject); - }); - - afterAll(async () => { - if (servers) { - await servers.shutdown; - } - }); - - afterEach(clearFixtures); - - describe('create', () => { - it('allow to create a token', async () => { - const user = getUser(); - const token = await adapter.create(user, { - active: true, - type: TokenType.ACCESS_TOKEN, - token: 'notencryptedtoken', - tokenHash: 'qwerty', - policyId: 'policyId', - }); - const soToken = (await soAdapter.get(user, 'tokens', token.id)) as SavedObject; - expect(soToken).toBeDefined(); - expect(token.id).toBeDefined(); - - expect(soToken.attributes.token !== 'notencryptedtoken').toBe(true); - - expect(soToken.attributes).toMatchObject({ - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'qwerty', - }); - }); - }); - - describe('update', () => { - let tokenId: string; - beforeEach(async () => { - const tokens = await loadFixtures([ - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'qwerty', - policy_id: 'policyId', - }, - ]); - - tokenId = tokens[0].id; - }); - - it('allow to update a token', async () => { - const user = getUser(); - await adapter.update(user, tokenId, { - active: false, - token: 'notencryptedtoken', - }); - - const soToken = (await soAdapter.get(user, 'tokens', tokenId)) as SavedObject; - expect(soToken.attributes.token !== 'notencryptedtoken').toBe(true); - expect(soToken.attributes).toMatchObject({ - active: false, - }); - }); - }); - - describe('getByTokenHash', () => { - beforeEach(async () => { - await loadFixtures([ - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'qwerty', - }, - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'azerty', - }, - ]); - }); - - it('allow to find a token', async () => { - const user = getUser(); - const token = await adapter.getByTokenHash(user, 'azerty'); - expect(token).toBeDefined(); - expect((token as Token).tokenHash).toBe('azerty'); - }); - - it('return null if the token does not exists', async () => { - const user = getUser(); - const token = await adapter.getByTokenHash(user, 'idonotexists'); - expect(token).toBeNull(); - }); - }); - - describe('getByPolicyId', () => { - beforeEach(async () => { - await loadFixtures([ - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'qwerty', - policy_id: 'policy1', - }, - { - active: true, - type: TokenType.ACCESS_TOKEN, - token: 'notencryptedtoken', - tokenHash: 'azerty', - policy_id: 'policy12', - }, - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'azerty', - policy_id: 'policy123', - }, - ]); - }); - - it('allow to find a token', async () => { - const user = getUser(); - const token = await adapter.getByPolicyId(user, 'policy12'); - expect(token).toBeDefined(); - expect((token as Token).policy_id).toBe('policy12'); - expect((token as Token).token).toBe('notencryptedtoken'); - }); - - it('return null if the token does not exists', async () => { - const user = getUser(); - const token = await adapter.getByTokenHash(user, 'policy1234'); - expect(token).toBeNull(); - }); - }); - - describe('delete', () => { - let tokenId: string; - beforeEach(async () => { - const tokens = await loadFixtures([ - { - active: true, - type: TokenType.ACCESS_TOKEN, - tokenHash: 'qwerty', - }, - ]); - - tokenId = tokens[0].id; - }); - - it('allow to update a token', async () => { - const user = getUser(); - await adapter.delete(user, tokenId); - const soToken = await soAdapter.get(user, 'tokens', tokenId); - expect(soToken).toBeNull(); - }); - }); -}); diff --git a/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.ts b/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.ts deleted file mode 100644 index 1d6b590e8c59f..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/repositories/tokens/default.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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 moment from 'moment'; -import { SavedObject } from 'src/core/server'; -import { SODatabaseAdapter } from '../../adapters/saved_objects_database/adapter_types'; -import { TokenType, Token, TokensRepository as TokensRepositoryType } from './types'; -import { EncryptedSavedObjects } from '../../adapters/encrypted_saved_objects/default'; -import { FrameworkUser } from '../../adapters/framework/adapter_types'; - -const SAVED_OBJECT_TYPE = 'tokens'; - -function getFirstOrNull(list: Token[]) { - return list.length > 0 ? list[0] : null; -} - -/** - * Token adapter that persist tokens using saved objects - */ -export class TokensRepository implements TokensRepositoryType { - constructor( - private readonly soAdapter: SODatabaseAdapter, - private readonly encryptedSavedObject: EncryptedSavedObjects - ) {} - - public async create( - user: FrameworkUser, - { - type, - token, - tokenHash, - active, - policyId, - expire_at, - }: { - type: TokenType; - token: string; - tokenHash: string; - active: boolean; - expire_at?: string; - policyId: string; - } - ): Promise { - if (user.kind !== 'authenticated') { - throw new Error('Only authenticated can update tokens'); - } - const so = await this.soAdapter.create(user, SAVED_OBJECT_TYPE, { - created_at: moment().toISOString(), - type, - token, - tokenHash, - policy_id: policyId, - expire_at, - active, - enrollment_rules: [], - }); - - return { - id: so.id, - ...so.attributes, - }; - } - - public async getByTokenHash(user: FrameworkUser, tokenHash: string): Promise { - const res = await this.soAdapter.find(user, { - type: SAVED_OBJECT_TYPE, - searchFields: ['tokenHash'], - search: tokenHash, - }); - - const tokens = res.saved_objects.map(this._savedObjectToToken); - const token = getFirstOrNull(tokens); - return token ? await this._getDecrypted(token.id) : null; - } - - public async getByPolicyId(user: FrameworkUser, policyId: string): Promise { - const res = await this.soAdapter.find(user, { - type: SAVED_OBJECT_TYPE, - searchFields: ['policy_id'], - search: policyId, - }); - - const tokens = res.saved_objects.map(this._savedObjectToToken); - const token = getFirstOrNull(tokens); - - return token ? await this._getDecrypted(token.id) : null; - } - - public async update(user: FrameworkUser, id: string, newData: Partial): Promise { - if (user.kind !== 'authenticated') { - throw new Error('Only authenticated can update tokens'); - } - const { error } = await this.soAdapter.update(user, SAVED_OBJECT_TYPE, id, newData); - - if (error) { - throw new Error(error.message); - } - } - - public async delete(user: FrameworkUser, id: string): Promise { - await this.soAdapter.delete(user, SAVED_OBJECT_TYPE, id); - } - - private async _getDecrypted(tokenId: string) { - return this._savedObjectToToken( - await this.encryptedSavedObject.getDecryptedAsInternalUser(SAVED_OBJECT_TYPE, tokenId) - ); - } - - private _savedObjectToToken({ error, attributes, id }: SavedObject): Token { - if (error) { - throw new Error(error.message); - } - - return { - id, - ...attributes, - }; - } -} diff --git a/x-pack/legacy/plugins/fleet/server/repositories/tokens/memory.ts b/x-pack/legacy/plugins/fleet/server/repositories/tokens/memory.ts deleted file mode 100644 index e9b3783f48bba..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/repositories/tokens/memory.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 moment from 'moment'; -import { TokenType, Token, TokensRepository as TokensRepositoryType } from './types'; -import { FrameworkUser } from '../../adapters/framework/adapter_types'; - -/** - * Memory adapter for persisting tokens, for tests purposes only. - */ -export class MemoryTokensRepository implements TokensRepositoryType { - public tokens: { [k: string]: Token } = {}; - private tokenId = 1; - public async create( - user: FrameworkUser, - { - type, - tokenHash, - token, - active, - policyId, - expire_at, - }: { - type: TokenType; - token: string; - tokenHash: string; - active: boolean; - policyId: string; - expire_at?: string; - } - ): Promise { - const id = `tokens-${this.tokenId++}`; - this.tokens[id] = { - id, - active, - created_at: moment().toISOString(), - type, - token, - tokenHash, - expire_at, - policy_id: policyId, - enrollment_rules: [], - }; - - return this.tokens[id]; - } - - public async getByTokenHash(user: FrameworkUser, tokenHash: string): Promise { - return Object.values(this.tokens).find(t => t.tokenHash === tokenHash) || null; - } - - public async update(user: FrameworkUser, id: string, newData: Partial): Promise { - const token = this.tokens[id]; - - Object.assign(token, newData); - } - - public async getByPolicyId(user: FrameworkUser, policyId: string) { - return Object.values(this.tokens).find(t => t.policy_id === policyId) || null; - } - - public async delete(user: FrameworkUser, id: string): Promise { - delete this.tokens[id]; - } -} 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 3d1f2222a41ae..4bdb0e2a79974 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/agents/checkin.ts @@ -11,7 +11,6 @@ import { PathReporter } from 'io-ts/lib/PathReporter'; import { isLeft } from 'fp-ts/lib/Either'; import { FrameworkRequest } from '../../adapters/framework/adapter_types'; import { ReturnTypeCheckin } from '../../../common/return_types'; -import { TokenType } from '../../repositories/tokens/types'; import { RuntimeAgentEvent, AgentEvent } from '../../repositories/agent_events/types'; import { FleetServerLib } from '../../libs/types'; @@ -20,9 +19,6 @@ type CheckinRequest = FrameworkRequest<{ events: any[]; local_metadata: any; }; - headers: { - 'kbn-fleet-access-token': string; - }; params: { agentId: string; }; @@ -34,11 +30,6 @@ export const createCheckinAgentsRoute = (libs: FleetServerLib) => ({ config: { auth: false, validate: { - headers: Joi.object({ - 'kbn-fleet-access-token': Joi.string().required(), - }).options({ - allowUnknown: true, - }), payload: { events: Joi.array().required(), local_metadata: Joi.object().optional(), @@ -46,13 +37,9 @@ export const createCheckinAgentsRoute = (libs: FleetServerLib) => ({ }, }, handler: async (request: CheckinRequest): Promise => { - await validateToken(request, libs); const { events } = await validateAndDecodePayload(request); const { actions, policy } = await libs.agents.checkin( - { - kind: 'internal', - }, - request.params.agentId, + request.user, events, request.payload.local_metadata ); @@ -68,14 +55,6 @@ export const createCheckinAgentsRoute = (libs: FleetServerLib) => ({ }, }); -async function validateToken(request: CheckinRequest, libs: FleetServerLib) { - const jsonToken = request.headers['kbn-fleet-access-token']; - const token = await libs.tokens.verify(request.user, jsonToken); - if (!token.valid || token.type !== TokenType.ACCESS_TOKEN) { - throw Boom.unauthorized('Invalid token'); - } -} - async function validateAndDecodePayload( request: CheckinRequest ): Promise<{ events: AgentEvent[] }> { 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 b93c1e4951c68..22f0a4253d404 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/agents/enroll.ts @@ -16,11 +16,6 @@ export const createEnrollAgentsRoute = (libs: FleetServerLib) => ({ options: { auth: false, validate: { - headers: Joi.object({ - 'kbn-fleet-enrollment-token': Joi.string().required(), - }).options({ - allowUnknown: true, - }), payload: { shared_id: Joi.string().optional(), type: Joi.string() @@ -41,17 +36,13 @@ export const createEnrollAgentsRoute = (libs: FleetServerLib) => ({ metadata: { local: any; user_provided: any }; }; headers: { - 'kbn-fleet-enrollment-token': string; + authorization: string; }; }> ): Promise> => { - const enrollmentToken = request.headers['kbn-fleet-enrollment-token']; const { shared_id: sharedId, type, metadata } = request.payload; const agent = await libs.agents.enroll( - { - kind: 'internal', - }, - enrollmentToken, + request.user, type, metadata && { local: metadata.local, diff --git a/x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/index.ts b/x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/index.ts new file mode 100644 index 0000000000000..3de3a1dccf3d8 --- /dev/null +++ b/x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/index.ts @@ -0,0 +1,119 @@ +/* + * 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 * as Joi from 'joi'; +import Boom from 'boom'; +import { FrameworkRequest } from '../../adapters/framework/adapter_types'; +import { FleetServerLib } from '../../libs/types'; +import { DEFAULT_AGENTS_PAGE_SIZE } from '../../../common/constants'; +import { + ReturnTypeList, + ReturnTypeCreate, + ReturnTypeGet, + ReturnTypeDelete, +} from '../../../common/return_types'; +import { EnrollmentApiKey } from '../../../common/types/domain_data'; + +export const createGETEnrollmentApiKeysRoute = (libs: FleetServerLib) => ({ + method: 'GET', + path: '/api/fleet/enrollment-api-keys', + options: { + tags: ['access:fleet-read'], + validate: { + query: { + page: Joi.number().default(1), + perPage: Joi.number().default(DEFAULT_AGENTS_PAGE_SIZE), + showInactive: Joi.boolean().default(false), + kuery: Joi.string() + .trim() + .optional(), + }, + }, + }, + handler: async ( + request: FrameworkRequest<{ + query: { page: string; perPage: string; kuery: string; showInactive: string }; + }> + ): Promise> => { + const { items, total, page, perPage } = await libs.apiKeys.listEnrollmentApiKeys(request.user, { + page: parseInt(request.query.page, 10), + perPage: parseInt(request.query.perPage, 10), + kuery: request.query.kuery, + showInactive: Boolean(request.query.showInactive), + }); + + return { list: items, success: true, total, page, perPage }; + }, +}); + +export const createPOSTEnrollmentApiKeysRoute = (libs: FleetServerLib) => ({ + method: 'POST', + path: '/api/fleet/enrollment-api-keys', + options: { + tags: ['access:fleet-write'], + validate: { + payload: Joi.object({ + name: Joi.string().optional(), + policy_id: Joi.string().optional(), + expiration: Joi.string().optional(), + }), + }, + }, + handler: async ( + request: FrameworkRequest<{ + payload: { policy_id?: string; expiration?: string; name?: string }; + }> + ): Promise> => { + const data = { + name: request.payload.name, + expiration: request.payload.expiration, + policyId: request.payload.policy_id, + }; + const apiKey = await libs.apiKeys.generateEnrollmentApiKey(request.user, data); + + return { item: apiKey, success: true, action: 'created' }; + }, +}); + +export const createGETEnrollmentApiKeyRoute = (libs: FleetServerLib) => ({ + method: 'GET', + path: '/api/fleet/enrollment-api-keys/{keyId}', + options: { + tags: ['access:fleet-read'], + validate: {}, + }, + handler: async ( + request: FrameworkRequest<{ + params: { keyId: string }; + }> + ): Promise> => { + const apiKey = await libs.apiKeys.getEnrollmentApiKey(request.user, request.params.keyId); + + if (!apiKey) { + throw Boom.notFound('Api key not found'); + } + + return { item: apiKey, success: true }; + }, +}); + +export const createDELETEEnrollmentApiKeyRoute = (libs: FleetServerLib) => ({ + method: 'DELETE', + path: '/api/fleet/enrollment-api-keys/{keyId}', + options: { + tags: ['access:fleet-write'], + validate: {}, + }, + handler: async ( + request: FrameworkRequest<{ + params: { keyId: string }; + }> + ): Promise => { + await libs.apiKeys.deleteEnrollmentApiKey(request.user, request.params.keyId); + + return { action: 'deleted', success: true }; + }, +}); diff --git a/x-pack/legacy/plugins/fleet/server/routes/policy/rules.ts b/x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/rules.ts similarity index 58% rename from x-pack/legacy/plugins/fleet/server/routes/policy/rules.ts rename to x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/rules.ts index a9849f7268fc0..3addbc9df3970 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/policy/rules.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/enrollment_api_keys/rules.ts @@ -10,16 +10,16 @@ import { isLeft } from 'fp-ts/lib/Either'; import { FrameworkRequest } from '../../adapters/framework/adapter_types'; import { ReturnTypeList, ReturnTypeCreate, ReturnTypeDelete } from '../../../common/return_types'; import { FleetServerLib } from '../../libs/types'; -import { RuntimeEnrollmentRuleData } from '../../repositories/tokens/types'; +import { RuntimeEnrollmentRuleData } from '../../repositories/enrollment_api_keys/types'; export const createPostEnrollmentRulesRoute = (libs: FleetServerLib) => ({ method: 'POST', - path: '/api/policy/{policyId}/enrollment-rules', + path: '/api/fleet/enrollment-api-keys/{keyId}/enrollment-rules', config: {}, handler: async ( - request: FrameworkRequest<{ params: { policyId: string } }> + request: FrameworkRequest<{ params: { keyId: string } }> ): Promise> => { - const { policyId } = request.params; + const { keyId } = request.params; const result = RuntimeEnrollmentRuleData.decode(request.payload); if (isLeft(result)) { @@ -27,7 +27,7 @@ export const createPostEnrollmentRulesRoute = (libs: FleetServerLib) => ({ `Malformed request, action is invalid, (${PathReporter.report(result)})` ); } - const rule = await libs.tokens.addEnrollmentRuleForPolicy(request.user, policyId, result.right); + const rule = await libs.apiKeys.addEnrollmentRule(request.user, keyId, result.right); return { item: rule, success: true, action: 'created' }; }, @@ -35,37 +35,37 @@ export const createPostEnrollmentRulesRoute = (libs: FleetServerLib) => ({ export const createGetEnrollmentRulesRoute = (libs: FleetServerLib) => ({ method: 'GET', - path: '/api/policy/{policyId}/enrollment-rules', + path: '/api/fleet/enrollment-api-keys/{keyId}/enrollment-rules', config: {}, handler: async ( - request: FrameworkRequest<{ params: { policyId: string } }> + request: FrameworkRequest<{ params: { keyId: string } }> ): Promise> => { - const { policyId } = request.params; - const token = await libs.tokens.getEnrollmentTokenForPolicy(request.user, policyId); + const { keyId } = request.params; + const apiKey = await libs.apiKeys.getEnrollmentApiKey(request.user, keyId); - if (!token) { - throw Boom.notFound(`token not found for policy ${policyId}`); + if (!apiKey) { + throw Boom.notFound('Enrollement api key not found'); } return { - list: token.enrollment_rules, + list: apiKey.enrollment_rules, page: 1, - total: token.enrollment_rules.length, + total: apiKey.enrollment_rules.length, success: true, - perPage: token.enrollment_rules.length, + perPage: apiKey.enrollment_rules.length, }; }, }); export const createDeleteEnrollmentRuleRoute = (libs: FleetServerLib) => ({ method: 'DELETE', - path: '/api/policy/{policyId}/enrollment-rules/{ruleId}', + path: '/api/fleet/enrollment-api-keys/{keyId}/enrollment-rules/{ruleId}', config: {}, handler: async ( - request: FrameworkRequest<{ params: { policyId: string; ruleId: string } }> + request: FrameworkRequest<{ params: { keyId: string; ruleId: string } }> ): Promise => { - const { policyId, ruleId } = request.params; - await libs.tokens.deleteEnrollmentRuleForPolicy(request.user, policyId, ruleId); + const { keyId, ruleId } = request.params; + await libs.apiKeys.deleteEnrollmentRule(request.user, keyId, ruleId); return { success: true, diff --git a/x-pack/legacy/plugins/fleet/server/routes/init_api.ts b/x-pack/legacy/plugins/fleet/server/routes/init_api.ts index b67e99e0a6bf0..29a4e86fbe0da 100644 --- a/x-pack/legacy/plugins/fleet/server/routes/init_api.ts +++ b/x-pack/legacy/plugins/fleet/server/routes/init_api.ts @@ -9,7 +9,6 @@ import { createListAgentsRoute } from './agents/list'; import { createDeleteAgentsRoute } from './agents/delete'; import { createEnrollAgentsRoute } from './agents/enroll'; import { createCheckinAgentsRoute } from './agents/checkin'; -import { createGetEnrollmentTokenRoute } from './policy/tokens'; import { FleetServerLib } from '../libs/types'; import { HapiFrameworkAdapter } from '../adapters/framework/hapi_framework_adapter'; import { createAgentsAddActionRoute } from './agents/actions'; @@ -17,20 +16,25 @@ import { createDeleteEnrollmentRuleRoute, createGetEnrollmentRulesRoute, createPostEnrollmentRulesRoute, -} from './policy/rules'; +} from './enrollment_api_keys/rules'; import { createGETArtifactsRoute } from './artifacts'; import { createGETAgentEventsRoute } from './agents/events'; import { createGETInstallScript } from './install'; import { createGETAgentsRoute } from './agents/get'; import { createPOSTAgentsUnenrollRoute } from './agents/unenroll'; import { createPUTAgentsRoute } from './agents/put'; +import { + createGETEnrollmentApiKeysRoute, + createPOSTEnrollmentApiKeysRoute, + createDELETEEnrollmentApiKeyRoute, + createGETEnrollmentApiKeyRoute, +} from './enrollment_api_keys'; export function initRestApi(server: Server, libs: FleetServerLib) { const frameworkAdapter = new HapiFrameworkAdapter(server); createAgentsRoutes(frameworkAdapter, libs); - createTokensRoutes(frameworkAdapter, libs); - createPolicyEnrollmentRoutes(frameworkAdapter, libs); + createEnrollmentApiKeysRoutes(frameworkAdapter, libs); frameworkAdapter.registerRoute(createGETArtifactsRoute(libs)); frameworkAdapter.registerRoute(createGETInstallScript(libs)); @@ -48,11 +52,13 @@ function createAgentsRoutes(adapter: HapiFrameworkAdapter, libs: FleetServerLib) adapter.registerRoute(createGETAgentEventsRoute(libs)); } -function createTokensRoutes(adapter: HapiFrameworkAdapter, libs: FleetServerLib) { - adapter.registerRoute(createGetEnrollmentTokenRoute(libs)); -} +function createEnrollmentApiKeysRoutes(adapter: HapiFrameworkAdapter, libs: FleetServerLib) { + adapter.registerRoute(createGETEnrollmentApiKeysRoute(libs)); + adapter.registerRoute(createPOSTEnrollmentApiKeysRoute(libs)); + adapter.registerRoute(createDELETEEnrollmentApiKeyRoute(libs)); + adapter.registerRoute(createGETEnrollmentApiKeyRoute(libs)); -function createPolicyEnrollmentRoutes(adapter: HapiFrameworkAdapter, libs: FleetServerLib) { + // enrollment rules adapter.registerRoute(createDeleteEnrollmentRuleRoute(libs)); adapter.registerRoute(createGetEnrollmentRulesRoute(libs)); adapter.registerRoute(createPostEnrollmentRulesRoute(libs)); diff --git a/x-pack/legacy/plugins/fleet/server/routes/policy/tokens.ts b/x-pack/legacy/plugins/fleet/server/routes/policy/tokens.ts deleted file mode 100644 index 946356fdd6987..0000000000000 --- a/x-pack/legacy/plugins/fleet/server/routes/policy/tokens.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 * as Joi from 'joi'; -import Boom from 'boom'; - -import { FrameworkRequest } from '../../adapters/framework/adapter_types'; -import { ReturnTypeGet } from '../../../common/return_types'; -import { FleetServerLib } from '../../libs/types'; - -export const createGetEnrollmentTokenRoute = (libs: FleetServerLib) => ({ - method: 'GET', - path: '/api/fleet/policies/{policyId}/enrollment-tokens', - config: { - auth: false, - validate: { - query: Joi.object({ - regenerate: Joi.boolean().default(false), - }), - }, - }, - handler: async ( - request: FrameworkRequest<{ params: { policyId: string }; query: { regenerate: string } }> - ): Promise> => { - const { policyId } = request.params; - const token = await libs.tokens.getEnrollmentTokenForPolicy( - request.user, - policyId, - Boolean(request.query.regenerate) - ); - - if (!token) { - throw Boom.notFound(`token not found for policy ${policyId}`); - } - - return { item: token, success: true }; - }, -}); diff --git a/x-pack/test/api_integration/apis/fleet/agent_actions.ts b/x-pack/test/api_integration/apis/fleet/agents/actions.ts similarity index 95% rename from x-pack/test/api_integration/apis/fleet/agent_actions.ts rename to x-pack/test/api_integration/apis/fleet/agents/actions.ts index e34369172eb63..ab03c2755e74f 100644 --- a/x-pack/test/api_integration/apis/fleet/agent_actions.ts +++ b/x-pack/test/api_integration/apis/fleet/agents/actions.ts @@ -6,8 +6,8 @@ import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; -import { SecurityService } from '../../../common/services'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { SecurityService } from '../../../../common/services'; export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); @@ -35,7 +35,7 @@ export default function({ getService }: FtrProviderContext) { password: 'changeme', }, }; - describe('fleet_agent_actions', () => { + describe('fleet_agents_actions', () => { before(async () => { for (const roleName in users) { if (users.hasOwnProperty(roleName)) { diff --git a/x-pack/test/api_integration/apis/fleet/agent_checkin.ts b/x-pack/test/api_integration/apis/fleet/agents/checkin.ts similarity index 56% rename from x-pack/test/api_integration/apis/fleet/agent_checkin.ts rename to x-pack/test/api_integration/apis/fleet/agents/checkin.ts index 3fd10ac49d96f..578f5dcec2a12 100644 --- a/x-pack/test/api_integration/apis/fleet/agent_checkin.ts +++ b/x-pack/test/api_integration/apis/fleet/agents/checkin.ts @@ -5,19 +5,48 @@ */ import expect from '@kbn/expect'; +import uuid from 'uuid'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { getSupertestWithoutAuth } from './services'; -const VALID_ACCESS_TOKEN = - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiQUNDRVNTX1RPS0VOIiwiYWdlbnRJZCI6ImIzNWQ2ZDIwLWQwYTAtMTFlOS1iNTkwLThiMGEzYWY4NzUwZCIsImNvbmZpZyI6eyJpZCI6ImNvbmZpZzEiLCJzaGFyZWRJZCI6ImNvbmZpZzEifSwiaWF0IjoxNTY3NzcyNDIzfQ.UQJjI9Ki6JL3iX6zMGhd-LFZynq8a6-Fti1qcq9poFQ'; - -export default function({ getService }: FtrProviderContext) { +export default function(providerContext: FtrProviderContext) { + const { getService } = providerContext; const esArchiver = getService('esArchiver'); - const supertest = getService('supertest'); + const esClient = getService('es'); + + const supertest = getSupertestWithoutAuth(providerContext); + let apiKey: { id: string; api_key: string }; - describe('fleet_agent_checkin', () => { + describe('fleet_agents_checkin', () => { before(async () => { await esArchiver.loadIfNeeded('fleet/agents'); + const options = { + method: 'POST', + path: '/_security/api_key', + body: { + name: `test access api key: ${uuid.v4()}`, + }, + }; + + // @ts-ignore + apiKey = await esClient.transport.request(options); + const { _source: agentDoc } = await esClient.get({ + index: '.kibana', + id: 'agents:agent1', + type: '_doc', + }); + // @ts-ignore + agentDoc.agents.access_api_key_id = apiKey.id; + await esClient.update({ + index: '.kibana', + id: 'agents:agent1', + type: '_doc', + body: { + doc: agentDoc, + }, + refresh: true, + }); }); after(async () => { await esArchiver.unload('fleet/agents'); @@ -27,7 +56,7 @@ export default function({ getService }: FtrProviderContext) { await supertest .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') - .set('kbn-fleet-access-token', 'i-am-not-a-valid-token') + .set('Authorization', 'ApiKey NOT_A_VALID_TOKEN') .send({ events: [], }) @@ -38,7 +67,10 @@ export default function({ getService }: FtrProviderContext) { await supertest .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') - .set('kbn-fleet-access-token', VALID_ACCESS_TOKEN) + .set( + 'Authorization', + `ApiKey ${Buffer.from(`${apiKey.id}:${apiKey.api_key}`).toString('base64')}` + ) .send({ events: ['i-am-not-valid-event'], metadata: {}, @@ -50,7 +82,10 @@ export default function({ getService }: FtrProviderContext) { const { body: apiResponse } = await supertest .post(`/api/fleet/agents/agent1/checkin`) .set('kbn-xsrf', 'xx') - .set('kbn-fleet-access-token', VALID_ACCESS_TOKEN) + .set( + 'Authorization', + `ApiKey ${Buffer.from(`${apiKey.id}:${apiKey.api_key}`).toString('base64')}` + ) .send({ events: [ { diff --git a/x-pack/test/api_integration/apis/fleet/enroll_agent.ts b/x-pack/test/api_integration/apis/fleet/agents/enroll.ts similarity index 53% rename from x-pack/test/api_integration/apis/fleet/enroll_agent.ts rename to x-pack/test/api_integration/apis/fleet/agents/enroll.ts index df6fc671d0905..9493805eb81da 100644 --- a/x-pack/test/api_integration/apis/fleet/enroll_agent.ts +++ b/x-pack/test/api_integration/apis/fleet/agents/enroll.ts @@ -5,16 +5,51 @@ */ import expect from '@kbn/expect'; +import uuid from 'uuid'; +import * as legacyElasticsearch from 'elasticsearch'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { getSupertestWithoutAuth } from './services'; + +export default function(providerContext: FtrProviderContext) { + const { getService } = providerContext; -export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const supertest = getService('supertest'); + const esClient = getService('es') as legacyElasticsearch.Client; + + const supertest = getSupertestWithoutAuth(providerContext); + let apiKey: { id: string; api_key: string }; - describe('fleet_enroll_agent', () => { + describe('fleet_agents_enroll', () => { before(async () => { await esArchiver.loadIfNeeded('fleet/agents'); + + const options = { + method: 'POST', + path: '/_security/api_key', + body: { + name: `test enrollment api key: ${uuid.v4()}`, + }, + }; + + // @ts-ignore + apiKey = await esClient.transport.request(options); + const { _source: enrollmentApiKeyDoc } = await esClient.get({ + index: '.kibana', + id: 'enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0', + type: '_doc', + }); + // @ts-ignore + enrollmentApiKeyDoc.enrollment_api_keys.api_key_id = apiKey.id; + await esClient.update({ + index: '.kibana', + id: 'enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0', + type: '_doc', + body: { + doc: enrollmentApiKeyDoc, + }, + refresh: true, + }); }); after(async () => { await esArchiver.unload('fleet/agents'); @@ -24,7 +59,7 @@ export default function({ getService }: FtrProviderContext) { const { body: apiResponse } = await supertest .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') - .set('kbn-fleet-enrollment-token', 'NotavalidJSONTOKEN') + .set('Authorization', 'ApiKey NOTAVALIDKEY') .send({ type: 'PERMANENT', metadata: { @@ -34,7 +69,7 @@ export default function({ getService }: FtrProviderContext) { }) .expect(401); - expect(apiResponse.message).to.match(/Enrollment token is not valid/); + expect(apiResponse.message).to.match(/Enrollment apiKey is not valid:/); }); it('should not allow to enroll an agent with a shared id if it already exists ', async () => { @@ -42,8 +77,8 @@ export default function({ getService }: FtrProviderContext) { .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( - 'kbn-fleet-enrollment-token', - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiRU5ST0xMTUVOVF9UT0tFTiIsInBvbGljeV9pZCI6InBvbGljeToxIiwiaWF0IjoxNTcwNzI1MDcyfQ.H41P_J2wsjfeZDOEAMYPj9TMRhCsUY3NZoLGZ9VQWpg' + 'authorization', + `ApiKey ${Buffer.from(`${apiKey.id}:${apiKey.api_key}`).toString('base64')}` ) .send({ shared_id: 'agent2_filebeat', @@ -62,8 +97,8 @@ export default function({ getService }: FtrProviderContext) { .post(`/api/fleet/agents/enroll`) .set('kbn-xsrf', 'xxx') .set( - 'kbn-fleet-enrollment-token', - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiRU5ST0xMTUVOVF9UT0tFTiIsInBvbGljeV9pZCI6InBvbGljeToxIiwiaWF0IjoxNTcwNzI1MDcyfQ.H41P_J2wsjfeZDOEAMYPj9TMRhCsUY3NZoLGZ9VQWpg' + 'Authorization', + `ApiKey ${Buffer.from(`${apiKey.id}:${apiKey.api_key}`).toString('base64')}` ) .send({ type: 'PERMANENT', @@ -74,7 +109,7 @@ export default function({ getService }: FtrProviderContext) { }) .expect(200); expect(apiResponse.success).to.eql(true); - expect(apiResponse.item).to.have.keys('id', 'active', 'access_token', 'type', 'policy_id'); + expect(apiResponse.item).to.have.keys('id', 'active', 'access_api_key', 'type', 'policy_id'); }); }); } diff --git a/x-pack/test/api_integration/apis/fleet/agent_events.ts b/x-pack/test/api_integration/apis/fleet/agents/events.ts similarity index 91% rename from x-pack/test/api_integration/apis/fleet/agent_events.ts rename to x-pack/test/api_integration/apis/fleet/agents/events.ts index b6a2404a9a0bf..f386afdb6b03d 100644 --- a/x-pack/test/api_integration/apis/fleet/agent_events.ts +++ b/x-pack/test/api_integration/apis/fleet/agents/events.ts @@ -6,13 +6,13 @@ import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../../../ftr_provider_context'; export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); - describe('fleet_agent_events', () => { + describe('fleet_agents_events', () => { before(async () => { await esArchiver.loadIfNeeded('fleet/agents'); }); diff --git a/x-pack/test/api_integration/apis/fleet/agents/services.ts b/x-pack/test/api_integration/apis/fleet/agents/services.ts new file mode 100644 index 0000000000000..76f663c572c6c --- /dev/null +++ b/x-pack/test/api_integration/apis/fleet/agents/services.ts @@ -0,0 +1,19 @@ +/* + * 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 supertestAsPromised from 'supertest-as-promised'; +import url from 'url'; + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export function getSupertestWithoutAuth({ getService }: FtrProviderContext) { + const config = getService('config'); + const kibanaUrl = config.get('servers.kibana'); + kibanaUrl.auth = null; + kibanaUrl.password = null; + + return supertestAsPromised(url.format(kibanaUrl)); +} diff --git a/x-pack/test/api_integration/apis/fleet/enrollment_api_keys/crud.ts b/x-pack/test/api_integration/apis/fleet/enrollment_api_keys/crud.ts new file mode 100644 index 0000000000000..9f6cee1a84a15 --- /dev/null +++ b/x-pack/test/api_integration/apis/fleet/enrollment_api_keys/crud.ts @@ -0,0 +1,81 @@ +/* + * 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 expect from '@kbn/expect'; + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +const ENROLLMENT_KEY_ID = 'ed22ca17-e178-4cfe-8b02-54ea29fbd6d0'; + +export default function({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const supertest = getService('supertest'); + + describe('fleet_enrollment_api_keys_crud', () => { + before(async () => { + await esArchiver.loadIfNeeded('fleet/agents'); + }); + after(async () => { + await esArchiver.unload('fleet/agents'); + }); + describe('GET /fleet/enrollment-api-keys', async () => { + it('should list existing api keys', async () => { + const { body: apiResponse } = await supertest + .get(`/api/fleet/enrollment-api-keys`) + .expect(200); + + expect(apiResponse.total).to.be(1); + expect(apiResponse.list[0]).to.have.keys('id', 'api_key_id', 'name'); + }); + }); + + describe('GET /fleet/enrollment-api-keys/{id}', async () => { + it('should allow to retrieve existing api keys', async () => { + const { body: apiResponse } = await supertest + .get(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}`) + .expect(200); + + expect(apiResponse.item).to.have.keys('id', 'api_key_id', 'name'); + }); + }); + + describe('GET /fleet/enrollment-api-keys/{id}', async () => { + it('should allow to retrieve existing api keys', async () => { + const { body: apiResponse } = await supertest + .delete(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}`) + .set('kbn-xsrf', 'xxx') + .expect(200); + + expect(apiResponse.success).to.eql(true); + }); + }); + + describe('POST /fleet/enrollment-api-keys', () => { + it('should not accept bad parameters', async () => { + await supertest + .post(`/api/fleet/enrollment-api-keys`) + .set('kbn-xsrf', 'xxx') + .send({ + raoul: 'raoul', + }) + .expect(400); + }); + + it('should allow to create an enrollment api key with a policy', async () => { + const { body: apiResponse } = await supertest + .post(`/api/fleet/enrollment-api-keys`) + .set('kbn-xsrf', 'xxx') + .send({ + policy_id: 'policy1', + }) + .expect(200); + + expect(apiResponse.success).to.eql(true); + expect(apiResponse.item).to.have.keys('id', 'api_key', 'api_key_id', 'name', 'policy_id'); + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/fleet/enrollment_rules.ts b/x-pack/test/api_integration/apis/fleet/enrollment_api_keys/rules.ts similarity index 65% rename from x-pack/test/api_integration/apis/fleet/enrollment_rules.ts rename to x-pack/test/api_integration/apis/fleet/enrollment_api_keys/rules.ts index 9d4ec29c7092b..98b8de7ae9ce3 100644 --- a/x-pack/test/api_integration/apis/fleet/enrollment_rules.ts +++ b/x-pack/test/api_integration/apis/fleet/enrollment_api_keys/rules.ts @@ -6,13 +6,15 @@ import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +const ENROLLMENT_KEY_ID = 'ed22ca17-e178-4cfe-8b02-54ea29fbd6d0'; export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); - describe('fleet_enrollment_rules', () => { + describe('fleet_enrollment_api_keys_rules', () => { before(async () => { await esArchiver.loadIfNeeded('fleet/agents'); }); @@ -20,9 +22,9 @@ export default function({ getService }: FtrProviderContext) { await esArchiver.unload('fleet/agents'); }); - it('should return enrollment rules for a policy', async () => { + it('should return enrollment rules for an api key', async () => { const { body: apiResponse } = await supertest - .get(`/api/policy/policy:1/enrollment-rules`) + .get(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}/enrollment-rules`) .expect(200); expect(apiResponse.success).to.be(true); @@ -30,9 +32,9 @@ export default function({ getService }: FtrProviderContext) { expect(apiResponse.list.length).to.be(1); }); - it('should add enrollment rules for a policy', async () => { + it('should add enrollment rules for an api key', async () => { const { body: apiResponse } = await supertest - .post(`/api/policy/policy:1/enrollment-rules`) + .post(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}/enrollment-rules`) .set('kbn-xsrf', 'xxx') .send({ types: ['PERMANENT'], @@ -42,9 +44,9 @@ export default function({ getService }: FtrProviderContext) { expect(apiResponse.item).to.have.key(['id', 'created_at', 'types']); }); - it('should delete an enrollment rules for a policy', async () => { + it('should delete an enrollment rules for an api key', async () => { const { body: apiResponse } = await supertest - .delete(`/api/policy/policy:1/enrollment-rules/rule:1`) + .delete(`/api/fleet/enrollment-api-keys/${ENROLLMENT_KEY_ID}/enrollment-rules/rule:1`) .set('kbn-xsrf', 'xxx') .expect(200); diff --git a/x-pack/test/api_integration/apis/fleet/get_enrollment_token.ts b/x-pack/test/api_integration/apis/fleet/get_enrollment_token.ts deleted file mode 100644 index 013294b8b9c1d..0000000000000 --- a/x-pack/test/api_integration/apis/fleet/get_enrollment_token.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 expect from '@kbn/expect'; - -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function({ getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); - const supertest = getService('supertest'); - - describe('fleet_get_tokens', () => { - before(async () => { - await esArchiver.loadIfNeeded('fleet/agents'); - }); - after(async () => { - await esArchiver.unload('fleet/agents'); - }); - - it('should allow to get an enrollment token', async () => { - const { body: apiResponse } = await supertest - .get(`/api/fleet/policies/policy:1/enrollment-tokens?regenerate=false`) - .expect(200); - - expect(apiResponse.success).to.eql(true); - expect(apiResponse.item).to.have.keys('id', 'type', 'token', 'type', 'policy_id'); - }); - - it('should allow to regenerate an enrollment token', async () => { - const { body: apiResponse } = await supertest - .get(`/api/fleet/policies/policy:1/enrollment-tokens?regenerate=true`) - .expect(200); - - expect(apiResponse.success).to.eql(true); - expect(apiResponse.item).to.have.keys('id', 'type', 'token', 'type', 'policy_id'); - }); - }); -} diff --git a/x-pack/test/api_integration/apis/fleet/index.js b/x-pack/test/api_integration/apis/fleet/index.js index 722ae4fc3f645..b46375f297c3c 100644 --- a/x-pack/test/api_integration/apis/fleet/index.js +++ b/x-pack/test/api_integration/apis/fleet/index.js @@ -8,13 +8,12 @@ export default function loadTests({ loadTestFile }) { describe('Fleet Endpoints', () => { loadTestFile(require.resolve('./delete_agent')); loadTestFile(require.resolve('./list_agent')); - loadTestFile(require.resolve('./enroll_agent')); - loadTestFile(require.resolve('./unenroll_agent')); - loadTestFile(require.resolve('./agent_checkin')); - loadTestFile(require.resolve('./agent_actions')); - loadTestFile(require.resolve('./agent_events')); - loadTestFile(require.resolve('./enrollment_rules')); - loadTestFile(require.resolve('./get_enrollment_token')); + loadTestFile(require.resolve('./agents/enroll')); + loadTestFile(require.resolve('./agents/checkin')); + loadTestFile(require.resolve('./agents/actions')); + loadTestFile(require.resolve('./agents/events')); + loadTestFile(require.resolve('./enrollment_api_keys/crud')); + loadTestFile(require.resolve('./enrollment_api_keys/rules')); loadTestFile(require.resolve('./artifacts')); loadTestFile(require.resolve('./install')); }); diff --git a/x-pack/test/api_integration/config.js b/x-pack/test/api_integration/config.js index 64a9cafca406a..ba7e0a601034f 100644 --- a/x-pack/test/api_integration/config.js +++ b/x-pack/test/api_integration/config.js @@ -7,7 +7,9 @@ import { services } from './services'; export async function getApiIntegrationConfig({ readConfigFile }) { - const xPackFunctionalTestsConfig = await readConfigFile(require.resolve('../functional/config.js')); + const xPackFunctionalTestsConfig = await readConfigFile( + require.resolve('../functional/config.js') + ); return { testFiles: [require.resolve('./apis')], @@ -28,7 +30,8 @@ export async function getApiIntegrationConfig({ readConfigFile }) { ...xPackFunctionalTestsConfig.get('esTestCluster'), serverArgs: [ ...xPackFunctionalTestsConfig.get('esTestCluster.serverArgs'), - 'node.attr.name=apiIntegrationTestNode' + 'node.attr.name=apiIntegrationTestNode', + 'xpack.security.authc.api_key.enabled=true', ], }, }; diff --git a/x-pack/test/functional/es_archives/fleet/agents/data.json b/x-pack/test/functional/es_archives/fleet/agents/data.json index ee4b7cb34b4cc..ea6fca6e6c5e5 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -6,7 +6,7 @@ "source": { "type": "agents", "agents": { - "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiQUNDRVNTX1RPS0VOIiwiYWdlbnRJZCI6ImIzNWQ2ZDIwLWQwYTAtMTFlOS1iNTkwLThiMGEzYWY4NzUwZCIsImNvbmZpZyI6eyJpZCI6ImNvbmZpZzEiLCJzaGFyZWRJZCI6ImNvbmZpZzEifSwiaWF0IjoxNTY3NzcyNDIzfQ.UQJjI9Ki6JL3iX6zMGhd-LFZynq8a6-Fti1qcq9poFQ", + "access_api_key_id": "api-key-2", "active": true, "shared_id": "agent1_filebeat", "policy_id": "1", @@ -37,7 +37,7 @@ "source": { "type": "agents", "agents": { - "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI", + "access_api_key_id": "api-key-2", "active": true, "shared_id": "agent2_filebeat", "type": "PERMANENT", @@ -57,7 +57,7 @@ "source": { "type": "agents", "agents": { - "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI", + "access_api_key_id": "api-key-3", "active": true, "shared_id": "agent3_metricbeat", "type": "PERMANENT", @@ -77,7 +77,7 @@ "source": { "type": "agents", "agents": { - "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI", + "access_api_key_id": "api-key-4", "active": true, "shared_id": "agent4_metricbeat", "type": "PERMANENT", @@ -92,14 +92,13 @@ { "type": "doc", "value": { - "id": "tokens:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0", + "id": "enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0", "index": ".kibana", "source": { - "tokens" : { + "enrollment_api_keys" : { "created_at" : "2019-10-10T16:31:12.518Z", - "type" : "ENROLLMENT_TOKEN", - "token" : "RQVHuNv3+KS82GnUHjgjdQFhJ8GOMBa5qMnfYEYdfalg5JChSAUmZNxt8rK9WQTEvQmoXCcoRgJK/4/vfmF8W0bZyTPlm8vVdci53nz03L2bfSlYExZ+0Dbjc+8e04DWQP06Qu+3Nx0OmDDRvRjTdJkrnz+xayHH0pZ7M3mjEd5gO7GBdn6OgM/J0kgqPCJEkKk4uxqu7PieX7miyYX9+paDcmuSMrWf83l43ocreWxXLlhZKFhHL2ed2thr4zixD/2Y+1j3WSWXsU5cIBfOeyfw8DLd0+ssLWPZue9MKqLfwvz4vuhDHFzFeIyYq3/8pRKZ7vmixDh0npy3m1QiHT0LFj8mAG/Fwg==", - "tokenHash" : "911e4ef197d476522e8fe65f3790cc39061a828924b1f9cfc9b16e5ed5e261ea84d4b1dc5319ced5cca7510ec360f2af3b048403dac133cfca90ea23da0d6db4", + "name": "FleetEnrollmentKey:1", + "api_key_id" : "key", "policy_id" : "policy:1", "active" : true, "enrollment_rules" : [{ @@ -108,7 +107,7 @@ "created_at" : "2019-09-20T01:57:50.986Z" }] }, - "type" : "tokens", + "type" : "enrollment_api_keys", "references": [] } } diff --git a/x-pack/test/functional/es_archives/fleet/agents/mappings.json b/x-pack/test/functional/es_archives/fleet/agents/mappings.json index f171f44edb727..65afe106fb313 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/mappings.json +++ b/x-pack/test/functional/es_archives/fleet/agents/mappings.json @@ -7,77 +7,107 @@ "index": ".kibana_1", "mappings": { "dynamic": "strict", + "_meta": { + "migrationMappingPropertyHashes": { + "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", + "server": "ec97f1c5da1a19609a60874e5af1100c", + "visualization": "52d7a13ad68a150c4525b292d23e12cc", + "code-repo": "d9191830f108c2687e809ad6817383c2", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", + "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", + "inputs": "996d4a57458106ecefe8072027c0020c", + "policies": "9eea0f300ed714bb4b25737aa26fa053", + "type": "2f4316de49999235636386fe51dc06c1", + "lens": "21c3ea0763beb1ecb0162529706b88c5", + "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", + "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "181661168bbadd1eff5902361e2a0d5c", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", + "map": "23d7aa4a720d4938ccde3983f87bd58d", + "dashboard": "d00f614b29a80360e1190193fd333bab", + "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", + "apm-telemetry": "07ee1939fa4302c62ddc052ec03fed90", + "siem-ui-timeline": "1f6f0860ad7bc0dba3e42467ca40470d", + "agent_events": "8060c5567d33f6697164e1fd5c81b8ed", + "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "agents": "1c8e942384219bd899f381fd40e407d7", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "inventory-view": "84b320fd67209906333ffce261128462", + "enrollment_api_keys": "ed5d54fb0e7003d445f62c46820a7d25", + "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", + "index-pattern": "66eccb05066c5a89924f48a9e9736499", + "canvas-element": "7390014e1091044523666d97247392fc", + "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", + "namespace": "2f4316de49999235636386fe51dc06c1", + "telemetry": "e1c8bc94e443aefd9458932cc0697a4d", + "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "config": "87aca8fdb053154f11383fce3dbf3edf", + "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", + "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327" + } + }, "properties": { - "updated_at": { - "type": "date" - }, - "type": { - "type": "keyword" - }, - "references": { - "type": "nested", + "agent_events": { "properties": { - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "id": { + "agent_id": { "type": "keyword" - } - } - }, - "tokens": { - "properties": { - "active": { - "type": "boolean" }, - "policy_id": { - "type": "keyword" + "data": { + "type": "text" }, - "created_at": { - "type": "date" + "message": { + "type": "text" }, - "expire_at": { - "type": "date" + "payload": { + "type": "text" }, - "tokenHash": { + "subtype": { "type": "keyword" }, - "token": { - "type": "binary" + "timestamp": { + "type": "date" }, "type": { "type": "keyword" - }, - "enrollment_rules": { - "type": "nested", - "properties": { - "id": { "type": "keyword" }, - "ip_ranges": { "type": "keyword" }, - "window_duration": { - "type": "nested", - "properties": { "from": { "type": "date" }, "to": { "type": "date" } } - }, - "types": { "type": "keyword" }, - "created_at": { "type": "date" }, - "updated_at": { "type": "date" } - } } } }, "agents": { "properties": { - "access_token": { + "access_api_key_id": { "type": "keyword" }, + "actions": { + "type": "nested", + "properties": { + "created_at": { + "type": "date" + }, + "data": { + "type": "text" + }, + "id": { + "type": "keyword" + }, + "sent_at": { + "type": "date" + }, + "type": { + "type": "keyword" + } + } + }, "active": { "type": "boolean" }, - "policy_id": { - "type": "keyword" - }, "enrolled_at": { "type": "date" }, @@ -90,120 +120,1266 @@ "local_metadata": { "type": "text" }, + "policy_id": { + "type": "keyword" + }, "shared_id": { "type": "keyword" }, "type": { "type": "keyword" }, + "updated_at": { + "type": "date" + }, "user_provided_metadata": { "type": "text" }, "version": { "type": "keyword" + } + } + }, + "apm-telemetry": { + "properties": { + "has_any_services": { + "type": "boolean" }, - "actions": { - "type": "nested", + "services_per_agent": { "properties": { - "id": { "type": "keyword" }, - "type": { "type": "keyword" }, - "data": { "type": "text" }, - "sent_at": { "type": "date" }, - "created_at": { "type": "date" } + "dotnet": { + "type": "long", + "null_value": 0 + }, + "go": { + "type": "long", + "null_value": 0 + }, + "java": { + "type": "long", + "null_value": 0 + }, + "js-base": { + "type": "long", + "null_value": 0 + }, + "nodejs": { + "type": "long", + "null_value": 0 + }, + "python": { + "type": "long", + "null_value": 0 + }, + "ruby": { + "type": "long", + "null_value": 0 + }, + "rum-js": { + "type": "long", + "null_value": 0 + } } } } }, - "agent_events": { + "canvas-element": { + "dynamic": "false", "properties": { - "created_at": { + "@created": { "type": "date" }, - "type": { - "type": "keyword" + "@timestamp": { + "type": "date" }, - "agent_id": { - "type": "keyword" + "content": { + "type": "text" }, - "subtype": { - "type": "keyword" + "help": { + "type": "text" }, - "timestamp": { + "image": { + "type": "text" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + }, + "canvas-workpad": { + "dynamic": "false", + "properties": { + "@created": { "type": "date" }, - "message": { + "@timestamp": { + "type": "date" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + }, + "code-repo": { + "properties": { + "uri": { + "type": "keyword" + } + } + }, + "config": { + "dynamic": "true", + "properties": { + "buildNum": { + "type": "keyword" + } + } + }, + "dashboard": { + "properties": { + "description": { "type": "text" }, - "payload": { + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "optionsJSON": { "type": "text" }, - "data": { + "panelsJSON": { + "type": "text" + }, + "refreshInterval": { + "properties": { + "display": { + "type": "keyword" + }, + "pause": { + "type": "boolean" + }, + "section": { + "type": "integer" + }, + "value": { + "type": "integer" + } + } + }, + "timeFrom": { + "type": "keyword" + }, + "timeRestore": { + "type": "boolean" + }, + "timeTo": { + "type": "keyword" + }, + "title": { "type": "text" + }, + "version": { + "type": "integer" } } }, - "policies": { + "enrollment_api_keys": { "properties": { - "agent_version": { - "type": "keyword" + "active": { + "type": "boolean" }, - "created_by": { - "type": "keyword" + "api_key": { + "type": "binary" }, - "created_on": { + "api_key_id": { "type": "keyword" }, - "data_sources": { + "created_at": { + "type": "date" + }, + "enrollment_rules": { + "type": "nested", "properties": { - "inputs": { - "type": "keyword" - }, - "meta": { - "type": "keyword" + "created_at": { + "type": "date" }, - "output": { + "id": { "type": "keyword" }, - "policy": { + "ip_ranges": { "type": "keyword" }, - "policy_id": { + "types": { "type": "keyword" }, - "queue": { - "type": "keyword" + "updated_at": { + "type": "date" }, - "uuid": { - "type": "keyword" + "window_duration": { + "type": "nested", + "properties": { + "from": { + "type": "date" + }, + "to": { + "type": "date" + } + } } } }, + "expire_at": { + "type": "date" + }, + "name": { + "type": "keyword" + }, + "policy_id": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + } + } + }, + "file-upload-telemetry": { + "properties": { + "filesUploadedTotalCount": { + "type": "long" + } + } + }, + "graph-workspace": { + "properties": { "description": { "type": "text" }, - "id": { + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "numLinks": { + "type": "integer" + }, + "numVertices": { + "type": "integer" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "wsState": { + "type": "text" + } + } + }, + "index-pattern": { + "properties": { + "fieldFormatMap": { + "type": "text" + }, + "fields": { + "type": "text" + }, + "intervalName": { "type": "keyword" }, - "monitoring_enabled": { + "notExpandable": { "type": "boolean" }, - "name": { + "sourceFilters": { "type": "text" }, - "shared_id": { + "timeFieldName": { "type": "keyword" }, - "status": { + "title": { + "type": "text" + }, + "type": { "type": "keyword" }, - "updated_by": { + "typeMeta": { "type": "keyword" + } + } + }, + "infrastructure-ui-source": { + "properties": { + "description": { + "type": "text" }, - "updated_on": { + "fields": { + "properties": { + "container": { + "type": "keyword" + }, + "host": { + "type": "keyword" + }, + "pod": { + "type": "keyword" + }, + "tiebreaker": { + "type": "keyword" + }, + "timestamp": { + "type": "keyword" + } + } + }, + "logAlias": { "type": "keyword" }, - "version": { - "type": "integer" + "logColumns": { + "type": "nested", + "properties": { + "fieldColumn": { + "properties": { + "field": { + "type": "keyword" + }, + "id": { + "type": "keyword" + } + } + }, + "messageColumn": { + "properties": { + "id": { + "type": "keyword" + } + } + }, + "timestampColumn": { + "properties": { + "id": { + "type": "keyword" + } + } + } + } + }, + "metricAlias": { + "type": "keyword" + }, + "name": { + "type": "text" + } + } + }, + "inputs": { + "properties": { + "data_source_id": { + "type": "keyword" + }, + "other": { + "type": "text" + } + } + }, + "inventory-view": { + "properties": { + "autoBounds": { + "type": "boolean" + }, + "autoReload": { + "type": "boolean" + }, + "boundsOverride": { + "properties": { + "max": { + "type": "integer" + }, + "min": { + "type": "integer" + } + } + }, + "customOptions": { + "type": "nested", + "properties": { + "field": { + "type": "keyword" + }, + "text": { + "type": "keyword" + } + } + }, + "filterQuery": { + "properties": { + "expression": { + "type": "keyword" + }, + "kind": { + "type": "keyword" + } + } + }, + "groupBy": { + "type": "nested", + "properties": { + "field": { + "type": "keyword" + }, + "label": { + "type": "keyword" + } + } + }, + "metric": { + "properties": { + "type": { + "type": "keyword" + } + } + }, + "name": { + "type": "keyword" + }, + "nodeType": { + "type": "keyword" + }, + "time": { + "type": "integer" + }, + "view": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" + }, + "optOutCount": { + "type": "long" + } + } + }, + "lens": { + "properties": { + "expression": { + "type": "keyword", + "index": false + }, + "state": { + "type": "flattened" + }, + "title": { + "type": "text" + }, + "visualizationType": { + "type": "keyword" + } + } + }, + "lens-ui-telemetry": { + "properties": { + "count": { + "type": "integer" + }, + "date": { + "type": "date" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + } + }, + "map": { + "properties": { + "bounds": { + "type": "geo_shape" + }, + "description": { + "type": "text" + }, + "layerListJSON": { + "type": "text" + }, + "mapStateJSON": { + "type": "text" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "maps-telemetry": { + "properties": { + "attributesPerMap": { + "properties": { + "dataSourcesCount": { + "properties": { + "avg": { + "type": "long" + }, + "max": { + "type": "long" + }, + "min": { + "type": "long" + } + } + }, + "emsVectorLayersCount": { + "type": "object", + "dynamic": "true" + }, + "layerTypesCount": { + "type": "object", + "dynamic": "true" + }, + "layersCount": { + "properties": { + "avg": { + "type": "long" + }, + "max": { + "type": "long" + }, + "min": { + "type": "long" + } + } + } + } + }, + "mapsTotalCount": { + "type": "long" + }, + "timeCaptured": { + "type": "date" + } + } + }, + "metrics-explorer-view": { + "properties": { + "chartOptions": { + "properties": { + "stack": { + "type": "boolean" + }, + "type": { + "type": "keyword" + }, + "yAxisMode": { + "type": "keyword" + } + } + }, + "currentTimerange": { + "properties": { + "from": { + "type": "keyword" + }, + "interval": { + "type": "keyword" + }, + "to": { + "type": "keyword" + } + } + }, + "name": { + "type": "keyword" + }, + "options": { + "properties": { + "aggregation": { + "type": "keyword" + }, + "filterQuery": { + "type": "keyword" + }, + "groupBy": { + "type": "keyword" + }, + "limit": { + "type": "integer" + }, + "metrics": { + "type": "nested", + "properties": { + "aggregation": { + "type": "keyword" + }, + "color": { + "type": "keyword" + }, + "field": { + "type": "keyword" + }, + "label": { + "type": "keyword" + } + } + } + } + } + } + }, + "migrationVersion": { + "dynamic": "true", + "properties": { + "space": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "ml-telemetry": { + "properties": { + "file_data_visualizer": { + "properties": { + "index_creation_count": { + "type": "long" + } + } + } + } + }, + "namespace": { + "type": "keyword" + }, + "policies": { + "properties": { + "agent_version": { + "type": "keyword" + }, + "created_by": { + "type": "keyword" + }, + "created_on": { + "type": "keyword" + }, + "data_sources": { + "properties": { + "inputs": { + "type": "keyword" + }, + "meta": { + "type": "keyword" + }, + "output": { + "type": "keyword" + }, + "policy": { + "type": "keyword" + }, + "policy_id": { + "type": "keyword" + }, + "queue": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + } + } + }, + "description": { + "type": "text" + }, + "id": { + "type": "keyword" + }, + "monitoring_enabled": { + "type": "boolean" + }, + "name": { + "type": "text" + }, + "shared_id": { + "type": "keyword" + }, + "status": { + "type": "keyword" + }, + "updated_by": { + "type": "keyword" + }, + "updated_on": { + "type": "keyword" + }, + "version": { + "type": "integer" + } + } + }, + "query": { + "properties": { + "description": { + "type": "text" + }, + "filters": { + "type": "object", + "enabled": false + }, + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "type": "keyword", + "index": false + } + } + }, + "timefilter": { + "type": "object", + "enabled": false + }, + "title": { + "type": "text" + } + } + }, + "references": { + "type": "nested", + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + } + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" + } + } + }, + "search": { + "properties": { + "columns": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "sort": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "server": { + "properties": { + "uuid": { + "type": "keyword" + } + } + }, + "siem-ui-timeline": { + "properties": { + "columns": { + "properties": { + "aggregatable": { + "type": "boolean" + }, + "category": { + "type": "keyword" + }, + "columnHeaderType": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "example": { + "type": "text" + }, + "id": { + "type": "keyword" + }, + "indexes": { + "type": "keyword" + }, + "name": { + "type": "text" + }, + "placeholder": { + "type": "text" + }, + "searchable": { + "type": "boolean" + }, + "type": { + "type": "keyword" + } + } + }, + "created": { + "type": "date" + }, + "createdBy": { + "type": "text" + }, + "dataProviders": { + "properties": { + "and": { + "properties": { + "enabled": { + "type": "boolean" + }, + "excluded": { + "type": "boolean" + }, + "id": { + "type": "keyword" + }, + "kqlQuery": { + "type": "text" + }, + "name": { + "type": "text" + }, + "queryMatch": { + "properties": { + "displayField": { + "type": "text" + }, + "displayValue": { + "type": "text" + }, + "field": { + "type": "text" + }, + "operator": { + "type": "text" + }, + "value": { + "type": "text" + } + } + } + } + }, + "enabled": { + "type": "boolean" + }, + "excluded": { + "type": "boolean" + }, + "id": { + "type": "keyword" + }, + "kqlQuery": { + "type": "text" + }, + "name": { + "type": "text" + }, + "queryMatch": { + "properties": { + "displayField": { + "type": "text" + }, + "displayValue": { + "type": "text" + }, + "field": { + "type": "text" + }, + "operator": { + "type": "text" + }, + "value": { + "type": "text" + } + } + } + } + }, + "dateRange": { + "properties": { + "end": { + "type": "date" + }, + "start": { + "type": "date" + } + } + }, + "description": { + "type": "text" + }, + "favorite": { + "properties": { + "favoriteDate": { + "type": "date" + }, + "fullName": { + "type": "text" + }, + "keySearch": { + "type": "text" + }, + "userName": { + "type": "text" + } + } + }, + "kqlMode": { + "type": "keyword" + }, + "kqlQuery": { + "properties": { + "filterQuery": { + "properties": { + "kuery": { + "properties": { + "expression": { + "type": "text" + }, + "kind": { + "type": "keyword" + } + } + }, + "serializedQuery": { + "type": "text" + } + } + } + } + }, + "sort": { + "properties": { + "columnId": { + "type": "keyword" + }, + "sortDirection": { + "type": "keyword" + } + } + }, + "title": { + "type": "text" + }, + "updated": { + "type": "date" + }, + "updatedBy": { + "type": "text" + } + } + }, + "siem-ui-timeline-note": { + "properties": { + "created": { + "type": "date" + }, + "createdBy": { + "type": "text" + }, + "eventId": { + "type": "keyword" + }, + "note": { + "type": "text" + }, + "timelineId": { + "type": "keyword" + }, + "updated": { + "type": "date" + }, + "updatedBy": { + "type": "text" + } + } + }, + "siem-ui-timeline-pinned-event": { + "properties": { + "created": { + "type": "date" + }, + "createdBy": { + "type": "text" + }, + "eventId": { + "type": "keyword" + }, + "timelineId": { + "type": "keyword" + }, + "updated": { + "type": "date" + }, + "updatedBy": { + "type": "text" + } + } + }, + "space": { + "properties": { + "_reserved": { + "type": "boolean" + }, + "color": { + "type": "keyword" + }, + "description": { + "type": "text" + }, + "disabledFeatures": { + "type": "keyword" + }, + "imageUrl": { + "type": "text", + "index": false + }, + "initials": { + "type": "keyword" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "telemetry": { + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" + } + } + }, + "type": { + "type": "keyword" + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "updated_at": { + "type": "date" + }, + "upgrade-assistant-reindex-operation": { + "dynamic": "true", + "properties": { + "indexName": { + "type": "keyword" + }, + "status": { + "type": "integer" + } + } + }, + "upgrade-assistant-telemetry": { + "properties": { + "features": { + "properties": { + "deprecation_logging": { + "properties": { + "enabled": { + "type": "boolean", + "null_value": true + } + } + } + } + }, + "ui_open": { + "properties": { + "cluster": { + "type": "long", + "null_value": 0 + }, + "indices": { + "type": "long", + "null_value": 0 + }, + "overview": { + "type": "long", + "null_value": 0 + } + } + }, + "ui_reindex": { + "properties": { + "close": { + "type": "long", + "null_value": 0 + }, + "open": { + "type": "long", + "null_value": 0 + }, + "start": { + "type": "long", + "null_value": 0 + }, + "stop": { + "type": "long", + "null_value": 0 + } + } + } + } + }, + "url": { + "properties": { + "accessCount": { + "type": "long" + }, + "accessDate": { + "type": "date" + }, + "createDate": { + "type": "date" + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 2048 + } + } + } + } + }, + "visualization": { + "properties": { + "description": { + "type": "text" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "savedSearchRefName": { + "type": "keyword" + }, + "title": { + "type": "text" + }, + "uiStateJSON": { + "type": "text" + }, + "version": { + "type": "integer" + }, + "visState": { + "type": "text" } } } @@ -211,6 +1387,7 @@ }, "settings": { "index": { + "auto_expand_replicas": "0-1", "number_of_replicas": "0", "number_of_shards": "1" } diff --git a/x-pack/test_utils/jest/contract_tests/servers.ts b/x-pack/test_utils/jest/contract_tests/servers.ts index acfdf50edeeae..734f51ba57f68 100644 --- a/x-pack/test_utils/jest/contract_tests/servers.ts +++ b/x-pack/test_utils/jest/contract_tests/servers.ts @@ -64,7 +64,13 @@ export async function _createSharedServer() { const servers = await kbnTestServer.createTestServers({ // adjustTimeout function is required by createTestServers fn adjustTimeout: (t: number) => {}, - settings: TestKbnServerConfig, + settings: { + ...TestKbnServerConfig, + es: { + ...TestKbnServerConfig.es, + esArgs: ['xpack.security.authc.api_key.enabled=true'], + }, + }, }); ESServer = await servers.startES(); const { hosts, username, password } = ESServer;