Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(request): unspecified location goes in body, also for blob #120

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ Release process:
1. test installing the rock from LuaRocks


### 1.x.x unreleased

- fix: when a "blob" type has no location specified, then use it as the body, same as with other types.
[120](https://github.com/Kong/lua-resty-aws/pull/120)

### 1.5.0 (20-May-2024)

- feat: decode AWS api response json body with array metatable
Expand Down
22 changes: 17 additions & 5 deletions spec/02-requests/02-build_request_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe("operations protocol", function()
local config
local params
local snapshot
local binary_data

setup(function()
snapshot = assert:snapshot()
Expand All @@ -26,6 +27,8 @@ describe("operations protocol", function()


before_each(function()
binary_data = "abcd" --"\00\01\02\03"

operation = {
name = "AssumeRole",
http = {
Expand Down Expand Up @@ -76,6 +79,9 @@ describe("operations protocol", function()
RoleSessionName = {
type = "string",
},
BinaryData = {
type = "blob",
},
subStructure = {
locationName = "someSubStructure",
type = "structure",
Expand Down Expand Up @@ -124,7 +130,8 @@ describe("operations protocol", function()
hello = "the default hello thinghy",
world = "the default world thinghy"
},
subList = { 1, 2 ,3, }
subList = { 1, 2 ,3, },
BinaryData = binary_data,
}

end)
Expand Down Expand Up @@ -164,6 +171,7 @@ describe("operations protocol", function()
Action = "AssumeRole",
Version = "2011-06-15",
nice = '',
BinaryData = binary_data,
}
}, request)
end)
Expand All @@ -182,7 +190,7 @@ describe("operations protocol", function()
assert.same({
headers = {
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 152,
["Content-Length"] = 172,
["Content-Type"] = "application/x-amz-json-1.0",
["X-Amz-Target"] = "sts.AssumeRole",
["Host"] = "sts.amazonaws.com",
Expand All @@ -199,11 +207,12 @@ describe("operations protocol", function()
subList = { 1,2,3 },
RoleArn = "hello",
RoleSessionName = "world",
BinaryData = binary_data,
},
query = {
UserId = "Arthur Dent",
nice = '',
}
},
}, request)
end)

Expand All @@ -221,7 +230,7 @@ describe("operations protocol", function()
assert.same({
headers = {
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 152,
["Content-Length"] = 172,
["Content-Type"] = "application/x-amz-json-1.0",
["X-Amz-Target"] = "sts.AssumeRole",
["Host"] = "sts.amazonaws.com",
Expand All @@ -238,6 +247,7 @@ describe("operations protocol", function()
subList = { 1,2,3 },
RoleArn = "hello",
RoleSessionName = "world",
BinaryData = binary_data,
},
query = {
UserId = "Arthur Dent",
Expand Down Expand Up @@ -280,7 +290,7 @@ describe("operations protocol", function()
assert.same({
headers = {
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 424,
["Content-Length"] = 456,
["Content-Type"] = "application/xml",
["X-Amz-Target"] = "sts.AssumeRole",
["Host"] = "sts.amazonaws.com",
Expand All @@ -294,6 +304,8 @@ describe("operations protocol", function()
[1] = 'hello' },
RoleSessionName = {
[1] = 'world' },
BinaryData = {
[1] = binary_data },
attr = {
[1] = 'xmlns',
xmlns = 'cool-name-space' },
Expand Down
2 changes: 0 additions & 2 deletions src/resty/aws/request/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ local function build_request(operation, config, params)
if config.protocol == "query" then
-- no location specified, but protocol is query, so it goes into query
request.query[name] = param_value
elseif member_config.type == "blob" then
request.body = param_value
else
-- nowhere else to go, so put it in the body (for json and xml)
body_tbl[name] = param_value
Expand Down
Loading