Files
wekan/tests/actionButtonsUseThemeClass.test.cjs
T
Lauri Ojansivu eb49a4b1b6 Override every login environment variable in Admin Panel / People.
Each login method has its own section: LDAP, OAuth2 (OpenID Connect and
Oracle OIM), CAS and Header login are new or complete, and the Login pane
gets PASSWORD_LOGIN_ENABLED and ACCOUNTS_COMMON_LOGIN_EXPIRATION_IN_DAYS.
models/lib/authConfigCatalog.js lists all 103 variables; server/lib/
authConfig.js resolves each one at run time (Admin Panel value first, then
the environment variable) for the app and, through
globalThis.__wekanAuthEnv, for the wekan-ldap, wekan-oidc and
wekan-accounts-cas packages. OAuth2 and CAS service configurations and LDAP
background sync are reapplied when their settings are saved.

Passwords and client secrets (LDAP_AUTHENTIFICATION_PASSWORD, OAUTH2_SECRET)
never reach the browser: the page learns only whether one is set and where
it comes from. Other values have credentials written inside a URL masked on
the server, and a URL field refuses them.

Fixed on the way:
- The Admin Panel LDAP overrides never applied. The bridge read Settings with
  a server-side findOne(), which Meteor 3 refuses; the error was swallowed and
  the environment used. The settings are now held in an observed cache.
- LDAP Test connection never existed on the server (testConnection.js was not
  imported) and used the synchronous Meteor.user().
- PROPAGATE_OIDC_DATA=false turned the feature on.
- CAS read only the misspelled CASE_VALIDATE_URL; CAS_VALIDATE_URL now works
  and the old name still does.
- snap help named three group-filter keys snap set does not know.

Every catalog variable is now listed in the Dockerfile, the docker-compose
files, snap config and help, and start-wekan.sh/.bat; 14 were missing.
tests/authConfigCatalog.test.cjs pins resolution, secrets, input validation,
platform coverage, and - across the whole tree - that no code reads a login
variable outside the catalog or straight from process.env, and that no
server code calls the synchronous Settings.findOne() or Meteor.user().
tests/playwright/specs/admin-login-env-overrides.e2e.js drives the pages.

Thanks to xet7 !
2026-10-05 19:48:48 +03:00

51 lines
2.3 KiB
JavaScript

'use strict';
// Regression guard: reported directly - on an opened card the Flowtime "Add
// Interruption" button rendered as an unthemed default button beside "Start
// Pomodoro", and the Timeline view's "Restore to this state" button the same
// way. WeKan's action buttons take their colors from the `.primary` (or
// `.negate` for destructive) theme class; a `button` with neither is the
// browser default, which looks like a different, unstyled control next to a
// themed one.
//
// This pins every labelled action button added by recent features to the
// `.primary` class. Pagination arrows, sort headers, icon-only toggles and the
// vote/poker buttons have their own deliberate styling and are not action
// buttons in this sense, so they are not listed.
//
// Run: node tests/actionButtonsUseThemeClass.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const ROOT = path.join(__dirname, '..');
let passed = 0;
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
const BUTTONS = [
['client/components/cards/cardFlowtime.jade', 'js-add-flow-interruption', 'Flowtime "Add Interruption"'],
['client/components/cards/cardFlowtime.jade', 'js-start-flow', 'Flowtime "Start"'],
['client/components/cards/cardPomodoro.jade', 'js-start-pomodoro', 'Pomodoro "Start"'],
['client/components/boards/timelineView.jade', 'js-restore-card-timeline', 'Timeline "Restore to this state"'],
['client/components/lists/listHeader.jade', 'js-list-sync-now', 'List "Sync now"'],
// Moved with the LDAP section to the catalog form's own template.
['client/components/settings/authProviderSettings.jade', 'js-ldap-test-connection', 'Admin Panel "Test LDAP Connection"'],
];
console.log('actionButtonsUseThemeClass:');
for (const [rel, cls, label] of BUTTONS) {
test(`${label} carries the .primary theme class`, () => {
const src = fs.readFileSync(path.join(ROOT, rel), 'utf8');
const line = src.split('\n').find(l => new RegExp(`^\\s*button[^\\s(]*\\.${cls}(?![\\w-])`).test(l));
assert.ok(line, `${rel} must still have a button.${cls}`);
const classChain = /^\s*button([.#][^\s(]*)/.exec(line)[1];
assert.ok(classChain.split('.').includes('primary'),
`${label} (${rel}) is an unthemed default button: ${line.trim()}`);
});
}
console.log(`\nactionButtonsUseThemeClass: ${passed} tests passed`);