Bug 40174: Require RESTBasicAuth turned ON

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 <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ddf8014ead)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-07-11 11:29:13 +02:00 committed by Paul Derscheid
parent b850118d3d
commit 26653b2a78
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 12 additions and 0 deletions

View File

@ -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."
);
}
});
});