[EDR Workflows] Add @serverless tag to more osquery tests (#168555)

This commit is contained in:
Tomasz Ciecierski 2023-10-11 17:49:42 +02:00 committed by GitHub
parent 967a2f1af2
commit 96de7662fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 126 additions and 118 deletions

View file

@ -30,7 +30,7 @@ import {
} from '../../tasks/integrations';
import { findAndClickButton, findFormFieldByRowsLabelAndType } from '../../tasks/live_query';
describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, () => {
describe('ALL - Add Integration', { tags: ['@ess', '@serverless'] }, () => {
let savedQueryId: string;
before(() => {
@ -47,32 +47,36 @@ describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, ()
cleanupSavedQuery(savedQueryId);
});
it('validate osquery is not available and nav search links to integration', () => {
cy.visit(OSQUERY);
cy.intercept('GET', '**/internal/osquery/status', (req) => {
req.continue((res) => res.send({ ...res.body, install_status: undefined }));
});
cy.contains('Add this integration to run and schedule queries for Elastic Agent.');
cy.contains('Add Osquery Manager');
cy.getBySel('osquery-add-integration-button');
cy.getBySel('nav-search-input').type('Osquery');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.MANAGEMENT}"]`).should('exist');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.LOGS}"]`).should('exist');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.MANAGER}"]`).should('exist').click();
});
it(
'validate osquery is not available and nav search links to integration',
{ tags: ['@ess', '@brokenInServerless'] },
() => {
cy.visit(OSQUERY);
cy.intercept('GET', '**/internal/osquery/status', (req) => {
req.continue((res) => res.send({ ...res.body, install_status: undefined }));
});
cy.contains('Add this integration to run and schedule queries for Elastic Agent.');
cy.contains('Add Osquery Manager');
cy.getBySel('osquery-add-integration-button');
cy.getBySel('nav-search-input').type('Osquery');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.MANAGEMENT}"]`).should('exist');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.LOGS}"]`).should('exist');
cy.get(`[url="${NAV_SEARCH_INPUT_OSQUERY_RESULTS.MANAGER}"]`).should('exist').click();
}
);
describe('Add and upgrade integration', { tags: ['@ess'] }, () => {
describe('Add and upgrade integration', { tags: ['@ess', '@serverless'] }, () => {
const oldVersion = '0.7.4';
const [integrationName, policyName] = generateRandomStringName(2);
let policyId: string;
before(() => {
beforeEach(() => {
interceptAgentPolicyId((agentPolicyId) => {
policyId = agentPolicyId;
});
});
after(() => {
afterEach(() => {
cleanupAgentPolicy(policyId);
});
@ -94,13 +98,13 @@ describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, ()
const [integrationName, policyName] = generateRandomStringName(2);
let policyId: string;
before(() => {
beforeEach(() => {
interceptAgentPolicyId((agentPolicyId) => {
policyId = agentPolicyId;
});
});
after(() => {
afterEach(() => {
cleanupAgentPolicy(policyId);
});
@ -134,7 +138,7 @@ describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, ()
let policyId: string;
let packId: string;
before(() => {
beforeEach(() => {
interceptAgentPolicyId((agentPolicyId) => {
policyId = agentPolicyId;
});
@ -143,7 +147,7 @@ describe('ALL - Add Integration', { tags: ['@ess', '@brokenInServerless'] }, ()
});
});
after(() => {
afterEach(() => {
cleanupPack(packId);
cleanupAgentPolicy(policyId);
});

View file

@ -25,7 +25,7 @@ import { getAdvancedButton } from '../../screens/integrations';
import { loadSavedQuery, cleanupSavedQuery } from '../../tasks/api_fixtures';
import { ServerlessRoleName } from '../../support/roles';
describe('ALL - Live Query run custom and saved', { tags: ['@ess'] }, () => {
describe('ALL - Live Query run custom and saved', { tags: ['@ess', '@serverless'] }, () => {
let savedQueryId: string;
let savedQueryName: string;

View file

@ -100,13 +100,13 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
describe('Check if result type is correct', { tags: ['@ess', '@serverless'] }, () => {
let resultTypePackId: string;
before(() => {
beforeEach(() => {
interceptPackId((pack) => {
resultTypePackId = pack;
});
});
after(() => {
afterEach(() => {
cleanupPack(resultTypePackId);
});
@ -225,17 +225,14 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packId: string;
let packName: string;
before(() => {
beforeEach(() => {
interceptPackId((pack) => {
packId = pack;
});
});
beforeEach(() => {
packName = 'Pack-name' + generateRandomStringName(1)[0];
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -270,7 +267,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packName: string;
let newQueryName: string;
before(() => {
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
url: '/internal/osquery/fleet_wrapper/package_policies',
headers: {
@ -289,12 +286,10 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
packId = pack.saved_object_id;
packName = pack.name;
});
});
beforeEach(() => {
newQueryName = 'new-query-name' + generateRandomStringName(1)[0];
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -374,7 +369,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packId: string;
let packName: string;
before(() => {
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
url: '/internal/osquery/fleet_wrapper/package_policies',
headers: {
@ -399,7 +394,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
});
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -483,7 +478,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packId: string;
let packName: string;
before(() => {
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
url: '/internal/osquery/fleet_wrapper/package_policies',
headers: {
@ -504,7 +499,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
});
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -519,7 +514,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packId: string;
let packName: string;
before(() => {
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
url: '/internal/osquery/fleet_wrapper/package_policies',
headers: {
@ -540,7 +535,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
});
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -634,7 +629,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
let packId: string;
let packName: string;
before(() => {
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
url: '/internal/osquery/fleet_wrapper/package_policies',
headers: {
@ -659,7 +654,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
});
});
after(() => {
afterEach(() => {
cleanupPack(packId);
});
@ -704,6 +699,7 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
describe('to click delete button', { tags: ['@ess', '@serverless'] }, () => {
let packName: string;
let packId: string;
beforeEach(() => {
request<{ items: PackagePolicy[] }>({
@ -722,8 +718,12 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
)
.then((pack) => {
packName = pack.name;
packId = pack.saved_object_id;
});
});
afterEach(() => {
cleanupPack(packId);
});
it('', { tags: ['@ess', '@serverless'] }, () => {
preparePack(packName);

View file

@ -40,11 +40,14 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
'Validate that agent policy is getting removed from pack if we remove agent policy',
{ tags: ['@ess'] },
() => {
let AGENT_POLICY_NAME: string;
let REMOVING_PACK: string;
beforeEach(() => {
cy.login('elastic');
AGENT_POLICY_NAME = `PackTest` + generateRandomStringName(1)[0];
REMOVING_PACK = 'removing-pack' + generateRandomStringName(1)[0];
});
const AGENT_POLICY_NAME = `PackTest` + generateRandomStringName(1)[0];
const REMOVING_PACK = 'removing-pack' + generateRandomStringName(1)[0];
it('add integration', () => {
cy.visit(FLEET_AGENT_POLICIES);
@ -94,86 +97,87 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
);
describe('Load prebuilt packs', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
cy.login(ServerlessRoleName.SOC_MANAGER);
navigateTo('/app/osquery/packs');
});
after(() => {
afterEach(() => {
cleanupAllPrebuiltPacks();
});
const PREBUILD_PACK_NAME = 'it-compliance';
it('should load prebuilt packs', () => {
cy.contains('Load Elastic prebuilt packs').click();
cy.contains('Load Elastic prebuilt packs').should('not.exist');
cy.wait(1000);
cy.react('EuiTableRow').should('have.length.above', 5);
});
it('should be able to activate pack', () => {
activatePack(PREBUILD_PACK_NAME);
deactivatePack(PREBUILD_PACK_NAME);
});
it('should be able to add policy to it', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
findFormFieldByRowsLabelAndType(
'Scheduled agent policies (optional)',
`${DEFAULT_POLICY} {downArrow}{enter}`
);
cy.contains('Update pack').click();
cy.getBySel('confirmModalConfirmButton').click();
cy.contains(`Successfully updated "${PREBUILD_PACK_NAME}" pack`);
});
it('should be able to activate pack with agent inside', () => {
activatePack(PREBUILD_PACK_NAME);
deactivatePack(PREBUILD_PACK_NAME);
});
it('should not be able to update prebuilt pack', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
cy.react('EuiFieldText', { props: { name: 'name', isDisabled: true } });
cy.react('EuiFieldText', { props: { name: 'description', isDisabled: true } });
cy.contains('Add Query').should('not.exist');
cy.react('ExpandedItemActions', { options: { timeout: 1000 } });
cy.get('.euiTableRowCell--hasActions').should('not.exist');
});
it('should be able to delete prebuilt pack and add it again', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
deleteAndConfirm('pack');
cy.contains(PREBUILD_PACK_NAME).should('not.exist');
cy.contains('Update Elastic prebuilt packs').click();
cy.contains('Successfully updated prebuilt packs');
cy.contains(PREBUILD_PACK_NAME).should('exist');
});
it('should be able to run live prebuilt pack', () => {
navigateTo('/app/osquery/live_queries');
cy.contains('New live query').click();
cy.contains('Run a set of queries in a pack.').click();
cy.get(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel('select-live-pack').click().type('osquery-monitoring{downArrow}{enter}');
selectAllAgents();
submitQuery();
cy.getBySel('toggleIcon-events').click();
checkResults();
checkActionItemsInResults({
lens: true,
discover: true,
cases: true,
timeline: false,
describe('', () => {
beforeEach(() => {
cy.login(ServerlessRoleName.SOC_MANAGER);
navigateTo('/app/osquery/packs');
});
it('should load prebuilt packs', () => {
cy.contains('Load Elastic prebuilt packs').click();
cy.contains('Load Elastic prebuilt packs').should('not.exist');
cy.wait(1000);
cy.react('EuiTableRow').should('have.length.above', 5);
});
it('should be able to activate pack', () => {
activatePack(PREBUILD_PACK_NAME);
deactivatePack(PREBUILD_PACK_NAME);
});
it('should be able to add policy to it', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
findFormFieldByRowsLabelAndType(
'Scheduled agent policies (optional)',
`${DEFAULT_POLICY} {downArrow}{enter}`
);
cy.contains('Update pack').click();
cy.getBySel('confirmModalConfirmButton').click();
cy.contains(`Successfully updated "${PREBUILD_PACK_NAME}" pack`);
});
it('should be able to activate pack with agent inside', () => {
activatePack(PREBUILD_PACK_NAME);
deactivatePack(PREBUILD_PACK_NAME);
});
it('should not be able to update prebuilt pack', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
cy.react('EuiFieldText', { props: { name: 'name', isDisabled: true } });
cy.react('EuiFieldText', { props: { name: 'description', isDisabled: true } });
cy.contains('Add Query').should('not.exist');
cy.react('ExpandedItemActions', { options: { timeout: 1000 } });
cy.get('.euiTableRowCell--hasActions').should('not.exist');
});
it('should be able to delete prebuilt pack and add it again', () => {
cy.contains(PREBUILD_PACK_NAME).click();
cy.contains('Edit').click();
deleteAndConfirm('pack');
cy.contains(PREBUILD_PACK_NAME).should('not.exist');
cy.contains('Update Elastic prebuilt packs').click();
cy.contains('Successfully updated prebuilt packs');
cy.contains(PREBUILD_PACK_NAME).should('exist');
});
it('should be able to run live prebuilt pack', () => {
navigateTo('/app/osquery/live_queries');
cy.contains('New live query').click();
cy.contains('Run a set of queries in a pack.').click();
cy.get(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel('select-live-pack').click().type('osquery-monitoring{downArrow}{enter}');
selectAllAgents();
submitQuery();
cy.getBySel('toggleIcon-events').click();
checkResults();
checkActionItemsInResults({
lens: true,
discover: true,
cases: true,
timeline: false,
});
navigateTo('/app/osquery');
cy.contains('osquery-monitoring');
});
navigateTo('/app/osquery');
cy.contains('osquery-monitoring');
});
});
describe('Global packs', { tags: ['@ess'] }, () => {
describe('Global packs', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
cy.login('elastic');
navigateTo('/app/osquery/packs');
@ -185,7 +189,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
let globalPackId: string;
let agentPolicyId: string;
before(() => {
beforeEach(() => {
interceptPackId((pack) => {
globalPackId = pack;
});
@ -194,7 +198,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
});
});
after(() => {
afterEach(() => {
cleanupPack(globalPackId);
cleanupAgentPolicy(agentPolicyId);
});
@ -251,13 +255,13 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
describe('add proper shard to policies packs config', () => {
let shardPackId: string;
before(() => {
beforeEach(() => {
interceptPackId((pack) => {
shardPackId = pack;
});
});
after(() => {
afterEach(() => {
cleanupPack(shardPackId);
});