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,111 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>AWS SDK for JavaScript - Console</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; }
|
|
7
|
+
#drop_zone { padding: 40px; border: 2px dashed #666; color: #777; font-size: 2em; }
|
|
8
|
+
</style>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="fb-root"></div>
|
|
12
|
+
<h1>Upload a file to S3</h1>
|
|
13
|
+
<p>Bucket name: <input type="text" id="bucket"/></p>
|
|
14
|
+
<div id="drop_zone">Drop files here</div>
|
|
15
|
+
<div id="notes"></div>
|
|
16
|
+
<script type="text/javascript" src="aws-sdk.js"></script>
|
|
17
|
+
<script type="text/javascript" src="appinfo.js"></script>
|
|
18
|
+
<script type="text/javascript">
|
|
19
|
+
var elDropZone = document.getElementById('drop_zone');
|
|
20
|
+
var elFile = document.getElementById('file');
|
|
21
|
+
var elBucket = document.getElementById('bucket');
|
|
22
|
+
var elNotes = document.getElementById('notes');
|
|
23
|
+
elBucket.value = localStorage.s3BucketName;
|
|
24
|
+
|
|
25
|
+
var s3 = new AWS.S3({params: {Bucket: elBucket.value || ''}});
|
|
26
|
+
|
|
27
|
+
function init() {
|
|
28
|
+
elDropZone.addEventListener('dragover', handleDragOver, false);
|
|
29
|
+
elDropZone.addEventListener('drop', handleFileSelect, false);
|
|
30
|
+
elBucket.addEventListener('change', function () {
|
|
31
|
+
localStorage.s3BucketName = elBucket.value;
|
|
32
|
+
s3.config.params.Bucket = elBucket.value;
|
|
33
|
+
}, false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var firstTime = true;
|
|
37
|
+
function handleFileSelect(evt) {
|
|
38
|
+
if (firstTime) {
|
|
39
|
+
firstTime = false;
|
|
40
|
+
elDropZone.innerHTML = '';
|
|
41
|
+
}
|
|
42
|
+
evt.stopPropagation();
|
|
43
|
+
evt.preventDefault();
|
|
44
|
+
|
|
45
|
+
var files = evt.dataTransfer.files; // FileList object.
|
|
46
|
+
for (var i = 0; i < files.length; i++) {
|
|
47
|
+
var params = {Key: files[i].name, ContentType: files[i].type, Body: files[i]};
|
|
48
|
+
var req = s3.putObject(params).on('httpUploadProgress', function (progress) {
|
|
49
|
+
console.log(progress);
|
|
50
|
+
}).send(function (err, data) {
|
|
51
|
+
console.log("FINISHED");
|
|
52
|
+
if (err) {
|
|
53
|
+
elDropZone.innerHTML += '<p>ERROR UPLOADING ' + files[i].name + '</p>';
|
|
54
|
+
} else {
|
|
55
|
+
var url = s3.getSignedUrl('getObject', {Key: params.Key});
|
|
56
|
+
console.log(url)
|
|
57
|
+
elDropZone.innerHTML += '<img src="' + url + '">';
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function handleDragOver(evt) {
|
|
65
|
+
evt.stopPropagation();
|
|
66
|
+
evt.preventDefault();
|
|
67
|
+
evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function loadIDPCredentials(provider, arn, accessToken) {
|
|
71
|
+
var params = {
|
|
72
|
+
ProviderId: provider,
|
|
73
|
+
RoleArn: arn,
|
|
74
|
+
WebIdentityToken: accessToken
|
|
75
|
+
};
|
|
76
|
+
if (provider === null) delete params.ProviderId;
|
|
77
|
+
s3.config.credentials = new AWS.WebIdentityCredentials(params);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
window.fbAsyncInit = function() {
|
|
81
|
+
// init the FB JS SDK
|
|
82
|
+
FB.init({
|
|
83
|
+
appId: window.appInfo.facebook.appId,
|
|
84
|
+
status: false,
|
|
85
|
+
xfbml: false
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
FB.Event.subscribe('auth.authResponseChange', function(response) {
|
|
89
|
+
if (response.status === 'connected') {
|
|
90
|
+
loadIDPCredentials('graph.facebook.com',
|
|
91
|
+
window.appInfo.facebook.roleArn,
|
|
92
|
+
response.authResponse.accessToken);
|
|
93
|
+
} else { FB.login(); }
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
FB.getLoginStatus();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Load the SDK asynchronously
|
|
100
|
+
(function(d, s, id){
|
|
101
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
|
102
|
+
if (d.getElementById(id)) {return;}
|
|
103
|
+
js = d.createElement(s); js.id = id;
|
|
104
|
+
js.src = "//connect.facebook.net/en_US/all.js";
|
|
105
|
+
fjs.parentNode.insertBefore(js, fjs);
|
|
106
|
+
}(document, 'script', 'facebook-jssdk'));
|
|
107
|
+
|
|
108
|
+
document.addEventListener('DOMContentLoaded', init, false);
|
|
109
|
+
</script>
|
|
110
|
+
</body>
|
|
111
|
+
</html>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
config = {}
|
|
4
|
+
try
|
|
5
|
+
config = require('./configuration')
|
|
6
|
+
|
|
7
|
+
s3 = new AWS.S3(AWS.util.merge(config, config.s3))
|
|
8
|
+
dynamodb = new AWS.DynamoDB(AWS.util.merge(config, config.dynamodb))
|
|
9
|
+
sqs = new AWS.SQS(AWS.util.merge(config, config.sqs))
|
|
10
|
+
sns = new AWS.SNS(AWS.util.merge(config, config.sns))
|
|
11
|
+
sts = new AWS.STS(AWS.util.merge(config, config.sts))
|
|
12
|
+
|
|
13
|
+
uniqueName = (prefix) ->
|
|
14
|
+
if prefix
|
|
15
|
+
prefix + '-' + AWS.util.date.getDate().getTime()
|
|
16
|
+
else
|
|
17
|
+
AWS.util.date.getDate().getTime().toString()
|
|
18
|
+
|
|
19
|
+
eventually = (condition, next, done) ->
|
|
20
|
+
options = delay: 0, backoff: 500, maxTime: 10
|
|
21
|
+
delay = options.delay
|
|
22
|
+
started = AWS.util.date.getDate()
|
|
23
|
+
id = 0
|
|
24
|
+
nextFn = ->
|
|
25
|
+
now = AWS.util.date.getDate()
|
|
26
|
+
if (now - started < options.maxTime * 1000)
|
|
27
|
+
next (err, data) ->
|
|
28
|
+
if condition(err, data)
|
|
29
|
+
done(err, data)
|
|
30
|
+
else
|
|
31
|
+
timeoutFn = ->
|
|
32
|
+
clearInterval(id)
|
|
33
|
+
delay += options.backoff
|
|
34
|
+
nextFn()
|
|
35
|
+
id = setInterval(timeoutFn, delay)
|
|
36
|
+
nextFn()
|
|
37
|
+
|
|
38
|
+
noError = (err) -> expect(err).toEqual(null)
|
|
39
|
+
|
|
40
|
+
integration = (label, fn) ->
|
|
41
|
+
if label.match(/\(no phantomjs\)/) and navigator.userAgent.match(/phantomjs/i)
|
|
42
|
+
return
|
|
43
|
+
it label, ->
|
|
44
|
+
done = false
|
|
45
|
+
runs -> fn(-> done = true)
|
|
46
|
+
waitsFor -> done == true
|
|
47
|
+
|
|
48
|
+
integrationTests = (fn) ->
|
|
49
|
+
if config.accessKeyId and AWS.util.isBrowser()
|
|
50
|
+
describe 'Integration tests', fn
|
|
51
|
+
|
|
52
|
+
integrationTests ->
|
|
53
|
+
describe 'Request.abort', ->
|
|
54
|
+
it 'can abort a request', ->
|
|
55
|
+
err = null
|
|
56
|
+
done = null
|
|
57
|
+
runs ->
|
|
58
|
+
req = s3.putObject Key: 'key', Body: 'body'
|
|
59
|
+
req.on 'complete', (resp) -> done = true; err = resp.error
|
|
60
|
+
req.on 'send', (resp) -> resp.request.abort()
|
|
61
|
+
req.send()
|
|
62
|
+
waitsFor -> done
|
|
63
|
+
runs ->
|
|
64
|
+
expect(err.name).toEqual('RequestAbortedError')
|
|
65
|
+
|
|
66
|
+
describe 'XHR', ->
|
|
67
|
+
it 'does not emit http events if networking issue occurs', ->
|
|
68
|
+
err = null
|
|
69
|
+
done = null
|
|
70
|
+
httpHeaders = false; httpData = false; httpError = false; httpDone = false
|
|
71
|
+
runs ->
|
|
72
|
+
svc = new AWS.S3(accessKeyId: 'akid', secretAccessKey: 'secret', maxRetries: 0)
|
|
73
|
+
date = AWS.util.date.iso8601().replace(/[^0-9]/g,'')
|
|
74
|
+
req = svc.getObject(Bucket:'invalidbucket' + date, Key: 'foo')
|
|
75
|
+
req.on 'httpHeaders', -> httpHeaders = true
|
|
76
|
+
req.on 'httpData', -> httpData = true
|
|
77
|
+
req.on 'httpDone', -> httpDone = true
|
|
78
|
+
req.on 'httpError', -> httpError = true
|
|
79
|
+
req.on 'complete', (resp) -> done = true; err = resp.error
|
|
80
|
+
req.send()
|
|
81
|
+
waitsFor -> done
|
|
82
|
+
runs ->
|
|
83
|
+
expect(httpHeaders).toEqual(false)
|
|
84
|
+
expect(httpData).toEqual(false)
|
|
85
|
+
expect(httpDone).toEqual(false)
|
|
86
|
+
expect(httpError).toEqual(true)
|
|
87
|
+
expect(err.name).toEqual('NetworkingError')
|
|
88
|
+
|
|
89
|
+
integration 'can send synchronous requests (no phantomjs)', (done) ->
|
|
90
|
+
key = uniqueName('test')
|
|
91
|
+
opts = AWS.util.merge(config, config.s3)
|
|
92
|
+
opts.httpOptions = xhrAsync: false
|
|
93
|
+
svc = new AWS.S3(opts)
|
|
94
|
+
resp1 = svc.putObject(Key: key, Body: 'body').send()
|
|
95
|
+
resp2 = svc.getObject(Key: key).send()
|
|
96
|
+
expect(resp2.data.Body.toString()).toEqual('body')
|
|
97
|
+
svc.deleteObject(Key: key).send()
|
|
98
|
+
done()
|
|
99
|
+
|
|
100
|
+
describe 'AWS.S3', ->
|
|
101
|
+
testWrite = (done, body, compareFn) ->
|
|
102
|
+
key = uniqueName('test')
|
|
103
|
+
s3.putObject {Key: key, Body: body}, (err, data) ->
|
|
104
|
+
noError(err)
|
|
105
|
+
s3.getObject {Key: key}, (err, data) ->
|
|
106
|
+
noError(err)
|
|
107
|
+
if compareFn
|
|
108
|
+
compareFn(data)
|
|
109
|
+
else
|
|
110
|
+
expect(data.Body.toString()).toEqual(body)
|
|
111
|
+
s3.deleteObject(Key: key).send(done)
|
|
112
|
+
|
|
113
|
+
integration 'GETs and PUTs objects to a bucket (no phantomjs)', (done) ->
|
|
114
|
+
testWrite done, 'ƒoo'
|
|
115
|
+
|
|
116
|
+
integration 'writes typed array data (no phantomjs)', (done) ->
|
|
117
|
+
testWrite done, new Uint8Array([2, 4, 8]), (data) ->
|
|
118
|
+
expect(data.Body[0]).toEqual(2)
|
|
119
|
+
expect(data.Body[1]).toEqual(4)
|
|
120
|
+
expect(data.Body[2]).toEqual(8)
|
|
121
|
+
|
|
122
|
+
integration 'writes blobs (no phantomjs)', (done) ->
|
|
123
|
+
testWrite done, new Blob(['a', 'b', 'c']), (data) ->
|
|
124
|
+
expect(data.Body[0]).toEqual(97)
|
|
125
|
+
expect(data.Body[1]).toEqual(98)
|
|
126
|
+
expect(data.Body[2]).toEqual(99)
|
|
127
|
+
|
|
128
|
+
integration 'writes with charset', (done) ->
|
|
129
|
+
key = uniqueName('test')
|
|
130
|
+
body = 'body string'
|
|
131
|
+
s3.putObject {Key: key, Body: body, ContentType: 'text/html'}, (err, data) ->
|
|
132
|
+
noError(err)
|
|
133
|
+
s3.deleteObject(Key: key).send(done)
|
|
134
|
+
s3.putObject {Key: key, Body: body, ContentType: 'text/html; charset=utf-8'}, (err, data) ->
|
|
135
|
+
noError(err)
|
|
136
|
+
s3.deleteObject(Key: key).send(done)
|
|
137
|
+
|
|
138
|
+
describe 'progress events', ->
|
|
139
|
+
integration 'emits http(Upload|Download)Progress events (no phantomjs)', (done) ->
|
|
140
|
+
data = []
|
|
141
|
+
progress = []
|
|
142
|
+
key = uniqueName('test')
|
|
143
|
+
body = new Blob([new Array(512 * 1024).join('x')])
|
|
144
|
+
req = s3.putObject(Key: key, Body: body)
|
|
145
|
+
req.on 'httpUploadProgress', (p) -> progress.push(p)
|
|
146
|
+
req.send (err, data) ->
|
|
147
|
+
noError(err)
|
|
148
|
+
expect(progress.length > 1).toEqual(true)
|
|
149
|
+
expect(progress[0].total).toEqual(body.size)
|
|
150
|
+
expect(progress[0].loaded > 10).toEqual(true)
|
|
151
|
+
|
|
152
|
+
progress = []
|
|
153
|
+
req = s3.getObject(Key: key)
|
|
154
|
+
req.on 'httpDownloadProgress', (p) -> progress.push(p)
|
|
155
|
+
req.send (err, data) ->
|
|
156
|
+
noError(err)
|
|
157
|
+
expect(progress.length > 1).toEqual(true)
|
|
158
|
+
expect(progress[0].total).toEqual(body.size)
|
|
159
|
+
expect(progress[0].loaded > 10).toEqual(true)
|
|
160
|
+
s3.deleteObject(Key: key).send()
|
|
161
|
+
done()
|
|
162
|
+
|
|
163
|
+
describe 'AWS.DynamoDB', ->
|
|
164
|
+
integration 'writes and reads from a table', (done) ->
|
|
165
|
+
key = uniqueName('test')
|
|
166
|
+
dynamodb.putItem {Item: {id: {S: key}, data: {S: 'ƒoo'}}}, (err, data) ->
|
|
167
|
+
noError(err)
|
|
168
|
+
dynamodb.getItem {Key: {id: {S: key}}}, (err, data) ->
|
|
169
|
+
noError(err)
|
|
170
|
+
expect(data.Item.data.S).toEqual('ƒoo')
|
|
171
|
+
dynamodb.deleteItem({Key: {id: {S: key}}}).send(done)
|
|
172
|
+
|
|
173
|
+
describe 'AWS.STS', ->
|
|
174
|
+
integration 'gets a session token', (done) ->
|
|
175
|
+
sts.getSessionToken (err, data) ->
|
|
176
|
+
noError(err)
|
|
177
|
+
expect(data.Credentials.AccessKeyId).not.toEqual('')
|
|
178
|
+
done()
|
|
179
|
+
|
|
180
|
+
describe 'AWS.SQS', ->
|
|
181
|
+
integration 'posts and receives messages on a queue', (done) ->
|
|
182
|
+
name = uniqueName('aws-sdk-js')
|
|
183
|
+
msg = 'ƒoo'
|
|
184
|
+
sqs.createQueue {QueueName: name}, (err, data) ->
|
|
185
|
+
url = data.QueueUrl
|
|
186
|
+
sqs = new AWS.SQS(sqs.config)
|
|
187
|
+
sqs.config.params = QueueUrl: url
|
|
188
|
+
eventually ((err) -> err == null),
|
|
189
|
+
((cb) -> sqs.getQueueUrl({QueueName: name}, cb)), ->
|
|
190
|
+
sqs.sendMessage {MessageBody:msg}, (err, data) ->
|
|
191
|
+
noError(err)
|
|
192
|
+
eventually ((err, data) -> data.Messages[0].Body == msg),
|
|
193
|
+
((cb) -> sqs.receiveMessage(cb)), (err, data) ->
|
|
194
|
+
noError(err)
|
|
195
|
+
expect(data.Messages[0].MD5OfBody).toEqual(AWS.util.crypto.md5(msg, 'hex'))
|
|
196
|
+
sqs.deleteQueue(done)
|
|
197
|
+
|
|
198
|
+
describe 'AWS.SNS', ->
|
|
199
|
+
integration 'creates and deletes topics', (done) ->
|
|
200
|
+
sns.createTopic {Name: uniqueName('aws-sdk-js')}, (err, data) ->
|
|
201
|
+
noError(err)
|
|
202
|
+
arn = data.TopicArn
|
|
203
|
+
sns = new AWS.SNS(sns.config)
|
|
204
|
+
sns.config.params = TopicArn: arn
|
|
205
|
+
sns.listTopics (err, data) ->
|
|
206
|
+
expect(data.Topics.filter((o) -> o.TopicArn == arn)).not.toEqual(null)
|
|
207
|
+
sns.deleteTopic(done)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
configure = (options) -> new AWS.Config(options)
|
|
5
|
+
|
|
6
|
+
describe 'AWS.Config', ->
|
|
7
|
+
|
|
8
|
+
describe 'constructor', ->
|
|
9
|
+
it 'should be able to pass in a Config object as parameter', ->
|
|
10
|
+
config = new AWS.Config(sslEnabled: false, maxRetries: 0)
|
|
11
|
+
copyConfig = new AWS.Config(config)
|
|
12
|
+
expect(copyConfig).not.toBe(config)
|
|
13
|
+
expect(copyConfig.sslEnabled).toEqual(false)
|
|
14
|
+
expect(copyConfig.maxRetries).toEqual(0)
|
|
15
|
+
|
|
16
|
+
it 'should be able to pass credential values directly', ->
|
|
17
|
+
config = new AWS.Config(
|
|
18
|
+
accessKeyId: 'akid',
|
|
19
|
+
secretAccessKey: 'secret',
|
|
20
|
+
sessionToken: 'session')
|
|
21
|
+
expect(config.credentials.accessKeyId).toEqual('akid')
|
|
22
|
+
expect(config.credentials.secretAccessKey).toEqual('secret')
|
|
23
|
+
expect(config.credentials.sessionToken).toEqual('session')
|
|
24
|
+
|
|
25
|
+
describe 'region', ->
|
|
26
|
+
oldEnv = process.env
|
|
27
|
+
beforeEach ->
|
|
28
|
+
process.env = {}
|
|
29
|
+
afterEach ->
|
|
30
|
+
process.env = oldEnv
|
|
31
|
+
|
|
32
|
+
it 'defaults to undefined', ->
|
|
33
|
+
expect(configure().region).toEqual(undefined)
|
|
34
|
+
|
|
35
|
+
if AWS.util.isNode()
|
|
36
|
+
it 'grabs AWS_REGION from the env', ->
|
|
37
|
+
process.env.AWS_REGION = 'us-west-2'
|
|
38
|
+
config = new AWS.Config()
|
|
39
|
+
expect(config.region).toEqual('us-west-2')
|
|
40
|
+
|
|
41
|
+
it 'also grabs AMAZON_REGION from the env', ->
|
|
42
|
+
process.env.AMAZON_REGION = 'us-west-1'
|
|
43
|
+
config = new AWS.Config()
|
|
44
|
+
expect(config.region).toEqual('us-west-1')
|
|
45
|
+
|
|
46
|
+
it 'prefers AWS_REGION to AMAZON_REGION', ->
|
|
47
|
+
process.env.AWS_REGION = 'us-west-2'
|
|
48
|
+
process.env.AMAZON_REGION = 'us-west-1'
|
|
49
|
+
config = new AWS.Config()
|
|
50
|
+
expect(config.region).toEqual('us-west-2')
|
|
51
|
+
|
|
52
|
+
it 'can be set to a string', ->
|
|
53
|
+
expect(configure(region: 'us-west-1').region).toEqual('us-west-1')
|
|
54
|
+
|
|
55
|
+
describe 'maxRetries', ->
|
|
56
|
+
it 'defaults to unefined', ->
|
|
57
|
+
expect(configure().maxRetries).toEqual(undefined)
|
|
58
|
+
it 'can be set to an integer', ->
|
|
59
|
+
expect(configure(maxRetries: 2).maxRetries).toEqual(2)
|
|
60
|
+
|
|
61
|
+
describe 'paramValidation', ->
|
|
62
|
+
it 'defaults to true', ->
|
|
63
|
+
expect(configure().paramValidation).toEqual(true)
|
|
64
|
+
|
|
65
|
+
describe 'computeChecksums', ->
|
|
66
|
+
it 'defaults to true', ->
|
|
67
|
+
expect(configure().computeChecksums).toEqual(true)
|
|
68
|
+
|
|
69
|
+
describe 'sslEnabled', ->
|
|
70
|
+
it 'defaults to true', ->
|
|
71
|
+
expect(configure().sslEnabled).toEqual(true)
|
|
72
|
+
it 'can be set to false', ->
|
|
73
|
+
expect(configure(sslEnabled: false).sslEnabled).toEqual(false)
|
|
74
|
+
|
|
75
|
+
describe 'httpOptions', ->
|
|
76
|
+
it 'defaults to {}', ->
|
|
77
|
+
expect(configure().httpOptions).toEqual({})
|
|
78
|
+
|
|
79
|
+
describe 'set', ->
|
|
80
|
+
it 'should set a default value for a key', ->
|
|
81
|
+
config = new AWS.Config()
|
|
82
|
+
config.set('maxRetries', undefined, 'DEFAULT')
|
|
83
|
+
expect(config.maxRetries).toEqual('DEFAULT')
|
|
84
|
+
|
|
85
|
+
it 'should execute default value if it is a function', ->
|
|
86
|
+
mock = jasmine.createSpy()
|
|
87
|
+
config = new AWS.Config()
|
|
88
|
+
config.set('maxRetries', undefined, mock)
|
|
89
|
+
expect(mock).toHaveBeenCalled()
|
|
90
|
+
|
|
91
|
+
it 'should not expand default value function if value is present', ->
|
|
92
|
+
mock = jasmine.createSpy()
|
|
93
|
+
config = new AWS.Config()
|
|
94
|
+
config.set('maxRetries', 'VALUE', mock)
|
|
95
|
+
expect(mock).not.toHaveBeenCalled()
|
|
96
|
+
|
|
97
|
+
describe 'clear', ->
|
|
98
|
+
it 'should be able to clear all key values from a config object', ->
|
|
99
|
+
config = new AWS.Config(credentials: {}, maxRetries: 300, sslEnabled: 'foo')
|
|
100
|
+
expect(config.maxRetries).toEqual(300)
|
|
101
|
+
expect(config.sslEnabled).toEqual('foo')
|
|
102
|
+
expect(config.credentials).not.toEqual(undefined)
|
|
103
|
+
|
|
104
|
+
config.clear()
|
|
105
|
+
|
|
106
|
+
expect(config.maxRetries).toEqual(undefined)
|
|
107
|
+
expect(config.sslEnabled).toEqual(undefined)
|
|
108
|
+
expect(config.credentials).not.toBe(undefined)
|
|
109
|
+
expect(config.credentialProvider).not.toBe(undefined)
|
|
110
|
+
|
|
111
|
+
describe 'update', ->
|
|
112
|
+
it 'should be able to update keyed values', ->
|
|
113
|
+
config = new AWS.Config()
|
|
114
|
+
expect(config.maxRetries).toEqual(undefined)
|
|
115
|
+
config.update(maxRetries: 10)
|
|
116
|
+
expect(config.maxRetries).toEqual(10)
|
|
117
|
+
|
|
118
|
+
it 'should ignore non-keyed values', ->
|
|
119
|
+
config = new AWS.Config()
|
|
120
|
+
config.update(foo: 10)
|
|
121
|
+
expect(config.foo).toEqual(undefined)
|
|
122
|
+
|
|
123
|
+
it 'allows unknown keys if allowUnknownKeys is set', ->
|
|
124
|
+
config = new AWS.Config()
|
|
125
|
+
config.update(foo: 10, true)
|
|
126
|
+
expect(config.foo).toEqual(10)
|
|
127
|
+
|
|
128
|
+
it 'should be able to update literal credentials', ->
|
|
129
|
+
config = new AWS.Config()
|
|
130
|
+
config.update(
|
|
131
|
+
accessKeyId: 'akid',
|
|
132
|
+
secretAccessKey: 'secret',
|
|
133
|
+
sessionToken: 'session')
|
|
134
|
+
expect(config.credentials.accessKeyId).toEqual('akid')
|
|
135
|
+
expect(config.credentials.secretAccessKey).toEqual('secret')
|
|
136
|
+
expect(config.credentials.sessionToken).toEqual('session')
|
|
137
|
+
|
|
138
|
+
describe 'getCredentials', ->
|
|
139
|
+
spy = null
|
|
140
|
+
config = null
|
|
141
|
+
beforeEach ->
|
|
142
|
+
spy = jasmine.createSpy('getCredentials callback')
|
|
143
|
+
|
|
144
|
+
expectValid = (options, key) ->
|
|
145
|
+
if options instanceof AWS.Config
|
|
146
|
+
config = options
|
|
147
|
+
else
|
|
148
|
+
config = new AWS.Config(options)
|
|
149
|
+
config.getCredentials(spy)
|
|
150
|
+
expect(spy).toHaveBeenCalled()
|
|
151
|
+
expect(spy.argsForCall[0][0]).toEqual(null)
|
|
152
|
+
if key
|
|
153
|
+
expect(config.credentials.accessKeyId).toEqual(key)
|
|
154
|
+
|
|
155
|
+
expectError = (options, message) ->
|
|
156
|
+
if options instanceof AWS.Config
|
|
157
|
+
config = options
|
|
158
|
+
else
|
|
159
|
+
config = new AWS.Config(options)
|
|
160
|
+
config.getCredentials(spy)
|
|
161
|
+
expect(spy).toHaveBeenCalled()
|
|
162
|
+
expect(spy.argsForCall[0][0].code).toEqual('CredentialsError')
|
|
163
|
+
expect(spy.argsForCall[0][0].message).toEqual(message)
|
|
164
|
+
|
|
165
|
+
it 'should check credentials for static object first', ->
|
|
166
|
+
expectValid credentials: accessKeyId: '123', secretAccessKey: '456'
|
|
167
|
+
|
|
168
|
+
it 'should error if static credentials are not available', ->
|
|
169
|
+
expectError(credentials: {}, 'Missing credentials')
|
|
170
|
+
|
|
171
|
+
it 'should check credentials for async get() method', ->
|
|
172
|
+
expectValid credentials: get: (cb) -> cb()
|
|
173
|
+
|
|
174
|
+
it 'should error if credentials.get() cannot resolve', ->
|
|
175
|
+
options = credentials:
|
|
176
|
+
constructor: name: 'CustomCredentials'
|
|
177
|
+
get: (cb) -> cb(new Error('Error!'), null)
|
|
178
|
+
expectError options, 'Could not load credentials from CustomCredentials'
|
|
179
|
+
|
|
180
|
+
it 'should check credentialProvider if no credentials', ->
|
|
181
|
+
expectValid credentials: null, credentialProvider:
|
|
182
|
+
resolve: (cb) -> cb(null, accessKeyId: 'key', secretAccessKey: 'secret')
|
|
183
|
+
|
|
184
|
+
it 'should error if credentialProvider fails to resolve', ->
|
|
185
|
+
options = credentials: null, credentialProvider:
|
|
186
|
+
resolve: (cb) -> cb(new Error('Error!'), null)
|
|
187
|
+
expectError options, 'Could not load credentials from any providers'
|
|
188
|
+
|
|
189
|
+
it 'should error if no credentials or credentialProvider', ->
|
|
190
|
+
options = credentials: null, credentialProvider: null
|
|
191
|
+
expectError options, 'No credentials to load'
|
|
192
|
+
|
|
193
|
+
describe 'AWS.config', ->
|
|
194
|
+
it 'should be a default Config object', ->
|
|
195
|
+
expect(AWS.config.sslEnabled).toEqual(true)
|
|
196
|
+
expect(AWS.config.maxRetries).toEqual(undefined)
|
|
197
|
+
|
|
198
|
+
it 'can set default config to an object literal', ->
|
|
199
|
+
oldConfig = AWS.config
|
|
200
|
+
AWS.config = {}
|
|
201
|
+
expect(AWS.config).toEqual({})
|
|
202
|
+
AWS.config = oldConfig
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
AWS = helpers.AWS
|
|
3
|
+
|
|
4
|
+
if AWS.util.isNode()
|
|
5
|
+
describe 'AWS.CredentialProviderChain', ->
|
|
6
|
+
describe 'resolve', ->
|
|
7
|
+
chain = null
|
|
8
|
+
defaultProviders = AWS.CredentialProviderChain.defaultProviders
|
|
9
|
+
|
|
10
|
+
beforeEach ->
|
|
11
|
+
process.env = {}
|
|
12
|
+
chain = new AWS.CredentialProviderChain [
|
|
13
|
+
-> new AWS.EnvironmentCredentials('AWS'),
|
|
14
|
+
-> new AWS.EnvironmentCredentials('AMAZON')
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
afterEach ->
|
|
18
|
+
AWS.CredentialProviderChain.defaultProviders = defaultProviders
|
|
19
|
+
|
|
20
|
+
it 'returns an error by default', ->
|
|
21
|
+
chain.resolve (err) ->
|
|
22
|
+
expect(err.message).toEqual('Variable AMAZON_ACCESS_KEY_ID not set.')
|
|
23
|
+
|
|
24
|
+
it 'returns AWS-prefixed credentials found in ENV', ->
|
|
25
|
+
|
|
26
|
+
process.env['AWS_ACCESS_KEY_ID'] = 'akid'
|
|
27
|
+
process.env['AWS_SECRET_ACCESS_KEY'] = 'secret'
|
|
28
|
+
process.env['AWS_SESSION_TOKEN'] = 'session'
|
|
29
|
+
|
|
30
|
+
chain.resolve (err, creds) ->
|
|
31
|
+
expect(creds.accessKeyId).toEqual('akid')
|
|
32
|
+
expect(creds.secretAccessKey).toEqual('secret')
|
|
33
|
+
expect(creds.sessionToken).toEqual('session')
|
|
34
|
+
|
|
35
|
+
it 'returns AMAZON-prefixed credentials found in ENV', ->
|
|
36
|
+
|
|
37
|
+
process.env['AMAZON_ACCESS_KEY_ID'] = 'akid'
|
|
38
|
+
process.env['AMAZON_SECRET_ACCESS_KEY'] = 'secret'
|
|
39
|
+
process.env['AMAZON_SESSION_TOKEN'] = 'session'
|
|
40
|
+
|
|
41
|
+
chain.resolve (err, creds) ->
|
|
42
|
+
expect(creds.accessKeyId).toEqual('akid')
|
|
43
|
+
expect(creds.secretAccessKey).toEqual('secret')
|
|
44
|
+
expect(creds.sessionToken).toEqual('session')
|
|
45
|
+
|
|
46
|
+
it 'prefers AWS credentials to AMAZON credentials', ->
|
|
47
|
+
|
|
48
|
+
process.env['AWS_ACCESS_KEY_ID'] = 'akid'
|
|
49
|
+
process.env['AWS_SECRET_ACCESS_KEY'] = 'secret'
|
|
50
|
+
process.env['AWS_SESSION_TOKEN'] = 'session'
|
|
51
|
+
|
|
52
|
+
process.env['AMAZON_ACCESS_KEY_ID'] = 'akid2'
|
|
53
|
+
process.env['AMAZON_SECRET_ACCESS_KEY'] = 'secret2'
|
|
54
|
+
process.env['AMAZON_SESSION_TOKEN'] = 'session2'
|
|
55
|
+
|
|
56
|
+
chain.resolve (err, creds) ->
|
|
57
|
+
expect(creds.accessKeyId).toEqual('akid')
|
|
58
|
+
expect(creds.secretAccessKey).toEqual('secret')
|
|
59
|
+
expect(creds.sessionToken).toEqual('session')
|
|
60
|
+
|
|
61
|
+
it 'uses the defaultProviders property on the constructor', ->
|
|
62
|
+
|
|
63
|
+
# remove default providers
|
|
64
|
+
AWS.CredentialProviderChain.defaultProviders = []
|
|
65
|
+
|
|
66
|
+
# these should now get ignored
|
|
67
|
+
process.env['AWS_ACCESS_KEY_ID'] = 'akid'
|
|
68
|
+
process.env['AWS_SECRET_ACCESS_KEY'] = 'secret'
|
|
69
|
+
process.env['AWS_SESSION_TOKEN'] = 'session'
|
|
70
|
+
|
|
71
|
+
chain = new AWS.CredentialProviderChain()
|
|
72
|
+
chain.resolve (err) ->
|
|
73
|
+
expect(err.message).toEqual('No providers')
|
|
74
|
+
|
|
75
|
+
it 'calls resolve on each provider in the chain, stopping for akid', ->
|
|
76
|
+
staticCreds = accessKeyId: 'abc', secretAccessKey: 'xyz'
|
|
77
|
+
chain = new AWS.CredentialProviderChain([staticCreds])
|
|
78
|
+
chain.resolve (err, creds) ->
|
|
79
|
+
expect(creds.accessKeyId).toEqual('abc')
|
|
80
|
+
expect(creds.secretAccessKey).toEqual('xyz')
|
|
81
|
+
expect(creds.sessionToken).toEqual(undefined)
|
|
82
|
+
|
|
83
|
+
it 'accepts providers as functions, elavuating them during resolution', ->
|
|
84
|
+
provider = ->
|
|
85
|
+
accessKeyId: 'abc', secretAccessKey: 'xyz'
|
|
86
|
+
chain = new AWS.CredentialProviderChain([provider])
|
|
87
|
+
chain.resolve (err, creds) ->
|
|
88
|
+
expect(creds.accessKeyId).toEqual('abc')
|
|
89
|
+
expect(creds.secretAccessKey).toEqual('xyz')
|
|
90
|
+
expect(creds.sessionToken).toEqual(undefined)
|