Skip to content

Commit

Permalink
Add test feature: generate a report from an agent (#4629)
Browse files Browse the repository at this point in the history
* Add pages and functionallity

* Add feature changes

* Try to capture text

* Add report name compare with agent id

* Add a validation for modules with no data

* Add time to refresh button status

* Add validation

* Add last changes

* Adding pages

* Rename agent-report-displayed-file

* Add sign to commit

Signed-off-by: Facundo Mayon <mayonf95@gmail.com>

* Add git signature

Signed-off-by: Facundo Mayon <mayonf95@gmail.com>

Signed-off-by: Facundo Mayon <mayonf95@gmail.com>
  • Loading branch information
Mayons95 authored Oct 12, 2022
1 parent 08e4ce5 commit 31c6a9d
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Generating reports from module and agents

As a Wazuh user
i want to generate a report from modules and agents
in order to could access to the report from management/reporting

@report
Scenario Outline: Create a report from modules and agents <Module Name>
Given The wazuh admin user is logged
When The user goes to <Module Name>
And The user generate a module report clicking on the generate report option
And The user choose an agent to apply filter
And The user generate a module report clicking on the generate report option
And The user navigates to management-reporting
Then The agent report is displayed in the table <Module Name>
Examples:
| Module Name |
| Security Events |
| Integrity Monitoring |
| System Auditing |
| Mitre & Attack |
| NIST |
| TSC |
| Policy Monitoring |
| PCIDSS |
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ export const AGENTS_PAGE = {
statusChart: '.agents-status-pie > .euiPanel > .euiCard__content > .euiCard__children > .euiFlexGroup',
agentDetails: 'euiFlexItem euiFlexItem--flexGrowZero agents-details-card',
deployNewAgentButton: '//span[contains(text(),"Deploy new agent")]',
exploreAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonEmpty .euiButtonContent .euiButtonEmpty__text:contains("Explore agent")',
firstAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(1)',
unPinnedAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonIcon[aria-label="Unpin agent"]',
secundAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(2)',
agentID: '.euiModal .euiTable .euiTableRow:nth-child(1) .euiTableRowCell:nth-child(1) .euiTableCellContent__text',
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REPORTING_PAGE = {
generateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiFlexItem .euiButtonEmpty[type="button"] .euiButtonEmpty__text:contains("Generate report")',
reportGeneratedToast: '.euiToast',
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text'
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text',
disableGenerateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiToolTipAnchor button.euiButtonEmpty-isDisabled',
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ export const AGENTS_PAGE = {
statusChart: '.agents-status-pie > .euiPanel > .euiCard__content > .euiCard__children > .euiFlexGroup',
agentDetails: 'euiFlexItem euiFlexItem--flexGrowZero agents-details-card',
deployNewAgentButton: '//span[contains(text(),"Deploy new agent")]',
exploreAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonEmpty .euiButtonContent .euiButtonEmpty__text:contains("Explore agent")',
firstAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(1)',
unPinnedAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonIcon[aria-label="Unpin agent"]',
secundAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(2)',
agentID: '.euiModal .euiTable .euiTableRow:nth-child(1) .euiTableRowCell:nth-child(1) .euiTableCellContent__text',
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REPORTING_PAGE = {
generateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiFlexItem .euiButtonEmpty[type="button"] .euiButtonEmpty__text:contains("Generate report")',
reportGeneratedToast: '.euiToast',
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text'
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text',
disableGenerateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiToolTipAnchor button.euiButtonEmpty-isDisabled',
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REPORTING_PAGE = {
generateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiFlexItem .euiButtonEmpty[type="button"] .euiButtonEmpty__text:contains("Generate report")',
reportGeneratedToast: '.euiToast',
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text'
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text',
disableGenerateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiToolTipAnchor button.euiButtonEmpty-isDisabled',
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ export const AGENTS_PAGE = {
statusChart: '.agents-status-pie > .euiPanel > .euiCard__content > .euiCard__children > .euiFlexGroup',
agentDetails: 'euiFlexItem euiFlexItem--flexGrowZero agents-details-card',
deployNewAgentButton: '//span[contains(text(),"Deploy new agent")]',
exploreAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonEmpty .euiButtonContent .euiButtonEmpty__text:contains("Explore agent")',
firstAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(1)',
unPinnedAgentButton: '.wz-module-header-nav .euiFlexItem .euiToolTipAnchor .euiButtonIcon[aria-label="Unpin agent"]',
secundAgentDisplayed: '.euiModal .euiTable .euiTableRow:nth-child(2)',
agentID: '.euiModal .euiTable .euiTableRow:nth-child(1) .euiTableRowCell:nth-child(1) .euiTableCellContent__text',
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REPORTING_PAGE = {
generateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiFlexItem .euiButtonEmpty[type="button"] .euiButtonEmpty__text:contains("Generate report")',
reportGeneratedToast: '.euiToast',
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text'
lastCreatedReport: '.euiTable .euiTableRow:nth-child(1) .euiTableRowCell .euiTableCellContent .euiTableCellContent__text',
disableGenerateReportButton: '.wz-welcome-page-agent-tabs .euiFlexItem .euiToolTipAnchor button.euiButtonEmpty-isDisabled',
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { When } from 'cypress-cucumber-preprocessor/steps';
import { forceClickElement, elementIsVisible, getSelector} from '../../utils/driver';

import { forceClickElement, elementIsVisible, getSelector, elementIsNotVisible} from '../../utils/driver';
import { REPORTING_PAGE as pageName} from '../../utils/pages-constants';
const generateReportButton = getSelector('generateReportButton', pageName);
const reportGeneratedToast = getSelector('reportGeneratedToast', pageName);
const disableGenerateReportButton = getSelector('disableGenerateReportButton', pageName);

When('The user generate a module report clicking on the generate report option', () => {
elementIsVisible(generateReportButton);
cy.wait(500);
elementIsNotVisible(disableGenerateReportButton);
forceClickElement(generateReportButton);
cy.wait(500);
elementIsVisible(reportGeneratedToast);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Then } from 'cypress-cucumber-preprocessor/steps';
import { elementIsVisible, elementTextIncludes, getSelector} from '../../utils/driver';
import {REPORT_NAME as reportName} from '../../utils/mappers/modules-mapper-report-data';
import { REPORTING_PAGE as pageName} from '../../utils/pages-constants';
const lastCreatedReport = getSelector('lastCreatedReport', pageName);

Then('The agent report is displayed in the table {}', (moduleName) => {
elementIsVisible(lastCreatedReport);
cy.wait(2000);
cy.get('@agentId').then(($agentId) => {
expect($agentId).to.be.eq($agentId);
const agentID = $agentId;
elementTextIncludes(lastCreatedReport, 'agents-' + agentID + '-' + reportName[moduleName]);
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { When } from 'cypress-cucumber-preprocessor/steps';
import { clickElement, elementIsVisible, getSelector} from '../../utils/driver';

import { AGENTS_PAGE as pageName} from '../../utils/pages-constants';
const exploreAgentButton = getSelector('exploreAgentButton', pageName);
const firstAgentDisplayed = getSelector('firstAgentDisplayed', pageName);
const agentID = getSelector('agentID', pageName);

When('The user choose an agent to apply filter', () => {
elementIsVisible(exploreAgentButton);
clickElement(exploreAgentButton);
cy.wait(500);
elementIsVisible(firstAgentDisplayed);
cy.get(agentID).then(($agentId) =>{
const agentId = $agentId.text();
cy.wrap(agentId).as('agentId');
})
clickElement(firstAgentDisplayed);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Then } from 'cypress-cucumber-preprocessor/steps';
import { elementIsVisible, elementTextIncludes, getSelector} from '../../utils/driver';
import {REPORT_NAME as reportName} from '../../step-definitions/reporting/modules-report-data';
import {REPORT_NAME as reportName} from '../../utils/mappers/modules-mapper-report-data';
import { REPORTING_PAGE as pageName} from '../../utils/pages-constants';
const lastCreatedReport = getSelector('lastCreatedReport', pageName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const REPORT_NAME = {
"Security Events":"general",
"Integrity Monitonring":"fim",
"System Auditing":"audit",
"Mitre & Attack":"mitre",
NIST:"nist",
TSC:"tsc",
"Policy Monitoring":"pm",
PCIDSS:"pci"
};

0 comments on commit 31c6a9d

Please sign in to comment.