|
1 | | -// Generated by CoffeeScript 1.12.3 |
| 1 | +var sqsModel = require('../../apis/sqs-2012-11-05.min.json'); |
| 2 | +var isJsonProtocol = sqsModel.metadata.protocol === 'json'; |
| 3 | + |
2 | 4 | (function() { |
3 | 5 | var AWS, helpers; |
4 | 6 |
|
|
7 | 9 | AWS = helpers.AWS; |
8 | 10 |
|
9 | 11 | describe('AWS.SQS', function() { |
10 | | - var checksumValidate, sqs; |
11 | | - sqs = null; |
| 12 | + var sqs = null; |
12 | 13 | beforeEach(function() { |
13 | 14 | return sqs = new AWS.SQS({ |
14 | 15 | params: { |
15 | 16 | QueueUrl: 'http://url' |
16 | 17 | } |
17 | 18 | }); |
18 | 19 | }); |
19 | | - checksumValidate = function(operation, input, response, shouldPass, cb) { |
| 20 | + var checksumValidate = function(operation, input, response, shouldPass, cb) { |
20 | 21 | helpers.mockHttpResponse(200, {}, response); |
21 | 22 | return sqs[operation](input).send(function(err, data) { |
22 | 23 | if (shouldPass) { |
| 24 | + if (err !== null) { |
| 25 | + throw err; |
| 26 | + } |
23 | 27 | expect(err).to.equal(null); |
24 | 28 | } else { |
25 | 29 | expect(err).not.to.equal(null); |
|
51 | 55 | }; |
52 | 56 | md5 = 'acbd18db4cc2f85cedef654fccc4a4d8'; |
53 | 57 | payload = function(md5) { |
| 58 | + if (isJsonProtocol) { |
| 59 | + return JSON.stringify({ |
| 60 | + MD5OfMessageBody: md5, |
| 61 | + MessageId: 'MSGID', |
| 62 | + }, null, 2); |
| 63 | + } |
54 | 64 | return '<SendMessageResponse><SendMessageResult>\n <MD5OfMessageBody>' + md5 + '</MD5OfMessageBody>\n <MessageId>MSGID</MessageId>\n</SendMessageResult></SendMessageResponse>'; |
55 | 65 | }; |
56 | 66 | it('correctly validates MD5 of message input', function(done) { |
|
92 | 102 | md5foo = 'acbd18db4cc2f85cedef654fccc4a4d8'; |
93 | 103 | md5bar = '37b51d194a7513e45b56f6524f2d51f2'; |
94 | 104 | payload = function(md5a, md5b, md5c) { |
| 105 | + if (isJsonProtocol) { |
| 106 | + return JSON.stringify({ |
| 107 | + Successful: [ |
| 108 | + { |
| 109 | + Id: 'a', |
| 110 | + MessageId: 'MSGID1', |
| 111 | + MD5OfMessageBody: md5a |
| 112 | + }, |
| 113 | + { |
| 114 | + Id: 'b', |
| 115 | + MessageId: 'MSGID2', |
| 116 | + MD5OfMessageBody: md5b |
| 117 | + }, |
| 118 | + { |
| 119 | + Id: 'c', |
| 120 | + MessageId: 'MSGID3', |
| 121 | + MD5OfMessageBody: md5c |
| 122 | + } |
| 123 | + ] |
| 124 | + }, null, 2); |
| 125 | + } |
95 | 126 | return '<SendMessageBatchResponse><SendMessageBatchResult>\n <SendMessageBatchResultEntry>\n <Id>a</Id>\n <MessageId>MSGID1</MessageId>\n <MD5OfMessageBody>' + md5a + '</MD5OfMessageBody>\n </SendMessageBatchResultEntry>\n <SendMessageBatchResultEntry>\n <Id>b</Id>\n <MessageId>MSGID2</MessageId>\n <MD5OfMessageBody>' + md5b + '</MD5OfMessageBody>\n </SendMessageBatchResultEntry>\n <SendMessageBatchResultEntry>\n <Id>c</Id>\n <MessageId>MSGID3</MessageId>\n <MD5OfMessageBody>' + md5c + '</MD5OfMessageBody>\n </SendMessageBatchResultEntry>\n</SendMessageBatchResult></SendMessageBatchResponse>'; |
96 | 127 | }; |
97 | 128 | it('correctly validates MD5 of operation', function(done) { |
|
126 | 157 | var md5, payload; |
127 | 158 | md5 = 'acbd18db4cc2f85cedef654fccc4a4d8'; |
128 | 159 | payload = function(body, md5, id) { |
| 160 | + if (isJsonProtocol) { |
| 161 | + return JSON.stringify({ |
| 162 | + Messages: [ |
| 163 | + { |
| 164 | + Body: body, |
| 165 | + MD5OfBody: md5, |
| 166 | + MessageId: id |
| 167 | + } |
| 168 | + ] |
| 169 | + }, null, 2); |
| 170 | + } |
129 | 171 | return '<ReceiveMessageResponse><ReceiveMessageResult><Message>\n <Body>' + body + '</Body>\n <MD5OfBody>' + md5 + '</MD5OfBody>\n <MessageId>' + id + '</MessageId>\n</Message></ReceiveMessageResult></ReceiveMessageResponse>'; |
130 | 172 | }; |
131 | 173 | it('correctly validates MD5 of operation', function(done) { |
|
0 commit comments