-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8.11' into backport/8.11/pr-170127
- Loading branch information
Showing
18 changed files
with
893 additions
and
590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ty_solution/public/management/cypress/e2e/response_actions/response_console/execute.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { PolicyData } from '../../../../../../common/endpoint/types'; | ||
import type { CreateAndEnrollEndpointHostResponse } from '../../../../../../scripts/endpoint/common/endpoint_host_services'; | ||
import { | ||
inputConsoleCommand, | ||
openResponseConsoleFromEndpointList, | ||
submitCommand, | ||
waitForCommandToBeExecuted, | ||
waitForEndpointListPageToBeLoaded, | ||
} from '../../../tasks/response_console'; | ||
import type { IndexedFleetEndpointPolicyResponse } from '../../../../../../common/endpoint/data_loaders/index_fleet_endpoint_policy'; | ||
import { createAgentPolicyTask, getEndpointIntegrationVersion } from '../../../tasks/fleet'; | ||
|
||
import { login } from '../../../tasks/login'; | ||
import { enableAllPolicyProtections } from '../../../tasks/endpoint_policy'; | ||
import { createEndpointHost } from '../../../tasks/create_endpoint_host'; | ||
import { deleteAllLoadedEndpointData } from '../../../tasks/delete_all_endpoint_data'; | ||
|
||
describe('Response console', { tags: ['@ess', '@serverless'] }, () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
describe('Execute operations: execute', () => { | ||
const homeFilePath = process.env.CI || true ? '/home/vagrant' : `/home/ubuntu`; | ||
|
||
let indexedPolicy: IndexedFleetEndpointPolicyResponse; | ||
let policy: PolicyData; | ||
let createdHost: CreateAndEnrollEndpointHostResponse; | ||
|
||
before(() => { | ||
getEndpointIntegrationVersion().then((version) => | ||
createAgentPolicyTask(version).then((data) => { | ||
indexedPolicy = data; | ||
policy = indexedPolicy.integrationPolicies[0]; | ||
|
||
return enableAllPolicyProtections(policy.id).then(() => { | ||
// Create and enroll a new Endpoint host | ||
return createEndpointHost(policy.policy_id).then((host) => { | ||
createdHost = host as CreateAndEnrollEndpointHostResponse; | ||
}); | ||
}); | ||
}) | ||
); | ||
}); | ||
|
||
after(() => { | ||
if (createdHost) { | ||
cy.task('destroyEndpointHost', createdHost); | ||
} | ||
|
||
if (indexedPolicy) { | ||
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy); | ||
} | ||
|
||
if (createdHost) { | ||
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] }); | ||
} | ||
}); | ||
|
||
it('"execute --command" - should execute a command', () => { | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
openResponseConsoleFromEndpointList(); | ||
inputConsoleCommand(`execute --command "ls -al ${homeFilePath}"`); | ||
submitCommand(); | ||
waitForCommandToBeExecuted('execute'); | ||
}); | ||
}); | ||
}); |
121 changes: 121 additions & 0 deletions
121
...ion/public/management/cypress/e2e/response_actions/response_console/file_operations.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { PolicyData } from '../../../../../../common/endpoint/types'; | ||
import type { CreateAndEnrollEndpointHostResponse } from '../../../../../../scripts/endpoint/common/endpoint_host_services'; | ||
import { | ||
inputConsoleCommand, | ||
openResponseConsoleFromEndpointList, | ||
submitCommand, | ||
waitForCommandToBeExecuted, | ||
waitForEndpointListPageToBeLoaded, | ||
} from '../../../tasks/response_console'; | ||
import type { IndexedFleetEndpointPolicyResponse } from '../../../../../../common/endpoint/data_loaders/index_fleet_endpoint_policy'; | ||
import { createAgentPolicyTask, getEndpointIntegrationVersion } from '../../../tasks/fleet'; | ||
|
||
import { login } from '../../../tasks/login'; | ||
import { enableAllPolicyProtections } from '../../../tasks/endpoint_policy'; | ||
import { createEndpointHost } from '../../../tasks/create_endpoint_host'; | ||
import { deleteAllLoadedEndpointData } from '../../../tasks/delete_all_endpoint_data'; | ||
|
||
describe('Response console', { tags: ['@ess', '@serverless'] }, () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
describe('File operations: get-file and upload', () => { | ||
const homeFilePath = process.env.CI || true ? '/home/vagrant' : `/home/ubuntu`; | ||
|
||
const fileContent = 'This is a test file for the get-file command.'; | ||
const filePath = `${homeFilePath}/test_file.txt`; | ||
|
||
let indexedPolicy: IndexedFleetEndpointPolicyResponse; | ||
let policy: PolicyData; | ||
let createdHost: CreateAndEnrollEndpointHostResponse; | ||
|
||
before(() => { | ||
getEndpointIntegrationVersion().then((version) => | ||
createAgentPolicyTask(version).then((data) => { | ||
indexedPolicy = data; | ||
policy = indexedPolicy.integrationPolicies[0]; | ||
|
||
return enableAllPolicyProtections(policy.id).then(() => { | ||
// Create and enroll a new Endpoint host | ||
return createEndpointHost(policy.policy_id).then((host) => { | ||
createdHost = host as CreateAndEnrollEndpointHostResponse; | ||
}); | ||
}); | ||
}) | ||
); | ||
}); | ||
|
||
after(() => { | ||
if (createdHost) { | ||
cy.task('destroyEndpointHost', createdHost); | ||
} | ||
|
||
if (indexedPolicy) { | ||
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy); | ||
} | ||
|
||
if (createdHost) { | ||
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] }); | ||
} | ||
}); | ||
|
||
it('"get-file --path" - should retrieve a file', () => { | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
cy.task('createFileOnEndpoint', { | ||
hostname: createdHost.hostname, | ||
path: filePath, | ||
content: fileContent, | ||
}); | ||
openResponseConsoleFromEndpointList(); | ||
inputConsoleCommand(`get-file --path ${filePath}`); | ||
submitCommand(); | ||
cy.getByTestSubj('getFileSuccess', { timeout: 60000 }).within(() => { | ||
cy.contains('File retrieved from the host.'); | ||
cy.contains('(ZIP file passcode: elastic)'); | ||
cy.contains( | ||
'Files are periodically deleted to clear storage space. Download and save file locally if needed.' | ||
); | ||
cy.contains('Click here to download').click(); | ||
const downloadsFolder = Cypress.config('downloadsFolder'); | ||
cy.readFile(`${downloadsFolder}/upload.zip`); | ||
|
||
cy.task('uploadFileToEndpoint', { | ||
hostname: createdHost.hostname, | ||
srcPath: `${downloadsFolder}/upload.zip`, | ||
destPath: `${homeFilePath}/upload.zip`, | ||
}); | ||
|
||
cy.task('readZippedFileContentOnEndpoint', { | ||
hostname: createdHost.hostname, | ||
path: `${homeFilePath}/upload.zip`, | ||
password: 'elastic', | ||
}).then((unzippedFileContent) => { | ||
expect(unzippedFileContent).to.equal(fileContent); | ||
}); | ||
}); | ||
}); | ||
|
||
it('"upload --file" - should upload a file', () => { | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
openResponseConsoleFromEndpointList(); | ||
inputConsoleCommand(`upload --file`); | ||
cy.getByTestSubj('console-arg-file-picker').selectFile( | ||
{ | ||
contents: Cypress.Buffer.from('upload file content here!'), | ||
fileName: 'upload_file.txt', | ||
lastModified: Date.now(), | ||
}, | ||
{ force: true } | ||
); | ||
submitCommand(); | ||
waitForCommandToBeExecuted('upload'); | ||
}); | ||
}); | ||
}); |
93 changes: 93 additions & 0 deletions
93
..._solution/public/management/cypress/e2e/response_actions/response_console/isolation.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { PolicyData } from '../../../../../../common/endpoint/types'; | ||
import type { CreateAndEnrollEndpointHostResponse } from '../../../../../../scripts/endpoint/common/endpoint_host_services'; | ||
import { | ||
openResponseConsoleFromEndpointList, | ||
performCommandInputChecks, | ||
submitCommand, | ||
waitForCommandToBeExecuted, | ||
waitForEndpointListPageToBeLoaded, | ||
} from '../../../tasks/response_console'; | ||
import type { IndexedFleetEndpointPolicyResponse } from '../../../../../../common/endpoint/data_loaders/index_fleet_endpoint_policy'; | ||
import { createAgentPolicyTask, getEndpointIntegrationVersion } from '../../../tasks/fleet'; | ||
import { | ||
checkEndpointListForOnlyIsolatedHosts, | ||
checkEndpointListForOnlyUnIsolatedHosts, | ||
} from '../../../tasks/isolate'; | ||
|
||
import { login } from '../../../tasks/login'; | ||
import { enableAllPolicyProtections } from '../../../tasks/endpoint_policy'; | ||
import { createEndpointHost } from '../../../tasks/create_endpoint_host'; | ||
import { deleteAllLoadedEndpointData } from '../../../tasks/delete_all_endpoint_data'; | ||
|
||
describe('Response console', { tags: ['@ess', '@serverless'] }, () => { | ||
beforeEach(() => { | ||
login(); | ||
}); | ||
|
||
describe('Host Isolation: isolate and release an endpoint', () => { | ||
let indexedPolicy: IndexedFleetEndpointPolicyResponse; | ||
let policy: PolicyData; | ||
let createdHost: CreateAndEnrollEndpointHostResponse; | ||
|
||
before(() => { | ||
getEndpointIntegrationVersion().then((version) => | ||
createAgentPolicyTask(version).then((data) => { | ||
indexedPolicy = data; | ||
policy = indexedPolicy.integrationPolicies[0]; | ||
|
||
return enableAllPolicyProtections(policy.id).then(() => { | ||
// Create and enroll a new Endpoint host | ||
return createEndpointHost(policy.policy_id).then((host) => { | ||
createdHost = host as CreateAndEnrollEndpointHostResponse; | ||
}); | ||
}); | ||
}) | ||
); | ||
}); | ||
|
||
after(() => { | ||
if (createdHost) { | ||
cy.task('destroyEndpointHost', createdHost); | ||
} | ||
|
||
if (indexedPolicy) { | ||
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy); | ||
} | ||
|
||
if (createdHost) { | ||
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] }); | ||
} | ||
}); | ||
|
||
it('should isolate host from response console', () => { | ||
const command = 'isolate'; | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
checkEndpointListForOnlyUnIsolatedHosts(); | ||
openResponseConsoleFromEndpointList(); | ||
performCommandInputChecks(command); | ||
submitCommand(); | ||
waitForCommandToBeExecuted(command); | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
checkEndpointListForOnlyIsolatedHosts(); | ||
}); | ||
|
||
it('should release host from response console', () => { | ||
const command = 'release'; | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
checkEndpointListForOnlyIsolatedHosts(); | ||
openResponseConsoleFromEndpointList(); | ||
performCommandInputChecks(command); | ||
submitCommand(); | ||
waitForCommandToBeExecuted(command); | ||
waitForEndpointListPageToBeLoaded(createdHost.hostname); | ||
checkEndpointListForOnlyUnIsolatedHosts(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.