Skip to content

Commit 71e84e1

Browse files
authored
Merge pull request #61 from v-shan/vicki/proxy
Add network proxy option
2 parents ff4cda9 + 7cc7435 commit 71e84e1

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ Sets the default mime type, used when it cannot be determined from the file exte
175175

176176
*Default:* `application/octet-stream`
177177

178+
### proxy
179+
180+
The network proxy url used when sending requests to S3.
181+
182+
*Default:* `undefined`
183+
178184
## Prerequisites
179185

180186
The following properties are expected to be present on the deployment `context` object:

lib/s3.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ module.exports = CoreObject.extend({
1616
region: this._plugin.readConfig('region')
1717
};
1818

19+
const proxy = this._plugin.readConfig('proxy');
20+
if (proxy) {
21+
this._proxyAgent = this._plugin.readConfig('proxyAgent') || require('proxy-agent');
22+
s3Options.httpOptions = {
23+
agent: this._proxyAgent(proxy)
24+
};
25+
}
26+
1927
const accessKeyId = this._plugin.readConfig('accessKeyId');
2028
const secretAccessKey = this._plugin.readConfig('secretAccessKey');
2129
const sessionToken = this._plugin.readConfig('sessionToken');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"ember-cli-deploy-plugin": "^0.2.2",
5353
"lodash": "^3.9.3",
5454
"mime": "^1.3.4",
55-
"minimatch": "^2.0.4"
55+
"minimatch": "^2.0.4",
56+
"proxy-agent": "^2.0.0"
5657
},
5758
"ember-addon": {
5859
"configPath": "tests/dummy/config",

tests/unit/index-nodetest.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('s3 plugin', function() {
4141
filePattern: '*.{css,js}',
4242
acl: 'authenticated-read',
4343
prefix: '',
44+
proxy: 'http://user:password@internal.proxy.com',
4445
distDir: function(context) {
4546
return context.distDir;
4647
},
@@ -247,6 +248,27 @@ describe('s3 plugin', function() {
247248
});
248249
});
249250

251+
it('calls proxy agent if a proxy is specified', function(done) {
252+
var plugin = subject.createDeployPlugin({
253+
name: 's3'
254+
});
255+
256+
var assertionCount = 0
257+
context.proxyAgent = function(proxy) {
258+
assertionCount++;
259+
};
260+
261+
plugin.beforeHook(context);
262+
plugin.configure(context);
263+
264+
return assert.isFulfilled(plugin.upload(context)).then(function(){
265+
assert.equal(assertionCount, 1);
266+
done();
267+
}).catch(function(reason){
268+
done(reason.actual.stack);
269+
});
270+
});
271+
250272
it('sets the appropriate header if the file is inclued in gzippedFiles list', function(done) {
251273
var plugin = subject.createDeployPlugin({
252274
name: 's3'

0 commit comments

Comments
 (0)