Skip to content

Commit

Permalink
Merge pull request #33 from apigee/better-verify-api-key-error
Browse files Browse the repository at this point in the history
Making the message passed to client more expressive. Including error data in log as well.
  • Loading branch information
Matthew Dobson authored Mar 8, 2017
2 parents 89d7ee3 + c8cd613 commit 93eb9f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/verify-api-key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('verify-api-key plugin', () => {
}

if (body.key === 'INVALID-KEY') {
res.end(JSON.stringify({type: 'ErrorResult', result: {errorCode: "PROVIDED_ERROR_CODE"}}));
res.end(JSON.stringify({type: 'ErrorResult', result: {errorCode: "PROVIDED_ERROR_CODE", reason: "LOL KEY ISNT HERE"}}));
} else if (body.key === 'REVOKED-KEY') {
res.end(JSON.stringify({result:{status: 'REVOKED'}}))
}
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('verify-api-key plugin', () => {
}
var res = {proxy: proxy};
var cb = (err, result) => {
assert.equal(err, "PROVIDED_ERROR_CODE");
assert.equal(err, "LOL KEY ISNT HERE");
assert.equal(res.statusCode, 401);
done();
}
Expand Down
4 changes: 2 additions & 2 deletions verify-api-key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ module.exports.init = function(config, logger, stats) {
}

if (jsonBody.type == 'ErrorResult') {
logger.error(jsonBody.result.errorCode, 'verify-api-key');
logger.error(jsonBody.result, jsonBody.result.reason, 'verify-api-key');
res.statusCode = 401;
next (jsonBody.result.errorCode);
next (jsonBody.result.reason);
}
else if (jsonBody.result.status == 'REVOKED') {
logger.info('API key has been revoked.', 'verify-api-key');
Expand Down

0 comments on commit 93eb9f9

Please sign in to comment.