mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
fix: Auth.api user limit test expecting incorrect status (#6836)
fix: auth.api user limit test expecting incorrect status
This commit is contained in:
parent
732416f52f
commit
371bfa0f48
|
@ -68,10 +68,16 @@ describe('POST /login', () => {
|
||||||
|
|
||||||
test('should throw AuthError for non-owner if not within users limit quota', async () => {
|
test('should throw AuthError for non-owner if not within users limit quota', async () => {
|
||||||
jest.spyOn(Container.get(License), 'isWithinUsersLimit').mockReturnValueOnce(false);
|
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');
|
const response = await testServer.authlessAgent.post('/login').send({
|
||||||
expect(response.statusCode).toBe(401);
|
email: member.email,
|
||||||
|
password,
|
||||||
|
});
|
||||||
|
expect(response.statusCode).toBe(403);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not throw AuthError for owner if not within users limit quota', async () => {
|
test('should not throw AuthError for owner if not within users limit quota', async () => {
|
||||||
|
|
|
@ -93,10 +93,8 @@ function createAgent(app: express.Application, options?: { auth: boolean; user:
|
||||||
const agent = request.agent(app);
|
const agent = request.agent(app);
|
||||||
void agent.use(prefix(REST_PATH_SEGMENT));
|
void agent.use(prefix(REST_PATH_SEGMENT));
|
||||||
if (options?.auth && options?.user) {
|
if (options?.auth && options?.user) {
|
||||||
try {
|
const { token } = issueJWT(options.user);
|
||||||
const { token } = issueJWT(options.user);
|
agent.jar.setCookie(`${AUTH_COOKIE_NAME}=${token}`);
|
||||||
agent.jar.setCookie(`${AUTH_COOKIE_NAME}=${token}`);
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue