Fix for unhandled undefined config in reset password pages (#4334)

* Fix for unhandled undefined config

When an invalid application id is passed either for reset/change password or email verification, config.get returns undefined. This causes internal server.

* Throwing a 403 exception instead of returning a 404 for an invalid app id

Also, added a missing semicolon

* Fix indent issues

* Fix invalid colon to semicolon

* Fix space and indent issues

* Tests for the fix for unhandled undefined config
This commit is contained in:
Bryan de Leon
2017-11-11 22:42:20 +08:00
committed by Florent Vilmart
parent 72e20be06d
commit 4e207d32a7
2 changed files with 73 additions and 1 deletions

View File

@@ -63,3 +63,47 @@ describe("public API without publicServerURL", () => {
});
});
});
describe("public API supplied with invalid application id", () => {
beforeEach(done => {
reconfigureServer({appName: "unused"})
.then(done, fail);
});
it("should get 403 on verify_email", (done) => {
request('http://localhost:8378/1/apps/invalid/verify_email', (err, httpResponse) => {
expect(httpResponse.statusCode).toBe(403);
done();
});
});
it("should get 403 choose_password", (done) => {
request('http://localhost:8378/1/apps/choose_password?id=invalid', (err, httpResponse) => {
expect(httpResponse.statusCode).toBe(403);
done();
});
});
it("should get 403 on get of request_password_reset", (done) => {
request('http://localhost:8378/1/apps/invalid/request_password_reset', (err, httpResponse) => {
expect(httpResponse.statusCode).toBe(403);
done();
});
});
it("should get 403 on post of request_password_reset", (done) => {
request.post('http://localhost:8378/1/apps/invalid/request_password_reset', (err, httpResponse) => {
expect(httpResponse.statusCode).toBe(403);
done();
});
});
it("should get 403 on resendVerificationEmail", (done) => {
request('http://localhost:8378/1/apps/invalid/resend_verification_email', (err, httpResponse) => {
expect(httpResponse.statusCode).toBe(403);
done();
});
});
});