|
1 | 1 | var assert = require('ember-cli/tests/helpers/assert');
|
2 | 2 |
|
| 3 | + |
3 | 4 | describe('cloudfront', function() {
|
4 | 5 | var CloudFront, mockUi, cloudfrontClient, plugin, subject;
|
5 | 6 |
|
6 | 7 | before(function() {
|
| 8 | + process.env['AWS_ACCESS_KEY_ID'] = 'set_via_env_var'; |
| 9 | + process.env['AWS_SECRET_ACCESS_KEY'] = 'set_via_env_var'; |
| 10 | + |
7 | 11 | CloudFront = require('../../../lib/cloudfront');
|
8 | 12 | });
|
9 | 13 |
|
@@ -34,6 +38,55 @@ describe('cloudfront', function() {
|
34 | 38 | };
|
35 | 39 | });
|
36 | 40 |
|
| 41 | + describe('#init', function() { |
| 42 | + context('with a custom CloudFront client', function() { |
| 43 | + it('uses the custom client', function() { |
| 44 | + assert.equal(cloudfrontClient, subject._client); |
| 45 | + }) |
| 46 | + }); |
| 47 | + |
| 48 | + context('using the aws-sdk CloudFront client', function() { |
| 49 | + beforeEach(function() { |
| 50 | + awsClient = {}; |
| 51 | + plugin.readConfig = function(propertyName) {}; |
| 52 | + subject = new CloudFront({plugin: plugin}); |
| 53 | + }); |
| 54 | + |
| 55 | + it('uses the AWS client', function() { |
| 56 | + var AWS = require('aws-sdk'); |
| 57 | + assert.ok(subject._client instanceof AWS.CloudFront); |
| 58 | + }); |
| 59 | + |
| 60 | + context('with credentials in plugin config', function() { |
| 61 | + beforeEach(function() { |
| 62 | + plugin.readConfig = function(propertyName) { |
| 63 | + if(propertyName === 'accessKeyId' || propertyName === 'secretAccessKey') { |
| 64 | + return 'set_via_config'; |
| 65 | + } |
| 66 | + }; |
| 67 | + subject = new CloudFront({plugin: plugin}); |
| 68 | + }); |
| 69 | + |
| 70 | + it('uses the configured credentials', function() { |
| 71 | + assert.equal('set_via_config', subject._client.config.credentials.accessKeyId); |
| 72 | + assert.equal('set_via_config', subject._client.config.credentials.secretAccessKey); |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
| 76 | + context('with no credentials in the plugin config', function() { |
| 77 | + beforeEach(function() { |
| 78 | + plugin.readConfig = function(propertyName) {}; |
| 79 | + subject = new CloudFront({plugin: plugin}); |
| 80 | + }); |
| 81 | + |
| 82 | + it('falls back to default AWS credential resolution', function() { |
| 83 | + assert.equal('set_via_env_var', subject._client.config.credentials.accessKeyId); |
| 84 | + assert.equal('set_via_env_var', subject._client.config.credentials.secretAccessKey); |
| 85 | + }); |
| 86 | + }); |
| 87 | + }); |
| 88 | + }); |
| 89 | + |
37 | 90 | describe('#invalidate', function() {
|
38 | 91 | it('resolves if invalidation succeeds', function() {
|
39 | 92 | var promises = subject.invalidate(validOptions);
|
|
0 commit comments