Skip to content

Commit

Permalink
Merge branch 'main' into im/details_page/fix_ilm
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech authored Nov 8, 2023
2 parents 6f2b97e + 0063691 commit 2e5fb8e
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { visit } from '../../../tasks/navigation';
import { ALERTS_URL } from '../../../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/169091
describe('Changing alert status', () => {
describe.skip('Changing alert status', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cy.task('esArchiverLoad', { archiveName: 'auditbeat_big' });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
previewErrorButtonClick,
} from '../../tasks/entity_analytics';

// TODO: https://github.com/elastic/kibana/issues/161539
describe(
'Entity analytics management page',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,179 +50,174 @@ import {
createEndpointExceptionListItem,
} from '../../../tasks/api_calls/exceptions';

// TODO: https://github.com/elastic/kibana/issues/161539
describe(
'Add endpoint exception from rule details',
{ tags: ['@ess', '@serverless', '@brokenInServerless'] },
() => {
const ITEM_NAME = 'Sample Exception List Item';
const NEW_ITEM_NAME = 'Exception item-EDITED';
const ITEM_FIELD = 'event.code';
const FIELD_DIFFERENT_FROM_EXISTING_ITEM_FIELD = 'agent.type';

describe('Add endpoint exception from rule details', { tags: ['@ess', '@serverless'] }, () => {
const ITEM_NAME = 'Sample Exception List Item';
const NEW_ITEM_NAME = 'Exception item-EDITED';
const ITEM_FIELD = 'event.code';
const FIELD_DIFFERENT_FROM_EXISTING_ITEM_FIELD = 'agent.type';

beforeEach(() => {
deleteExceptionLists();
deleteEndpointExceptionList();
login();
deleteAlertsAndRules();
});

describe('without exception items', () => {
beforeEach(() => {
deleteExceptionLists();
deleteEndpointExceptionList();
login();
deleteAlertsAndRules();
});

describe('without exception items', () => {
beforeEach(() => {
createEndpointExceptionList().then((response) => {
createRule(
getNewRule({
query: 'event.code:*',
index: ['auditbeat*'],
exceptions_list: [
{
id: response.body.id,
list_id: response.body.list_id,
type: response.body.type,
namespace_type: response.body.namespace_type,
},
],
rule_id: '2',
enabled: false,
})
).then((rule) => visitRuleDetailsPage(rule.body.id, { tab: 'endpoint_exceptions' }));
});
createEndpointExceptionList().then((response) => {
createRule(
getNewRule({
query: 'event.code:*',
index: ['auditbeat*'],
exceptions_list: [
{
id: response.body.id,
list_id: response.body.list_id,
type: response.body.type,
namespace_type: response.body.namespace_type,
},
],
rule_id: '2',
enabled: false,
})
).then((rule) => visitRuleDetailsPage(rule.body.id, { tab: 'endpoint_exceptions' }));
});
});

it('creates an exception item', () => {
// when no exceptions exist, empty component shows with action to add exception
cy.get(NO_EXCEPTIONS_EXIST_PROMPT).should('exist');
it('creates an exception item', () => {
// when no exceptions exist, empty component shows with action to add exception
cy.get(NO_EXCEPTIONS_EXIST_PROMPT).should('exist');

// open add exception modal
openExceptionFlyoutFromEmptyViewerPrompt();
// open add exception modal
openExceptionFlyoutFromEmptyViewerPrompt();

// submit button is disabled if no paramerters were added
cy.get(CONFIRM_BTN).should('have.attr', 'disabled');
// submit button is disabled if no paramerters were added
cy.get(CONFIRM_BTN).should('have.attr', 'disabled');

// for endpoint exceptions, must specify OS
selectOs('windows');
// for endpoint exceptions, must specify OS
selectOs('windows');

// add exception item conditions
addExceptionConditions({
field: 'event.code',
operator: 'is',
values: ['foo'],
});
// add exception item conditions
addExceptionConditions({
field: 'event.code',
operator: 'is',
values: ['foo'],
});

// Name is required so want to check that submit is still disabled
cy.get(CONFIRM_BTN).should('have.attr', 'disabled');
// Name is required so want to check that submit is still disabled
cy.get(CONFIRM_BTN).should('have.attr', 'disabled');

// add exception item name
addExceptionFlyoutItemName(ITEM_NAME);
// add exception item name
addExceptionFlyoutItemName(ITEM_NAME);

// Option to add to rule or add to list should NOT appear
cy.get(ADD_TO_RULE_OR_LIST_SECTION).should('not.exist');
// Option to add to rule or add to list should NOT appear
cy.get(ADD_TO_RULE_OR_LIST_SECTION).should('not.exist');

// not testing close alert functionality here, just ensuring that the options appear as expected
cy.get(CLOSE_SINGLE_ALERT_CHECKBOX).should('not.exist');
cy.get(CLOSE_ALERTS_CHECKBOX).should('exist');
// not testing close alert functionality here, just ensuring that the options appear as expected
cy.get(CLOSE_SINGLE_ALERT_CHECKBOX).should('not.exist');
cy.get(CLOSE_ALERTS_CHECKBOX).should('exist');

// submit
submitNewExceptionItem();
// submit
submitNewExceptionItem();

// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
});
// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
});
});

describe('with exception items', () => {
beforeEach(() => {
createEndpointExceptionList().then((response) => {
createEndpointExceptionListItem({
comments: [],
description: 'Exception list item',
entries: [
{
field: ITEM_FIELD,
operator: 'included',
type: 'match',
value: 'foo',
},
],
name: ITEM_NAME,
tags: [],
type: 'simple',
os_types: ['windows'],
});

describe('with exception items', () => {
beforeEach(() => {
createEndpointExceptionList().then((response) => {
createEndpointExceptionListItem({
comments: [],
description: 'Exception list item',
entries: [
createRule(
getNewRule({
name: 'Rule with exceptions',
query: 'event.code:*',
index: ['auditbeat*'],
exceptions_list: [
{
field: ITEM_FIELD,
operator: 'included',
type: 'match',
value: 'foo',
id: response.body.id,
list_id: response.body.list_id,
type: response.body.type,
namespace_type: response.body.namespace_type,
},
],
name: ITEM_NAME,
tags: [],
type: 'simple',
os_types: ['windows'],
});

createRule(
getNewRule({
name: 'Rule with exceptions',
query: 'event.code:*',
index: ['auditbeat*'],
exceptions_list: [
{
id: response.body.id,
list_id: response.body.list_id,
type: response.body.type,
namespace_type: response.body.namespace_type,
},
],
rule_id: '2',
enabled: false,
})
).then((rule) => {
visitRuleDetailsPage(rule.body.id, { tab: 'endpoint_exceptions' });
waitForRuleDetailsPageToBeLoaded('Rule with exceptions');
});
rule_id: '2',
enabled: false,
})
).then((rule) => {
visitRuleDetailsPage(rule.body.id, { tab: 'endpoint_exceptions' });
waitForRuleDetailsPageToBeLoaded('Rule with exceptions');
});
});
});

it('edits an endpoint exception item', () => {
// displays existing exception items
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
cy.get(NO_EXCEPTIONS_EXIST_PROMPT).should('not.exist');
cy.get(EXCEPTION_CARD_ITEM_NAME).should('have.text', ITEM_NAME);
cy.get(EXCEPTION_CARD_ITEM_CONDITIONS).should('have.text', ` ${ITEM_FIELD}IS foo`);
it('edits an endpoint exception item', () => {
// displays existing exception items
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
cy.get(NO_EXCEPTIONS_EXIST_PROMPT).should('not.exist');
cy.get(EXCEPTION_CARD_ITEM_NAME).should('have.text', ITEM_NAME);
cy.get(EXCEPTION_CARD_ITEM_CONDITIONS).should('have.text', ` ${ITEM_FIELD}IS foo`);

// open edit exception modal
openEditException();
// open edit exception modal
openEditException();

// edit exception item name
editExceptionFlyoutItemName(NEW_ITEM_NAME);
// edit exception item name
editExceptionFlyoutItemName(NEW_ITEM_NAME);

// check that the existing item's field is being populated
cy.get(EXCEPTION_ITEM_CONTAINER)
.eq(0)
.find(FIELD_INPUT_PARENT)
.eq(0)
.should('have.text', ITEM_FIELD);
cy.get(VALUES_INPUT).should('have.text', 'foo');
// check that the existing item's field is being populated
cy.get(EXCEPTION_ITEM_CONTAINER)
.eq(0)
.find(FIELD_INPUT_PARENT)
.eq(0)
.should('have.text', ITEM_FIELD);
cy.get(VALUES_INPUT).should('have.text', 'foo');

// edit conditions
editException(FIELD_DIFFERENT_FROM_EXISTING_ITEM_FIELD, 0, 0);
// edit conditions
editException(FIELD_DIFFERENT_FROM_EXISTING_ITEM_FIELD, 0, 0);

// submit
submitEditedExceptionItem();
// submit
submitEditedExceptionItem();

// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);

// check that updates stuck
cy.get(EXCEPTION_CARD_ITEM_NAME).should('have.text', NEW_ITEM_NAME);
cy.get(EXCEPTION_CARD_ITEM_CONDITIONS).should('have.text', ' agent.typeIS foo');
});
// check that updates stuck
cy.get(EXCEPTION_CARD_ITEM_NAME).should('have.text', NEW_ITEM_NAME);
cy.get(EXCEPTION_CARD_ITEM_CONDITIONS).should('have.text', ' agent.typeIS foo');
});

it('allows user to search for items', () => {
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
it('allows user to search for items', () => {
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);

// can search for an exception value
searchForExceptionItem('foo');
// can search for an exception value
searchForExceptionItem('foo');

// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);
// new exception item displays
cy.get(EXCEPTION_ITEM_VIEWER_CONTAINER).should('have.length', 1);

// displays empty search result view if no matches found
searchForExceptionItem('abc');
// displays empty search result view if no matches found
searchForExceptionItem('abc');

// new exception item displays
cy.get(NO_EXCEPTIONS_SEARCH_RESULTS_PROMPT).should('exist');
});
// new exception item displays
cy.get(NO_EXCEPTIONS_SEARCH_RESULTS_PROMPT).should('exist');
});
}
);
});
});

0 comments on commit 2e5fb8e

Please sign in to comment.