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,329 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
Buffer = AWS.util.Buffer
|
|
4
|
+
|
|
5
|
+
svc = AWS.Protocol.RestXml
|
|
6
|
+
describe 'AWS.Protocol.RestXml', ->
|
|
7
|
+
|
|
8
|
+
MockRESTXMLService = AWS.util.inherit AWS.Service,
|
|
9
|
+
endpointPrefix: 'mockservice'
|
|
10
|
+
|
|
11
|
+
xmlns = 'http://mockservice.com/xmlns'
|
|
12
|
+
request = null
|
|
13
|
+
response = null
|
|
14
|
+
service = null
|
|
15
|
+
|
|
16
|
+
beforeEach ->
|
|
17
|
+
MockRESTXMLService.prototype.api = new AWS.Model.Api
|
|
18
|
+
metadata:
|
|
19
|
+
xmlNamespace: xmlns
|
|
20
|
+
operations:
|
|
21
|
+
SampleOperation:
|
|
22
|
+
http:
|
|
23
|
+
method: 'POST'
|
|
24
|
+
requestUri: '/'
|
|
25
|
+
|
|
26
|
+
AWS.Service.defineMethods(MockRESTXMLService)
|
|
27
|
+
service = new MockRESTXMLService(region: 'region')
|
|
28
|
+
request = new AWS.Request(service, 'sampleOperation')
|
|
29
|
+
response = request.response
|
|
30
|
+
|
|
31
|
+
defop = (op) ->
|
|
32
|
+
AWS.util.property(service.api.operations, 'sampleOperation',
|
|
33
|
+
new AWS.Model.Operation('sampleOperation', op, api: service.api))
|
|
34
|
+
|
|
35
|
+
describe 'buildRequest', ->
|
|
36
|
+
build = -> svc.buildRequest(request); request
|
|
37
|
+
|
|
38
|
+
describe 'empty bodies', ->
|
|
39
|
+
it 'defaults body to empty string when there are no inputs', ->
|
|
40
|
+
defop input: type: 'structure', members: {}
|
|
41
|
+
expect(build().httpRequest.body).toEqual('')
|
|
42
|
+
|
|
43
|
+
it 'defaults body to empty string when no body params are present', ->
|
|
44
|
+
request.params = Bucket: 'abc', ACL: 'canned-acl'
|
|
45
|
+
defop
|
|
46
|
+
http: requestUri: '/{Bucket}'
|
|
47
|
+
input:
|
|
48
|
+
type: 'structure'
|
|
49
|
+
members:
|
|
50
|
+
Bucket:
|
|
51
|
+
location: 'uri'
|
|
52
|
+
ACL:
|
|
53
|
+
locationName: 'x-amz-acl'
|
|
54
|
+
location: 'header'
|
|
55
|
+
|
|
56
|
+
build()
|
|
57
|
+
expect(request.httpRequest.body).toEqual('')
|
|
58
|
+
expect(request.httpRequest.path).toEqual('/abc')
|
|
59
|
+
expect(request.httpRequest.headers['x-amz-acl']).toEqual('canned-acl')
|
|
60
|
+
|
|
61
|
+
describe 'string bodies', ->
|
|
62
|
+
it 'populates the body with string types directly', ->
|
|
63
|
+
request.params = Bucket: 'bucket-name', Data: 'abc'
|
|
64
|
+
defop
|
|
65
|
+
http: requestUri: '/{Bucket}'
|
|
66
|
+
input:
|
|
67
|
+
payload: 'Data'
|
|
68
|
+
members:
|
|
69
|
+
Bucket:
|
|
70
|
+
location: 'uri'
|
|
71
|
+
Data:
|
|
72
|
+
type: 'string'
|
|
73
|
+
expect(build().httpRequest.body).toEqual('abc')
|
|
74
|
+
|
|
75
|
+
describe 'xml bodies', ->
|
|
76
|
+
it 'populates the body with XML from the params', ->
|
|
77
|
+
request.params =
|
|
78
|
+
ACL: 'canned-acl'
|
|
79
|
+
Config:
|
|
80
|
+
Abc: 'abc'
|
|
81
|
+
Locations: ['a', 'b', 'c']
|
|
82
|
+
Data: [
|
|
83
|
+
{ Foo:'foo1', Bar:'bar1' },
|
|
84
|
+
{ Foo:'foo2', Bar:'bar2' },
|
|
85
|
+
]
|
|
86
|
+
Bucket: 'bucket-name'
|
|
87
|
+
Marker: 'marker'
|
|
88
|
+
Limit: 123
|
|
89
|
+
Metadata:
|
|
90
|
+
abc: 'xyz'
|
|
91
|
+
mno: 'hjk'
|
|
92
|
+
defop
|
|
93
|
+
http: requestUri: '/{Bucket}'
|
|
94
|
+
input:
|
|
95
|
+
payload: 'Config'
|
|
96
|
+
members:
|
|
97
|
+
Bucket: # uri path param
|
|
98
|
+
type: 'string'
|
|
99
|
+
location: 'uri'
|
|
100
|
+
Marker: # uri querystring param
|
|
101
|
+
type: 'string'
|
|
102
|
+
location: 'querystring'
|
|
103
|
+
locationName: 'next-marker'
|
|
104
|
+
Limit: # uri querystring integer param
|
|
105
|
+
type: 'integer'
|
|
106
|
+
location: 'querystring'
|
|
107
|
+
locationName: 'limit'
|
|
108
|
+
ACL: # header string param
|
|
109
|
+
type: 'string'
|
|
110
|
+
location: 'header'
|
|
111
|
+
locationName: 'x-amz-acl'
|
|
112
|
+
Metadata: # header map param
|
|
113
|
+
type: 'map'
|
|
114
|
+
location: 'headers'
|
|
115
|
+
locationName: 'x-amz-meta-'
|
|
116
|
+
Config: # structure of mixed tpyes
|
|
117
|
+
type: 'structure'
|
|
118
|
+
members:
|
|
119
|
+
Abc: type: 'string'
|
|
120
|
+
Locations: # array of strings
|
|
121
|
+
type: 'list'
|
|
122
|
+
member:
|
|
123
|
+
type: 'string'
|
|
124
|
+
locationName: 'Location'
|
|
125
|
+
Data: # array of structures
|
|
126
|
+
type: 'list'
|
|
127
|
+
member:
|
|
128
|
+
type: 'structure'
|
|
129
|
+
members:
|
|
130
|
+
Foo: type: 'string'
|
|
131
|
+
Bar: type: 'string'
|
|
132
|
+
xml = """
|
|
133
|
+
<Config xmlns="http://mockservice.com/xmlns">
|
|
134
|
+
<Abc>abc</Abc>
|
|
135
|
+
<Locations>
|
|
136
|
+
<Location>a</Location>
|
|
137
|
+
<Location>b</Location>
|
|
138
|
+
<Location>c</Location>
|
|
139
|
+
</Locations>
|
|
140
|
+
<Data>
|
|
141
|
+
<member>
|
|
142
|
+
<Foo>foo1</Foo>
|
|
143
|
+
<Bar>bar1</Bar>
|
|
144
|
+
</member>
|
|
145
|
+
<member>
|
|
146
|
+
<Foo>foo2</Foo>
|
|
147
|
+
<Bar>bar2</Bar>
|
|
148
|
+
</member>
|
|
149
|
+
</Data>
|
|
150
|
+
</Config>
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
build()
|
|
154
|
+
expect(request.httpRequest.method).toEqual('POST')
|
|
155
|
+
expect(request.httpRequest.path).
|
|
156
|
+
toEqual('/bucket-name?limit=123&next-marker=marker')
|
|
157
|
+
expect(request.httpRequest.headers['x-amz-acl']).toEqual('canned-acl')
|
|
158
|
+
expect(request.httpRequest.headers['x-amz-meta-abc']).toEqual('xyz')
|
|
159
|
+
expect(request.httpRequest.headers['x-amz-meta-mno']).toEqual('hjk')
|
|
160
|
+
helpers.matchXML(request.httpRequest.body, xml)
|
|
161
|
+
|
|
162
|
+
it 'omits the body xml when body params are not present', ->
|
|
163
|
+
request.params = Bucket:'abc' # omitting Config purposefully
|
|
164
|
+
defop
|
|
165
|
+
http: requestUri: '/{Bucket}'
|
|
166
|
+
input:
|
|
167
|
+
members:
|
|
168
|
+
Bucket:
|
|
169
|
+
location: 'uri'
|
|
170
|
+
Config: {}
|
|
171
|
+
|
|
172
|
+
build()
|
|
173
|
+
expect(request.httpRequest.body).toEqual('')
|
|
174
|
+
expect(request.httpRequest.path).toEqual('/abc')
|
|
175
|
+
|
|
176
|
+
it 'uses payload member name for payloads', ->
|
|
177
|
+
request.params =
|
|
178
|
+
Data:
|
|
179
|
+
Member1: 'member1'
|
|
180
|
+
Member2: 'member2'
|
|
181
|
+
defop
|
|
182
|
+
input:
|
|
183
|
+
payload: 'Data'
|
|
184
|
+
members:
|
|
185
|
+
Data:
|
|
186
|
+
type: 'structure'
|
|
187
|
+
locationName: 'RootElement'
|
|
188
|
+
members:
|
|
189
|
+
Member1: type: 'string'
|
|
190
|
+
Member2: type: 'string'
|
|
191
|
+
helpers.matchXML build().httpRequest.body, """
|
|
192
|
+
<RootElement xmlns="http://mockservice.com/xmlns">
|
|
193
|
+
<Member1>member1</Member1>
|
|
194
|
+
<Member2>member2</Member2>
|
|
195
|
+
</RootElement>
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
describe 'extractError', ->
|
|
199
|
+
extractError = (body) ->
|
|
200
|
+
if body == undefined
|
|
201
|
+
body = """
|
|
202
|
+
<Error>
|
|
203
|
+
<Code>InvalidArgument</Code>
|
|
204
|
+
<Message>Provided param is bad</Message>
|
|
205
|
+
</Error>
|
|
206
|
+
"""
|
|
207
|
+
response.httpResponse.statusCode = 400
|
|
208
|
+
response.httpResponse.body = new Buffer(body)
|
|
209
|
+
svc.extractError(response)
|
|
210
|
+
|
|
211
|
+
it 'extracts the error code and message', ->
|
|
212
|
+
extractError()
|
|
213
|
+
expect(response.error instanceof Error).toBeTruthy()
|
|
214
|
+
expect(response.error.code).toEqual('InvalidArgument')
|
|
215
|
+
expect(response.error.message).toEqual('Provided param is bad')
|
|
216
|
+
expect(response.data).toEqual(null)
|
|
217
|
+
|
|
218
|
+
it 'returns an empty error when the body is blank', ->
|
|
219
|
+
extractError ''
|
|
220
|
+
expect(response.error instanceof Error).toBeTruthy()
|
|
221
|
+
expect(response.error.code).toEqual(400)
|
|
222
|
+
expect(response.error.message).toEqual(null)
|
|
223
|
+
expect(response.data).toEqual(null)
|
|
224
|
+
|
|
225
|
+
it 'extracts error when inside <Errors>', ->
|
|
226
|
+
extractError """
|
|
227
|
+
<SomeResponse>
|
|
228
|
+
<Errors>
|
|
229
|
+
<Error>
|
|
230
|
+
<Code>code</Code><Message>msg</Message>
|
|
231
|
+
</Error>
|
|
232
|
+
</Errors>
|
|
233
|
+
</SomeResponse>"""
|
|
234
|
+
expect(response.error.code).toEqual('code')
|
|
235
|
+
expect(response.error.message).toEqual('msg')
|
|
236
|
+
|
|
237
|
+
it 'extracts error when <Error> is nested', ->
|
|
238
|
+
extractError """
|
|
239
|
+
<SomeResponse>
|
|
240
|
+
<Error>
|
|
241
|
+
<Code>code</Code><Message>msg</Message>
|
|
242
|
+
</Error>
|
|
243
|
+
</SomeResponse>"""
|
|
244
|
+
expect(response.error.code).toEqual('code')
|
|
245
|
+
expect(response.error.message).toEqual('msg')
|
|
246
|
+
|
|
247
|
+
describe 'extractData', ->
|
|
248
|
+
extractData = (body) ->
|
|
249
|
+
response.httpResponse.statusCode = 200
|
|
250
|
+
response.httpResponse.body = new Buffer(body)
|
|
251
|
+
svc.extractData(response)
|
|
252
|
+
|
|
253
|
+
it 'parses the xml body', ->
|
|
254
|
+
defop output:
|
|
255
|
+
type: 'structure'
|
|
256
|
+
members:
|
|
257
|
+
Foo: {}
|
|
258
|
+
Bar:
|
|
259
|
+
type: 'list'
|
|
260
|
+
member:
|
|
261
|
+
locationName: 'Item'
|
|
262
|
+
extractData """
|
|
263
|
+
<xml>
|
|
264
|
+
<Foo>foo</Foo>
|
|
265
|
+
<Bar>
|
|
266
|
+
<Item>a</Item>
|
|
267
|
+
<Item>b</Item>
|
|
268
|
+
<Item>c</Item>
|
|
269
|
+
</Bar>
|
|
270
|
+
</xml>
|
|
271
|
+
"""
|
|
272
|
+
expect(response.data).toEqual({Foo:'foo', Bar:['a', 'b', 'c']})
|
|
273
|
+
|
|
274
|
+
it 'sets payload element to a Buffer object when it streams', ->
|
|
275
|
+
defop output:
|
|
276
|
+
type: 'structure'
|
|
277
|
+
payload: 'Body'
|
|
278
|
+
members:
|
|
279
|
+
Body:
|
|
280
|
+
streaming: true
|
|
281
|
+
extractData 'Buffer data'
|
|
282
|
+
expect(Buffer.isBuffer(response.data.Body)).toBeTruthy()
|
|
283
|
+
expect(response.data.Body.toString()).toEqual('Buffer data')
|
|
284
|
+
|
|
285
|
+
it 'sets payload element to String when it does not stream', ->
|
|
286
|
+
defop output:
|
|
287
|
+
type: 'structure'
|
|
288
|
+
payload: 'Body'
|
|
289
|
+
members:
|
|
290
|
+
Body: type: 'string'
|
|
291
|
+
extractData 'Buffer data'
|
|
292
|
+
expect(typeof response.data.Body).toEqual('string')
|
|
293
|
+
expect(response.data.Body).toEqual('Buffer data')
|
|
294
|
+
|
|
295
|
+
it 'sets payload element along with other outputs', ->
|
|
296
|
+
response.httpResponse.headers['x-amz-foo'] = 'foo'
|
|
297
|
+
response.httpResponse.headers['x-amz-bar'] = 'bar'
|
|
298
|
+
defop output:
|
|
299
|
+
type: 'structure'
|
|
300
|
+
payload: 'Baz'
|
|
301
|
+
members:
|
|
302
|
+
Foo:
|
|
303
|
+
location: 'header'
|
|
304
|
+
locationName: 'x-amz-foo'
|
|
305
|
+
Bar:
|
|
306
|
+
location: 'header'
|
|
307
|
+
locationName: 'x-amz-bar'
|
|
308
|
+
Baz: {}
|
|
309
|
+
extractData 'Buffer data'
|
|
310
|
+
expect(response.data.Foo).toEqual('foo')
|
|
311
|
+
expect(response.data.Bar).toEqual('bar')
|
|
312
|
+
expect(response.data.Baz).toEqual('Buffer data')
|
|
313
|
+
|
|
314
|
+
it 'parses headers when a payload is provided', ->
|
|
315
|
+
response.httpResponse.headers['x-amz-foo'] = 'foo'
|
|
316
|
+
defop output:
|
|
317
|
+
type: 'structure'
|
|
318
|
+
payload: 'Bar'
|
|
319
|
+
members:
|
|
320
|
+
Foo:
|
|
321
|
+
location: 'header'
|
|
322
|
+
locationName: 'x-amz-foo'
|
|
323
|
+
Bar:
|
|
324
|
+
type: 'structure'
|
|
325
|
+
members:
|
|
326
|
+
Baz: type: 'string'
|
|
327
|
+
extractData '<Bar><Baz>Buffer data</Baz></Bar>'
|
|
328
|
+
expect(response.data.Foo).toEqual('foo')
|
|
329
|
+
expect(response.data.Baz).toEqual('Buffer data')
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
QueryParamSerializer = require('../../lib/query/query_param_serializer')
|
|
3
|
+
Shape = helpers.AWS.Model.Shape
|
|
4
|
+
|
|
5
|
+
describe 'QueryParamSerializer', ->
|
|
6
|
+
|
|
7
|
+
serialize = (requestParams, rules) ->
|
|
8
|
+
params = []
|
|
9
|
+
serializer = new QueryParamSerializer()
|
|
10
|
+
shape = Shape.create type: 'structure', members: rules
|
|
11
|
+
serializer.serialize requestParams, shape, (name, value) ->
|
|
12
|
+
params.push([name, value])
|
|
13
|
+
params
|
|
14
|
+
|
|
15
|
+
describe 'scalar params', ->
|
|
16
|
+
|
|
17
|
+
it 'can serialize simple strings', ->
|
|
18
|
+
rules = {Name1:{type:'string'},Name2:{type:'string'}}
|
|
19
|
+
params = serialize({Name1:'abc',Name2:'xyz'}, rules)
|
|
20
|
+
expect(params).toEqual([
|
|
21
|
+
['Name1', 'abc']
|
|
22
|
+
['Name2', 'xyz']
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
it 'stringifies values', ->
|
|
26
|
+
rules = {Count: {type:'string'}}
|
|
27
|
+
params = serialize({ Count:1 }, rules)
|
|
28
|
+
expect(params).toEqual([['Count', '1']])
|
|
29
|
+
|
|
30
|
+
it 'defaults params to strings when type not specified', ->
|
|
31
|
+
rules = {ParamName: {}}
|
|
32
|
+
params = serialize({ ParamName:'abc' }, rules)
|
|
33
|
+
expect(params).toEqual([['ParamName', 'abc']])
|
|
34
|
+
|
|
35
|
+
it 'ignores null values', ->
|
|
36
|
+
rules = {ParamName: {}}
|
|
37
|
+
params = serialize({ ParamName:null }, rules)
|
|
38
|
+
expect(params).toEqual([])
|
|
39
|
+
|
|
40
|
+
describe 'structures', ->
|
|
41
|
+
|
|
42
|
+
it 'works with deeply nested objects', ->
|
|
43
|
+
rules =
|
|
44
|
+
Aa:
|
|
45
|
+
type: 'structure'
|
|
46
|
+
members:
|
|
47
|
+
Bb:
|
|
48
|
+
type: 'structure'
|
|
49
|
+
members:
|
|
50
|
+
Cc:
|
|
51
|
+
type: 'structure'
|
|
52
|
+
members:
|
|
53
|
+
Dd: {}
|
|
54
|
+
params = serialize({Aa:Bb:Cc:Dd:'value'}, rules)
|
|
55
|
+
expect(params).toEqual([
|
|
56
|
+
['Aa.Bb.Cc.Dd', 'value']
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
it 'works with nested objects that have multiple properties', ->
|
|
60
|
+
rules =
|
|
61
|
+
Root:
|
|
62
|
+
type: 'structure'
|
|
63
|
+
members:
|
|
64
|
+
Abc: {}
|
|
65
|
+
Xyz: {}
|
|
66
|
+
Root2: {}
|
|
67
|
+
params = serialize({Root:{Abc:'1',Xyz:'2'},Root2:'3'}, rules)
|
|
68
|
+
expect(params).toEqual([
|
|
69
|
+
['Root.Abc', '1']
|
|
70
|
+
['Root.Xyz', '2']
|
|
71
|
+
['Root2', '3']
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
it 'applies structure member names', ->
|
|
75
|
+
rules =
|
|
76
|
+
Root:
|
|
77
|
+
type: 'structure'
|
|
78
|
+
locationName: 'ROOT'
|
|
79
|
+
members:
|
|
80
|
+
Leaf:
|
|
81
|
+
locationName: 'lEAF'
|
|
82
|
+
params = serialize({Root:{Leaf:'value'}}, rules)
|
|
83
|
+
expect(params).toEqual([
|
|
84
|
+
['ROOT.lEAF', 'value']
|
|
85
|
+
])
|
|
86
|
+
|
|
87
|
+
it 'ignores null', ->
|
|
88
|
+
rules =
|
|
89
|
+
Root:
|
|
90
|
+
type: 'structure'
|
|
91
|
+
locationName: 'ROOT'
|
|
92
|
+
members:
|
|
93
|
+
Leaf:
|
|
94
|
+
locationName: 'lEAF'
|
|
95
|
+
params = serialize({Root:null}, rules)
|
|
96
|
+
expect(params).toEqual([])
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
describe 'lists', ->
|
|
100
|
+
|
|
101
|
+
describe 'flattened', ->
|
|
102
|
+
|
|
103
|
+
it 'numbers list members starting at 1', ->
|
|
104
|
+
rules =
|
|
105
|
+
Name:
|
|
106
|
+
type: 'list'
|
|
107
|
+
flattened: true
|
|
108
|
+
member: type: 'string'
|
|
109
|
+
params = serialize({Name:['a','b','c']}, rules)
|
|
110
|
+
expect(params).toEqual([
|
|
111
|
+
['Name.1', 'a'],
|
|
112
|
+
['Name.2', 'b'],
|
|
113
|
+
['Name.3', 'c'],
|
|
114
|
+
])
|
|
115
|
+
|
|
116
|
+
it 'supports queryFlattened key', ->
|
|
117
|
+
rules =
|
|
118
|
+
Name:
|
|
119
|
+
type: 'list'
|
|
120
|
+
queryFlattened: true
|
|
121
|
+
member: type: 'string'
|
|
122
|
+
params = serialize({Name:['a','b','c']}, rules)
|
|
123
|
+
expect(params).toEqual([
|
|
124
|
+
['Name.1', 'a'],
|
|
125
|
+
['Name.2', 'b'],
|
|
126
|
+
['Name.3', 'c'],
|
|
127
|
+
])
|
|
128
|
+
|
|
129
|
+
it 'Uses list-member names instead of the list name', ->
|
|
130
|
+
rules =
|
|
131
|
+
Root:
|
|
132
|
+
type: 'structure'
|
|
133
|
+
members:
|
|
134
|
+
Items:
|
|
135
|
+
type: 'list'
|
|
136
|
+
flattened: true
|
|
137
|
+
member:
|
|
138
|
+
locationName: 'ListItem'
|
|
139
|
+
params = serialize({Root:{Items:['a', 'b', 'c']}}, rules)
|
|
140
|
+
expect(params).toEqual([
|
|
141
|
+
['Root.ListItem.1', 'a'],
|
|
142
|
+
['Root.ListItem.2', 'b'],
|
|
143
|
+
['Root.ListItem.3', 'c'],
|
|
144
|
+
])
|
|
145
|
+
|
|
146
|
+
it 'accepts nested arrays', ->
|
|
147
|
+
rules =
|
|
148
|
+
Person:
|
|
149
|
+
type: 'structure'
|
|
150
|
+
members:
|
|
151
|
+
Name:
|
|
152
|
+
type: 'list'
|
|
153
|
+
flattened: true
|
|
154
|
+
member: type: 'string'
|
|
155
|
+
params = serialize({Person:{Name:['a','b','c']}}, rules)
|
|
156
|
+
expect(params).toEqual([
|
|
157
|
+
['Person.Name.1', 'a'],
|
|
158
|
+
['Person.Name.2', 'b'],
|
|
159
|
+
['Person.Name.3', 'c'],
|
|
160
|
+
])
|
|
161
|
+
|
|
162
|
+
it 'supports lists of complex types', ->
|
|
163
|
+
rules =
|
|
164
|
+
Root:
|
|
165
|
+
type: 'list'
|
|
166
|
+
flattened: true
|
|
167
|
+
member:
|
|
168
|
+
type: 'structure'
|
|
169
|
+
members:
|
|
170
|
+
Aa: {}
|
|
171
|
+
Bb: {}
|
|
172
|
+
params = serialize({Root:[{Aa:'a1',Bb:'b1'},{Aa:'a2',Bb:'b2'}]},rules)
|
|
173
|
+
expect(params.sort()).toEqual([
|
|
174
|
+
['Root.1.Aa', 'a1'],
|
|
175
|
+
['Root.1.Bb', 'b1'],
|
|
176
|
+
['Root.2.Aa', 'a2'],
|
|
177
|
+
['Root.2.Bb', 'b2'],
|
|
178
|
+
])
|
|
179
|
+
|
|
180
|
+
it 'serializes list members as strings when member rule not present', ->
|
|
181
|
+
rules =
|
|
182
|
+
Root:
|
|
183
|
+
type: 'list'
|
|
184
|
+
flattened: true
|
|
185
|
+
member: type: 'string'
|
|
186
|
+
params = serialize({Root:['a', 'b', 'c']}, rules)
|
|
187
|
+
expect(params).toEqual([
|
|
188
|
+
['Root.1', 'a'],
|
|
189
|
+
['Root.2', 'b'],
|
|
190
|
+
['Root.3', 'c'],
|
|
191
|
+
])
|
|
192
|
+
|
|
193
|
+
describe 'non-flat', ->
|
|
194
|
+
it 'adds a `.member` prefix to each list member', ->
|
|
195
|
+
rules =
|
|
196
|
+
Person:
|
|
197
|
+
type: 'list'
|
|
198
|
+
member: type: 'string'
|
|
199
|
+
params = serialize({Person:['a','b','c']}, rules)
|
|
200
|
+
expect(params).toEqual([
|
|
201
|
+
['Person.member.1', 'a'],
|
|
202
|
+
['Person.member.2', 'b'],
|
|
203
|
+
['Person.member.3', 'c'],
|
|
204
|
+
])
|
|
205
|
+
|
|
206
|
+
it 'ignores the list-member name', ->
|
|
207
|
+
rules =
|
|
208
|
+
Person:
|
|
209
|
+
type: 'list'
|
|
210
|
+
member:
|
|
211
|
+
locationName: 'Name'
|
|
212
|
+
params = serialize({Person:['a','b','c']}, rules)
|
|
213
|
+
expect(params).toEqual([
|
|
214
|
+
['Person.member.1', 'a'],
|
|
215
|
+
['Person.member.2', 'b'],
|
|
216
|
+
['Person.member.3', 'c'],
|
|
217
|
+
])
|
|
218
|
+
|
|
219
|
+
it 'observes both list name and list member name', ->
|
|
220
|
+
rules =
|
|
221
|
+
People:
|
|
222
|
+
type: 'list'
|
|
223
|
+
locationName: 'Person',
|
|
224
|
+
member:
|
|
225
|
+
locationName: 'Name'
|
|
226
|
+
params = serialize({People:['a','b','c']}, rules)
|
|
227
|
+
expect(params).toEqual([
|
|
228
|
+
['Person.member.1', 'a'],
|
|
229
|
+
['Person.member.2', 'b'],
|
|
230
|
+
['Person.member.3', 'c'],
|
|
231
|
+
])
|
|
232
|
+
|
|
233
|
+
describe 'maps', -> # maps are hashes with user defined keys
|
|
234
|
+
|
|
235
|
+
it 'accepts a hash (object) of arbitrary key/value pairs', ->
|
|
236
|
+
rules =
|
|
237
|
+
Attributes:
|
|
238
|
+
type: 'map'
|
|
239
|
+
flattened: true
|
|
240
|
+
key: {}
|
|
241
|
+
value: {}
|
|
242
|
+
data = {Attributes:{Color:'red',Size:'large',Value:'low'}}
|
|
243
|
+
params = serialize(data, rules)
|
|
244
|
+
expect(params).toEqual([
|
|
245
|
+
['Attributes.1.key', 'Color'],
|
|
246
|
+
['Attributes.1.value', 'red'],
|
|
247
|
+
['Attributes.2.key', 'Size'],
|
|
248
|
+
['Attributes.2.value', 'large'],
|
|
249
|
+
['Attributes.3.key', 'Value'],
|
|
250
|
+
['Attributes.3.value', 'low'],
|
|
251
|
+
])
|
|
252
|
+
|
|
253
|
+
it 'supports queryFlattened key', ->
|
|
254
|
+
rules =
|
|
255
|
+
Attributes:
|
|
256
|
+
type: 'map'
|
|
257
|
+
queryFlattened: true
|
|
258
|
+
key: {}
|
|
259
|
+
value: {}
|
|
260
|
+
data = {Attributes:{Color:'red',Size:'large',Value:'low'}}
|
|
261
|
+
params = serialize(data, rules)
|
|
262
|
+
expect(params).toEqual([
|
|
263
|
+
['Attributes.1.key', 'Color'],
|
|
264
|
+
['Attributes.1.value', 'red'],
|
|
265
|
+
['Attributes.2.key', 'Size'],
|
|
266
|
+
['Attributes.2.value', 'large'],
|
|
267
|
+
['Attributes.3.key', 'Value'],
|
|
268
|
+
['Attributes.3.value', 'low'],
|
|
269
|
+
])
|
|
270
|
+
|
|
271
|
+
describe 'non-flat', ->
|
|
272
|
+
it 'adds .entry. to name', ->
|
|
273
|
+
rules =
|
|
274
|
+
Attributes:
|
|
275
|
+
type: 'map'
|
|
276
|
+
key: {}
|
|
277
|
+
value: {}
|
|
278
|
+
data = Attributes: Color: 'red', Size: 'large', Value: 'low'
|
|
279
|
+
params = serialize(data, rules)
|
|
280
|
+
expect(params).toEqual([
|
|
281
|
+
['Attributes.entry.1.key', 'Color'],
|
|
282
|
+
['Attributes.entry.1.value', 'red'],
|
|
283
|
+
['Attributes.entry.2.key', 'Size'],
|
|
284
|
+
['Attributes.entry.2.value', 'large'],
|
|
285
|
+
['Attributes.entry.3.key', 'Value'],
|
|
286
|
+
['Attributes.entry.3.value', 'low'],
|
|
287
|
+
])
|
|
288
|
+
|
|
289
|
+
describe 'maps with member names', ->
|
|
290
|
+
|
|
291
|
+
it 'applies member name traits', ->
|
|
292
|
+
rules =
|
|
293
|
+
Attributes:
|
|
294
|
+
type: 'map'
|
|
295
|
+
flattened: true
|
|
296
|
+
key:
|
|
297
|
+
locationName: 'Name'
|
|
298
|
+
value:
|
|
299
|
+
locationName: 'Value'
|
|
300
|
+
data = {Attributes:{Color:'red',Size:'large',Value:'low'}}
|
|
301
|
+
params = serialize(data, rules)
|
|
302
|
+
expect(params).toEqual([
|
|
303
|
+
['Attributes.1.Name', 'Color'],
|
|
304
|
+
['Attributes.1.Value', 'red'],
|
|
305
|
+
['Attributes.2.Name', 'Size'],
|
|
306
|
+
['Attributes.2.Value', 'large'],
|
|
307
|
+
['Attributes.3.Name', 'Value'],
|
|
308
|
+
['Attributes.3.Value', 'low'],
|
|
309
|
+
])
|
|
310
|
+
|
|
311
|
+
describe 'timestamps', ->
|
|
312
|
+
|
|
313
|
+
it 'serializes timestamp to iso8601 strings by default', ->
|
|
314
|
+
date = new Date(); date.setMilliseconds(0)
|
|
315
|
+
rules = { Date: { type: 'timestamp' } }
|
|
316
|
+
params = serialize({ Date: date }, rules)
|
|
317
|
+
expect(params).toEqual([
|
|
318
|
+
['Date', helpers.util.date.iso8601(date)],
|
|
319
|
+
])
|
|
320
|
+
|
|
321
|
+
it 'obeys format options in the rules', ->
|
|
322
|
+
date = new Date(); date.setMilliseconds(0)
|
|
323
|
+
rules = { Date: { type: 'timestamp', timestampFormat: 'rfc822' } }
|
|
324
|
+
params = serialize({ Date: date }, rules)
|
|
325
|
+
expect(params).toEqual([
|
|
326
|
+
['Date', helpers.util.date.rfc822(date)],
|
|
327
|
+
])
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
EventEmitter = require('events').EventEmitter
|
|
3
|
+
AWS = helpers.AWS
|
|
4
|
+
MockService = helpers.MockService
|
|
5
|
+
Buffer = AWS.util.Buffer
|
|
6
|
+
|
|
7
|
+
describe 'region_config.js', ->
|
|
8
|
+
it 'sets endpoint configuration option for default regions', ->
|
|
9
|
+
service = new MockService
|
|
10
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
11
|
+
expect(service.endpoint.host).toEqual('mockservice.mock-region.amazonaws.com')
|
|
12
|
+
|
|
13
|
+
[AWS.CloudFront, AWS.IAM, AWS.ImportExport, AWS.Route53, AWS.STS].forEach (svcClass) ->
|
|
14
|
+
it 'uses a global endpoint for ' + svcClass.serviceIdentifier, ->
|
|
15
|
+
service = new svcClass
|
|
16
|
+
expect(service.endpoint.host).toEqual(service.serviceIdentifier + '.amazonaws.com')
|
|
17
|
+
expect(service.isGlobalEndpoint).toEqual(true)
|
|
18
|
+
|
|
19
|
+
it 'always enables SSL for Route53', ->
|
|
20
|
+
service = new AWS.Route53
|
|
21
|
+
expect(service.config.sslEnabled).toEqual(true)
|
|
22
|
+
|
|
23
|
+
it 'uses "global" endpoint for SimpleDB in us-east-1', ->
|
|
24
|
+
service = new AWS.SimpleDB(region: 'us-east-1')
|
|
25
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
26
|
+
expect(service.endpoint.host).toEqual('sdb.amazonaws.com')
|
|
27
|
+
|
|
28
|
+
it 'uses "global" endpoint for SimpleDB in us-east-1', ->
|
|
29
|
+
service = new AWS.S3(region: 'us-east-1')
|
|
30
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
31
|
+
expect(service.endpoint.host).toEqual('s3.amazonaws.com')
|
|
32
|
+
|
|
33
|
+
it 'does not use any global endpoints in cn-*', ->
|
|
34
|
+
service = new AWS.IAM(region: 'cn-north-1')
|
|
35
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
36
|
+
expect(service.endpoint.host).toEqual('iam.cn-north-1.amazonaws.com.cn')
|
|
37
|
+
|
|
38
|
+
it 'enables signature version 4 signing in cn-*', ->
|
|
39
|
+
service = new AWS.IAM(region: 'cn-north-1')
|
|
40
|
+
expect(service.config.signatureVersion).toEqual('v4')
|
|
41
|
+
|
|
42
|
+
it 'uses - as separator for S3 in public regions', ->
|
|
43
|
+
service = new AWS.S3(region: 'us-west-2')
|
|
44
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
45
|
+
expect(service.endpoint.host).toEqual('s3-us-west-2.amazonaws.com')
|
|
46
|
+
|
|
47
|
+
it 'uses . as separator for S3 in cn-*', ->
|
|
48
|
+
service = new AWS.S3(region: 'cn-north-1')
|
|
49
|
+
expect(service.isGlobalEndpoint).toEqual(false)
|
|
50
|
+
expect(service.endpoint.host).toEqual('s3.cn-north-1.amazonaws.com.cn')
|