11local cjson = require " cjson"
2- local pl_stringx = require " pl.stringx"
32
43describe (" operations protocol" , function ()
54
@@ -37,10 +36,6 @@ describe("operations protocol", function()
3736 },
3837 input = {
3938 type = " structure" ,
40- locationName = " mainXmlElement" , -- only for rest-xml protocol
41- xmlNamespace = { -- only for rest-xml protocol
42- uri = " cool-name-space"
43- },
4439 required = {
4540 " RoleArn" ,
4641 " RoleSessionName"
@@ -206,6 +201,7 @@ describe("operations protocol", function()
206201 local request = build_request (operation , config , params )
207202 assert .same ({
208203 headers = {
204+ [" Accept" ] = ' application/json' ,
209205 [" X-Sooper-Secret" ] = " towel" ,
210206 [" X-Amz-Target" ] = " sts.AssumeRole" ,
211207 [" Host" ] = " sts.amazonaws.com" ,
@@ -239,6 +235,7 @@ describe("operations protocol", function()
239235
240236 assert .same ({
241237 headers = {
238+ [" Accept" ] = ' application/json' ,
242239 [" X-Sooper-Secret" ] = " towel" ,
243240 [" Content-Length" ] = 172 ,
244241 [" Content-Type" ] = " application/x-amz-json-1.0" ,
@@ -279,6 +276,7 @@ describe("operations protocol", function()
279276
280277 assert .same ({
281278 headers = {
279+ [" Accept" ] = ' application/json' ,
282280 [" X-Sooper-Secret" ] = " towel" ,
283281 [" Content-Length" ] = 172 ,
284282 [" Content-Type" ] = " application/x-amz-json-1.0" ,
@@ -314,6 +312,7 @@ describe("operations protocol", function()
314312
315313 assert .same ({
316314 headers = {
315+ [" Accept" ] = ' application/json' ,
317316 [" Content-Length" ] = 4 ,
318317 [" X-Amz-Target" ] = " s3.PutObject" ,
319318 [" Host" ] = " s3.amazonaws.com" ,
@@ -328,85 +327,6 @@ describe("operations protocol", function()
328327 end )
329328
330329
331- it (" rest-xml: querystring, uri, header and body params" , function ()
332-
333- config .protocol = " rest-xml"
334-
335- local request = build_request (operation , config , params )
336- if request and request .body then
337- -- cannot reliably compare non-canonicalized json, so decode to Lua table
338- local body_lines = pl_stringx .splitlines (request .body )
339- for i , line in ipairs (body_lines ) do
340- body_lines [i ] = pl_stringx .strip (line , ' ' )
341- end
342- request .body = assert (require (" pl.xml" ).parse (table.concat (body_lines , " " )))
343- local to_lua = function (t )
344- -- convert LOM to comparable Lua table
345- for i , v in ipairs (t ) do
346- if type (v ) == " table" and v .tag then
347- t [v .tag ] = v
348- v .tag = nil
349- t [i ] = nil
350- if type (v .attr ) == " table" and not next (v .attr ) then
351- -- delete empty attr table
352- v .attr = nil
353- end
354- end
355- end
356- end
357- to_lua (request .body )
358- to_lua (request .body .someSubStructure )
359- end
360-
361- assert .same ({
362- headers = {
363- [" X-Sooper-Secret" ] = " towel" ,
364- [" Content-Length" ] = 456 ,
365- [" Content-Type" ] = " application/xml" ,
366- [" X-Amz-Target" ] = " sts.AssumeRole" ,
367- [" Host" ] = " sts.amazonaws.com" ,
368- },
369- method = ' POST' ,
370- path = ' /hello%20world/42' ,
371- host = ' sts.amazonaws.com' ,
372- port = 443 ,
373- body = {
374- RoleArn = {
375- [1 ] = ' hello' },
376- RoleSessionName = {
377- [1 ] = ' world' },
378- BinaryData = {
379- [1 ] = binary_data },
380- attr = {
381- [1 ] = ' xmlns' ,
382- xmlns = ' cool-name-space' },
383- someSubStructure = {
384- hello = {
385- [1 ] = ' the default hello thinghy' },
386- world = {
387- [1 ] = ' the default world thinghy' } },
388- subList = {
389- [1 ] = {
390- [1 ] = ' 1' ,
391- attr = {},
392- tag = ' listELement' },
393- [2 ] = {
394- [1 ] = ' 2' ,
395- attr = {},
396- tag = ' listELement' },
397- [3 ] = {
398- [1 ] = ' 3' ,
399- attr = {},
400- tag = ' listELement' } },
401- tag = ' mainXmlElement' },
402- query = {
403- UserId = " Arthur Dent" ,
404- nice = ' ' ,
405- }
406- }, request )
407- end )
408-
409-
410330 pending (" ec2: querystring, uri, header and body params" , function ()
411331
412332 config .protocol = " ec2"
0 commit comments