From 4c583e2be4ed23dfa3c32492db6d7f9fea64b413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 23 Mar 2023 16:54:35 +0100 Subject: [PATCH] ci: Fix saml.api.test.ts (no-changelog) (#5764) --- packages/cli/src/sso/ssoHelpers.ts | 1 + .../cli/test/integration/saml/saml.api.test.ts | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/sso/ssoHelpers.ts b/packages/cli/src/sso/ssoHelpers.ts index dcd5c1ac3e..99cf43cfd8 100644 --- a/packages/cli/src/sso/ssoHelpers.ts +++ b/packages/cli/src/sso/ssoHelpers.ts @@ -25,5 +25,6 @@ export async function setCurrentAuthenticationMethod( await Db.collections.Settings.save({ key: 'userManagement.authenticationMethod', value: authenticationMethod, + loadOnStartup: true, }); } diff --git a/packages/cli/test/integration/saml/saml.api.test.ts b/packages/cli/test/integration/saml/saml.api.test.ts index 3eda945f9e..32b5f7fa63 100644 --- a/packages/cli/test/integration/saml/saml.api.test.ts +++ b/packages/cli/test/integration/saml/saml.api.test.ts @@ -10,9 +10,8 @@ import * as utils from '../shared/utils'; let owner: User; let authOwnerAgent: SuperAgentTest; -function enableSaml(enable: boolean) { - setSamlLoginEnabled(enable); - setCurrentAuthenticationMethod(enable ? 'saml' : 'email'); +async function enableSaml(enable: boolean) { + await setSamlLoginEnabled(enable); config.set('enterprise.features.saml', enable); } @@ -22,10 +21,6 @@ beforeAll(async () => { authOwnerAgent = utils.createAuthAgent(app)(owner); }); -// beforeEach(async () => { -// await testDb.truncate(['User']); -// }); - afterAll(async () => { await testDb.terminate(); }); @@ -33,7 +28,7 @@ afterAll(async () => { describe('Instance owner', () => { describe('PATCH /me', () => { test('should succeed with valid inputs', async () => { - enableSaml(false); + await enableSaml(false); await authOwnerAgent .patch('/me') .send({ @@ -46,7 +41,7 @@ describe('Instance owner', () => { }); test('should throw BadRequestError if email is changed when SAML is enabled', async () => { - enableSaml(true); + await enableSaml(true); await authOwnerAgent .patch('/me') .send({ @@ -60,7 +55,7 @@ describe('Instance owner', () => { describe('PATCH /password', () => { test('should throw BadRequestError if password is changed when SAML is enabled', async () => { - enableSaml(true); + await enableSaml(true); await authOwnerAgent .patch('/me/password') .send({