ci: Fix saml.api.test.ts (no-changelog) (#5764)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-03-23 16:54:35 +01:00 committed by GitHub
parent 15412b2b2b
commit 4c583e2be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View file

@ -25,5 +25,6 @@ export async function setCurrentAuthenticationMethod(
await Db.collections.Settings.save({ await Db.collections.Settings.save({
key: 'userManagement.authenticationMethod', key: 'userManagement.authenticationMethod',
value: authenticationMethod, value: authenticationMethod,
loadOnStartup: true,
}); });
} }

View file

@ -10,9 +10,8 @@ import * as utils from '../shared/utils';
let owner: User; let owner: User;
let authOwnerAgent: SuperAgentTest; let authOwnerAgent: SuperAgentTest;
function enableSaml(enable: boolean) { async function enableSaml(enable: boolean) {
setSamlLoginEnabled(enable); await setSamlLoginEnabled(enable);
setCurrentAuthenticationMethod(enable ? 'saml' : 'email');
config.set('enterprise.features.saml', enable); config.set('enterprise.features.saml', enable);
} }
@ -22,10 +21,6 @@ beforeAll(async () => {
authOwnerAgent = utils.createAuthAgent(app)(owner); authOwnerAgent = utils.createAuthAgent(app)(owner);
}); });
// beforeEach(async () => {
// await testDb.truncate(['User']);
// });
afterAll(async () => { afterAll(async () => {
await testDb.terminate(); await testDb.terminate();
}); });
@ -33,7 +28,7 @@ afterAll(async () => {
describe('Instance owner', () => { describe('Instance owner', () => {
describe('PATCH /me', () => { describe('PATCH /me', () => {
test('should succeed with valid inputs', async () => { test('should succeed with valid inputs', async () => {
enableSaml(false); await enableSaml(false);
await authOwnerAgent await authOwnerAgent
.patch('/me') .patch('/me')
.send({ .send({
@ -46,7 +41,7 @@ describe('Instance owner', () => {
}); });
test('should throw BadRequestError if email is changed when SAML is enabled', async () => { test('should throw BadRequestError if email is changed when SAML is enabled', async () => {
enableSaml(true); await enableSaml(true);
await authOwnerAgent await authOwnerAgent
.patch('/me') .patch('/me')
.send({ .send({
@ -60,7 +55,7 @@ describe('Instance owner', () => {
describe('PATCH /password', () => { describe('PATCH /password', () => {
test('should throw BadRequestError if password is changed when SAML is enabled', async () => { test('should throw BadRequestError if password is changed when SAML is enabled', async () => {
enableSaml(true); await enableSaml(true);
await authOwnerAgent await authOwnerAgent
.patch('/me/password') .patch('/me/password')
.send({ .send({