From ed1607f0884ebe7d3580d6404a7866593b829445 Mon Sep 17 00:00:00 2001 From: Matthew Dobson Date: Tue, 7 Mar 2017 19:34:13 -0500 Subject: [PATCH 1/2] Making the message passed to client more expressive. Including error data in log as well. --- verify-api-key/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/verify-api-key/index.js b/verify-api-key/index.js index 02f1a72..aedb166 100644 --- a/verify-api-key/index.js +++ b/verify-api-key/index.js @@ -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'); From c8cd6139feccb0edc12bd15bd0de8d7c2751e686 Mon Sep 17 00:00:00 2001 From: Matthew Dobson Date: Tue, 7 Mar 2017 19:37:32 -0500 Subject: [PATCH 2/2] Fixing tests for api change. --- test/verify-api-key-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/verify-api-key-test.js b/test/verify-api-key-test.js index 1d848d8..fe28b6c 100644 --- a/test/verify-api-key-test.js +++ b/test/verify-api-key-test.js @@ -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'}})) } @@ -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(); }