From 463f0c5261998ece1c1216f8209564f04aafa901 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:53:32 -0700 Subject: [PATCH] updates based off feedback --- lib/aws.ts | 4 ++-- lib/private/handlers/files.ts | 2 +- test/files.test.ts | 21 +++++++-------------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/aws.ts b/lib/aws.ts index 24e0af2..b2ccadc 100644 --- a/lib/aws.ts +++ b/lib/aws.ts @@ -21,7 +21,7 @@ export interface IAws { s3Client(options: ClientOptions): Promise; ecrClient(options: ClientOptions): Promise; secretsManagerClient(options: ClientOptions): Promise; - upload(params: PutObjectCommandInput, options: ClientOptions): Promise + upload(params: PutObjectCommandInput, options?: ClientOptions): Promise; } export interface ClientOptions { @@ -82,7 +82,7 @@ export class DefaultAwsClient implements IAws { return new S3Client(await this.awsOptions(options)); } - public async upload(params: PutObjectCommandInput, options: ClientOptions): Promise { + public async upload(params: PutObjectCommandInput, options: ClientOptions = {}): Promise { try { const upload = new Upload({ client: await this.s3Client(options), diff --git a/lib/private/handlers/files.ts b/lib/private/handlers/files.ts index 3c168d8..78c1237 100644 --- a/lib/private/handlers/files.ts +++ b/lib/private/handlers/files.ts @@ -131,7 +131,7 @@ export class FileAssetHandler implements IAssetHandler { paramsEncryption ); - await this.host.aws.upload(params, {}); + await this.host.aws.upload(params); } private async packageFile(source: FileSource): Promise { diff --git a/test/files.test.ts b/test/files.test.ts index 17feed9..cf3b30c 100644 --- a/test/files.test.ts +++ b/test/files.test.ts @@ -177,8 +177,7 @@ test('upload with server side encryption AES256 header', async () => { Key: 'some_key', ContentType: 'application/octet-stream', ServerSideEncryption: 'AES256', - }), - {} + }) ); // We'll just have to assume the contents are correct @@ -211,8 +210,7 @@ test('upload with server side encryption aws:kms header and key id', async () => ContentType: 'application/octet-stream', ServerSideEncryption: 'aws:kms', SSEKMSKeyId: 'the-key-id', - }), - {} + }) ); // We'll just have to assume the contents are correct @@ -235,15 +233,13 @@ test('no server side encryption header if access denied for bucket encryption', expect(upload).toHaveBeenCalledWith( expect.not.objectContaining({ ServerSideEncryption: 'aws:kms', - }), - {} + }) ); expect(upload).toHaveBeenCalledWith( expect.not.objectContaining({ ServerSideEncryption: 'AES256', - }), - {} + }) ); }); @@ -260,8 +256,7 @@ test('correctly looks up content type', async () => { Bucket: 'some_bucket', Key: 'some_key.txt', ContentType: 'text/plain', - }), - {} + }) ); expect(upload).toHaveBeenCalledWith( @@ -269,8 +264,7 @@ test('correctly looks up content type', async () => { Bucket: 'some_bucket', Key: 'some_key.png', ContentType: 'image/png', - }), - {} + }) ); // We'll just have to assume the contents are correct @@ -287,8 +281,7 @@ test('upload file if new (list returns no key)', async () => { expect.objectContaining({ Bucket: 'some_bucket', Key: 'some_key', - }), - {} + }) ); // We'll just have to assume the contents are correct