Skip to content

Commit 850c62d

Browse files
committed
refactor: simplify system tests by removing uniform bucket-level access checks and switching to arrow functions
1 parent 04dc40f commit 850c62d

1 file changed

Lines changed: 21 additions & 128 deletions

File tree

handwritten/storage/system-test/storage.ts

Lines changed: 21 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,12 @@ describe('storage', function () {
238238
);
239239
});
240240

241-
it('should get access controls', async function () {
242-
const [metadata] = await bucket.getMetadata();
243-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
244-
this.skip();
245-
}
246-
241+
it('should get access controls', async () => {
247242
const accessControls = await bucket.acl.get();
248243
assert(Array.isArray(accessControls));
249244
});
250245

251-
it('should add entity to default access controls', async function () {
252-
const [metadata] = await bucket.getMetadata();
253-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
254-
this.skip();
255-
}
256-
246+
it('should add entity to default access controls', async () => {
257247
const [accessControl] = await bucket.acl.default.add({
258248
entity: USER_ACCOUNT,
259249
role: storage.acl.OWNER_ROLE,
@@ -268,22 +258,12 @@ describe('storage', function () {
268258
await bucket.acl.default.delete({entity: USER_ACCOUNT});
269259
});
270260

271-
it('should get default access controls', async function () {
272-
const [metadata] = await bucket.getMetadata();
273-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
274-
this.skip();
275-
}
276-
261+
it('should get default access controls', async () => {
277262
const accessControls = await bucket.acl.default.get();
278263
assert(Array.isArray(accessControls));
279264
});
280265

281-
it('should grant an account access', async function () {
282-
const [metadata] = await bucket.getMetadata();
283-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
284-
this.skip();
285-
}
286-
266+
it('should grant an account access', async () => {
287267
const [accessControl] = await bucket.acl.add({
288268
entity: USER_ACCOUNT,
289269
role: storage.acl.OWNER_ROLE,
@@ -298,12 +278,7 @@ describe('storage', function () {
298278
await bucket.acl.delete(opts);
299279
});
300280

301-
it('should update an account', async function () {
302-
const [metadata] = await bucket.getMetadata();
303-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
304-
this.skip();
305-
}
306-
281+
it('should update an account', async () => {
307282
const [accessControl] = await bucket.acl.add({
308283
entity: USER_ACCOUNT,
309284
role: storage.acl.OWNER_ROLE,
@@ -317,12 +292,7 @@ describe('storage', function () {
317292
await bucket.acl.delete({entity: USER_ACCOUNT});
318293
});
319294

320-
it('should make a bucket public', async function () {
321-
const [metadata] = await bucket.getMetadata();
322-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
323-
this.skip();
324-
}
325-
295+
it('should make a bucket public', async () => {
326296
await bucket.makePublic();
327297
const [aclObject] = await bucket.acl.get({entity: 'allUsers'});
328298
assert.deepStrictEqual(aclObject, {
@@ -335,12 +305,7 @@ describe('storage', function () {
335305
await bucket.acl.delete({entity: 'allUsers'});
336306
});
337307

338-
it('should make files public', async function () {
339-
const [metadata] = await bucket.getMetadata();
340-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
341-
this.skip();
342-
}
343-
308+
it('should make files public', async () => {
344309
await Promise.all(
345310
['a', 'b', 'c'].map(text => createFileWithContentPromise(text)),
346311
);
@@ -357,12 +322,7 @@ describe('storage', function () {
357322
]);
358323
});
359324

360-
it('should make a bucket private', async function () {
361-
const [metadata] = await bucket.getMetadata();
362-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
363-
this.skip();
364-
}
365-
325+
it('should make a bucket private', async () => {
366326
try {
367327
await bucket.makePublic();
368328
await new Promise(resolve =>
@@ -378,12 +338,7 @@ describe('storage', function () {
378338
}
379339
});
380340

381-
it('should make files private', async function () {
382-
const [metadata] = await bucket.getMetadata();
383-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
384-
this.skip();
385-
}
386-
341+
it('should make files private', async () => {
387342
await Promise.all(
388343
['a', 'b', 'c'].map(text => createFileWithContentPromise(text)),
389344
);
@@ -414,12 +369,7 @@ describe('storage', function () {
414369
await file.delete();
415370
});
416371

417-
it('should get access controls', async function () {
418-
const [metadata] = await bucket.getMetadata();
419-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
420-
this.skip();
421-
}
422-
372+
it('should get access controls', async () => {
423373
const [accessControls] = await file.acl.get();
424374
assert(Array.isArray(accessControls));
425375
});
@@ -429,12 +379,7 @@ describe('storage', function () {
429379
assert.strictEqual(typeof (file as any).default, 'undefined');
430380
});
431381

432-
it('should grant an account access', async function () {
433-
const [metadata] = await bucket.getMetadata();
434-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
435-
this.skip();
436-
}
437-
382+
it('should grant an account access', async () => {
438383
const [accessControl] = await file.acl.add({
439384
entity: USER_ACCOUNT,
440385
role: storage.acl.OWNER_ROLE,
@@ -448,12 +393,7 @@ describe('storage', function () {
448393
await file.acl.delete({entity: USER_ACCOUNT});
449394
});
450395

451-
it('should update an account', async function () {
452-
const [metadata] = await bucket.getMetadata();
453-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
454-
this.skip();
455-
}
456-
396+
it('should update an account', async () => {
457397
const [accessControl] = await file.acl.add({
458398
entity: USER_ACCOUNT,
459399
role: storage.acl.OWNER_ROLE,
@@ -467,12 +407,7 @@ describe('storage', function () {
467407
await file.acl.delete({entity: USER_ACCOUNT});
468408
});
469409

470-
it('should make a file public', async function () {
471-
const [metadata] = await bucket.getMetadata();
472-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
473-
this.skip();
474-
}
475-
410+
it('should make a file public', async () => {
476411
await file.makePublic();
477412
const [aclObject] = await file.acl.get({entity: 'allUsers'});
478413
assert.deepStrictEqual(aclObject, {
@@ -482,12 +417,7 @@ describe('storage', function () {
482417
await file.acl.delete({entity: 'allUsers'});
483418
});
484419

485-
it('should make a file private', async function () {
486-
const [metadata] = await bucket.getMetadata();
487-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
488-
this.skip();
489-
}
490-
420+
it('should make a file private', async () => {
491421
const validateMakeFilePrivateRejects = (err: any) => {
492422
assert.strictEqual(err.code, 404);
493423
assert.strictEqual(err.errors![0].reason, 'notFound');
@@ -525,12 +455,7 @@ describe('storage', function () {
525455
assert.strictEqual(encryptionAlgorithm, 'AES256');
526456
});
527457

528-
it('should make a file public during the upload', async function () {
529-
const [metadata] = await bucket.getMetadata();
530-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
531-
this.skip();
532-
}
533-
458+
it('should make a file public during the upload', async () => {
534459
const [file] = await bucket.upload(FILES.big.path, {
535460
resumable: false,
536461
public: true,
@@ -543,12 +468,7 @@ describe('storage', function () {
543468
});
544469
});
545470

546-
it('should make a file public from a resumable upload', async function () {
547-
const [metadata] = await bucket.getMetadata();
548-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
549-
this.skip();
550-
}
551-
471+
it('should make a file public from a resumable upload', async () => {
552472
const [file] = await bucket.upload(FILES.big.path, {
553473
resumable: true,
554474
public: true,
@@ -560,12 +480,7 @@ describe('storage', function () {
560480
});
561481
});
562482

563-
it('should make a file private from a resumable upload', async function () {
564-
const [metadata] = await bucket.getMetadata();
565-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
566-
this.skip();
567-
}
568-
483+
it('should make a file private from a resumable upload', async () => {
569484
const validateMakeFilePrivateRejects = (err: GaxiosError) => {
570485
assert.strictEqual((err as GaxiosError)!.status, 404);
571486
assert.strictEqual((err as GaxiosError).message, 'notFound');
@@ -628,12 +543,7 @@ describe('storage', function () {
628543
]);
629544
});
630545

631-
it('should set a policy', async function () {
632-
const [metadata] = await bucket.getMetadata();
633-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
634-
this.skip();
635-
}
636-
546+
it('should set a policy', async () => {
637547
const [policy] = await bucket.iam.getPolicy();
638548
policy!.bindings.push({
639549
role: 'roles/storage.legacyBucketReader',
@@ -1234,12 +1144,7 @@ describe('storage', function () {
12341144
describe('preserves bucket/file ACL over uniform bucket-level access on/off', () => {
12351145
beforeEach(createBucket);
12361146

1237-
it('should preserve default bucket ACL', async function () {
1238-
const [metadata] = await bucket.getMetadata();
1239-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
1240-
this.skip();
1241-
}
1242-
1147+
it('should preserve default bucket ACL', async () => {
12431148
await bucket.acl.default.update(customAcl);
12441149
const [aclBefore] = await bucket.acl.default.get();
12451150

@@ -1258,12 +1163,7 @@ describe('storage', function () {
12581163
}
12591164
}).timeout(UNIFORM_ACCESS_TIMEOUT);
12601165

1261-
it('should preserve file ACL', async function () {
1262-
const [metadata] = await bucket.getMetadata();
1263-
if (metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
1264-
this.skip();
1265-
}
1266-
1166+
it('should preserve file ACL', async () => {
12671167
const file = bucket.file(`file-${crypto.randomUUID()}`);
12681168
await file.save('data', {resumable: false});
12691169

@@ -3275,14 +3175,7 @@ describe('storage', function () {
32753175
await Promise.all([file.delete, copiedFile.delete()]);
32763176
});
32773177

3278-
it('should respect predefined Acl at file#copy', async function () {
3279-
const [metadata] = await bucket.getMetadata();
3280-
const ublaEnabled =
3281-
metadata.iamConfiguration?.uniformBucketLevelAccess?.enabled;
3282-
if (ublaEnabled) {
3283-
return this.skip();
3284-
}
3285-
3178+
it('should respect predefined Acl at file#copy', async () => {
32863179
const opts = {destination: 'CloudLogo'};
32873180
const [file] = await bucket.upload(FILES.logo.path, opts);
32883181
const copyOpts = {predefinedAcl: 'publicRead'};

0 commit comments

Comments
 (0)