Skip to content

Commit

Permalink
[Backport 2.x] Updating cypress version and fixing CVE-2024-21538 (#1247
Browse files Browse the repository at this point in the history
) (#1249)

* Updating cypress version and fixing CVE-2024-21538 (#1247)

* Updating cypress version

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Fixing CVE-2024-21538

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Testing cypress baselining

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Modifying spec patterns

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Fixing an issue in snpashot e2e test

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

---------

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
(cherry picked from commit 3eb1b24)

* Updating upload artifacts to v4

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Updating certificates and key

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

* Updating cypress.config

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>

---------

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
  • Loading branch information
tandonks authored Jan 30, 2025
1 parent 3db302c commit 8a9e7f5
Show file tree
Hide file tree
Showing 25 changed files with 686 additions and 1,214 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ jobs:
wait-on: 'http://localhost:5601'
browser: chrome
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin/cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos
Expand Down
32 changes: 32 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { defineConfig } = require("cypress");
const fs = require("fs");
const path = require("path");

module.exports = defineConfig({
e2e: {
specPattern: "cypress/e2e/plugins/index-management-dashboards-plugin/*.{js,jsx,ts,tsx}",
defaultCommandTimeout: 60000,
requestTimeout: 60000,
responseTimeout: 60000,
baseUrl: "http://localhost:5601",
viewportWidth: 2000,
viewportHeight: 1320,
env: {
openSearchUrl: "http://localhost:9200",
SECURITY_ENABLED: false,
username: "admin",
password: "admin",
},
setupNodeEvents(on, config) {
on("task", {
readCertAndKey() {
const cert = fs.readFileSync(path.resolve(__dirname, "cypress/resources/kirk.pem"));
const key = fs.readFileSync(path.resolve(__dirname, "cypress/resources/kirk-key.pem"));
return { cert, key };
},
});
// implement node event listeners here
return config;
},
},
});
14 changes: 0 additions & 14 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe("Snapshots", () => {

describe("Snapshot can be restored", () => {
it("Successfully restores indexes from snapshot", () => {
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/snapshots`);
// Wait for snapshot to be created successfully with a 12sec timeout
cy.get(`[data-test-subj="refreshButton"]`, { timeout: 12000 })
.should("be.visible")
Expand Down Expand Up @@ -124,6 +125,7 @@ describe("Snapshots", () => {

describe("Snapshot can be deleted", () => {
it("deletes snapshot successfully", () => {
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/snapshots`);
// Select test snapshot
cy.get(`[data-test-subj="checkboxSelectRow-test_repo:test_snapshot"]`).check({ force: true });

Expand Down
57 changes: 0 additions & 57 deletions cypress/plugins/index.js

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Cypress.Commands.add("login", () => {

Cypress.Commands.add("deleteAllIndices", () => {
cy.log("Deleting all indexes");
cy.request("DELETE", `${Cypress.env("openSearchUrl")}/index*,sample*,opensearch_dashboards*`);
cy.request("DELETE", `${Cypress.env("openSearchUrl")}/test_index_*,index*,sample*,opensearch_dashboards*`);
cy.task("readCertAndKey").then(({ cert, key }) => {
cy.request({
method: "DELETE",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"**/nth-check": "^2.0.1",
"**/typescript": "4.0.2",
"**/terser": "^4.8.1",
"braces": "^3.0.3"
"braces": "^3.0.3",
"**/eslint/cross-spawn": "^7.0.5"
},
"devDependencies": {
"@elastic/elastic-eslint-config-kibana": "link:../../packages/opensearch-eslint-config-opensearch-dashboards",
Expand All @@ -72,7 +73,7 @@
"@types/json-schema": "^7.0.11",
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.3.2",
"cypress": "9.5.4",
"cypress": "12.17.4",
"diff": "^4.0.1",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
Expand All @@ -83,4 +84,4 @@
"engines": {
"yarn": "^1.21.1"
}
}
}
Loading

0 comments on commit 8a9e7f5

Please sign in to comment.