Files
wekan/tests/oauth2RocketChatSamlChainDocs.test.cjs
T
Lauri Ojansivu b7589737f5 File docs/Features the way the WeKan menus are.
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 !
2026-10-16 23:45:35 +03:00

30 lines
1.6 KiB
JavaScript

'use strict';
// #6549: WeKan -> Rocket.Chat (OAuth2) -> G Suite (SAML) only completes when
// every hop returns to the page that started it. The documented answer is the
// redirect login style, so the default must stay redirect and the doc must say
// how to configure the chain.
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const root = path.join(__dirname, '..');
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
const auth = read('server/authentication.js');
assert.match(auth, /loginStyle:\s*authEnv\('OAUTH2_LOGIN_STYLE'\) === 'popup' \? 'popup' : 'redirect'/,
'OIDC login style defaults to redirect; popup only when asked');
assert.match(read('snap-src/bin/config'), /DEFAULT_OAUTH2_LOGIN_STYLE="redirect"/, 'snap default is redirect');
const doc = read('docs/Features/Login-Page/OAuth2.md');
const start = doc.indexOf('### Rocket.Chat signing in with SAML');
assert.ok(start > 0, 'the SAML chain section exists');
const section = doc.slice(start, doc.indexOf('\n## ', start) > 0 ? doc.indexOf('\n## ', start) : undefined);
assert.match(section, /issues\/6549/);
assert.match(section, /oauth2-login-style='redirect'/);
assert.match(section, /OAUTH2_LOGIN_STYLE=redirect/);
assert.match(section, /_oauth\/oidc/, 'names the exact redirect URI');
assert.match(section, /NameID/, 'says what Google must send');
// Negative: the section never recommends the popup style for this chain.
assert.doesNotMatch(section, /login-style='popup'|OAUTH2_LOGIN_STYLE=popup/);
console.log('oauth2RocketChatSamlChainDocs: all tests passed');