Skip to content

Commit

Permalink
chore: added test
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed May 18, 2024
1 parent 456c947 commit 595f50e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 18 additions & 0 deletions spec/validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,24 @@ describe("Request validation middleware", () => {
expect(response.statusCode).toEqual(200);
});

it("should validate if options passed but not validate flag", () => {
const newUrl =
fullUrl.pathname + fullUrl.search + "&somethingUnexpected=true";
const request = httpMocks.createRequest(
Object.assign({}, defaultRequest, {
originalUrl: newUrl,
})
);

const middleware = webhook(token, {});

middleware(request, response, () => {
expect(true).toBeFalsy();
});

expect(response.statusCode).toEqual(403);
});

it("should accept manual host+proto", (done) => {
const request = httpMocks.createRequest(
Object.assign({}, defaultRequest, {
Expand Down
6 changes: 2 additions & 4 deletions src/webhooks/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,8 @@ export function webhook(
}
}

if (!options)
options = {};
if (!options.validate)
options.validate = true
if (!options) options = {};
if (!options.validate) options.validate = true;

// Process arguments
var tokenString;
Expand Down

0 comments on commit 595f50e

Please sign in to comment.