mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
#5695 #4897 #4654 #5174 #4825 #5659 #4730 #4419 #4158 #4560 #4036
#1959 #1971.
- Startup schema upgrade (server/lib/schemaUpgradeSteps.js): on start,
check that data from EVERY old WeKan version is migrated to the newest
structure and migrate only what is missing - all platforms, MongoDB and
FerretDB. Version-gated (marker stores WeKan version + datetime of the
last re-check; one findOne per boot until a new release), non-blocking,
live dashboard at /schema-upgrade-status showing the product name, fast
on big databases (distinct() set-joins, updateMany batches). Steps:
archived-flag backfill, swimlane structure + visibility rescue
(#1959 #1971: cards under deleted/archived/foreign swimlanes reassigned
to a visible swimlane; card-insert hook validates supplied swimlaneIds),
merge-per-swimlane-lists (v7.98/v8.0x list copies merged back into
shared lists: no duplicate columns in Lists view, everything visible in
Swimlanes view, cards keep their swimlane), embedded checklist items,
customFields boardIds, allows* backfills, members isActive, permission
lowercase, filesystem path healing.
- Migration speed (5-hour reports): insertMany batches in the text phase,
preloaded target-record maps in the file phases.
- Snap attachment-repair + FILES_ONLY importer mode (see prior commit
wiring) extended with CFS FileSystem-store coverage
(ATTACHMENTS_STORE_PATH era), missing-binary reporting, and
migrate-gridfs-to-fs.mjs bucket fixes.
- OAuth2/OIDC: OAUTH2_LOGIN_STYLE=redirect honored (#5695); concurrent
logins no longer contaminate each other's user data (#4897); account
merge no longer wipes avatars/templates (#4560).
- LDAP: background sync fixed (#4654), password login rejected after LDAP
migration (#4419), LDAP_ENCRYPTION=true actually encrypts (#4158),
group filter accepts multiple groups and admits admin-sync groups
(#4036).
- All Boards tiles: per-list card counts + member avatars restored
non-reactively (#5174 #4825). Uniform default list widths (#5659).
Declined invitations no longer resurrect membership (#4730).
- Tests with negative cases for every fix (tests/*.test.cjs; suite green
except the pre-existing environment-only htmljs failure).
Closes #5600: OAUTH2_CA_CERT already works - the fetch migration
(49a272d6c) applies the CA to all OIDC calls via https.Agent.
Closes #3828: board members seeing all board cards is by design (no
per-card visibility model), and organizations/teams now exist.
Thanks to mueschel, ArturRuta, gerardo-junior, fabianrbz, Miuler,
butteredCat-2021, Griiimm, preciousamorc, farwayer, LeoLu-eng, hnb1,
rangersdo and xet7.
188 lines
7.3 KiB
JavaScript
188 lines
7.3 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node unit test (no Meteor) for LDAP_ENCRYPTION value normalization.
|
|
// Run: node tests/ldapEncryptionSetting.test.cjs
|
|
//
|
|
// Regression guard for #4158 ("Documentation/configuration of
|
|
// LDAP_ENCRYPTION"). Historically only the magic strings 'ssl' (= LDAPS) and
|
|
// 'tls' (= STARTTLS) did anything; the DOCUMENTED value 'true' was silently
|
|
// ignored (settings_get() JSON-parses it into boolean true, which matched
|
|
// neither string), and any typo/unknown value silently meant "no encryption".
|
|
//
|
|
// normalizeLdapEncryption(value) must:
|
|
// - map 'true'/boolean true -> LDAPS ('tls' mode);
|
|
// - keep the legacy values working with their HISTORICAL meaning
|
|
// ('ssl' -> LDAPS, 'tls' -> STARTTLS) plus a one-line deprecation notice
|
|
// naming the preferred value;
|
|
// - map 'starttls' -> STARTTLS;
|
|
// - map 'false'/''/unset/boolean false -> no encryption, no warning;
|
|
// - map anything else -> no encryption WITH a clear warning listing the
|
|
// accepted values (never silently treat an unknown value as enabled).
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
normalizeLdapEncryption,
|
|
} = require('../packages/wekan-ldap/server/encryptionSetting');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
// --- POSITIVE: LDAPS (immediate TLS) -----------------------------------------
|
|
|
|
test("'true' means LDAPS, no warning", () => {
|
|
const r = normalizeLdapEncryption('true');
|
|
assert.strictEqual(r.mode, 'tls');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('boolean true (settings_get JSON-parses the env string) means LDAPS', () => {
|
|
// ldap.js settings_get() turns the env string 'true' into boolean true;
|
|
// this is exactly the value that used to be silently ignored (#4158).
|
|
const r = normalizeLdapEncryption(true);
|
|
assert.strictEqual(r.mode, 'tls');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test("'TRUE' (any case) means LDAPS", () => {
|
|
assert.strictEqual(normalizeLdapEncryption('TRUE').mode, 'tls');
|
|
assert.strictEqual(normalizeLdapEncryption('True').mode, 'tls');
|
|
});
|
|
|
|
test("legacy 'ssl' still means LDAPS (backwards compatible)", () => {
|
|
const r = normalizeLdapEncryption('ssl');
|
|
assert.strictEqual(r.mode, 'tls');
|
|
});
|
|
|
|
test("legacy 'ssl' logs a deprecation notice naming 'true'", () => {
|
|
const r = normalizeLdapEncryption('ssl');
|
|
assert.ok(typeof r.warning === 'string' && r.warning.length > 0);
|
|
assert.ok(r.warning.includes("'true'"), 'must name the preferred value');
|
|
assert.ok(/deprecat/i.test(r.warning), 'must say it is deprecated');
|
|
});
|
|
|
|
test("legacy 'SSL' (any case) still means LDAPS", () => {
|
|
const r = normalizeLdapEncryption('SSL');
|
|
assert.strictEqual(r.mode, 'tls');
|
|
assert.ok(r.warning, 'still deprecated regardless of case');
|
|
});
|
|
|
|
// --- POSITIVE: STARTTLS ------------------------------------------------------
|
|
|
|
test("'starttls' means STARTTLS, no warning", () => {
|
|
const r = normalizeLdapEncryption('starttls');
|
|
assert.strictEqual(r.mode, 'starttls');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test("'StartTLS' (any case) means STARTTLS", () => {
|
|
assert.strictEqual(normalizeLdapEncryption('StartTLS').mode, 'starttls');
|
|
assert.strictEqual(normalizeLdapEncryption('STARTTLS').mode, 'starttls');
|
|
});
|
|
|
|
test("legacy 'tls' still means STARTTLS (its historical behavior)", () => {
|
|
// Backwards compatibility: 'tls' has ALWAYS meant STARTTLS in WeKan.
|
|
// Remapping it to LDAPS would break every existing STARTTLS setup.
|
|
const r = normalizeLdapEncryption('tls');
|
|
assert.strictEqual(r.mode, 'starttls');
|
|
});
|
|
|
|
test("legacy 'tls' logs a deprecation notice naming 'starttls'", () => {
|
|
const r = normalizeLdapEncryption('tls');
|
|
assert.ok(typeof r.warning === 'string' && r.warning.length > 0);
|
|
assert.ok(r.warning.includes("'starttls'"), 'must name the preferred value');
|
|
assert.ok(/deprecat/i.test(r.warning), 'must say it is deprecated');
|
|
});
|
|
|
|
// --- POSITIVE: no encryption -------------------------------------------------
|
|
|
|
test("'false' means no encryption, no warning", () => {
|
|
const r = normalizeLdapEncryption('false');
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('boolean false (settings_get JSON-parses the env string) means no encryption', () => {
|
|
const r = normalizeLdapEncryption(false);
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('empty string means no encryption, no warning', () => {
|
|
const r = normalizeLdapEncryption('');
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('unset (undefined) means no encryption, no warning', () => {
|
|
const r = normalizeLdapEncryption(undefined);
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('null means no encryption, no warning', () => {
|
|
const r = normalizeLdapEncryption(null);
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.strictEqual(r.warning, undefined);
|
|
});
|
|
|
|
test('surrounding whitespace is tolerated', () => {
|
|
assert.strictEqual(normalizeLdapEncryption(' true ').mode, 'tls');
|
|
assert.strictEqual(normalizeLdapEncryption(' starttls ').mode, 'starttls');
|
|
assert.strictEqual(normalizeLdapEncryption(' false ').mode, 'off');
|
|
});
|
|
|
|
// --- NEGATIVE: unknown values must warn, never silently enable/disable -------
|
|
|
|
test('NEGATIVE: unknown value means no encryption plus a clear warning', () => {
|
|
const r = normalizeLdapEncryption('bogus');
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.ok(typeof r.warning === 'string' && r.warning.length > 0,
|
|
'unknown values must warn, never fail silently');
|
|
assert.ok(r.warning.includes("'bogus'"), 'warning must echo the bad value');
|
|
});
|
|
|
|
test('NEGATIVE: the warning for unknown values lists all accepted values', () => {
|
|
const w = normalizeLdapEncryption('yes').warning;
|
|
assert.ok(w.includes("'true'"), "must list 'true'");
|
|
assert.ok(w.includes("'starttls'"), "must list 'starttls'");
|
|
assert.ok(w.includes("'false'"), "must list 'false'");
|
|
assert.ok(w.includes("'ssl'"), "must mention legacy 'ssl'");
|
|
assert.ok(w.includes("'tls'"), "must mention legacy 'tls'");
|
|
});
|
|
|
|
test('NEGATIVE: unknown value is never treated as encryption enabled', () => {
|
|
for (const bad of ['yes', 'on', '1', 'ldaps', 'sttarttls', 'enable', 'TLSv1.2']) {
|
|
const r = normalizeLdapEncryption(bad);
|
|
assert.strictEqual(r.mode, 'off', `'${bad}' must not silently enable encryption`);
|
|
assert.ok(r.warning, `'${bad}' must produce a warning`);
|
|
}
|
|
});
|
|
|
|
test('NEGATIVE: numeric values (settings_get converts digits) warn and stay off', () => {
|
|
// settings_get() turns '1'/'0' into Numbers; neither is a valid setting.
|
|
for (const bad of [1, 0]) {
|
|
const r = normalizeLdapEncryption(bad);
|
|
assert.strictEqual(r.mode, 'off');
|
|
assert.ok(r.warning, `${bad} must produce a warning`);
|
|
}
|
|
});
|
|
|
|
test("NEGATIVE: 'starttls' must NOT map to LDAPS and 'true' must NOT map to STARTTLS", () => {
|
|
assert.notStrictEqual(normalizeLdapEncryption('starttls').mode, 'tls');
|
|
assert.notStrictEqual(normalizeLdapEncryption('true').mode, 'starttls');
|
|
});
|
|
|
|
test('NEGATIVE: valid values never carry the invalid-value warning', () => {
|
|
for (const good of ['true', 'starttls', 'false', '', undefined, true, false]) {
|
|
const r = normalizeLdapEncryption(good);
|
|
assert.strictEqual(r.warning, undefined,
|
|
`'${good}' is valid and must not warn`);
|
|
}
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|