diff --git a/test/verify-api-key-test.js b/test/verify-api-key-test.js index fe28b6c..c422354 100644 --- a/test/verify-api-key-test.js +++ b/test/verify-api-key-test.js @@ -179,4 +179,45 @@ describe('verify-api-key plugin', () => { badPlugin.onrequest.apply(null, [req, res, Buffer.alloc(5, 'a'), cb]); }); + + it('will pass the url path to verifier instead of the proxy', (done) => { + var express = require('express') + var app = express() + + app.post('/verifiers/apikey', function (req, res) { + res.setHeader("content-type", "application/json") + + accumulate(req, function (err, body) { + assert.equal('/foo/bar/baz', body.uriPath); + res.end(JSON.stringify({result: {status: "valid"}})); + }) + }) + + var srv = app.listen(9092); + + var config = { + apidEndpoint: 'http://localhost:9092/' + }; + var logger = { + error: (data, err) => console.error(data, err), + info: (data) => console.log(data) + }; + var stats = {}; + + badPlugin = verifyApiKey.init.apply(null, [config, logger, stats]); + + var req = { + headers: { + }, + url: '/foo/bar/baz?apikey=VALID-KEY' + } + var res = {proxy: proxy}; + var cb = (err, result) => { + srv.close(); + done(); + } + + badPlugin.onrequest.apply(null, [req, res, Buffer.alloc(5, 'a'), cb]); + + }); }) diff --git a/verify-api-key/index.js b/verify-api-key/index.js index aedb166..a230601 100644 --- a/verify-api-key/index.js +++ b/verify-api-key/index.js @@ -34,7 +34,7 @@ module.exports.init = function(config, logger, stats) { form: { key: apiKey, scopeuuid: scope, - uriPath: base_path, + uriPath: parsedRequestUrl.pathname, action: 'verify' } }