mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Catch any unexpected error during login and return 403 (#76)
This commit is contained in:
@@ -680,6 +680,27 @@ describe("server", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when an unexpected failure occurs", () => {
|
||||
it("should return 403 with message", async () => {
|
||||
const username = "userDoesntExist";
|
||||
const password = "password";
|
||||
const linkCode = uuid();
|
||||
|
||||
linkCodes.has.mockReturnValue(true);
|
||||
musicService.generateToken.mockRejectedValue("BOOOOOOM");
|
||||
|
||||
const res = await request(server)
|
||||
.post(bonobUrl.append({ pathname: "/login" }).pathname())
|
||||
.set("accept-language", acceptLanguage)
|
||||
.type("form")
|
||||
.send({ username, password, linkCode })
|
||||
.expect(403);
|
||||
|
||||
expect(res.text).toContain(lang("loginFailed"));
|
||||
expect(res.text).toContain('Unexpected error occured - BOOOOOOM');
|
||||
});
|
||||
});
|
||||
|
||||
describe("when linkCode is invalid", () => {
|
||||
it("should return 400 with message", async () => {
|
||||
const username = "jane";
|
||||
|
||||
Reference in New Issue
Block a user