Catch any unexpected error during login and return 403 (#76)

This commit is contained in:
Simon J
2021-11-08 17:26:09 +11:00
committed by GitHub
parent c804627a0a
commit bb4172acf4
2 changed files with 41 additions and 13 deletions

View File

@@ -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";