From 295bbd4a29ccff6154b79c7de616cf1b5c960c37 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Jul 2025 11:29:13 +0200 Subject: [PATCH] Bug 40174: Require RESTBasicAuth turned ON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From MM thread https://chat.koha-community.org/koha-community/pl/aptoodssm7gu8x491onfgxs1xr Cypress tests need RESTBasicAuth - I’m stuck in a chicken-and-egg problem being eaten by its own tail... I need advice. Some Cypress tests need RESTBasicAuth, but it's disabled by default. My plan was to turn it on globally (ie. set before any tests, and reset to its original value after) but we cannot right now: Update in DB could work, but its cached Call the svc script won't work, as we are not logged in yet (and this script require the session cookie) so, I have a lot of solutions, but not sure which one to pick * have a "flush cache" route (smells the rabbit hole) * login to get the cookie, set the syspref via the svc script, logout (ugly, and will slower the cypress tests) * require the pref on for cypress tests * ? I would opt now for the third option, turn it on in Jenkins when we run the cypress tests. And explode for devs when the pref is not set. What do you think? If we push this as it, Jenkins is going to fail. We need to restructure how Jenkins is running the Cypress tests anyway: we need a dedicated job to run them all. We will turn ON the syspref for this job. Signed-off-by: Matt Blenkinsop --- t/cypress/support/e2e.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js index 40265d607bf..b4f07fda5c5 100644 --- a/t/cypress/support/e2e.js +++ b/t/cypress/support/e2e.js @@ -1916,3 +1916,15 @@ Cypress.Commands.add("mock_table_settings", (settings, table_settings_var) => { cy.wrap(table_settings.columns).as("columns"); }); }); + +before(() => { + cy.task("query", { + sql: "SELECT value FROM systempreferences WHERE variable='RESTBasicAuth'", + }).then(value => { + if (value[0].value !== "1") { + throw new Error( + "Cypress tests tests require 'RESTBasicAuth'. Skipping suite." + ); + } + }); +}); -- 2.48.1