fix: Auth.api user limit test expecting incorrect status (#6836)

fix: auth.api user limit test expecting incorrect status
This commit is contained in:
Val 2023-08-03 13:03:26 +01:00 committed by GitHub
parent 732416f52f
commit 371bfa0f48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -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 () => {

View file

@ -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 {}
}
return agent;
}