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,129 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
describe 'AWS.JSON.Builder', ->
|
|
5
|
+
|
|
6
|
+
builder = new AWS.JSON.Builder()
|
|
7
|
+
timestampFormat = 'iso8601'
|
|
8
|
+
api = null
|
|
9
|
+
|
|
10
|
+
beforeEach ->
|
|
11
|
+
api = new AWS.Model.Api
|
|
12
|
+
metadata:
|
|
13
|
+
timestampFormat: timestampFormat
|
|
14
|
+
protocol: 'json'
|
|
15
|
+
|
|
16
|
+
build = (rules, params) ->
|
|
17
|
+
shape = AWS.Model.Shape.create(rules, api: api)
|
|
18
|
+
builder.build(params, shape)
|
|
19
|
+
|
|
20
|
+
describe 'build', ->
|
|
21
|
+
|
|
22
|
+
it 'returns an empty document when there are no params', ->
|
|
23
|
+
expect(build({}, {})).toEqual("{}")
|
|
24
|
+
|
|
25
|
+
describe 'structures', ->
|
|
26
|
+
rules =
|
|
27
|
+
type: 'structure'
|
|
28
|
+
members:
|
|
29
|
+
Items:
|
|
30
|
+
type: 'structure'
|
|
31
|
+
members:
|
|
32
|
+
A: type: 'string'
|
|
33
|
+
B: type: 'string'
|
|
34
|
+
|
|
35
|
+
it 'translates input', ->
|
|
36
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
37
|
+
expect(build(rules, params)).toEqual('{"Items":{"A":"a","B":"b"}}')
|
|
38
|
+
|
|
39
|
+
it 'ignores null', ->
|
|
40
|
+
expect(build(rules, Items: null)).toEqual('{}')
|
|
41
|
+
|
|
42
|
+
it 'ignores undefined', ->
|
|
43
|
+
expect(build(rules, Items: undefined)).toEqual('{}')
|
|
44
|
+
|
|
45
|
+
describe 'lists', ->
|
|
46
|
+
rules =
|
|
47
|
+
type: 'structure'
|
|
48
|
+
members:
|
|
49
|
+
Items:
|
|
50
|
+
type: 'list'
|
|
51
|
+
member:
|
|
52
|
+
type: 'string'
|
|
53
|
+
|
|
54
|
+
it 'translates input', ->
|
|
55
|
+
params = Items: ['a', 'b', 'c']
|
|
56
|
+
expect(build(rules, params)).toEqual('{"Items":["a","b","c"]}')
|
|
57
|
+
|
|
58
|
+
it 'ignores null', ->
|
|
59
|
+
expect(build(rules, Items: null)).toEqual('{}')
|
|
60
|
+
|
|
61
|
+
it 'ignores undefined', ->
|
|
62
|
+
expect(build(rules, Items: undefined)).toEqual('{}')
|
|
63
|
+
|
|
64
|
+
describe 'maps', ->
|
|
65
|
+
rules =
|
|
66
|
+
type: 'structure'
|
|
67
|
+
members:
|
|
68
|
+
Items:
|
|
69
|
+
type: 'map'
|
|
70
|
+
key: type: 'string'
|
|
71
|
+
value: type: 'string'
|
|
72
|
+
|
|
73
|
+
it 'translates maps', ->
|
|
74
|
+
params = { Items: { A: 'a', B: 'b' } }
|
|
75
|
+
expect(build(rules, params)).toEqual('{"Items":{"A":"a","B":"b"}}')
|
|
76
|
+
|
|
77
|
+
it 'ignores null', ->
|
|
78
|
+
expect(build(rules, Items: null)).toEqual('{}')
|
|
79
|
+
|
|
80
|
+
it 'ignores undefined', ->
|
|
81
|
+
expect(build(rules, Items: undefined)).toEqual('{}')
|
|
82
|
+
|
|
83
|
+
it 'translates nested maps', ->
|
|
84
|
+
rules =
|
|
85
|
+
type: 'structure'
|
|
86
|
+
members:
|
|
87
|
+
Items: type: 'map', value: type: 'integer'
|
|
88
|
+
now = new Date()
|
|
89
|
+
now.setMilliseconds(100)
|
|
90
|
+
params = Items: MyKey: "5", MyOtherKey: "10"
|
|
91
|
+
str = '{"Items":{"MyKey":5,"MyOtherKey":10}}'
|
|
92
|
+
expect(build(rules, params)).toEqual(str)
|
|
93
|
+
|
|
94
|
+
it 'traslates nested timestamps', ->
|
|
95
|
+
rules =
|
|
96
|
+
type: 'structure'
|
|
97
|
+
members:
|
|
98
|
+
Build:
|
|
99
|
+
type: 'structure'
|
|
100
|
+
members:
|
|
101
|
+
When:
|
|
102
|
+
type: 'timestamp'
|
|
103
|
+
now = new Date()
|
|
104
|
+
now.setMilliseconds(100)
|
|
105
|
+
params = Build: When: now
|
|
106
|
+
formatted = AWS.util.date.iso8601(now).replace(/\.\d+Z$/, '')
|
|
107
|
+
expect(build(rules, params)).toMatch('\\{"Build":\\{"When":"'+formatted+'\\.\\d+Z"\\}\\}')
|
|
108
|
+
|
|
109
|
+
it 'translates integers formatted as strings', ->
|
|
110
|
+
rules =
|
|
111
|
+
type: 'structure'
|
|
112
|
+
members:
|
|
113
|
+
Integer: type: 'integer'
|
|
114
|
+
expect(build(rules, Integer: '20')).toEqual('{"Integer":20}')
|
|
115
|
+
|
|
116
|
+
it 'translates floats formatted as strings', ->
|
|
117
|
+
rules =
|
|
118
|
+
type: 'structure'
|
|
119
|
+
members:
|
|
120
|
+
Float: type: 'float'
|
|
121
|
+
expect(build(rules, Float: '20.1')).toEqual('{"Float":20.1}')
|
|
122
|
+
|
|
123
|
+
it 'ignores nulls null as null', ->
|
|
124
|
+
rules =
|
|
125
|
+
type: 'structure'
|
|
126
|
+
members:
|
|
127
|
+
Float: type: 'float'
|
|
128
|
+
Other: type: 'string'
|
|
129
|
+
expect(build(rules, Float: null, Other: 'foo')).toEqual('{"Other":"foo"}')
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
describe 'AWS.JSON.Parser', ->
|
|
5
|
+
|
|
6
|
+
parser = new AWS.JSON.Parser()
|
|
7
|
+
timestampFormat = 'iso8601'
|
|
8
|
+
api = null
|
|
9
|
+
|
|
10
|
+
beforeEach ->
|
|
11
|
+
api = new AWS.Model.Api metadata: timestampFormat: timestampFormat
|
|
12
|
+
|
|
13
|
+
parse = (rules, params) ->
|
|
14
|
+
shape = AWS.Model.Shape.create(rules, api: api)
|
|
15
|
+
parser.parse(params, shape)
|
|
16
|
+
|
|
17
|
+
describe 'parse', ->
|
|
18
|
+
|
|
19
|
+
it 'returns an empty document when there are no params', ->
|
|
20
|
+
expect(parse({}, '{}')).toEqual({})
|
|
21
|
+
|
|
22
|
+
describe 'structures', ->
|
|
23
|
+
rules =
|
|
24
|
+
type: 'structure'
|
|
25
|
+
members:
|
|
26
|
+
Items:
|
|
27
|
+
type: 'structure'
|
|
28
|
+
members:
|
|
29
|
+
A: type: 'string'
|
|
30
|
+
B: type: 'string'
|
|
31
|
+
|
|
32
|
+
it 'translates input', ->
|
|
33
|
+
params = '{ "Items": { "A": "a", "B": "b" } }'
|
|
34
|
+
expect(parse(rules, params)).toEqual({"Items":{"A":"a","B":"b"}})
|
|
35
|
+
|
|
36
|
+
it 'ignores null', ->
|
|
37
|
+
expect(parse(rules, '{"Items": null}')).toEqual({})
|
|
38
|
+
|
|
39
|
+
describe 'lists', ->
|
|
40
|
+
rules =
|
|
41
|
+
type: 'structure'
|
|
42
|
+
members:
|
|
43
|
+
Items:
|
|
44
|
+
type: 'list'
|
|
45
|
+
member:
|
|
46
|
+
type: 'string'
|
|
47
|
+
|
|
48
|
+
it 'translates input', ->
|
|
49
|
+
params = '{"Items":["a","b","c"]}'
|
|
50
|
+
expect(parse(rules, params)).toEqual(Items: ['a', 'b', 'c'])
|
|
51
|
+
|
|
52
|
+
it 'ignores null', ->
|
|
53
|
+
expect(parse(rules, '{"Items": null}')).toEqual({})
|
|
54
|
+
|
|
55
|
+
describe 'maps', ->
|
|
56
|
+
rules =
|
|
57
|
+
type: 'structure'
|
|
58
|
+
members:
|
|
59
|
+
Items:
|
|
60
|
+
type: 'map'
|
|
61
|
+
key: type: 'string'
|
|
62
|
+
value: type: 'string'
|
|
63
|
+
|
|
64
|
+
it 'translates maps', ->
|
|
65
|
+
params = '{"Items":{"A":"a","B":"b"}}'
|
|
66
|
+
expect(parse(rules, params)).toEqual({ Items: { A: 'a', B: 'b' } })
|
|
67
|
+
|
|
68
|
+
it 'ignores null', ->
|
|
69
|
+
expect(parse(rules, '{"Items": null}')).toEqual({})
|
|
70
|
+
|
|
71
|
+
it 'translates nested maps', ->
|
|
72
|
+
rules =
|
|
73
|
+
type: 'structure'
|
|
74
|
+
members:
|
|
75
|
+
Items: type: 'map', value: type: 'integer'
|
|
76
|
+
now = new Date()
|
|
77
|
+
now.setMilliseconds(100)
|
|
78
|
+
params = Items: MyKey: 5, MyOtherKey: 10
|
|
79
|
+
str = '{"Items":{"MyKey":5,"MyOtherKey":10}}'
|
|
80
|
+
expect(parse(rules, str)).toEqual(params)
|
|
81
|
+
|
|
82
|
+
it 'traslates nested timestamps', ->
|
|
83
|
+
rules =
|
|
84
|
+
type: 'structure'
|
|
85
|
+
members:
|
|
86
|
+
Build:
|
|
87
|
+
type: 'structure'
|
|
88
|
+
members:
|
|
89
|
+
When:
|
|
90
|
+
type: 'timestamp'
|
|
91
|
+
time = new Date(0)
|
|
92
|
+
params = Build: When: time
|
|
93
|
+
formatted = AWS.util.date.iso8601(time)
|
|
94
|
+
expect(parse(rules, '{"Build":{"When":"'+formatted+'"}}')).toEqual(params)
|
|
95
|
+
|
|
96
|
+
it 'translates binary types', ->
|
|
97
|
+
rules =
|
|
98
|
+
type: 'structure'
|
|
99
|
+
members:
|
|
100
|
+
Binary1:
|
|
101
|
+
type: 'binary'
|
|
102
|
+
Binary2:
|
|
103
|
+
type: 'base64'
|
|
104
|
+
data = parse(rules, '{"Binary1":"AQID","Binary2":"AQID"}')
|
|
105
|
+
expect(AWS.util.Buffer.isBuffer(data.Binary1))
|
|
106
|
+
expect(AWS.util.Buffer.isBuffer(data.Binary2))
|
|
107
|
+
expect(data.Binary1.toString()).toEqual('\u0001\u0002\u0003')
|
|
108
|
+
expect(data.Binary2.toString()).toEqual('\u0001\u0002\u0003')
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
url = require('url')
|
|
3
|
+
http = require('http')
|
|
4
|
+
AWS = helpers.AWS
|
|
5
|
+
|
|
6
|
+
if AWS.util.isNode()
|
|
7
|
+
describe 'AWS.MetadataService', ->
|
|
8
|
+
describe 'loadCredentials', ->
|
|
9
|
+
[server, port, service] = [null, 1024 + parseInt(Math.random() * 100), null]
|
|
10
|
+
|
|
11
|
+
beforeEach ->
|
|
12
|
+
service = new AWS.MetadataService(host: '127.0.0.1:' + port)
|
|
13
|
+
server = http.createServer (req, res) ->
|
|
14
|
+
re = new RegExp('^/latest/meta-data/iam/security-credentials/(.*)$')
|
|
15
|
+
match = url.parse(req.url).pathname.match(re)
|
|
16
|
+
if match
|
|
17
|
+
res.writeHead(200, 'Content-Type': 'text/plain')
|
|
18
|
+
if match[1] == ''
|
|
19
|
+
res.write('TestingRole\n')
|
|
20
|
+
res.write('TestingRole2\n')
|
|
21
|
+
else
|
|
22
|
+
data = '{"Code":"Success","AccessKeyId":"KEY","SecretAccessKey":"SECRET","Token":"TOKEN"}'
|
|
23
|
+
res.write(data)
|
|
24
|
+
else
|
|
25
|
+
res.writeHead(404, {})
|
|
26
|
+
res.end()
|
|
27
|
+
|
|
28
|
+
server.listen(port)
|
|
29
|
+
|
|
30
|
+
afterEach -> server.close() if server
|
|
31
|
+
|
|
32
|
+
it 'should load credentials from metadata service', ->
|
|
33
|
+
[err, data] = [null, null]
|
|
34
|
+
runs ->
|
|
35
|
+
service.loadCredentials (e, d) -> [err, data] = [e, d]
|
|
36
|
+
waitsFor -> err || data
|
|
37
|
+
runs ->
|
|
38
|
+
expect(err).toBe(null)
|
|
39
|
+
expect(data.Code).toEqual('Success')
|
|
40
|
+
expect(data.AccessKeyId).toEqual('KEY')
|
|
41
|
+
expect(data.SecretAccessKey).toEqual('SECRET')
|
|
42
|
+
expect(data.Token).toEqual('TOKEN')
|
|
43
|
+
|
|
44
|
+
it 'should fail if server is not up', ->
|
|
45
|
+
server.close(); server = null
|
|
46
|
+
service = new AWS.MetadataService(host: '255.255.255.255')
|
|
47
|
+
service.httpOptions.timeout = 10
|
|
48
|
+
[err, data] = [null, null]
|
|
49
|
+
runs ->
|
|
50
|
+
service.loadCredentials (e, d) -> [err, data] = [e, d]
|
|
51
|
+
waitsFor -> err || data
|
|
52
|
+
runs ->
|
|
53
|
+
expect(err instanceof Error).toBe(true)
|
|
54
|
+
expect(data).toEqual(null)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
make = (obj, opts) -> new AWS.Model.Api(obj, opts)
|
|
5
|
+
|
|
6
|
+
describe 'AWS.Model.Api', ->
|
|
7
|
+
describe 'loading', ->
|
|
8
|
+
it 'loads properties from metadata', ->
|
|
9
|
+
api = make metadata:
|
|
10
|
+
apiVersion: '1.0', endpointPrefix: 'endpoint', globalEndpoint: 'global'
|
|
11
|
+
signatureVersion: 'v4', protocol: 'json', timestampFormat: 'rfc822'
|
|
12
|
+
xmlNamespace: 'URI', serviceAbbreviation: 'abbr', serviceFullName: 'name'
|
|
13
|
+
|
|
14
|
+
expect(api.apiVersion).toEqual('1.0')
|
|
15
|
+
expect(api.endpointPrefix).toEqual('endpoint')
|
|
16
|
+
expect(api.globalEndpoint).toEqual('global')
|
|
17
|
+
expect(api.signatureVersion).toEqual('v4')
|
|
18
|
+
expect(api.protocol).toEqual('json')
|
|
19
|
+
expect(api.timestampFormat).toEqual('rfc822')
|
|
20
|
+
expect(api.xmlNamespaceUri).toEqual('URI')
|
|
21
|
+
expect(api.abbreviation).toEqual('abbr')
|
|
22
|
+
expect(api.fullName).toEqual('name')
|
|
23
|
+
|
|
24
|
+
describe 'isApi', ->
|
|
25
|
+
it 'is an API', ->
|
|
26
|
+
expect(make().isApi).toBe(true)
|
|
27
|
+
|
|
28
|
+
describe 'className', ->
|
|
29
|
+
it 'generates the correct class name from fullName', ->
|
|
30
|
+
api = make metadata: serviceFullName: 'Amazon Service Name HeRE'
|
|
31
|
+
expect(api.className).toEqual('ServiceNameHeRE')
|
|
32
|
+
|
|
33
|
+
it 'uses abbreviation if supplied', ->
|
|
34
|
+
api = make metadata: serviceAbbreviation: 'Amazon SNH'
|
|
35
|
+
expect(api.className).toEqual('SNH')
|
|
36
|
+
|
|
37
|
+
it 'special cases ELB', ->
|
|
38
|
+
api = make metadata: serviceFullName: 'AWS Elastic Load Balancing'
|
|
39
|
+
expect(api.className).toEqual('ELB')
|
|
40
|
+
|
|
41
|
+
it 'handles lack of service name', ->
|
|
42
|
+
expect(make().className).toEqual(null)
|
|
43
|
+
|
|
44
|
+
describe 'documentation', ->
|
|
45
|
+
it 'does not provide documentation by default', ->
|
|
46
|
+
api = make documentation: 'foo'
|
|
47
|
+
expect(api.documentation).toEqual(null)
|
|
48
|
+
|
|
49
|
+
it 'can attach documentation if option is enabled', ->
|
|
50
|
+
api = make {documentation: 'foo'}, documentation: true
|
|
51
|
+
expect(api.documentation).toEqual('foo')
|
|
52
|
+
|
|
53
|
+
describe 'shapes', ->
|
|
54
|
+
it 'creates a set of shapes', ->
|
|
55
|
+
api = make
|
|
56
|
+
shapes:
|
|
57
|
+
Shape1:
|
|
58
|
+
type: 'structure'
|
|
59
|
+
members:
|
|
60
|
+
Member1:
|
|
61
|
+
shape: 'MemberShape'
|
|
62
|
+
timestampFormat: 'rfc822'
|
|
63
|
+
MemberShape:
|
|
64
|
+
type: 'timestamp'
|
|
65
|
+
timestampFormat: 'iso8601'
|
|
66
|
+
|
|
67
|
+
expect(api.shapes.Shape1.members.Member1.type).toEqual('timestamp')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
helpers = require('../helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
describe 'AWS.Model.Shape', ->
|
|
5
|
+
describe 'TimestampShape', ->
|
|
6
|
+
describe 'toType()', ->
|
|
7
|
+
it 'converts unix timestamps', ->
|
|
8
|
+
api = new AWS.Model.Api metadata: timestampFormat: 'unixTimestamp'
|
|
9
|
+
shape = AWS.Model.Shape.create { type: 'timestamp' }, { api: api }
|
|
10
|
+
date = shape.toType(12300)
|
|
11
|
+
expect(date).toEqual(new Date(12300000))
|
|
12
|
+
|
|
13
|
+
it 'converts iso8601 timestamps', ->
|
|
14
|
+
api = new AWS.Model.Api metadata: timestampFormat: 'iso8601'
|
|
15
|
+
shape = AWS.Model.Shape.create { type: 'timestamp' }, { api: api }
|
|
16
|
+
date = shape.toType('1970-01-01T00:00:00.000Z')
|
|
17
|
+
expect(date).toEqual(new Date(0))
|
|
18
|
+
|
|
19
|
+
it 'converts rfc822 timestamps', ->
|
|
20
|
+
api = new AWS.Model.Api metadata: timestampFormat: 'rfc822'
|
|
21
|
+
shape = AWS.Model.Shape.create { type: 'timestamp' }, { api: api }
|
|
22
|
+
date = shape.toType('Thu, 01 Jan 1970 00:00:00 GMT')
|
|
23
|
+
expect(date).toEqual(new Date(0))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
if AWS.util.isNode()
|
|
5
|
+
describe 'AWS.NodeHttpClient', ->
|
|
6
|
+
http = new AWS.NodeHttpClient()
|
|
7
|
+
|
|
8
|
+
describe 'maxSockets delegation', ->
|
|
9
|
+
it 'delegates maxSockets from agent to globalAgent', ->
|
|
10
|
+
https = require('https')
|
|
11
|
+
agent = http.sslAgent()
|
|
12
|
+
expect(https.globalAgent.maxSockets).toEqual(agent.maxSockets)
|
|
13
|
+
https.globalAgent.maxSockets += 1
|
|
14
|
+
expect(https.globalAgent.maxSockets).toEqual(agent.maxSockets)
|
|
15
|
+
|
|
16
|
+
describe 'handleRequest', ->
|
|
17
|
+
it 'emits error event', ->
|
|
18
|
+
error = null
|
|
19
|
+
req = new AWS.HttpRequest 'http://invalid'
|
|
20
|
+
runs ->
|
|
21
|
+
http.handleRequest req, {}, null, (err) ->
|
|
22
|
+
error = err
|
|
23
|
+
waitsFor -> error
|
|
24
|
+
runs ->
|
|
25
|
+
expect(error.code).toEqual 'ENOTFOUND'
|
|
26
|
+
|
|
27
|
+
it 'supports timeout in httpOptions', ->
|
|
28
|
+
error = null
|
|
29
|
+
numCalls = 0
|
|
30
|
+
req = new AWS.HttpRequest 'http://1.1.1.1'
|
|
31
|
+
runs ->
|
|
32
|
+
http.handleRequest req, {timeout: 1}, null, (err) ->
|
|
33
|
+
error = err
|
|
34
|
+
numCalls += 1
|
|
35
|
+
|
|
36
|
+
waitsFor((-> error), 'Timed out', 100)
|
|
37
|
+
runs ->
|
|
38
|
+
expect(error.code).toEqual 'TimeoutError'
|
|
39
|
+
expect(error.message).toEqual 'Connection timed out after 1ms'
|
|
40
|
+
expect(numCalls).toEqual 1
|