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.
111 lines
4.6 KiB
JavaScript
111 lines
4.6 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node unit test for issue #4654: LDAP background sync
|
|
// (LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED) only worked once for new
|
|
// users. getUserById() built its search filter from LDAP_UNIQUE_IDENTIFIER_FIELD
|
|
// alone: unset -> TypeError (undefined.split) aborting the whole sync run;
|
|
// empty -> invalid filter "(|(=value))" (seen in the issue logs), so existing
|
|
// users were never found again ("Can't sync user"). The stored id can also come
|
|
// from LDAP_USER_SEARCH_FIELD (getLdapUserUniqueID fallback), so the filter must
|
|
// consider both settings.
|
|
// Run: node tests/ldapUserIdFilter.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
splitFieldSetting,
|
|
buildUserIdFilter,
|
|
} = require('../packages/wekan-ldap/server/userIdFilter');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
// ── splitFieldSetting ─────────────────────────────────────────────────────────
|
|
|
|
test('split: comma list with whitespace', () => {
|
|
assert.deepStrictEqual(splitFieldSetting(' guid , sAMAccountName '), ['guid', 'sAMAccountName']);
|
|
});
|
|
|
|
test('split: unset/empty/non-string means no fields', () => {
|
|
assert.deepStrictEqual(splitFieldSetting(undefined), []);
|
|
assert.deepStrictEqual(splitFieldSetting(''), []);
|
|
assert.deepStrictEqual(splitFieldSetting(null), []);
|
|
assert.deepStrictEqual(splitFieldSetting(123), []);
|
|
});
|
|
|
|
test('split: drops empty entries so no "(=value)" clause can be built', () => {
|
|
assert.deepStrictEqual(splitFieldSetting('a,,b,'), ['a', 'b']);
|
|
assert.deepStrictEqual(splitFieldSetting(' , '), []);
|
|
});
|
|
|
|
// ── buildUserIdFilter: positive cases ─────────────────────────────────────────
|
|
|
|
test('stored idAttribute wins and is used directly', () => {
|
|
assert.strictEqual(
|
|
buildUserIdFilter('sAMAccountName', '\\6d\\2e', 'guid', 'uid'),
|
|
'(sAMAccountName=\\6d\\2e)',
|
|
);
|
|
});
|
|
|
|
test('single unique identifier field gives a plain equality filter', () => {
|
|
assert.strictEqual(
|
|
buildUserIdFilter(undefined, '\\01\\02', 'objectGUID', ''),
|
|
'(objectGUID=\\01\\02)',
|
|
);
|
|
});
|
|
|
|
test('multiple fields are OR-ed', () => {
|
|
assert.strictEqual(
|
|
buildUserIdFilter(undefined, 'v', 'guid,entryUUID', 'uid'),
|
|
'(|(guid=v)(entryUUID=v)(uid=v))',
|
|
);
|
|
});
|
|
|
|
test('#4654 config: unset LDAP_UNIQUE_IDENTIFIER_FIELD falls back to LDAP_USER_SEARCH_FIELD', () => {
|
|
// The issue reporter had only LDAP_USER_SEARCH_FIELD=sAMAccountName set;
|
|
// the old code crashed on settings_get(...).split(',') here.
|
|
assert.strictEqual(
|
|
buildUserIdFilter(undefined, '\\6d\\2e\\75\\73\\65\\72', undefined, 'sAMAccountName'),
|
|
'(sAMAccountName=\\6d\\2e\\75\\73\\65\\72)',
|
|
);
|
|
});
|
|
|
|
test('duplicate attribute across both settings is de-duplicated', () => {
|
|
// The workaround from the issue comments: LDAP_UNIQUE_IDENTIFIER_FIELD set
|
|
// to the same attribute as LDAP_USER_SEARCH_FIELD.
|
|
assert.strictEqual(
|
|
buildUserIdFilter(undefined, 'v', 'sAMAccountName', 'sAMAccountName'),
|
|
'(sAMAccountName=v)',
|
|
);
|
|
});
|
|
|
|
// ── buildUserIdFilter: negative cases ─────────────────────────────────────────
|
|
|
|
test('empty unique identifier field never yields the invalid "(|(=value))" filter', () => {
|
|
// Old behavior: ''.split(',') -> [''] -> "(|(=m.user))" as in the issue log.
|
|
const filter = buildUserIdFilter(undefined, 'm.user', '', 'sAMAccountName');
|
|
assert.strictEqual(filter, '(sAMAccountName=m.user)');
|
|
assert.ok(!filter.includes('(='), 'filter must not contain an empty attribute name');
|
|
});
|
|
|
|
test('no usable attribute anywhere returns null instead of throwing or "(|)"', () => {
|
|
assert.strictEqual(buildUserIdFilter(undefined, 'v', undefined, undefined), null);
|
|
assert.strictEqual(buildUserIdFilter(undefined, 'v', '', ''), null);
|
|
assert.strictEqual(buildUserIdFilter(null, 'v', ' , ', ' '), null);
|
|
});
|
|
|
|
test('old implementation would have failed on the issue configuration', () => {
|
|
// Documents the regression this test guards against: the pre-fix code path.
|
|
const oldGetUserByIdFilter = (uniqueIdentifierSetting, escapedValue) => {
|
|
const fields = uniqueIdentifierSetting.split(','); // throws when unset
|
|
return `(|${fields.map((item) => `(${item}=${escapedValue})`).join('')})`;
|
|
};
|
|
assert.throws(() => oldGetUserByIdFilter(undefined, 'm.user'), TypeError);
|
|
assert.strictEqual(oldGetUserByIdFilter('', 'm.user'), '(|(=m.user))'); // invalid filter
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|