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

WZD - Feature - Search by parameters with AND, OR #4709

Closed
Tracked by #4578
mauceballos opened this issue Oct 18, 2022 · 3 comments · Fixed by #4720
Closed
Tracked by #4578

WZD - Feature - Search by parameters with AND, OR #4709

mauceballos opened this issue Oct 18, 2022 · 3 comments · Fixed by #4720
Assignees
Labels
automation automation type/test Test issue

Comments

@mauceballos
Copy link
Contributor

Wazuh Elastic Rev Security
4.3.9 7.17.4 4308 WZD
Browser
Chrome

Describe

The feature increases the coverage for each module because this validates the results with the parameters of searching.

Feature

When The user navigates to any module (Ex: Vulnerabilities)
And The user types a particular search on the search bar like: “name=vim AND severity=critical ”
And The user applies the filters
Then The query is accepted and the results should be displayed.
@mauceballos mauceballos self-assigned this Oct 18, 2022
@mauceballos mauceballos added automation automation type/test Test issue labels Oct 18, 2022
@mauceballos
Copy link
Contributor Author

I include a feature with "OR" parameter and I'll work both.

Scenario: Search by parameters with OR
Given The Wazuh admin user is logged
When The user navigates to any module (Ex: Vulnerabilities)
And The user types a particular search on the search bar like: “severity=critical OR severity=High”
And The user applies the filters
Then The query is accepted and the results should be displayed.

@mauceballos mauceballos changed the title WZD - Feature - Search by parameters with AND WZD - Feature - Search by parameters with AND , OR Oct 18, 2022
@mauceballos mauceballos changed the title WZD - Feature - Search by parameters with AND , OR WZD - Feature - Search by parameters with AND, OR Oct 18, 2022
@mauceballos
Copy link
Contributor Author

Feature

Feature: Search by parameters

    As a Wazuh user
    I want to pin a filter
    in order to aplly it across the modules
    Background:
        Given The wazuh admin user is logged

    Scenario Outline: Search by parameters with AND
        When The user goes to <Module Name>
        And The user types a particular search on the search bar like: “name=vim AND severity=critical ”
        And The user applies the filters
        Then The query is accepted and the results should be displayed.
        Examples:
            | Module Name          |
            | Security Events      |
            | Integrity Monitoring |
            | NIST                 |
            | TSC                  |
            | PCIDSS               |

    Scenario: Search by parameters with OR
        When The user goes to <Module Name>
        And The user types a particular search on the search bar like: “severity=critical OR severity=High”
        And The user applies the filters
        Then The query is accepted and the results should be displayed.
        Examples:
            | Module Name          |
            | Security Events      |
            | Integrity Monitoring |
            | NIST                 |
            | TSC                  |
            | PCIDSS               |

@mauceballos
Copy link
Contributor Author

Feature Implemented Plan

In order to implement both features, we need to include a pre-step after the user is logged step and the request is executed to activate the sample data.
The activation of the sample data allows us to use the search with filters and we will have results to be able to validate them

example
import { Given } from 'cypress-cucumber-preprocessor/steps';
import { navigate, elementIsVisible, getSelector, getCookiesFromBrowser } from '../../utils/driver';
import { WAZUH_MENU_PAGE as pageName} from '../../utils/pages-constants';
const wazuhMenuButton = getSelector('wazuhMenuButton', pageName);
let urlsList = ['https://localhost:5601/elastic/samplealerts/security','https://localhost:5601/elastic/samplealerts/auditing-policy-monitoring','https://localhost:5601/elastic/samplealerts/threat-detection'];
let urlBodys = [{"alertCount": 27000,"index": "wazuh-alerts-4.x-sample-security"},{"alertCount": 12000,"index": "wazuh-alerts-4.x-sample-auditing-policy-monitoring"},{"alertCount": 15000,"index": "wazuh-alerts-4.x-sample-threat-detection"}]

Given('The wazuh admin user is logged',  () => {
    if (Cypress.env('type') != 'wzd') {
    navigate("app/wazuh");}else{navigate("/")}
    elementIsVisible(wazuhMenuButton);
})

Given('The sample data is loaded', () => {
    cy.readFile('cookies.json').then((cookies) => {
        let headersFormat = {"content-type":"application/json; charset=utf-8","Cookie": getCookiesFromBrowser(cookies),"Accept":"application/json, text/plain, */*","Accept-Encoding":"gzip, deflate, br","osd-xsrf":"kibana"};
        for(let i = 0; i < urlsList.length; i++){
            cy.request({
                method: 'POST',
                url: urlsList[i],
                headers: headersFormat,
                body: urlBodys[i]
            }).should((response) => {
                expect(response.status).to.eq(200)
            })
        }

    })
})

The requests must include the cookie in the header, with a special format for these to be successful.

example
export const getCookiesFromBrowser = (values) => {
  return values.filter(item=>['wz-token', 'wz-user', 'wz-api', 'security_authentication'].includes(item.name))
  .map(item=>{
      return `${item.name}:${item.value}`
  }).join(';');
}
evidencie

2022-10-19_12-44

2022-10-19_12-46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation automation type/test Test issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants