-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/w/8.6/bugfix/CLDSRV-508-fix-buck…
…et-tagging' into w/8.7/bugfix/CLDSRV-508-fix-bucket-tagging
- Loading branch information
Showing
8 changed files
with
221 additions
and
4 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
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,74 @@ | ||
const assert = require('assert'); | ||
|
||
const { bucketPut } = require('../../../lib/api/bucketPut'); | ||
const { cleanup, | ||
DummyRequestLogger, | ||
makeAuthInfo, | ||
TaggingConfigTester } | ||
= require('../helpers'); | ||
const bucketPutTagging = require('../../../lib/api/bucketPutTagging'); | ||
const bucketGetTagging = require('../../../lib/api/bucketGetTagging'); | ||
const bucketDeleteTagging = require('../../../lib/api/bucketDeleteTagging'); | ||
const log = new DummyRequestLogger(); | ||
const authInfo = makeAuthInfo('accessKey1'); | ||
const bucketName = 'bucketGetTaggingTest'; | ||
|
||
const testBucketPutRequest = { | ||
bucketName, | ||
headers: { host: `${bucketName}.s3.amazonaws.com` }, | ||
url: '/', | ||
actionImplicitDenies: false, | ||
}; | ||
|
||
describe('deleteBucketTagging API', () => { | ||
beforeEach(done => { | ||
cleanup(); | ||
bucketPut(authInfo, testBucketPutRequest, log, done); | ||
}); | ||
|
||
afterEach(() => cleanup()); | ||
|
||
it('should delete tags resource', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
assert.strictEqual(err, undefined); | ||
|
||
const testBucketGetTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('GET', bucketName); | ||
return bucketGetTagging(authInfo, testBucketGetTaggingRequest, log, | ||
(err, xml) => { | ||
assert.ifError(err); | ||
assert.strictEqual(xml, taggingUtil.constructXml()); | ||
const testBucketDeleteTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('DELETE', bucketName); | ||
return bucketDeleteTagging(authInfo, testBucketDeleteTaggingRequest, | ||
log, err => { | ||
assert.ifError(err); | ||
return bucketGetTagging(authInfo, testBucketGetTaggingRequest, | ||
log, err => { | ||
assert(err.NoSuchTagSet); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should return access denied if the authorization check fails', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
assert.ifError(err); | ||
const testBucketDeleteTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('DELETE', bucketName, null, true); | ||
return bucketDeleteTagging(authInfo, testBucketDeleteTaggingRequest, | ||
log, err => { | ||
assert(err.AccessDenied); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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,67 @@ | ||
const assert = require('assert'); | ||
|
||
const { bucketPut } = require('../../../lib/api/bucketPut'); | ||
const { cleanup, | ||
DummyRequestLogger, | ||
makeAuthInfo, | ||
TaggingConfigTester, | ||
} = require('../helpers'); | ||
const bucketPutTagging = require('../../../lib/api/bucketPutTagging'); | ||
const bucketGetTagging = require('../../../lib/api/bucketGetTagging'); | ||
const log = new DummyRequestLogger(); | ||
const authInfo = makeAuthInfo('accessKey1'); | ||
const bucketName = 'bucketGetTaggingTest'; | ||
|
||
const testBucketPutRequest = { | ||
bucketName, | ||
headers: { host: `${bucketName}.s3.amazonaws.com` }, | ||
url: '/', | ||
actionImplicitDenies: false, | ||
}; | ||
|
||
describe('getBucketTagging API', () => { | ||
beforeEach(done => { | ||
cleanup(); | ||
bucketPut(authInfo, testBucketPutRequest, log, done); | ||
}); | ||
|
||
afterEach(() => cleanup()); | ||
|
||
it('should return tags resource', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
assert.strictEqual(err, undefined); | ||
const testBucketGetTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('GET', bucketName); | ||
return bucketGetTagging(authInfo, testBucketGetTaggingRequest, log, | ||
(err, xml) => { | ||
if (err) { | ||
process.stdout.write(`Err getting object tagging ${err}`); | ||
return done(err); | ||
} | ||
assert.strictEqual(xml, taggingUtil.constructXml()); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should return access denied if the authorization check fails', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
assert.strictEqual(err, undefined); | ||
const testBucketGetTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('GET', bucketName, true); | ||
const badAuthInfo = makeAuthInfo('accessKey2'); | ||
return bucketGetTagging(badAuthInfo, testBucketGetTaggingRequest, log, | ||
err => { | ||
assert.strictEqual(err.AccessDenied, true); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
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,53 @@ | ||
const assert = require('assert'); | ||
|
||
const { bucketPut } = require('../../../lib/api/bucketPut'); | ||
const { cleanup, | ||
DummyRequestLogger, | ||
makeAuthInfo, | ||
TaggingConfigTester, | ||
} = require('../helpers'); | ||
const bucketPutTagging = require('../../../lib/api/bucketPutTagging'); | ||
const log = new DummyRequestLogger(); | ||
const authInfo = makeAuthInfo('accessKey1'); | ||
const bucketName = 'bucketGetTaggingTest'; | ||
|
||
const testBucketPutRequest = { | ||
bucketName, | ||
headers: { host: `${bucketName}.s3.amazonaws.com` }, | ||
url: '/', | ||
actionImplicitDenies: false, | ||
}; | ||
|
||
describe('putBucketTagging API', () => { | ||
beforeEach(done => { | ||
cleanup(); | ||
bucketPut(authInfo, testBucketPutRequest, log, done); | ||
}); | ||
|
||
afterEach(() => cleanup()); | ||
|
||
it('should set tags resource', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
if (err) { | ||
process.stdout.write(`Err putting object tagging ${err}`); | ||
return done(err); | ||
} | ||
assert.strictEqual(err, undefined); | ||
return done(); | ||
}); | ||
}); | ||
|
||
it('should return access denied if the authorization check fails', done => { | ||
const taggingUtil = new TaggingConfigTester(); | ||
const testBucketPutTaggingRequest = taggingUtil | ||
.createBucketTaggingRequest('PUT', bucketName); | ||
const authInfo = makeAuthInfo('accessKey2'); | ||
bucketPutTagging(authInfo, testBucketPutTaggingRequest, log, err => { | ||
assert(err.AccessDenied); | ||
return done(); | ||
}); | ||
}); | ||
}); |
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