Skip to content

Commit 111ecf8

Browse files
author
Will Toozs
committed
CLDSRV-431: updatye other API impDeny test logic
1 parent 15ddc02 commit 111ecf8

16 files changed

Lines changed: 131 additions & 51 deletions

tests/multipleBackend/multipartUpload.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const bucketPutRequest = {
5454
url: '/',
5555
post: '',
5656
parsedHost: 'localhost',
57+
iamAuthzResults: false,
5758
};
5859

5960
const awsETag = 'be747eb4b75517bf6b3cf7c5fbb62f3a';
@@ -73,6 +74,7 @@ const completeBody = '<CompleteMultipartUpload>' +
7374
const basicParams = {
7475
bucketName,
7576
namespace,
77+
iamAuthzResults: false,
7678
};
7779

7880
function getObjectGetRequest(objectKey) {
@@ -270,6 +272,7 @@ function mpuSetup(location, key, cb) {
270272
'x-amz-meta-scal-location-constraint': location },
271273
url: `/${key}?uploads`,
272274
parsedHost: 'localhost',
275+
iamAuthzResults: false,
273276
};
274277
initiateMultipartUpload(authInfo, initiateRequest, log,
275278
(err, result) => {
@@ -342,6 +345,7 @@ describe.skip('Multipart Upload API with AWS Backend', function mpuTestSuite() {
342345
'x-amz-meta-scal-location-constraint': `${awsLocation}` },
343346
url: `/${objectKey}?uploads`,
344347
parsedHost: 'localhost',
348+
iamAuthzResults: false,
345349
};
346350

347351
initiateMultipartUpload(authInfo, initiateRequest, log,
@@ -365,6 +369,7 @@ describe.skip('Multipart Upload API with AWS Backend', function mpuTestSuite() {
365369
`${awsLocationMismatch}` },
366370
url: `/${objectKey}?uploads`,
367371
parsedHost: 'localhost',
372+
iamAuthzResults: false,
368373
};
369374

370375
initiateMultipartUpload(authInfo, initiateRequest, log,
@@ -389,6 +394,7 @@ describe.skip('Multipart Upload API with AWS Backend', function mpuTestSuite() {
389394
},
390395
url: `/${objectKey}?uploads`,
391396
parsedHost: 'localhost',
397+
iamAuthzResults: false,
392398
};
393399

394400
initiateMultipartUpload(authInfo, initiateRequest, log,
@@ -612,6 +618,7 @@ describe.skip('Multipart Upload API with AWS Backend', function mpuTestSuite() {
612618
'x-amz-meta-scal-location-constraint': awsLocation },
613619
url: `/${objectKey}?uploads`,
614620
parsedHost: 'localhost',
621+
iamAuthzResults: false,
615622
};
616623
initiateMultipartUpload(authInfo, initiateRequest, log,
617624
err => {
@@ -712,6 +719,7 @@ describe.skip('Multipart Upload API with AWS Backend', function mpuTestSuite() {
712719
headers: { host: '/' },
713720
url: `/${bucketName}?uploads`,
714721
query: {},
722+
iamAuthzResults: false,
715723
};
716724
listMultipartUploads(authInfo, listMpuParams, log,
717725
(err, mpuListXml) => {

tests/unit/api/bucketACLauth.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe.skip('bucket authorization for bucketGet, bucketHead, ' +
107107
}
108108
bucket.setCannedAcl(value.canned);
109109
const results = requestTypes.map(type =>
110-
isBucketAuthorized(bucket, type, value.id, value.auth, log));
110+
isBucketAuthorized(bucket, type, value.id, value.auth, false, log));
111111
assert.deepStrictEqual(results, value.response);
112112
done();
113113
});
@@ -129,13 +129,13 @@ describe('bucket authorization for bucketGetACL', () => {
129129

130130
it('should allow access to bucket owner', () => {
131131
const result = isBucketAuthorized(bucket, 'bucketGetACL',
132-
ownerCanonicalId, authInfo);
132+
ownerCanonicalId, authInfo, false);
133133
assert.strictEqual(result, true);
134134
});
135135

136136
it('should allow access to user in bucket owner account', () => {
137137
const result = isBucketAuthorized(bucket, 'bucketGetACL',
138-
ownerCanonicalId, userAuthInfo);
138+
ownerCanonicalId, userAuthInfo, false);
139139
assert.strictEqual(result, true);
140140
});
141141

@@ -158,15 +158,15 @@ describe('bucket authorization for bucketGetACL', () => {
158158
orders.forEach(value => {
159159
it(`should allow access to ${value.it}`, done => {
160160
const noAuthResult = isBucketAuthorized(bucket, 'bucketGetACL',
161-
value.id);
161+
value.id, null, false);
162162
assert.strictEqual(noAuthResult, false);
163163
if (value.aclParam) {
164164
bucket.setSpecificAcl(value.aclParam[1], value.aclParam[0]);
165165
} else if (value.canned) {
166166
bucket.setCannedAcl(value.canned);
167167
}
168168
const authorizedResult = isBucketAuthorized(bucket, 'bucketGetACL',
169-
value.id, value.auth);
169+
value.id, value.auth, false);
170170
assert.strictEqual(authorizedResult, true);
171171
done();
172172
});
@@ -188,13 +188,13 @@ describe('bucket authorization for bucketPutACL', () => {
188188

189189
it('should allow access to bucket owner', () => {
190190
const result = isBucketAuthorized(bucket, 'bucketPutACL',
191-
ownerCanonicalId, authInfo);
191+
ownerCanonicalId, authInfo, false);
192192
assert.strictEqual(result, true);
193193
});
194194

195195
it('should allow access to user in bucket owner account', () => {
196196
const result = isBucketAuthorized(bucket, 'bucketPutACL',
197-
ownerCanonicalId, userAuthInfo);
197+
ownerCanonicalId, userAuthInfo, false);
198198
assert.strictEqual(result, true);
199199
});
200200

@@ -203,11 +203,11 @@ describe('bucket authorization for bucketPutACL', () => {
203203
it('should allow access to account if ' +
204204
`account was granted ${value} right`, done => {
205205
const noAuthResult = isBucketAuthorized(bucket, 'bucketPutACL',
206-
accountToVet, altAcctAuthInfo);
206+
accountToVet, altAcctAuthInfo, false);
207207
assert.strictEqual(noAuthResult, false);
208208
bucket.setSpecificAcl(accountToVet, value);
209209
const authorizedResult = isBucketAuthorized(bucket, 'bucketPutACL',
210-
accountToVet, altAcctAuthInfo);
210+
accountToVet, altAcctAuthInfo, false);
211211
assert.strictEqual(authorizedResult, true);
212212
done();
213213
});
@@ -229,13 +229,13 @@ describe('bucket authorization for bucketOwnerAction', () => {
229229

230230
it('should allow access to bucket owner', () => {
231231
const result = isBucketAuthorized(bucket, 'bucketDeleteCors',
232-
ownerCanonicalId, authInfo);
232+
ownerCanonicalId, authInfo, false);
233233
assert.strictEqual(result, true);
234234
});
235235

236236
it('should allow access to user in bucket owner account', () => {
237237
const result = isBucketAuthorized(bucket, 'bucketDeleteCors',
238-
ownerCanonicalId, userAuthInfo);
238+
ownerCanonicalId, userAuthInfo, false);
239239
assert.strictEqual(result, true);
240240
});
241241

@@ -257,7 +257,7 @@ describe('bucket authorization for bucketOwnerAction', () => {
257257
}
258258
bucket.setCannedAcl(value.canned);
259259
const result = isBucketAuthorized(bucket, 'bucketDeleteCors',
260-
value.id, value.auth);
260+
value.id, value.auth, false);
261261
assert.strictEqual(result, false);
262262
done();
263263
});
@@ -279,13 +279,13 @@ describe('bucket authorization for bucketDelete', () => {
279279

280280
it('should allow access to bucket owner', () => {
281281
const result = isBucketAuthorized(bucket, 'bucketDelete',
282-
ownerCanonicalId, authInfo);
282+
ownerCanonicalId, authInfo, false);
283283
assert.strictEqual(result, true);
284284
});
285285

286286
it('should allow access to user in bucket owner account', () => {
287287
const result = isBucketAuthorized(bucket, 'bucketDelete',
288-
ownerCanonicalId, userAuthInfo);
288+
ownerCanonicalId, userAuthInfo, false);
289289
assert.strictEqual(result, true);
290290
});
291291

@@ -306,7 +306,7 @@ describe('bucket authorization for bucketDelete', () => {
306306
bucket.setSpecificAcl(value.aclParam[1], value.aclParam[0]);
307307
}
308308
bucket.setCannedAcl(value.canned);
309-
const result = isBucketAuthorized(bucket, 'bucketDelete', value.id, value.auth);
309+
const result = isBucketAuthorized(bucket, 'bucketDelete', value.id, value.auth, false);
310310
assert.strictEqual(result, false);
311311
done();
312312
});
@@ -330,13 +330,13 @@ describe('bucket authorization for objectDelete and objectPut', () => {
330330

331331
it('should allow access to bucket owner', () => {
332332
const results = requestTypes.map(type =>
333-
isBucketAuthorized(bucket, type, ownerCanonicalId, authInfo));
333+
isBucketAuthorized(bucket, type, ownerCanonicalId, authInfo, false));
334334
assert.deepStrictEqual(results, [true, true]);
335335
});
336336

337337
it('should allow access to user in bucket owner account', () => {
338338
const results = requestTypes.map(type =>
339-
isBucketAuthorized(bucket, type, ownerCanonicalId, userAuthInfo));
339+
isBucketAuthorized(bucket, type, ownerCanonicalId, userAuthInfo, false));
340340
assert.deepStrictEqual(results, [true, true]);
341341
});
342342

@@ -361,13 +361,13 @@ describe('bucket authorization for objectDelete and objectPut', () => {
361361
it(`should allow access to ${value.it}`, done => {
362362
bucket.setCannedAcl(value.canned);
363363
const noAuthResults = requestTypes.map(type =>
364-
isBucketAuthorized(bucket, type, value.id, value.auth));
364+
isBucketAuthorized(bucket, type, value.id, value.auth, false));
365365
assert.deepStrictEqual(noAuthResults, value.response);
366366
if (value.aclParam) {
367367
bucket.setSpecificAcl(value.aclParam[1], value.aclParam[0]);
368368
}
369369
const authResults = requestTypes.map(type =>
370-
isBucketAuthorized(bucket, type, accountToVet, altAcctAuthInfo));
370+
isBucketAuthorized(bucket, type, accountToVet, altAcctAuthInfo, false));
371371
assert.deepStrictEqual(authResults, [true, true]);
372372
done();
373373
});
@@ -379,10 +379,10 @@ describe('bucket authorization for objectPutACL and objectGetACL', () => {
379379
'are done at object level', done => {
380380
const requestTypes = ['objectPutACL', 'objectGetACL'];
381381
const results = requestTypes.map(type =>
382-
isBucketAuthorized(bucket, type, accountToVet, altAcctAuthInfo));
382+
isBucketAuthorized(bucket, type, accountToVet, altAcctAuthInfo, false));
383383
assert.deepStrictEqual(results, [true, true]);
384384
const publicUserResults = requestTypes.map(type =>
385-
isBucketAuthorized(bucket, type, constants.publicId));
385+
isBucketAuthorized(bucket, type, constants.publicId, null, false));
386386
assert.deepStrictEqual(publicUserResults, [true, true]);
387387
done();
388388
});

tests/unit/api/bucketHead.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const testRequest = {
1414
namespace,
1515
headers: { host: `${bucketName}.s3.amazonaws.com` },
1616
url: '/',
17+
iamAuthzResults: false,
1718
};
1819
// TODO CLDSRV-431 remove skip
1920
describe.skip('bucketHead API', () => {

tests/unit/api/deleteMarker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ const testPutBucketRequest = new DummyRequest({
2828
namespace,
2929
headers: { host: `${bucketName}.s3.amazonaws.com` },
3030
url: '/',
31+
iamAuthzResults: false,
3132
});
3233
const testDeleteRequest = new DummyRequest({
3334
bucketName,
3435
namespace,
3536
objectKey: objectName,
3637
headers: {},
3738
url: `/${bucketName}/${objectName}`,
39+
iamAuthzResults: false,
3840
});
3941

4042
function _createBucketPutVersioningReq(status) {
@@ -45,6 +47,7 @@ function _createBucketPutVersioningReq(status) {
4547
},
4648
url: '/?versioning',
4749
query: { versioning: '' },
50+
iamAuthzResults: false,
4851
};
4952
const xml = '<VersioningConfiguration ' +
5053
'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' +
@@ -62,6 +65,7 @@ function _createMultiObjectDeleteRequest(numObjects) {
6265
},
6366
url: '/?delete',
6467
query: { delete: '' },
68+
iamAuthzResults: false,
6569
};
6670
const xml = [];
6771
xml.push('<?xml version="1.0" encoding="UTF-8"?>');

tests/unit/api/deletedFlagBucket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ const baseTestRequest = {
5858
post: '',
5959
headers: { host: `${bucketName}.s3.amazonaws.com` },
6060
query: {},
61+
iamAuthzResults: false,
6162
};
6263
const serviceGetRequest = {
6364
parsedHost: 's3.amazonaws.com',
6465
headers: { host: 's3.amazonaws.com' },
6566
url: '/',
67+
iamAuthzResults: false,
6668
};
6769

6870
const userBucketOwner = 'admin';

tests/unit/api/listMultipartUploads.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,31 @@ describe.skip('listMultipartUploads API', () => {
3232
namespace,
3333
headers: {},
3434
url: `/${bucketName}`,
35+
iamAuthzResults: false,
3536
};
3637
const testInitiateMPURequest1 = {
3738
bucketName,
3839
namespace,
3940
objectKey: objectName1,
4041
headers: {},
4142
url: `/${bucketName}/${objectName1}?uploads`,
43+
iamAuthzResults: false,
4244
};
4345
const testInitiateMPURequest2 = {
4446
bucketName,
4547
namespace,
4648
objectKey: objectName2,
4749
headers: {},
4850
url: `/${bucketName}/${objectName2}?uploads`,
51+
iamAuthzResults: false,
4952
};
5053
const testInitiateMPURequest3 = {
5154
bucketName,
5255
namespace,
5356
objectKey: objectName3,
5457
headers: {},
5558
url: `/${bucketName}/${objectName3}?uploads`,
59+
iamAuthzResults: false,
5660
};
5761

5862
it('should return the name of the common prefix ' +
@@ -65,6 +69,7 @@ describe.skip('listMultipartUploads API', () => {
6569
headers: { host: '/' },
6670
url: `/${bucketName}?uploads&delimiter=/&prefix=sub`,
6771
query: { delimiter, prefix },
72+
iamAuthzResults: false,
6873
};
6974

7075
async.waterfall([
@@ -94,6 +99,7 @@ describe.skip('listMultipartUploads API', () => {
9499
headers: { host: '/' },
95100
url: `/${bucketName}?uploads`,
96101
query: {},
102+
iamAuthzResults: false,
97103
};
98104

99105

@@ -127,6 +133,7 @@ describe.skip('listMultipartUploads API', () => {
127133
headers: { host: '/' },
128134
url: `/${bucketName}?uploads`,
129135
query: { 'max-uploads': '1' },
136+
iamAuthzResults: false,
130137
};
131138

132139
async.waterfall([
@@ -163,6 +170,7 @@ describe.skip('listMultipartUploads API', () => {
163170
headers: { host: '/' },
164171
url: `/${bucketName}?uploads`,
165172
query: { 'encoding-type': 'url' },
173+
iamAuthzResults: false,
166174
};
167175

168176
async.waterfall([
@@ -195,6 +203,7 @@ describe.skip('listMultipartUploads API', () => {
195203
headers: { host: '/' },
196204
url: `/${bucketName}?uploads`,
197205
query: { 'key-marker': objectName1 },
206+
iamAuthzResults: false,
198207
};
199208

200209
async.waterfall([

0 commit comments

Comments
 (0)