-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/stop stringing payload blobs (#1457)
* Update rest-json and rest-xml to only cast payloads to strings when they are actually strings * Add customizations to AWS.APIGateway, AWS.IotData, and AWS.Lambda to continue converting JSON payloads modeled as blobs into strings * Move payload-to-string conversion function to AWS.util * Add changelog entry
- Loading branch information
Showing
17 changed files
with
163 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "Parser", | ||
"description": "Makes casting payload blobs to strings an exceptional behavior rather than the default" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var AWS = require('../core'); | ||
|
||
AWS.util.update(AWS.Lambda.prototype, { | ||
/** | ||
* @api private | ||
*/ | ||
setupRequestListeners: function setupRequestListeners(request) { | ||
if (request.operation === 'invoke') { | ||
request.addListener('extractData', AWS.util.convertPayloadToString); | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var AWS = require('../../index'); | ||
var helpers = require('../helpers'); | ||
var Buffer = AWS.util.Buffer; | ||
|
||
describe('AWS.IotData', function() { | ||
var blobPayloadOutputOps = [ | ||
'deleteThingShadow', | ||
'getThingShadow', | ||
'updateThingShadow' | ||
]; | ||
|
||
for (var i = 0; i < blobPayloadOutputOps.length; i++) { | ||
describe(blobPayloadOutputOps[i], (function(operation) { | ||
return function() { | ||
it('converts the body to a string', function(done) { | ||
var client = new AWS.IotData({endpoint: 'localhost'}); | ||
var shadow = JSON.stringify({foo: 'bar', fizz: ['buzz', 'pop']}); | ||
var body = new Buffer(shadow); | ||
helpers.mockHttpResponse(200, {}, body); | ||
client[operation]({thingName: 'thing'}, function(err, data) { | ||
expect(Buffer.isBuffer(data.payload)).to.be.false; | ||
expect(data.payload).to.eql(shadow); | ||
done(); | ||
}); | ||
}); | ||
}; | ||
})(blobPayloadOutputOps[i])); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var AWS = require('../../index'); | ||
var helpers = require('../helpers'); | ||
var Buffer = AWS.util.Buffer; | ||
|
||
describe('AWS.IotData', function() { | ||
describe('invoke', function() { | ||
it('converts the body to a string', function(done) { | ||
var client = new AWS.Lambda(); | ||
var payload = JSON.stringify({foo: 'bar', fizz: ['buzz', 'pop']}); | ||
var body = new Buffer(payload); | ||
helpers.mockHttpResponse(200, {}, body); | ||
client.invoke({FunctionName: 'function'}, function(err, data) { | ||
expect(Buffer.isBuffer(data.Payload)).to.be.false; | ||
expect(data.Payload).to.eql(payload); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters