Skip to content

Commit

Permalink
Merge pull request #134 from TraceGenomics/feature/acl-optional
Browse files Browse the repository at this point in the history
Optionally ignore ACLs
  • Loading branch information
lukemelia authored Apr 3, 2024
2 parents 63e88b0 + 9209f40 commit 00e0c59
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ A file matching this pattern will be uploaded to S3. The active key in S3 will b

The ACL to apply to the objects.

Set to `false` to not apply any ACLs.

*Default:* `'public-read'`

### cacheControl
Expand Down Expand Up @@ -151,7 +153,7 @@ or Openstack Swift

If `endpoint` set the `region` option will be ignored.

*Default:* `[region].s3.amazonaws.com`
*Default:* `[region].s3.amazonaws.com`


### serverSideEncryption
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ module.exports = {
var options = {
bucket: bucket,
prefix: prefix,
acl: acl,
cacheControl: cacheControl,
filePattern: filePattern,
filePath: filePath,
Expand All @@ -77,6 +76,10 @@ module.exports = {
urlEncodeSourceObject: urlEncodeSourceObject
};

if (acl) {
options.acl = acl;
}

if (serverSideEncryption) {
options.serverSideEncryption = serverSideEncryption;
}
Expand All @@ -99,12 +102,15 @@ module.exports = {
var options = {
bucket: bucket,
prefix: prefix,
acl: acl,
filePattern: filePattern,
revisionKey: revisionKey,
urlEncodeSourceObject: urlEncodeSourceObject,
};

if (acl) {
options.acl = acl;
}

if (serverSideEncryption) {
options.serverSideEncryption = serverSideEncryption;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ describe('s3-index plugin', function() {
});
});

it('filters acl when not defined', function() {
context.config['s3-index'].acl = false;
var promise = plugin.upload(context);

return assert.isFulfilled(promise)
.then(function() {
assert.equal(Object.prototype.hasOwnProperty.call(s3Options, 'acl'), false, 'acl filtered correctly');
});
});

it('passes cacheControl options based on the cacheControl option to the s3-abstraction', function() {
var cacheControl = 'max-age=3600';
context.config['s3-index'].cacheControl = cacheControl;
Expand Down Expand Up @@ -264,6 +274,16 @@ describe('s3-index plugin', function() {
});
});

it('filters acl when not defined', function() {
context.config['s3-index'].acl = false;
var promise = plugin.upload(context);

return assert.isFulfilled(promise)
.then(function() {
assert.equal(Object.prototype.hasOwnProperty.call(s3Options, 'acl'), false, 'acl filtered correctly');
});
});

it('displays activation message when revision is activated', function() {
var promise = plugin.activate(context);

Expand Down

0 comments on commit 00e0c59

Please sign in to comment.