From 371bfa0f488f0a240bd1a8854759d6f6639e6eea Mon Sep 17 00:00:00 2001 From: Val <68596159+valya@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:03:26 +0100 Subject: [PATCH] fix: Auth.api user limit test expecting incorrect status (#6836) fix: auth.api user limit test expecting incorrect status --- packages/cli/test/integration/auth.api.test.ts | 12 +++++++++--- .../cli/test/integration/shared/utils/testServer.ts | 6 ++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/test/integration/auth.api.test.ts b/packages/cli/test/integration/auth.api.test.ts index 009c2a590b..99944887b9 100644 --- a/packages/cli/test/integration/auth.api.test.ts +++ b/packages/cli/test/integration/auth.api.test.ts @@ -68,10 +68,16 @@ describe('POST /login', () => { test('should throw AuthError for non-owner if not within users limit quota', async () => { jest.spyOn(Container.get(License), 'isWithinUsersLimit').mockReturnValueOnce(false); - const member = await testDb.createUserShell(globalMemberRole); + const password = 'testpassword'; + const member = await testDb.createUser({ + password, + }); - const response = await testServer.authAgentFor(member).get('/login'); - expect(response.statusCode).toBe(401); + const response = await testServer.authlessAgent.post('/login').send({ + email: member.email, + password, + }); + expect(response.statusCode).toBe(403); }); test('should not throw AuthError for owner if not within users limit quota', async () => { diff --git a/packages/cli/test/integration/shared/utils/testServer.ts b/packages/cli/test/integration/shared/utils/testServer.ts index 1f4e2ecee5..8c9d9e059a 100644 --- a/packages/cli/test/integration/shared/utils/testServer.ts +++ b/packages/cli/test/integration/shared/utils/testServer.ts @@ -93,10 +93,8 @@ function createAgent(app: express.Application, options?: { auth: boolean; user: const agent = request.agent(app); void agent.use(prefix(REST_PATH_SEGMENT)); if (options?.auth && options?.user) { - try { - const { token } = issueJWT(options.user); - agent.jar.setCookie(`${AUTH_COOKIE_NAME}=${token}`); - } catch {} + const { token } = issueJWT(options.user); + agent.jar.setCookie(`${AUTH_COOKIE_NAME}=${token}`); } return agent; }