-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 4.4-7.16] Add an environment validation to check the request (
#4741) Adding a environment validation to check the request (#4738) * Adding a environment validation to check the request * Deleting dependency (cherry picked from commit 4ff3b8c) Co-authored-by: Mayons95 <104914131+Mayons95@users.noreply.github.com>
- Loading branch information
1 parent
8ff154e
commit 22490ce
Showing
1 changed file
with
41 additions
and
23 deletions.
There are no files selected for viewing
64 changes: 41 additions & 23 deletions
64
...ess/cypress/integration/step-definitions/settings/The-wazuh-admin-user-is-logged.given.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,47 @@ | ||
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'; | ||
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"}] | ||
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 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) | ||
}) | ||
} | ||
|
||
}) | ||
}) | ||
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', | ||
}; | ||
Cypress.env('type') == 'xpack' | ||
? (headersFormat['kbn-xsrf'] = 'kibana') | ||
: (headersFormat['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); | ||
}); | ||
} | ||
}); | ||
}); |