Skip to content

Commit

Permalink
Merge pull request #36 from apigee/XAPID-802
Browse files Browse the repository at this point in the history
Fixes for XAPID-802
  • Loading branch information
Matthew Dobson authored Mar 10, 2017
2 parents c7fb46c + 6655abb commit 2a1f0ba
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions test/verify-api-key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

});
})
2 changes: 1 addition & 1 deletion verify-api-key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports.init = function(config, logger, stats) {
form: {
key: apiKey,
scopeuuid: scope,
uriPath: base_path,
uriPath: parsedRequestUrl.pathname,
action: 'verify'
}
}
Expand Down

0 comments on commit 2a1f0ba

Please sign in to comment.