From c7530b35e0ed15b8c8466a10cff18270cd038be3 Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Wed, 17 Jan 2024 08:22:26 -0500 Subject: [PATCH 01/17] STCOR-793 avoid potentially unsafe optional chaining Optional chaining may, of course, return `undefined`, causing `foo?.permissions.map(...)` to throw a TypeError since you cannot call `map` on `undefined`. Refs STCOR-793 --- CHANGELOG.md | 1 + src/loginServices.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5378cb31f..e90776469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Opt-in: handle access-control via cookies. Refs STCOR-671. * Opt-in: disable login when cookies are disabled. Refs STCOR-762. * Add arial-label for `ProfileDropdown.js`. Refs STCOR-753. +* Avoid calling `map` on `undefined` via optional-chaining. Refs STCOR-793. ## [10.0.0](https://github.com/folio-org/stripes-core/tree/v10.0.0) (2023-10-11) [Full Changelog](https://github.com/folio-org/stripes-core/compare/v9.0.0...v10.0.0) diff --git a/src/loginServices.js b/src/loginServices.js index b4d8a2c89..6d2bf10a8 100644 --- a/src/loginServices.js +++ b/src/loginServices.js @@ -397,9 +397,11 @@ export function spreadUserWithPerms(userWithPerms) { ...userWithPerms?.user?.personal, }; - // remap data's array of permission-names to set with - // permission-names for keys and `true` for values - const perms = Object.assign({}, ...userWithPerms?.permissions?.permissions.map(p => ({ [p.permissionName]: true }))); + // remap permissions from [foo, bar, bat] to { foo: true, bar: true, ... } + const perms = userWithPerms?.permissions?.permissions.reduce((acc, i) => { + acc[i.permissionName] = true; + return acc; + }, {}); return { user, perms }; } From 6e72ed858e05e23cbff4665e57ad196c44ad85f1 Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Wed, 17 Jan 2024 09:33:40 -0500 Subject: [PATCH 02/17] even safer optional-chaining --- src/loginServices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loginServices.js b/src/loginServices.js index 6d2bf10a8..a86873945 100644 --- a/src/loginServices.js +++ b/src/loginServices.js @@ -398,7 +398,7 @@ export function spreadUserWithPerms(userWithPerms) { }; // remap permissions from [foo, bar, bat] to { foo: true, bar: true, ... } - const perms = userWithPerms?.permissions?.permissions.reduce((acc, i) => { + const perms = userWithPerms?.permissions?.permissions?.reduce((acc, i) => { acc[i.permissionName] = true; return acc; }, {}); From 0669885c5385f7772181fc3887ec77feca705504 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:14:23 -0600 Subject: [PATCH 03/17] increase mirage timing for sso param test --- .vscode/launch.json | 19 ++++++++++++ .../network/scenarios/userWithPerms.js | 31 +++++++++++++++++++ test/bigtest/tests/sso-login-test.js | 15 ++++++--- 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 test/bigtest/network/scenarios/userWithPerms.js diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..913730bdf --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "attach", + "name": "Attach Karma Chrome", + "address": "localhost", + "port": 9333, + "pathMapping": { + "/": "${workspaceRoot}", + "/base/": "${workspaceRoot}/" + } + }, + ] +} \ No newline at end of file diff --git a/test/bigtest/network/scenarios/userWithPerms.js b/test/bigtest/network/scenarios/userWithPerms.js new file mode 100644 index 000000000..f66ccc220 --- /dev/null +++ b/test/bigtest/network/scenarios/userWithPerms.js @@ -0,0 +1,31 @@ +export default (server) => { + server.get('/bl-users/_self', { + 'user': { + 'username': 'diku_admin', + 'id': '882c886a-2d9a-5ffa-afc5-13912c257b99', + 'active': true, + 'patronGroup': '3684a786-6671-4268-8ed0-9db82ebca60b', + 'proxyFor': [ + ], + 'personal': { + 'lastName': 'ADMINISTRATOR', + 'firstName': 'DIKU', + 'email': 'admin@diku.example.org', + 'addresses': [ + ] + }, + 'createdDate': '2024-01-22T01:55:50.661+00:00', + 'updatedDate': '2024-01-22T01:55:50.661+00:00', + 'metadata': { + 'createdDate': '2024-01-22T01:52:08.076+00:00', + 'updatedDate': '2024-01-22T01:55:50.656+00:00', + 'updatedByUserId': '882c886a-2d9a-5ffa-afc5-13912c257b99' + }, + 'departments': [ + ] + }, + 'permissions': { + 'permissions': ['configuration.entries.collection.get'] + } + }); +} \ No newline at end of file diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 640772824..0b368b92b 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -1,7 +1,7 @@ import React from 'react'; import { expect } from 'chai'; import { beforeEach, it, describe } from '@bigtest/mocha'; - +import localforage from 'localforage'; import setupApplication from '../helpers/setup-core-application'; import SSOLandingInteractor from '../interactors/SSOLanding'; @@ -14,14 +14,14 @@ import SSOLandingInteractor from '../interactors/SSOLanding'; // derivatives). The two types don't play nice together because of they way // the do (or don't) clean up their mount points after running. // -describe('Login via SSO', () => { +describe.only('Login via SSO', () => { describe('SSO redirect', () => { const sso = new SSOLandingInteractor(); + setupApplication({ + disableAuth: false, + }); describe('Renders error without token', () => { - setupApplication({ - disableAuth: false, - }); beforeEach(async function () { this.visit('/sso-landing'); }); @@ -37,10 +37,15 @@ describe('Login via SSO', () => { describe('Reads token in params', () => { setupApplication({ + scenarios: ['userWithPerms'], disableAuth: false, + mirageOptions: { + timing: 20 + } }); beforeEach(async function () { + await localforage.clear(); this.visit('/sso-landing?ssoToken=c0ffee'); }); From 847b8a6a59b0a43566571e79300e0ca71449f08e Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:17:06 -0600 Subject: [PATCH 04/17] add .vscode folder to gitignore --- .gitignore | 1 + .vscode/launch.json | 19 ------------------- 2 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index c2756433b..fde854701 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.swp *.swo node_modules +/.vscode !test/webpack/node_modules/@folio/app2/node_modules/ !test/webpack/node_modules/ npm-debug.log diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 913730bdf..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "chrome", - "request": "attach", - "name": "Attach Karma Chrome", - "address": "localhost", - "port": 9333, - "pathMapping": { - "/": "${workspaceRoot}", - "/base/": "${workspaceRoot}/" - } - }, - ] -} \ No newline at end of file From ae7b8cd9b9fcfa76e1826ca91f68aa12890b4805 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:18:43 -0600 Subject: [PATCH 05/17] correct gitignore entry --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fde854701..effe34675 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ *.swp *.swo node_modules -/.vscode +.vscode/ !test/webpack/node_modules/@folio/app2/node_modules/ !test/webpack/node_modules/ npm-debug.log From 418aea31e09d604faece67a94096973aaf31163f Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:22:00 -0600 Subject: [PATCH 06/17] lint --- test/bigtest/network/scenarios/userWithPerms.js | 2 +- test/bigtest/tests/sso-login-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bigtest/network/scenarios/userWithPerms.js b/test/bigtest/network/scenarios/userWithPerms.js index f66ccc220..81a13be16 100644 --- a/test/bigtest/network/scenarios/userWithPerms.js +++ b/test/bigtest/network/scenarios/userWithPerms.js @@ -28,4 +28,4 @@ export default (server) => { 'permissions': ['configuration.entries.collection.get'] } }); -} \ No newline at end of file +}; diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 0b368b92b..0d4dec187 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -14,7 +14,7 @@ import SSOLandingInteractor from '../interactors/SSOLanding'; // derivatives). The two types don't play nice together because of they way // the do (or don't) clean up their mount points after running. // -describe.only('Login via SSO', () => { +describe('Login via SSO', () => { describe('SSO redirect', () => { const sso = new SSOLandingInteractor(); setupApplication({ From 4f1c082333726278f86d5808a2435c48b311fe14 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:31:21 -0600 Subject: [PATCH 07/17] add debug logging --- src/RootWithIntl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/RootWithIntl.js b/src/RootWithIntl.js index a507fff5a..981d7a8d3 100644 --- a/src/RootWithIntl.js +++ b/src/RootWithIntl.js @@ -77,6 +77,7 @@ class RootWithIntl extends React.Component { const connect = connectFor('@folio/core', this.props.stripes.epics, this.props.stripes.logger); const stripes = this.props.stripes.clone({ connect }); + console.log(`isAuthenticated: ${isAuthenticated}, token: ${token}`); return ( From 42cd76dbcee7d54fbf10bd2e004c0ce4b4d2bcf7 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:32:00 -0600 Subject: [PATCH 08/17] increase mirage timing --- test/bigtest/tests/sso-login-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 0d4dec187..9281df8d8 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -40,7 +40,7 @@ describe('Login via SSO', () => { scenarios: ['userWithPerms'], disableAuth: false, mirageOptions: { - timing: 20 + timing: 100 } }); From 3c775b94d9ee1dda84ede75d1ed5b5ae1cab5cea Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 15:42:03 -0600 Subject: [PATCH 09/17] add more logging --- src/components/ModuleContainer/ModuleContainer.js | 1 + src/components/SSOLanding.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/components/ModuleContainer/ModuleContainer.js b/src/components/ModuleContainer/ModuleContainer.js index 2c2308396..200e1c017 100644 --- a/src/components/ModuleContainer/ModuleContainer.js +++ b/src/components/ModuleContainer/ModuleContainer.js @@ -7,6 +7,7 @@ const propTypes = { }; function ModuleContainer(props) { + console.log('Module Container...'); return (
{props.children}
); diff --git a/src/components/SSOLanding.js b/src/components/SSOLanding.js index 655976178..516bee2d1 100644 --- a/src/components/SSOLanding.js +++ b/src/components/SSOLanding.js @@ -34,6 +34,7 @@ const SSOLanding = () => { } }, [token, store]); + console.log('SSOLanding...'); if (!token) { return (
@@ -42,6 +43,7 @@ const SSOLanding = () => { ); } + console.log('displaying message...'); return (

From ab39c98dc8593f39e7497323348cbabd8204c6d7 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 16:32:33 -0600 Subject: [PATCH 10/17] tweak async --- test/bigtest/tests/sso-login-test.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 9281df8d8..b3f3f09f5 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -22,7 +22,7 @@ describe('Login via SSO', () => { }); describe('Renders error without token', () => { - beforeEach(async function () { + beforeEach(function () { this.visit('/sso-landing'); }); @@ -44,8 +44,7 @@ describe('Login via SSO', () => { } }); - beforeEach(async function () { - await localforage.clear(); + beforeEach(function () { this.visit('/sso-landing?ssoToken=c0ffee'); }); From 65042374d63d3d8d50b326a2b0a3a285f50c2cf3 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 23 Jan 2024 16:37:52 -0600 Subject: [PATCH 11/17] remove debug comments --- src/RootWithIntl.js | 1 - src/components/ModuleContainer/ModuleContainer.js | 1 - src/components/SSOLanding.js | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/RootWithIntl.js b/src/RootWithIntl.js index 981d7a8d3..a507fff5a 100644 --- a/src/RootWithIntl.js +++ b/src/RootWithIntl.js @@ -77,7 +77,6 @@ class RootWithIntl extends React.Component { const connect = connectFor('@folio/core', this.props.stripes.epics, this.props.stripes.logger); const stripes = this.props.stripes.clone({ connect }); - console.log(`isAuthenticated: ${isAuthenticated}, token: ${token}`); return ( diff --git a/src/components/ModuleContainer/ModuleContainer.js b/src/components/ModuleContainer/ModuleContainer.js index 200e1c017..2c2308396 100644 --- a/src/components/ModuleContainer/ModuleContainer.js +++ b/src/components/ModuleContainer/ModuleContainer.js @@ -7,7 +7,6 @@ const propTypes = { }; function ModuleContainer(props) { - console.log('Module Container...'); return (

{props.children}
); diff --git a/src/components/SSOLanding.js b/src/components/SSOLanding.js index 516bee2d1..655976178 100644 --- a/src/components/SSOLanding.js +++ b/src/components/SSOLanding.js @@ -34,7 +34,6 @@ const SSOLanding = () => { } }, [token, store]); - console.log('SSOLanding...'); if (!token) { return (
@@ -43,7 +42,6 @@ const SSOLanding = () => { ); } - console.log('displaying message...'); return (

From 9a15f09272e6829bdb289b1b3ca53f9e4ae50e3b Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 08:22:36 -0600 Subject: [PATCH 12/17] async/await all the visits --- test/bigtest/tests/sso-login-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index b3f3f09f5..3b024b77d 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -22,8 +22,8 @@ describe('Login via SSO', () => { }); describe('Renders error without token', () => { - beforeEach(function () { - this.visit('/sso-landing'); + beforeEach(async function () { + await this.visit('/sso-landing'); }); it('Shows error message', () => { @@ -44,8 +44,8 @@ describe('Login via SSO', () => { } }); - beforeEach(function () { - this.visit('/sso-landing?ssoToken=c0ffee'); + beforeEach(async function () { + await this.visit('/sso-landing?ssoToken=c0ffee'); }); it('Shows token message', () => { @@ -60,7 +60,7 @@ describe('Login via SSO', () => { }); beforeEach(async function () { - this.visit('/sso-landing'); + await this.visit('/sso-landing'); }); it('Shows token message', () => { From d839d4c6d036303bdf1e6aa8c26b9fef01e22a01 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 08:45:25 -0600 Subject: [PATCH 13/17] wait for element for SSO tests --- src/components/SSOLanding.js | 4 ++-- test/bigtest/tests/sso-login-test.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/SSOLanding.js b/src/components/SSOLanding.js index 655976178..3b0b4c397 100644 --- a/src/components/SSOLanding.js +++ b/src/components/SSOLanding.js @@ -36,14 +36,14 @@ const SSOLanding = () => { if (!token) { return ( -

+
No ssoToken cookie or query parameter
); } return ( -
+

Logged in with token {token} from {getParams()?.ssoToken ? 'param' : 'cookie'}.

diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 3b024b77d..20cceb407 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -1,6 +1,7 @@ import React from 'react'; import { expect } from 'chai'; import { beforeEach, it, describe } from '@bigtest/mocha'; +import { when } from '@bigtest/convergence'; import localforage from 'localforage'; import setupApplication from '../helpers/setup-core-application'; import SSOLandingInteractor from '../interactors/SSOLanding'; @@ -23,7 +24,8 @@ describe('Login via SSO', () => { describe('Renders error without token', () => { beforeEach(async function () { - await this.visit('/sso-landing'); + this.visit('/sso-landing'); + await when(() => document.getElementById('sso-landing')); }); it('Shows error message', () => { @@ -45,7 +47,8 @@ describe('Login via SSO', () => { }); beforeEach(async function () { - await this.visit('/sso-landing?ssoToken=c0ffee'); + this.visit('/sso-landing?ssoToken=c0ffee'); + await when(() => document.getElementById('sso-landing')); }); it('Shows token message', () => { @@ -60,7 +63,8 @@ describe('Login via SSO', () => { }); beforeEach(async function () { - await this.visit('/sso-landing'); + this.visit('/sso-landing'); + await when(() => document.getElementById('sso-landing')); }); it('Shows token message', () => { From 906c7275bb8b2d431f788041e265441a107e7ec4 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 08:53:46 -0600 Subject: [PATCH 14/17] remove nested setupApp --- src/components/ModuleContainer/ModuleContainer.js | 1 + src/components/SSOLanding.js | 2 ++ test/bigtest/tests/sso-login-test.js | 10 ++++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/ModuleContainer/ModuleContainer.js b/src/components/ModuleContainer/ModuleContainer.js index 2c2308396..e0d7cc11b 100644 --- a/src/components/ModuleContainer/ModuleContainer.js +++ b/src/components/ModuleContainer/ModuleContainer.js @@ -7,6 +7,7 @@ const propTypes = { }; function ModuleContainer(props) { + console.log('rendering module container'); return (
{props.children}
); diff --git a/src/components/SSOLanding.js b/src/components/SSOLanding.js index 3b0b4c397..41dd9dc4d 100644 --- a/src/components/SSOLanding.js +++ b/src/components/SSOLanding.js @@ -35,6 +35,7 @@ const SSOLanding = () => { }, [token, store]); if (!token) { + console.log('rendering token error'); return (
No ssoToken cookie or query parameter @@ -42,6 +43,7 @@ const SSOLanding = () => { ); } + console.log('rendering token message'); return (

diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 20cceb407..faf7d8504 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -1,8 +1,6 @@ -import React from 'react'; import { expect } from 'chai'; import { beforeEach, it, describe } from '@bigtest/mocha'; import { when } from '@bigtest/convergence'; -import localforage from 'localforage'; import setupApplication from '../helpers/setup-core-application'; import SSOLandingInteractor from '../interactors/SSOLanding'; @@ -18,11 +16,11 @@ import SSOLandingInteractor from '../interactors/SSOLanding'; describe('Login via SSO', () => { describe('SSO redirect', () => { const sso = new SSOLandingInteractor(); - setupApplication({ - disableAuth: false, - }); - describe('Renders error without token', () => { + setupApplication({ + disableAuth: false, + }); + beforeEach(async function () { this.visit('/sso-landing'); await when(() => document.getElementById('sso-landing')); From 92266e14eb8ce10ad983023d56120d289e3c709a Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 10:45:08 -0600 Subject: [PATCH 15/17] manually clear local storage in tests, re-arrange for predictable failure --- test/bigtest/tests/sso-login-test.js | 41 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index faf7d8504..9950c9831 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { beforeEach, it, describe } from '@bigtest/mocha'; +import { beforeEach, afterEach, it, describe } from '@bigtest/mocha'; +import localforage from 'localforage'; import { when } from '@bigtest/convergence'; import setupApplication from '../helpers/setup-core-application'; import SSOLandingInteractor from '../interactors/SSOLanding'; @@ -16,48 +17,50 @@ import SSOLandingInteractor from '../interactors/SSOLanding'; describe('Login via SSO', () => { describe('SSO redirect', () => { const sso = new SSOLandingInteractor(); - describe('Renders error without token', () => { + + describe('Reads token in params', () => { setupApplication({ + scenarios: ['userWithPerms'], disableAuth: false, }); beforeEach(async function () { - this.visit('/sso-landing'); + this.visit('/sso-landing?ssoToken=c0ffee'); await when(() => document.getElementById('sso-landing')); }); - it('Shows error message', () => { - expect(sso.isError).to.be.true; + afterEach(async () => { + await localforage.clear(); }); - it('Does not show token message', () => { - expect(sso.isValid).to.be.false; + it('Shows token message', () => { + expect(sso.isValid).to.be.true; }); }); - describe('Reads token in params', () => { + describe('Reads token in cookie', () => { setupApplication({ - scenarios: ['userWithPerms'], disableAuth: false, - mirageOptions: { - timing: 100 - } + cookies: { ssoToken: 'c0ffee-c0ffee' }, }); beforeEach(async function () { - this.visit('/sso-landing?ssoToken=c0ffee'); + this.visit('/sso-landing'); await when(() => document.getElementById('sso-landing')); }); + afterEach(async () => { + await localforage.clear(); + }); + it('Shows token message', () => { expect(sso.isValid).to.be.true; }); }); - describe('Reads token in cookie', () => { + describe('Renders error without token', () => { setupApplication({ disableAuth: false, - cookies: { ssoToken: 'c0ffee-c0ffee' }, }); beforeEach(async function () { @@ -65,8 +68,12 @@ describe('Login via SSO', () => { await when(() => document.getElementById('sso-landing')); }); - it('Shows token message', () => { - expect(sso.isValid).to.be.true; + it('Shows error message', () => { + expect(sso.isError).to.be.true; + }); + + it('Does not show token message', () => { + expect(sso.isValid).to.be.false; }); }); }); From 5a2ff6d49fab6dc6c9980a2afc15d89b01a0e25d Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 10:57:56 -0600 Subject: [PATCH 16/17] remove logging, remove awaiting elements --- src/components/ModuleContainer/ModuleContainer.js | 1 - test/bigtest/tests/sso-login-test.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/components/ModuleContainer/ModuleContainer.js b/src/components/ModuleContainer/ModuleContainer.js index e0d7cc11b..2c2308396 100644 --- a/src/components/ModuleContainer/ModuleContainer.js +++ b/src/components/ModuleContainer/ModuleContainer.js @@ -7,7 +7,6 @@ const propTypes = { }; function ModuleContainer(props) { - console.log('rendering module container'); return (

{props.children}
); diff --git a/test/bigtest/tests/sso-login-test.js b/test/bigtest/tests/sso-login-test.js index 9950c9831..e4159d38f 100644 --- a/test/bigtest/tests/sso-login-test.js +++ b/test/bigtest/tests/sso-login-test.js @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { beforeEach, afterEach, it, describe } from '@bigtest/mocha'; import localforage from 'localforage'; -import { when } from '@bigtest/convergence'; import setupApplication from '../helpers/setup-core-application'; import SSOLandingInteractor from '../interactors/SSOLanding'; @@ -26,7 +25,6 @@ describe('Login via SSO', () => { beforeEach(async function () { this.visit('/sso-landing?ssoToken=c0ffee'); - await when(() => document.getElementById('sso-landing')); }); afterEach(async () => { @@ -46,7 +44,6 @@ describe('Login via SSO', () => { beforeEach(async function () { this.visit('/sso-landing'); - await when(() => document.getElementById('sso-landing')); }); afterEach(async () => { @@ -65,7 +62,6 @@ describe('Login via SSO', () => { beforeEach(async function () { this.visit('/sso-landing'); - await when(() => document.getElementById('sso-landing')); }); it('Shows error message', () => { From 7f3b01111ca8d6b596da57808bbdf28f7b59b6df Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 24 Jan 2024 11:07:34 -0600 Subject: [PATCH 17/17] remove more logging --- src/components/SSOLanding.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/SSOLanding.js b/src/components/SSOLanding.js index 41dd9dc4d..3b0b4c397 100644 --- a/src/components/SSOLanding.js +++ b/src/components/SSOLanding.js @@ -35,7 +35,6 @@ const SSOLanding = () => { }, [token, store]); if (!token) { - console.log('rendering token error'); return (
No ssoToken cookie or query parameter @@ -43,7 +42,6 @@ const SSOLanding = () => { ); } - console.log('rendering token message'); return (