Skip to content

Commit

Permalink
Add a test for 405 to reproduce #90
Browse files Browse the repository at this point in the history
  • Loading branch information
comino committed Oct 25, 2019
1 parent a8dacc4 commit ad21502
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/security.top.level.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ describe(packageJson.name, () => {
);
}));

it('should return 405 if apikey exist, but invalid method used', async () =>
request(app)
.post(`${basePath}/api_key`)
.set('X-API-Key', 'test')
.expect(405)
.then(r => {
const body = r.body;
console.log(body)
expect(body.errors).to.be.an('array');
expect(body.errors).to.have.length(1);
expect(body.errors[0].message).to.equals(
'POST method not allowed',
);
}));

it('should return 200 if apikey or anonymous', async () =>
request(app)
.get(`${basePath}/api_key_or_anonymous`)
Expand Down

0 comments on commit ad21502

Please sign in to comment.