-
Notifications
You must be signed in to change notification settings - Fork 39
Adds a feature where even request with GET query strings having dependent values can be pipelined #96
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @adisingh007, this is a great first step but there's a few things that need to be worked on before we can land this.
test/batch.js
Outdated
|
||
it('Now parses URL query params in pipelined requests', async () => { | ||
|
||
const res = await Internals.makeRequest(server, `{ "requests": [ {"method": "get", "path": "/string/${encodeURI('Aditya Pratap Singh')}"}, { "method": "get", "path": "/profile", "query": {"id": "$0"}}, { "method": "post", "path": "/echo", "payload": { "name": "$1.id" }} ] }`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the test string a non-identifying piece of data, rather than your full name.
test/batch.js
Outdated
|
||
expect(res[0]).to.equal('Aditya Pratap Singh'); | ||
expect(res[1].id).to.equal('Aditya Pratap Singh'); | ||
expect(res[2].name).to.equal('Aditya Pratap Singh'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same request here, and the lines above.
lib/batch.js
Outdated
@@ -33,6 +33,10 @@ module.exports.config = function (settings) { | |||
|
|||
request.payload.requests.every((req, idx) => { | |||
|
|||
if (req.query) { | |||
req.payload = req.query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not convert query parameters into request payloads in order to pipeline data into query parameters.
Bassmaster should look at the request it's processing, and if it contains a query object, it should see if previous request responses need to be pipelined into it before constructing a URL and injecting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cadecairos Hello Chris,
I have made another commit. Please have a look at it. Just how it was desired. Bassmaster looks at the request it is processing, and if the request contains a query object, it sees if the previous request responses needs to be pipelined into it before constructing a URL and injecting it. Wrote a test case too to cover the same.
Please review and let me know if anything else also needs to be done.
Thankyou,
Aditya
deca5ce
to
18453c5
Compare
@cadecairos
I have made the required changes. Now it works as it was expected.
Bassmaster now looks if the request has a query object and if it depends on
responses of previous request. Just like it handles payloads depended on
responses of previous request.
Please review.
|
18453c5
to
da14dbe
Compare
da14dbe
to
955c698
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I have one requested change!
lib/batch.js
Outdated
|
||
internals.requestRegex = /(?:\/)(?:\$(\d+)\.)?([^\/\$]*)/g; | ||
|
||
internals.parsePayload = function (obj) { | ||
internals.parseParsable = function (obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just call this parse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cadecairos Done
3a8927c
to
baf3aaf
Compare
… both pipelinable query and pipelinable payload objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful stuff, thanks @adisingh007
Closes #95
Now when the requests are:
inspite of being a query parameter(and not a path parameter),
$0.manufacturer_id
will now be parsed.Hence, even pipe lined query parameters will now be parsed if dependent on previous requests.