aws-sdk 2.0.1 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +20 -0
- package/.gitignore +10 -0
- package/.travis.yml +20 -0
- package/.yardopts +20 -0
- package/.yardopts_guide +21 -0
- package/Gemfile +16 -0
- package/Gemfile.lock +34 -0
- package/README.md +5 -6
- package/Rakefile +14 -0
- package/UPGRADING.md +9 -4
- package/configuration.sample +5 -0
- package/dist/BUNDLE_LICENSE.txt +96 -0
- package/dist/aws-sdk.js +9594 -0
- package/dist/aws-sdk.min.js +21 -0
- package/dist-tools/.eslintrc +10 -0
- package/dist-tools/browser-builder.js +142 -0
- package/dist-tools/strategies/cache.js +68 -0
- package/dist-tools/strategies/default.js +165 -0
- package/dist-tools/test/browser-builder.mocha.spec.coffee +182 -0
- package/dist-tools/test/helpers.coffee +16 -0
- package/doc-src/guide/browser-building.md +93 -0
- package/doc-src/guide/browser-configuring-wif.md +287 -0
- package/doc-src/guide/browser-configuring.md +218 -0
- package/doc-src/guide/browser-examples.md +220 -0
- package/doc-src/guide/browser-intro.md +46 -0
- package/doc-src/guide/browser-making-requests.md +279 -0
- package/doc-src/guide/browser-services.md +75 -0
- package/doc-src/guide/index.md +41 -0
- package/doc-src/guide/node-configuring.md +272 -0
- package/doc-src/guide/node-examples.md +341 -0
- package/doc-src/guide/node-intro.md +32 -0
- package/doc-src/guide/node-making-requests.md +309 -0
- package/doc-src/guide/node-services.md +159 -0
- package/doc-src/templates/api-versions/model_documentor.rb +366 -0
- package/doc-src/templates/api-versions/plugin.rb +230 -0
- package/doc-src/templates/api-versions/templates/default/class/html/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_details_list.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_summary.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/docstring/html/experimental.erb +4 -0
- package/doc-src/templates/api-versions/templates/default/docstring/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/css/common.css +6 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/setup.rb +62 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/services.erb +10 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/setup.rb +28 -0
- package/doc-src/templates/api-versions/templates/default/module/html/box_info.erb +45 -0
- package/doc-src/templates/api-versions/templates/default/module/html/children.erb +8 -0
- package/doc-src/templates/api-versions/templates/default/tags/setup.rb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/method_signature.erb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/setup.rb +5 -0
- package/doc-src/templates/default/layout/html/footer.erb +31 -0
- package/doc-src/templates/default/layout/html/layout.erb +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/highlight.github.css +127 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/style.css +1192 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/img/logo.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/app.js +33 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/highlight.pack.js +27 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/AUTHORS +55 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/LICENSE +25 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js +247 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/file.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js +568 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/underscore.js +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search.erb +29 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search_index.erb +1 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/setup.rb +75 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/layout.erb +93 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/setup.rb +9 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/sidebar.erb +45 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/layout.erb +51 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/setup.rb +1 -0
- package/eslint-rules/no-require-in-service.js +10 -0
- package/features/autoscaling/autoscaling.feature +21 -0
- package/features/autoscaling/step_definitions/autoscaling.js +49 -0
- package/features/cloudformation/cloudformation.feature +22 -0
- package/features/cloudformation/step_definitions/cloudformation.js +26 -0
- package/features/cloudfront/cloudfront.feature +28 -0
- package/features/cloudfront/step_definitions/cloudfront-latest.js +54 -0
- package/features/cloudfront/step_definitions/cloudfront.js +21 -0
- package/features/cloudsearch/cloudsearch.feature +34 -0
- package/features/cloudsearch/step_definitions/cloudsearch.js +42 -0
- package/features/cloudtrail/cloudtrail.feature +17 -0
- package/features/cloudtrail/step_definitions/cloudtrail.js +14 -0
- package/features/cloudwatch/cloudwatch.feature +15 -0
- package/features/cloudwatch/step_definitions/cloudwatch.js +48 -0
- package/features/datapipeline/datapipeline.feature +23 -0
- package/features/datapipeline/step_definitions/datapipeline.js +79 -0
- package/features/directconnect/directconnect.feature +20 -0
- package/features/directconnect/step_definitions/directconnect.js +44 -0
- package/features/dynamodb/crc32.feature +18 -0
- package/features/dynamodb/step_definitions/dynamodb.js +154 -0
- package/features/dynamodb/tables.feature +50 -0
- package/features/ec2/ec2.feature +28 -0
- package/features/ec2/step_definitions/ec2.js +65 -0
- package/features/elasticache/elasticache.feature +20 -0
- package/features/elasticache/step_definitions/elasticache.js +34 -0
- package/features/elasticbeanstalk/elasticbeanstalk.feature +22 -0
- package/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js +38 -0
- package/features/elastictranscoder/elastictranscoder.feature +24 -0
- package/features/elastictranscoder/step_definitions/elastictranscoder.js +56 -0
- package/features/elb/elb.feature +19 -0
- package/features/elb/step_definitions/elb.js +37 -0
- package/features/emr/emr.feature +16 -0
- package/features/emr/step_definitions/emr.js +45 -0
- package/features/extra/assertions.js +29 -0
- package/features/extra/dummy.feature +0 -0
- package/features/extra/fixtures/testfile.txt +1 -0
- package/features/extra/helpers.js +113 -0
- package/features/extra/hooks.js +107 -0
- package/features/extra/world.js +12 -0
- package/features/glacier/glacier.feature +47 -0
- package/features/glacier/step_definitions/glacier.js +112 -0
- package/features/iam/iam.feature +24 -0
- package/features/iam/step_definitions/iam.js +66 -0
- package/features/importexport/importexport.feature +53 -0
- package/features/importexport/step_definitions/importexport.js +42 -0
- package/features/kinesis/kinesis.feature +9 -0
- package/features/kinesis/step_definitions/kinesis.js +10 -0
- package/features/opsworks/opsworks.feature +26 -0
- package/features/opsworks/step_definitions/opsworks.js +42 -0
- package/features/rds/rds.feature +32 -0
- package/features/rds/step_definitions/rds.js +72 -0
- package/features/redshift/redshift.feature +20 -0
- package/features/redshift/step_definitions/redshift.js +33 -0
- package/features/route53/route53.feature +41 -0
- package/features/route53/step_definitions/route53.js +97 -0
- package/features/s3/buckets.feature +40 -0
- package/features/s3/objects.feature +122 -0
- package/features/s3/step_definitions/buckets.js +136 -0
- package/features/s3/step_definitions/hooks.js +39 -0
- package/features/s3/step_definitions/objects.js +204 -0
- package/features/s3/step_definitions/proxy.js +44 -0
- package/features/ses/ses.feature +20 -0
- package/features/ses/step_definitions/ses.js +22 -0
- package/features/simpledb/simpledb.feature +29 -0
- package/features/simpledb/step_definitions/simpledb.js +46 -0
- package/features/sns/sns.feature +15 -0
- package/features/sns/step_definitions/sns.js +33 -0
- package/features/sqs/messages.feature +21 -0
- package/features/sqs/queues.feature +18 -0
- package/features/sqs/step_definitions/messages.js +46 -0
- package/features/sqs/step_definitions/queues.js +33 -0
- package/features/sqs/step_definitions/sqs.js +7 -0
- package/features/storagegateway/step_definitions/storagegateway.js +16 -0
- package/features/storagegateway/storagegateway.feature +13 -0
- package/features/sts/step_definitions/sts.js +35 -0
- package/features/sts/sts.feature +29 -0
- package/features/support/step_definitions/support.js +35 -0
- package/features/support/support.feature +18 -0
- package/features/swf/step_definitions/swf.js +38 -0
- package/features/swf/swf.feature +15 -0
- package/index.js +2 -0
- package/lib/core.js +2 -2
- package/lib/credentials/shared_ini_file_credentials.js +0 -1
- package/lib/event_listeners.js +13 -1
- package/lib/http/node.js +19 -30
- package/lib/model/resource_waiter.js +0 -4
- package/lib/model/shape.js +2 -1
- package/lib/protocol/rest_xml.js +1 -1
- package/lib/region_config.js +31 -0
- package/lib/region_config.json +56 -0
- package/lib/request.js +37 -45
- package/lib/sequential_executor.js +17 -34
- package/lib/service.js +17 -44
- package/lib/services/cloudsearchdomain.js +69 -0
- package/lib/services/route53.js +0 -12
- package/lib/services/s3.js +3 -19
- package/lib/signers/v4.js +2 -1
- package/lib/util.js +28 -3
- package/package.json +3 -3
- package/scripts/console +11 -3
- package/scripts/coverage +126 -0
- package/tasks/apis.rake +122 -0
- package/tasks/browser.rake +89 -0
- package/tasks/docs.rake +36 -0
- package/tasks/lib/cucumber_generator.rb +40 -0
- package/tasks/util.rake +33 -0
- package/test/browser/js/jasmine-1.3.1.js +2600 -0
- package/test/browser/js/jasmine-html.js +681 -0
- package/test/browser/runner.html +109 -0
- package/test/browser/runner.js +92 -0
- package/test/browser/sample/appinfo.sample.js +15 -0
- package/test/browser/sample/console.html +429 -0
- package/test/browser/sample/css/smoothness/images/animated-overlay.gif +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.css +1175 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.min.css +5 -0
- package/test/browser/sample/img/loading.gif +0 -0
- package/test/browser/sample/js/jquery-1.9.1.js +9597 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.js +14903 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.min.js +6 -0
- package/test/browser/sample/s3upload.html +111 -0
- package/test/browser.spec.coffee +207 -0
- package/test/config.spec.coffee +202 -0
- package/test/credential_provider_chain.spec.coffee +90 -0
- package/test/credentials.spec.coffee +452 -0
- package/test/endpoint.spec.coffee +80 -0
- package/test/event_listeners.spec.coffee +493 -0
- package/test/helpers.coffee +150 -0
- package/test/http_request.spec.coffee +55 -0
- package/test/json/builder.spec.coffee +129 -0
- package/test/json/parser.spec.coffee +108 -0
- package/test/metadata_service.spec.coffee +54 -0
- package/test/model/api.spec.coffee +67 -0
- package/test/model/shape.spec.coffee +23 -0
- package/test/node_http_client.spec.coffee +40 -0
- package/test/param_validator.spec.coffee +456 -0
- package/test/protocol/json.spec.coffee +167 -0
- package/test/protocol/query.spec.coffee +191 -0
- package/test/protocol/rest.spec.coffee +237 -0
- package/test/protocol/rest_json.spec.coffee +255 -0
- package/test/protocol/rest_xml.spec.coffee +329 -0
- package/test/query/query_param_serializer.spec.coffee +327 -0
- package/test/region_config.spec.coffee +50 -0
- package/test/request.spec.coffee +316 -0
- package/test/resource_waiter.spec.coffee +89 -0
- package/test/response.spec.coffee +81 -0
- package/test/sequential_executor.spec.coffee +118 -0
- package/test/service.spec.coffee +230 -0
- package/test/services/cloudfront.spec.coffee +44 -0
- package/test/services/cloudsearchdomain.spec.coffee +23 -0
- package/test/services/dynamodb.spec.coffee +32 -0
- package/test/services/ec2.spec.coffee +78 -0
- package/test/services/elastictranscoder.spec.coffee +43 -0
- package/test/services/glacier.spec.coffee +61 -0
- package/test/services/rds.spec.coffee +38 -0
- package/test/services/route53.spec.coffee +77 -0
- package/test/services/s3.spec.coffee +538 -0
- package/test/services/simpledb.spec.coffee +12 -0
- package/test/services/sqs.spec.coffee +130 -0
- package/test/services/sts.spec.coffee +72 -0
- package/test/services/swf.spec.coffee +6 -0
- package/test/signers/presign.spec.coffee +36 -0
- package/test/signers/s3.spec.coffee +297 -0
- package/test/signers/v2.spec.coffee +68 -0
- package/test/signers/v4.spec.coffee +135 -0
- package/test/util.spec.coffee +510 -0
- package/test/xml/builder.spec.coffee +529 -0
- package/test/xml/parser.spec.coffee +587 -0
- package/lib/services/simpledb.js +0 -15
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
matchXML = helpers.matchXML
|
|
4
|
+
|
|
5
|
+
describe 'AWS.XML.Builder', ->
|
|
6
|
+
|
|
7
|
+
xmlns = 'http://mockservice.com/xmlns'
|
|
8
|
+
api = null
|
|
9
|
+
|
|
10
|
+
beforeEach ->
|
|
11
|
+
api = new AWS.Model.Api metadata: xmlNamespace: xmlns
|
|
12
|
+
|
|
13
|
+
toXML = (rules, params) ->
|
|
14
|
+
rules.type = 'structure'
|
|
15
|
+
shape = AWS.Model.Shape.create(rules, api: api)
|
|
16
|
+
|
|
17
|
+
builder = new AWS.XML.Builder()
|
|
18
|
+
builder.toXML(params, shape, 'Data')
|
|
19
|
+
|
|
20
|
+
describe 'toXML', ->
|
|
21
|
+
it 'wraps simple structures with location of body', ->
|
|
22
|
+
rules = members: { Name:{}, State:{} }
|
|
23
|
+
params = { Name:'abc', State: 'Enabled' }
|
|
24
|
+
xml = """
|
|
25
|
+
<Data xmlns="#{xmlns}">
|
|
26
|
+
<Name>abc</Name>
|
|
27
|
+
<State>Enabled</State>
|
|
28
|
+
</Data>
|
|
29
|
+
"""
|
|
30
|
+
matchXML(toXML(rules, params), xml)
|
|
31
|
+
|
|
32
|
+
it 'ignores null input', ->
|
|
33
|
+
rules = members: { Name:{}, State:{} }
|
|
34
|
+
params = { Name:null, State:undefined }
|
|
35
|
+
xml = ''
|
|
36
|
+
matchXML(toXML(rules, params), xml)
|
|
37
|
+
|
|
38
|
+
it 'ignores nested null input', ->
|
|
39
|
+
rules = members: {Struct:{type: 'structure', members: {State:{}}}}
|
|
40
|
+
params = { Struct: { State: null } }
|
|
41
|
+
xml = """
|
|
42
|
+
<Data xmlns="#{xmlns}">
|
|
43
|
+
<Struct/>
|
|
44
|
+
</Data>
|
|
45
|
+
"""
|
|
46
|
+
matchXML(toXML(rules, params), xml)
|
|
47
|
+
|
|
48
|
+
it 'orders xml members by the order they appear in the rules', ->
|
|
49
|
+
rules = xmlOrder: ['Count', 'State'], members: {Count:{type:'integer'},State:{}}
|
|
50
|
+
params = { State: 'Disabled', Count: 123 }
|
|
51
|
+
xml = """
|
|
52
|
+
<Data xmlns="#{xmlns}">
|
|
53
|
+
<Count>123</Count>
|
|
54
|
+
<State>Disabled</State>
|
|
55
|
+
</Data>
|
|
56
|
+
"""
|
|
57
|
+
matchXML(toXML(rules, params), xml)
|
|
58
|
+
|
|
59
|
+
it 'can serializes structures into XML', ->
|
|
60
|
+
rules = members:
|
|
61
|
+
Name: {}
|
|
62
|
+
Details:
|
|
63
|
+
type: 'structure'
|
|
64
|
+
members:
|
|
65
|
+
Abc: {}
|
|
66
|
+
Xyz: {}
|
|
67
|
+
params =
|
|
68
|
+
Details:
|
|
69
|
+
Xyz: 'xyz'
|
|
70
|
+
Abc: 'abc'
|
|
71
|
+
Name: 'john'
|
|
72
|
+
xml = """
|
|
73
|
+
<Data xmlns="#{xmlns}">
|
|
74
|
+
<Name>john</Name>
|
|
75
|
+
<Details>
|
|
76
|
+
<Abc>abc</Abc>
|
|
77
|
+
<Xyz>xyz</Xyz>
|
|
78
|
+
</Details>
|
|
79
|
+
</Data>
|
|
80
|
+
"""
|
|
81
|
+
matchXML(toXML(rules, params), xml)
|
|
82
|
+
|
|
83
|
+
it 'serializes empty structures as empty element', ->
|
|
84
|
+
rules = {members:{Config:{type:'structure',members:{Foo:{},Bar:{}}}}}
|
|
85
|
+
params = { Config: {} }
|
|
86
|
+
xml = """
|
|
87
|
+
<Data xmlns="#{xmlns}">
|
|
88
|
+
<Config/>
|
|
89
|
+
</Data>
|
|
90
|
+
"""
|
|
91
|
+
matchXML(toXML(rules, params), xml)
|
|
92
|
+
|
|
93
|
+
it 'does not serialize missing members', ->
|
|
94
|
+
rules = {members:{Config:{type:'structure',members:{Foo:{},Bar:{}}}}}
|
|
95
|
+
params = { Config: { Foo: 'abc' } }
|
|
96
|
+
xml = """
|
|
97
|
+
<Data xmlns="#{xmlns}">
|
|
98
|
+
<Config>
|
|
99
|
+
<Foo>abc</Foo>
|
|
100
|
+
</Config>
|
|
101
|
+
</Data>
|
|
102
|
+
"""
|
|
103
|
+
matchXML(toXML(rules, params), xml)
|
|
104
|
+
|
|
105
|
+
describe 'lists', ->
|
|
106
|
+
|
|
107
|
+
it 'serializes lists (default member names)', ->
|
|
108
|
+
rules = {members:{Aliases:{type:'list',member:{}}}}
|
|
109
|
+
params = {Aliases:['abc','mno','xyz']}
|
|
110
|
+
xml = """
|
|
111
|
+
<Data xmlns="#{xmlns}">
|
|
112
|
+
<Aliases>
|
|
113
|
+
<member>abc</member>
|
|
114
|
+
<member>mno</member>
|
|
115
|
+
<member>xyz</member>
|
|
116
|
+
</Aliases>
|
|
117
|
+
</Data>
|
|
118
|
+
"""
|
|
119
|
+
matchXML(toXML(rules, params), xml)
|
|
120
|
+
|
|
121
|
+
it 'serializes lists (custom member names)', ->
|
|
122
|
+
rules = {members:{Aliases:{type:'list',member:{locationName:'Alias'}}}}
|
|
123
|
+
params = {Aliases:['abc','mno','xyz']}
|
|
124
|
+
xml = """
|
|
125
|
+
<Data xmlns="#{xmlns}">
|
|
126
|
+
<Aliases>
|
|
127
|
+
<Alias>abc</Alias>
|
|
128
|
+
<Alias>mno</Alias>
|
|
129
|
+
<Alias>xyz</Alias>
|
|
130
|
+
</Aliases>
|
|
131
|
+
</Data>
|
|
132
|
+
"""
|
|
133
|
+
matchXML(toXML(rules, params), xml)
|
|
134
|
+
|
|
135
|
+
it 'includes lists elements even if they have no members', ->
|
|
136
|
+
rules = {members:{Aliases:{type:'list',member:{locationName:'Alias'}}}}
|
|
137
|
+
params = {Aliases:[]}
|
|
138
|
+
xml = """
|
|
139
|
+
<Data xmlns="#{xmlns}">
|
|
140
|
+
<Aliases/>
|
|
141
|
+
</Data>
|
|
142
|
+
"""
|
|
143
|
+
matchXML(toXML(rules, params), xml)
|
|
144
|
+
|
|
145
|
+
it 'serializes lists of structures', ->
|
|
146
|
+
rules = members:
|
|
147
|
+
Points:
|
|
148
|
+
type: 'list'
|
|
149
|
+
member:
|
|
150
|
+
type: 'structure'
|
|
151
|
+
locationName: 'Point'
|
|
152
|
+
members:
|
|
153
|
+
X: {type:'float'}
|
|
154
|
+
Y: {type:'float'}
|
|
155
|
+
params = {Points:[{X:1.2,Y:2.1},{X:3.4,Y:4.3}]}
|
|
156
|
+
xml = """
|
|
157
|
+
<Data xmlns="#{xmlns}">
|
|
158
|
+
<Points>
|
|
159
|
+
<Point>
|
|
160
|
+
<X>1.2</X>
|
|
161
|
+
<Y>2.1</Y>
|
|
162
|
+
</Point>
|
|
163
|
+
<Point>
|
|
164
|
+
<X>3.4</X>
|
|
165
|
+
<Y>4.3</Y>
|
|
166
|
+
</Point>
|
|
167
|
+
</Points>
|
|
168
|
+
</Data>
|
|
169
|
+
"""
|
|
170
|
+
matchXML(toXML(rules, params), xml)
|
|
171
|
+
|
|
172
|
+
describe 'flattened lists', ->
|
|
173
|
+
|
|
174
|
+
it 'serializes lists without a base wrapper', ->
|
|
175
|
+
rules = {members:{Aliases:{type:'list',flattened:true,member:{}}}}
|
|
176
|
+
params = {Aliases:['abc','mno','xyz']}
|
|
177
|
+
xml = """
|
|
178
|
+
<Data xmlns="#{xmlns}">
|
|
179
|
+
<Aliases>abc</Aliases>
|
|
180
|
+
<Aliases>mno</Aliases>
|
|
181
|
+
<Aliases>xyz</Aliases>
|
|
182
|
+
</Data>
|
|
183
|
+
"""
|
|
184
|
+
matchXML(toXML(rules, params), xml)
|
|
185
|
+
|
|
186
|
+
it 'serializes lists (custom member names)', ->
|
|
187
|
+
rules = members: {Aliases:{type:'list',flattened:true,member:{locationName:'Alias'}}}
|
|
188
|
+
params = {Aliases:['abc','mno','xyz']}
|
|
189
|
+
xml = """
|
|
190
|
+
<Data xmlns="#{xmlns}">
|
|
191
|
+
<Alias>abc</Alias>
|
|
192
|
+
<Alias>mno</Alias>
|
|
193
|
+
<Alias>xyz</Alias>
|
|
194
|
+
</Data>
|
|
195
|
+
"""
|
|
196
|
+
matchXML(toXML(rules, params), xml)
|
|
197
|
+
|
|
198
|
+
it 'omits lists elements when no members are given', ->
|
|
199
|
+
rules = {members:{Aliases:{type:'list',flattened:true,member:{locationName:'Alias'}}}}
|
|
200
|
+
params = {Aliases:[]}
|
|
201
|
+
xml = ''
|
|
202
|
+
matchXML(toXML(rules, params), xml)
|
|
203
|
+
|
|
204
|
+
it 'serializes lists of structures', ->
|
|
205
|
+
rules = members:
|
|
206
|
+
Points:
|
|
207
|
+
type: 'list'
|
|
208
|
+
flattened: true
|
|
209
|
+
name: 'Point'
|
|
210
|
+
member:
|
|
211
|
+
type: 'structure'
|
|
212
|
+
locationName: 'Point'
|
|
213
|
+
members:
|
|
214
|
+
X: {type:'float'}
|
|
215
|
+
Y: {type:'float'}
|
|
216
|
+
params = {Points:[{X:1.2,Y:2.1},{X:3.4,Y:4.3}]}
|
|
217
|
+
xml = """
|
|
218
|
+
<Data xmlns="#{xmlns}">
|
|
219
|
+
<Point>
|
|
220
|
+
<X>1.2</X>
|
|
221
|
+
<Y>2.1</Y>
|
|
222
|
+
</Point>
|
|
223
|
+
<Point>
|
|
224
|
+
<X>3.4</X>
|
|
225
|
+
<Y>4.3</Y>
|
|
226
|
+
</Point>
|
|
227
|
+
</Data>
|
|
228
|
+
"""
|
|
229
|
+
matchXML(toXML(rules, params), xml)
|
|
230
|
+
|
|
231
|
+
describe 'maps', ->
|
|
232
|
+
rules =
|
|
233
|
+
type: 'structure'
|
|
234
|
+
members:
|
|
235
|
+
Items:
|
|
236
|
+
type: 'map'
|
|
237
|
+
key: type: 'string'
|
|
238
|
+
value: type: 'string'
|
|
239
|
+
|
|
240
|
+
it 'translates maps', ->
|
|
241
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
242
|
+
xml = """
|
|
243
|
+
<Data xmlns="#{xmlns}">
|
|
244
|
+
<Items>
|
|
245
|
+
<entry>
|
|
246
|
+
<key>A</key>
|
|
247
|
+
<value>a</value>
|
|
248
|
+
</entry>
|
|
249
|
+
<entry>
|
|
250
|
+
<key>B</key>
|
|
251
|
+
<value>b</value>
|
|
252
|
+
</entry>
|
|
253
|
+
</Items>
|
|
254
|
+
</Data>
|
|
255
|
+
"""
|
|
256
|
+
matchXML(toXML(rules, params), xml)
|
|
257
|
+
|
|
258
|
+
it 'allows renamed map keys and values', ->
|
|
259
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
260
|
+
otherRules =
|
|
261
|
+
type: 'structure'
|
|
262
|
+
members:
|
|
263
|
+
Items:
|
|
264
|
+
type: 'map'
|
|
265
|
+
key: type: 'string', locationName: 'MKEY'
|
|
266
|
+
value: type: 'string', locationName: 'MVALUE'
|
|
267
|
+
xml = """
|
|
268
|
+
<Data xmlns="#{xmlns}">
|
|
269
|
+
<Items>
|
|
270
|
+
<entry>
|
|
271
|
+
<MKEY>A</MKEY>
|
|
272
|
+
<MVALUE>a</MVALUE>
|
|
273
|
+
</entry>
|
|
274
|
+
<entry>
|
|
275
|
+
<MKEY>B</MKEY>
|
|
276
|
+
<MVALUE>b</MVALUE>
|
|
277
|
+
</entry>
|
|
278
|
+
</Items>
|
|
279
|
+
</Data>
|
|
280
|
+
"""
|
|
281
|
+
matchXML(toXML(otherRules, params), xml)
|
|
282
|
+
|
|
283
|
+
it 'ignores null', ->
|
|
284
|
+
expect(toXML(rules, Items: null)).toEqual('')
|
|
285
|
+
|
|
286
|
+
it 'ignores undefined', ->
|
|
287
|
+
expect(toXML(rules, Items: undefined)).toEqual('')
|
|
288
|
+
|
|
289
|
+
describe 'flattened maps', ->
|
|
290
|
+
rules =
|
|
291
|
+
type: 'structure'
|
|
292
|
+
members:
|
|
293
|
+
Items:
|
|
294
|
+
type: 'map'
|
|
295
|
+
locationName: 'Item'
|
|
296
|
+
flattened: true
|
|
297
|
+
key: type: 'string'
|
|
298
|
+
value: type: 'string'
|
|
299
|
+
|
|
300
|
+
it 'translates flattened maps', ->
|
|
301
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
302
|
+
xml = """
|
|
303
|
+
<Data xmlns="#{xmlns}">
|
|
304
|
+
<Item>
|
|
305
|
+
<key>A</key>
|
|
306
|
+
<value>a</value>
|
|
307
|
+
</Item>
|
|
308
|
+
<Item>
|
|
309
|
+
<key>B</key>
|
|
310
|
+
<value>b</value>
|
|
311
|
+
</Item>
|
|
312
|
+
</Data>
|
|
313
|
+
"""
|
|
314
|
+
matchXML(toXML(rules, params), xml)
|
|
315
|
+
|
|
316
|
+
it 'allows renamed map keys and values', ->
|
|
317
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
318
|
+
otherRules =
|
|
319
|
+
type: 'structure'
|
|
320
|
+
members:
|
|
321
|
+
Items:
|
|
322
|
+
locationName: 'Item'
|
|
323
|
+
flattened: true
|
|
324
|
+
type: 'map'
|
|
325
|
+
key: type: 'string', locationName: 'MKEY'
|
|
326
|
+
value: type: 'string', locationName: 'MVALUE'
|
|
327
|
+
xml = """
|
|
328
|
+
<Data xmlns="#{xmlns}">
|
|
329
|
+
<Item>
|
|
330
|
+
<MKEY>A</MKEY>
|
|
331
|
+
<MVALUE>a</MVALUE>
|
|
332
|
+
</Item>
|
|
333
|
+
<Item>
|
|
334
|
+
<MKEY>B</MKEY>
|
|
335
|
+
<MVALUE>b</MVALUE>
|
|
336
|
+
</Item>
|
|
337
|
+
</Data>
|
|
338
|
+
"""
|
|
339
|
+
matchXML(toXML(otherRules, params), xml)
|
|
340
|
+
|
|
341
|
+
it 'ignores null', ->
|
|
342
|
+
expect(toXML(rules, Items: null)).toEqual('')
|
|
343
|
+
|
|
344
|
+
it 'ignores undefined', ->
|
|
345
|
+
expect(toXML(rules, Items: undefined)).toEqual('')
|
|
346
|
+
|
|
347
|
+
describe 'numbers', ->
|
|
348
|
+
|
|
349
|
+
it 'integers', ->
|
|
350
|
+
rules = members: {Count:{type:'integer'}}
|
|
351
|
+
params = { Count: 123.0 }
|
|
352
|
+
xml = """
|
|
353
|
+
<Data xmlns="#{xmlns}">
|
|
354
|
+
<Count>123</Count>
|
|
355
|
+
</Data>
|
|
356
|
+
"""
|
|
357
|
+
matchXML(toXML(rules, params), xml)
|
|
358
|
+
|
|
359
|
+
it 'floats', ->
|
|
360
|
+
rules = members: {Count:{type:'float'}}
|
|
361
|
+
params = { Count: 123.123 }
|
|
362
|
+
xml = """
|
|
363
|
+
<Data xmlns="#{xmlns}">
|
|
364
|
+
<Count>123.123</Count>
|
|
365
|
+
</Data>
|
|
366
|
+
"""
|
|
367
|
+
matchXML(toXML(rules, params), xml)
|
|
368
|
+
|
|
369
|
+
it 'ints and floats formatted as numbers', ->
|
|
370
|
+
rules = members: {CountI:{type:'integer'},CountF:{type:'float'}}
|
|
371
|
+
params = { CountI: '123', CountF: '1.23' }
|
|
372
|
+
xml = """
|
|
373
|
+
<Data xmlns="#{xmlns}">
|
|
374
|
+
<CountI>123</CountI>
|
|
375
|
+
<CountF>1.23</CountF>
|
|
376
|
+
</Data>
|
|
377
|
+
"""
|
|
378
|
+
matchXML(toXML(rules, params), xml)
|
|
379
|
+
|
|
380
|
+
describe 'booleans', ->
|
|
381
|
+
|
|
382
|
+
it 'true', ->
|
|
383
|
+
rules = members: {Enabled:{type:'boolean'}}
|
|
384
|
+
params = { Enabled: true }
|
|
385
|
+
xml = """
|
|
386
|
+
<Data xmlns="#{xmlns}">
|
|
387
|
+
<Enabled>true</Enabled>
|
|
388
|
+
</Data>
|
|
389
|
+
"""
|
|
390
|
+
matchXML(toXML(rules, params), xml)
|
|
391
|
+
|
|
392
|
+
it 'false', ->
|
|
393
|
+
rules = members: {Enabled:{type:'boolean'}}
|
|
394
|
+
params = { Enabled: false }
|
|
395
|
+
xml = """
|
|
396
|
+
<Data xmlns="#{xmlns}">
|
|
397
|
+
<Enabled>false</Enabled>
|
|
398
|
+
</Data>
|
|
399
|
+
"""
|
|
400
|
+
matchXML(toXML(rules, params), xml)
|
|
401
|
+
|
|
402
|
+
describe 'timestamps', ->
|
|
403
|
+
|
|
404
|
+
time = new Date()
|
|
405
|
+
time.setMilliseconds(0)
|
|
406
|
+
|
|
407
|
+
it 'iso8601', ->
|
|
408
|
+
api.timestampFormat = 'iso8601'
|
|
409
|
+
rules = members: {Expires:{type:'timestamp'}}
|
|
410
|
+
params = { Expires: time }
|
|
411
|
+
xml = """
|
|
412
|
+
<Data xmlns="#{xmlns}">
|
|
413
|
+
<Expires>#{AWS.util.date.iso8601(time)}</Expires>
|
|
414
|
+
</Data>
|
|
415
|
+
"""
|
|
416
|
+
matchXML(toXML(rules, params), xml)
|
|
417
|
+
|
|
418
|
+
it 'rfc822', ->
|
|
419
|
+
api.timestampFormat = 'rfc822'
|
|
420
|
+
rules = members: {Expires:{type:'timestamp'}}
|
|
421
|
+
params = { Expires: time }
|
|
422
|
+
xml = """
|
|
423
|
+
<Data xmlns="#{xmlns}">
|
|
424
|
+
<Expires>#{AWS.util.date.rfc822(time)}</Expires>
|
|
425
|
+
</Data>
|
|
426
|
+
"""
|
|
427
|
+
matchXML(toXML(rules, params), xml)
|
|
428
|
+
|
|
429
|
+
it 'unix timestamp', ->
|
|
430
|
+
api.timestampFormat = 'unixTimestamp'
|
|
431
|
+
rules = members: {Expires:{type:'timestamp'}}
|
|
432
|
+
params = { Expires: time }
|
|
433
|
+
xml = """
|
|
434
|
+
<Data xmlns="#{xmlns}">
|
|
435
|
+
<Expires>#{AWS.util.date.unixTimestamp(time)}</Expires>
|
|
436
|
+
</Data>
|
|
437
|
+
"""
|
|
438
|
+
matchXML(toXML(rules, params), xml)
|
|
439
|
+
|
|
440
|
+
it 'follows the forat given on the shape', ->
|
|
441
|
+
api.timestampFormat = 'unixTimestamp'
|
|
442
|
+
rules = members: {Expires:{type:'timestamp',timestampFormat:'rfc822'}}
|
|
443
|
+
params = { Expires: time }
|
|
444
|
+
# despite the api configuration will specify unixTimesmap, we expect
|
|
445
|
+
# an rfc822 formatted date based on the format attribute
|
|
446
|
+
xml = """
|
|
447
|
+
<Data xmlns="#{xmlns}">
|
|
448
|
+
<Expires>#{AWS.util.date.rfc822(time)}</Expires>
|
|
449
|
+
</Data>
|
|
450
|
+
"""
|
|
451
|
+
matchXML(toXML(rules, params), xml)
|
|
452
|
+
|
|
453
|
+
describe 'xml attributes', ->
|
|
454
|
+
it 'can serialize xml attributes', ->
|
|
455
|
+
rules = members:
|
|
456
|
+
Config:
|
|
457
|
+
type: 'structure'
|
|
458
|
+
members:
|
|
459
|
+
Foo:
|
|
460
|
+
type: 'string'
|
|
461
|
+
Attr:
|
|
462
|
+
type: 'string'
|
|
463
|
+
xmlAttribute: true
|
|
464
|
+
locationName: 'attr:name'
|
|
465
|
+
params = { Config: { Foo: 'bar', Attr: 'abc' } }
|
|
466
|
+
xml = """
|
|
467
|
+
<Data xmlns="#{xmlns}">
|
|
468
|
+
<Config attr:name="abc"><Foo>bar</Foo></Config>
|
|
469
|
+
</Data>
|
|
470
|
+
"""
|
|
471
|
+
matchXML(toXML(rules, params), xml)
|
|
472
|
+
|
|
473
|
+
describe 'xml namespaces', ->
|
|
474
|
+
it 'can apply xml namespaces on structures', ->
|
|
475
|
+
rules = members:
|
|
476
|
+
Config:
|
|
477
|
+
type: 'structure'
|
|
478
|
+
xmlNamespace:
|
|
479
|
+
uri: 'URI'
|
|
480
|
+
members:
|
|
481
|
+
Foo:
|
|
482
|
+
type: 'string'
|
|
483
|
+
params = { Config: { Foo: 'bar' } }
|
|
484
|
+
xml = """
|
|
485
|
+
<Data xmlns="#{xmlns}">
|
|
486
|
+
<Config xmlns="URI"><Foo>bar</Foo></Config>
|
|
487
|
+
</Data>
|
|
488
|
+
"""
|
|
489
|
+
matchXML(toXML(rules, params), xml)
|
|
490
|
+
|
|
491
|
+
it 'applies namespace prefixes to the xmlns attribute', ->
|
|
492
|
+
rules = members:
|
|
493
|
+
Config:
|
|
494
|
+
type: 'structure'
|
|
495
|
+
xmlNamespace:
|
|
496
|
+
prefix: 'xsi'
|
|
497
|
+
uri: 'URI'
|
|
498
|
+
members:
|
|
499
|
+
Foo:
|
|
500
|
+
type: 'string'
|
|
501
|
+
params = { Config: { Foo: 'bar' } }
|
|
502
|
+
xml = """
|
|
503
|
+
<Data xmlns="#{xmlns}">
|
|
504
|
+
<Config xmlns:xsi="URI"><Foo>bar</Foo></Config>
|
|
505
|
+
</Data>
|
|
506
|
+
"""
|
|
507
|
+
matchXML(toXML(rules, params), xml)
|
|
508
|
+
|
|
509
|
+
it 'can apply namespaces to elements that have other attributes', ->
|
|
510
|
+
rules = members:
|
|
511
|
+
Config:
|
|
512
|
+
type: 'structure'
|
|
513
|
+
xmlNamespace:
|
|
514
|
+
prefix: 'xsi'
|
|
515
|
+
uri: 'URI'
|
|
516
|
+
members:
|
|
517
|
+
Foo:
|
|
518
|
+
type: 'string'
|
|
519
|
+
Bar:
|
|
520
|
+
type: 'string'
|
|
521
|
+
xmlAttribute: true
|
|
522
|
+
locationName: 'xsi:label'
|
|
523
|
+
params = { Config: { Foo: 'abc', Bar: 'xyz' } }
|
|
524
|
+
xml = """
|
|
525
|
+
<Data xmlns="#{xmlns}">
|
|
526
|
+
<Config xmlns:xsi="URI" xsi:label="xyz"><Foo>abc</Foo></Config>
|
|
527
|
+
</Data>
|
|
528
|
+
"""
|
|
529
|
+
matchXML(toXML(rules, params), xml)
|