From 9f1ffde4c07e2515bde6c0c03edb8eb6c23ae16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Aug 2022 16:23:16 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20e2e:=20Make=20port=20configurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cookie are port specific, so they need to be determine from the port from the base URL. --- tests/cypress/integration/login.js | 16 +++++++++++----- tests/cypress/util/util.js | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/cypress/integration/login.js b/tests/cypress/integration/login.js index afe7307fa..1281ffd99 100644 --- a/tests/cypress/integration/login.js +++ b/tests/cypress/integration/login.js @@ -1,4 +1,10 @@ -import {prepare_server, await_coreui, await_loginui, login} from "../util/util"; +import { + prepare_server, + await_coreui, + await_loginui, + login, + get_cookie_name +} from "../util/util"; context("Login tests", () => { const username = "admin"; @@ -27,8 +33,8 @@ context("Login tests", () => { await_coreui(); cy.get("[data-test-id=login-menu-title]").should("contain", username); - cy.getCookie("session_P5000").should("exist"); - cy.getCookie("remember_token_P5000").should("not.exist"); + cy.getCookie(get_cookie_name("session")).should("exist"); + cy.getCookie(get_cookie_name("remember_token")).should("not.exist"); cy.location().should((loc) => { expect(loc.hash).to.eq("#temp"); }); @@ -45,8 +51,8 @@ context("Login tests", () => { await_coreui(); cy.get("[data-test-id=login-menu-title]").should("contain", username); - cy.getCookie("session_P5000").should("exist"); - cy.getCookie("remember_token_P5000").should(($cookie) => { + cy.getCookie(get_cookie_name("session")).should("exist"); + cy.getCookie(get_cookie_name("remember_token")).should(($cookie) => { expect($cookie).to.have.property("value"); expect($cookie.value).to.match(new RegExp("^" + username + "|")); }); diff --git a/tests/cypress/util/util.js b/tests/cypress/util/util.js index 81e769ad8..2b568e660 100644 --- a/tests/cypress/util/util.js +++ b/tests/cypress/util/util.js @@ -70,3 +70,9 @@ export const ensure_file_unknown = (location, name) => { failOnStatusCode: false }); }; + +export const get_cookie_name = (cookie) => { + const url = new URL(Cypress.config("baseUrl")); + const port = url.port || (url.protocol === "https:" ? 443 : 80); + return `${cookie}_P${port}`; +};