-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: CLDSRV-282 fix regression from CLDSRV-280
* auth results can be an array of arrays * Object.assign needs an empty object or it modifies the original * should be `_isObjectLockEnabled` not `!_isObjectLockEnabled` * add unit tests (cherry picked from commit bbb3e2f)
- Loading branch information
1 parent
f9e695b
commit 0a432f2
Showing
3 changed files
with
101 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const assert = require('assert'); | ||
const DummyRequest = require('./DummyRequest'); | ||
const { authBucketPut } = require('../../lib/api/bucketPut'); | ||
|
||
function prepareDummyRequest(headers = {}) { | ||
const request = new DummyRequest({ | ||
hostname: 'localhost', | ||
port: 80, | ||
headers, | ||
socket: { | ||
remoteAddress: '0.0.0.0', | ||
}, | ||
}); | ||
return request; | ||
} | ||
|
||
describe('Policies: permission checks for S3 APIs', () => { | ||
describe('PutBucket', () => { | ||
function putBucketApiMethods(headers) { | ||
const request = prepareDummyRequest(headers); | ||
const result = authBucketPut(null, 'name', null, request, null); | ||
return result.map(req => req.apiMethod); | ||
} | ||
|
||
it('should return s3:PutBucket without any provided header', () => { | ||
assert.deepStrictEqual( | ||
putBucketApiMethods(), | ||
['bucketPut'], | ||
); | ||
}); | ||
|
||
it('should return s3:PutBucket and s3:PutBucketObjectLockConfiguration with ACL headers', () => { | ||
assert.deepStrictEqual( | ||
putBucketApiMethods({ 'x-amz-bucket-object-lock-enabled': 'true' }), | ||
['bucketPut', 'bucketPutObjectLock', 'bucketPutVersioning'], | ||
); | ||
}); | ||
}); | ||
}); |