mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
A feature's guide now sits under the menu it is used from, read from the templates rather than from where somebody once put it: Header-Bar, All-Boards, Pages, Board-Header (search and every Board View), Board-Sidebar (Board Settings, Filter, Members, Labels, Archive), Rules, Swimlanes, Lists, Cards, Member-Settings, Admin-Panel and Login-Page. Topics used from several menus (editor, history, theme, translations, email, troubleshooting) are in General. - Each area has a README mapping its menu entries to their guides and to the template or server module that implements them. Board-Header/README.md lists all 40 Board View entries with the template boardBody.jade renders; five views (Table, Calendar Mode, Time, Timeline, Map) have no guide of their own yet and say so. - Board-View.md listed 25 views while BOARD_VIEWS has 40; it now lists all of them with their English labels. - Pages keep their file names. Where a released changelog links an old path, a "# Moved" page stays there and points to the new one; test-menu.sh skips folders holding only those. - Undo was filed under Login; it is General/Undo now. - Every link in docs, code comments, scripts and tests follows the move; docsLinksResolve checks them all. Tests that read a doc follow it to its new place. boardViewSettings now fails when Board-View.md or Board-Header/README.md differs from BOARD_VIEWS, or names a template boardBody.jade does not render. Thanks to xet7 !
93 lines
2.8 KiB
JavaScript
93 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { resolveOidcEndpoint } = require('../packages/wekan-oidc/endpoint');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
test('#5150 joins Spring Authorization Server default endpoints', () => {
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint('http://localhost:9000', '/oauth2/authorize'),
|
|
'http://localhost:9000/oauth2/authorize',
|
|
);
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint('http://localhost:9000/', 'oauth2/token'),
|
|
'http://localhost:9000/oauth2/token',
|
|
);
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint('http://localhost:9000/', '/userinfo'),
|
|
'http://localhost:9000/userinfo',
|
|
);
|
|
});
|
|
|
|
test('absolute HTTPS endpoints remain unchanged', () => {
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint(
|
|
'https://issuer.example',
|
|
'https://accounts.example/oauth2/token?tenant=one',
|
|
),
|
|
'https://accounts.example/oauth2/token?tenant=one',
|
|
);
|
|
});
|
|
|
|
test('#5150 absolute HTTP endpoints remain unchanged', () => {
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint(
|
|
'http://issuer.internal',
|
|
'http://userinfo.internal/userinfo',
|
|
),
|
|
'http://userinfo.internal/userinfo',
|
|
);
|
|
});
|
|
|
|
test('negative: slash normalization never creates a double slash in the path', () => {
|
|
for (const [base, endpoint] of [
|
|
['https://issuer.example/', '/oauth2/token'],
|
|
['https://issuer.example///', '///oauth2/token'],
|
|
['https://issuer.example', 'oauth2/token'],
|
|
]) {
|
|
assert.strictEqual(
|
|
resolveOidcEndpoint(base, endpoint),
|
|
'https://issuer.example/oauth2/token',
|
|
);
|
|
}
|
|
});
|
|
|
|
test('authorization, token, Oracle token and userinfo paths share the resolver', () => {
|
|
const client = fs.readFileSync(
|
|
path.join(__dirname, '..', 'packages', 'wekan-oidc', 'oidc_client.js'),
|
|
'utf8',
|
|
);
|
|
const server = fs.readFileSync(
|
|
path.join(__dirname, '..', 'packages', 'wekan-oidc', 'oidc_server.js'),
|
|
'utf8',
|
|
);
|
|
assert.match(
|
|
client,
|
|
/resolveOidcEndpoint\([\s\S]*config\.authorizationEndpoint/,
|
|
);
|
|
assert.strictEqual((server.match(/resolveOidcEndpoint\(/g) || []).length, 3);
|
|
assert.doesNotMatch(server, /includes\(['"]https:\/\/['"]\)/);
|
|
});
|
|
|
|
test('maintained docs name Spring defaults and the exact callback', () => {
|
|
const docs = fs.readFileSync(
|
|
path.join(__dirname, '..', 'docs', 'Features', 'Login-Page', 'OAuth2.md'),
|
|
'utf8',
|
|
);
|
|
assert.match(docs, /Spring Authorization Server/);
|
|
assert.match(docs, /OAUTH2_AUTH_ENDPOINT=\/oauth2\/authorize/);
|
|
assert.match(docs, /OAUTH2_TOKEN_ENDPOINT=\/oauth2\/token/);
|
|
assert.match(docs, /OAUTH2_USERINFO_ENDPOINT=\/userinfo/);
|
|
assert.match(docs, /_oauth\/oidc/);
|
|
});
|
|
|
|
console.log(`\noidcEndpoint: all ${passed} tests passed`);
|