Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.12] [Serverless][Security Solution][Endpoint] Unskip file operations tests (#171984) #172867

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const getCypressBaseConfig = (
// grep related configs
grepFilterSpecs: true,
grepOmitFiltered: true,
IS_CI: process.env.CI,
},

e2e: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ describe('Response console', { tags: ['@ess', '@serverless'] }, () => {
login();
});

// FLAKY: https://github.com/elastic/kibana/issues/170482
describe.skip('File operations:', () => {
const homeFilePath = process.env.CI || true ? '/home/vagrant' : `/home/ubuntu`;
describe('File operations:', () => {
const homeFilePath = Cypress.env('IS_CI') ? '/home/vagrant' : '/home/ubuntu';

const fileContent = 'This is a test file for the get-file command.';
const filePath = `${homeFilePath}/test_file.txt`;
Expand Down Expand Up @@ -68,38 +67,52 @@ describe('Response console', { tags: ['@ess', '@serverless'] }, () => {
});

it('"get-file --path" - should retrieve a file', () => {
const downloadsFolder = Cypress.config('downloadsFolder');

waitForEndpointListPageToBeLoaded(createdHost.hostname);
cy.task('createFileOnEndpoint', {
hostname: createdHost.hostname,
path: filePath,
content: fileContent,
});

// initiate get file action and wait for the API to complete
cy.intercept('api/endpoint/action/get_file').as('getFileAction');
openResponseConsoleFromEndpointList();
inputConsoleCommand(`get-file --path ${filePath}`);
submitCommand();
cy.getByTestSubj('getFileSuccess', { timeout: 60000 }).within(() => {
cy.wait('@getFileAction', { timeout: 60000 });

// verify that the file was retrieved
// and that the file download link is available
cy.getByTestSubj('getFileSuccess').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);
});
cy.contains('Click here to download').should('exist');
});

cy.contains('Click here to download').click();

// wait for file to be downloaded
cy.readFile(`${downloadsFolder}/upload.zip`, { timeout: 120000 }).should('exist');

// move the zip file to VM
cy.task('uploadFileToEndpoint', {
hostname: createdHost.hostname,
srcPath: `${downloadsFolder}/upload.zip`,
destPath: `${homeFilePath}/upload.zip`,
});

// unzip the file and read its content
cy.task('readZippedFileContentOnEndpoint', {
hostname: createdHost.hostname,
path: `${homeFilePath}/upload.zip`,
password: 'elastic',
}).then((unzippedFileContent) => {
expect(unzippedFileContent).to.equal(fileContent);
});
});

Expand Down
Loading