Skip to content

Commit d2f931d

Browse files
authored
Merge pull request #1361 from jeskew/chore/sync-protocol-tests
Sync protocol tests
2 parents 5eec2b1 + 6abbbd5 commit d2f931d

14 files changed

+1198
-194
lines changed

lib/event_listeners.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var AWS = require('./core');
22
var SequentialExecutor = require('./sequential_executor');
3-
var uuid = require('uuid');
43
/**
54
* The namespace used to register global event listeners for request building
65
* and sending.
@@ -97,7 +96,7 @@ AWS.EventListeners = {
9796
for (var i = 0, iLen = idempotentMembers.length; i < iLen; i++) {
9897
if (!params[idempotentMembers[i]]) {
9998
// add the member
100-
params[idempotentMembers[i]] = uuid.v4();
99+
params[idempotentMembers[i]] = AWS.util.uuid.v4();
101100
}
102101
}
103102
req.params = params;

lib/query/query_param_serializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function serializeList(name, list, rules, fn) {
5959
name = parts.join('.');
6060
}
6161
} else {
62-
suffix = '.member' + suffix;
62+
suffix = '.' + (memberRules.name ? memberRules.name : 'member') + suffix;
6363
}
6464
serializeMember(name + suffix, v, memberRules, fn);
6565
});

lib/util.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,15 @@ var util = {
871871
};
872872

873873
process.nextTick(sendRequest);
874+
},
875+
876+
/**
877+
* @api private
878+
*/
879+
uuid: {
880+
v4: function uuidV4() {
881+
return require('uuid').v4();
882+
}
874883
}
875884

876885
};

test/fixtures/protocol/input/ec2.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,5 +356,59 @@
356356
}
357357
}
358358
]
359+
},
360+
{
361+
"description": "Idempotency token auto fill",
362+
"metadata": {
363+
"protocol": "ec2",
364+
"apiVersion": "2014-01-01"
365+
},
366+
"shapes": {
367+
"InputShape": {
368+
"type": "structure",
369+
"members": {
370+
"Token": {
371+
"shape": "StringType",
372+
"idempotencyToken": true
373+
}
374+
}
375+
},
376+
"StringType": {
377+
"type": "string"
378+
}
379+
},
380+
"cases": [
381+
{
382+
"given": {
383+
"input": {
384+
"shape": "InputShape"
385+
},
386+
"name": "OperationName"
387+
},
388+
"params": {
389+
"Token": "abc123"
390+
},
391+
"serialized": {
392+
"uri": "/",
393+
"headers": {},
394+
"body": "Action=OperationName&Version=2014-01-01&Token=abc123"
395+
}
396+
},
397+
{
398+
"given": {
399+
"input": {
400+
"shape": "InputShape"
401+
},
402+
"name": "OperationName"
403+
},
404+
"params": {
405+
},
406+
"serialized": {
407+
"uri": "/",
408+
"headers": {},
409+
"body": "Action=OperationName&Version=2014-01-01&Token=00000000-0000-4000-8000-000000000000"
410+
}
411+
}
412+
]
359413
}
360414
]

test/fixtures/protocol/input/json.json

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
"description": "Empty maps",
427427
"metadata": {
428428
"protocol": "json",
429-
"jsonVersion": 1.1,
429+
"jsonVersion": "1.1",
430430
"targetPrefix": "com.amazonaws.foo"
431431
},
432432
"shapes": {
@@ -475,5 +475,65 @@
475475
}
476476
}
477477
]
478+
},
479+
{
480+
"description": "Idempotency token auto fill",
481+
"metadata": {
482+
"protocol": "json",
483+
"apiVersion": "2014-01-01"
484+
},
485+
"shapes": {
486+
"InputShape": {
487+
"type": "structure",
488+
"members": {
489+
"Token": {
490+
"shape": "StringType",
491+
"idempotencyToken": true
492+
}
493+
}
494+
},
495+
"StringType": {
496+
"type": "string"
497+
}
498+
},
499+
"cases": [
500+
{
501+
"given": {
502+
"input": {
503+
"shape": "InputShape"
504+
},
505+
"http": {
506+
"method": "POST"
507+
},
508+
"name": "OperationName"
509+
},
510+
"params": {
511+
"Token": "abc123"
512+
},
513+
"serialized": {
514+
"uri": "/",
515+
"headers": {},
516+
"body": "{\"Token\": \"abc123\"}"
517+
}
518+
},
519+
{
520+
"given": {
521+
"input": {
522+
"shape": "InputShape"
523+
},
524+
"http": {
525+
"method": "POST"
526+
},
527+
"name": "OperationName"
528+
},
529+
"params": {
530+
},
531+
"serialized": {
532+
"uri": "/",
533+
"headers": {},
534+
"body": "{\"Token\": \"00000000-0000-4000-8000-000000000000\"}"
535+
}
536+
}
537+
]
478538
}
479539
]

0 commit comments

Comments
 (0)