Skip to content

Commit d5d17ec

Browse files
committed
fix: cleanup IAM policy payloads, refactor file upload options, and migrate deprecated ACL system tests to the testbench approach.
1 parent 4b3168f commit d5d17ec

5 files changed

Lines changed: 414 additions & 372 deletions

File tree

handwritten/storage/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@types/mime": "3.0.0",
9494
"@types/mocha": "^10.0.10",
9595
"@types/mockery": "^1.4.33",
96-
"@types/node": "^24.0.0",
96+
"@types/node": "^24.13.3",
9797
"@types/node-fetch": "^2.6.12",
9898
"@types/proxyquire": "^1.3.31",
9999
"@types/sinon": "^17.0.4",
@@ -117,4 +117,4 @@
117117
"yargs": "^17.7.2"
118118
},
119119
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/storage"
120-
}
120+
}

handwritten/storage/src/file.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,9 +4548,10 @@ class File extends ServiceObject<File, FileMetadata> {
45484548
*/
45494549
startSimpleUpload_(
45504550
dup: Duplexify,
4551-
options: CreateWriteStreamOptionsInternal = {},
4551+
options: CreateWriteStreamOptions = {},
45524552
): void {
4553-
options.metadata ??= {};
4553+
const opts = options as CreateWriteStreamOptionsInternal;
4554+
opts.metadata ??= {};
45544555

45554556
const apiEndpoint = this.storage.apiEndpoint;
45564557
const bucketName = this.bucket.name;
@@ -4562,7 +4563,7 @@ class File extends ServiceObject<File, FileMetadata> {
45624563
uploadType: 'multipart',
45634564
},
45644565
url,
4565-
invocationId: options.invocationId,
4566+
invocationId: opts.invocationId,
45664567
[GCCL_GCS_CMD_KEY]: options[GCCL_GCS_CMD_KEY],
45674568
method: 'POST',
45684569
responseType: 'json',
@@ -4606,12 +4607,12 @@ class File extends ServiceObject<File, FileMetadata> {
46064607
reqOpts.multipart = [
46074608
{
46084609
headers: new Headers({'Content-Type': 'application/json'}),
4609-
content: JSON.stringify(options.metadata),
4610+
content: JSON.stringify(opts.metadata),
46104611
},
46114612
{
46124613
headers: new Headers({
46134614
'Content-Type':
4614-
options.metadata.contentType || 'application/octet-stream',
4615+
opts.metadata?.contentType || 'application/octet-stream',
46154616
}),
46164617
content: writeStream,
46174618
},

handwritten/storage/src/iam.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,12 @@ class Iam {
350350
SetPolicyCallback
351351
>(optionsOrCallback, callback);
352352

353+
const policyToSet = {...policy};
354+
delete (policyToSet as any).headers;
355+
delete (policyToSet as any).status;
356+
353357
let maxRetries;
354-
if (policy.etag === undefined) {
358+
if (policyToSet.etag === undefined) {
355359
maxRetries = 0;
356360
}
357361

@@ -361,7 +365,7 @@ class Iam {
361365
method: 'PUT',
362366
url: `/storage/v1/b/${this.bucket.name}/iam`,
363367
maxRetries,
364-
body: JSON.stringify(policy),
368+
body: JSON.stringify(policyToSet),
365369
headers: {'Content-Type': 'application/json'},
366370
queryParameters: options as unknown as StorageQueryParameters,
367371
},

handwritten/storage/system-test/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('pack-n-play tests', () => {
2121
await packNTest({
2222
sample: {
2323
description: 'Should be able to import the storage library in ESM',
24-
cjs: readFileSync('./system-test/fixtures/index-esm.js').toString(),
24+
ts: readFileSync('./system-test/fixtures/index-esm.js').toString(),
2525
},
2626
});
2727
});

0 commit comments

Comments
 (0)