From b30add8c70dcf6239c137a38eb764513ce1e1f29 Mon Sep 17 00:00:00 2001 From: AlexCheema <41707476+AlexCheema@users.noreply.github.com> Date: Thu, 6 Feb 2020 14:31:34 +0100 Subject: [PATCH] fix(s3-deployment): passing any system metadata causes lambda to fail on "Unknown options:" when invoking aws cli. (#6086) * fix(aws-s3-deployment): fix passing system metadata to deployment * fix(s3-deployment): fix custom metadata, tests for checking individual elements in aws commands * fix(s3-metadata): test custom types, update expected cloudformation templates * test(s3-deployment): clarify object metadata and user metadata tests * test(s3-deployment): missing semicolons * test(s3-deployment): consistent test for Expires.after * Apply suggestions from code review fix(s3-deployment): remove unnecessary fstring Co-Authored-By: Eli Polonsky * fix(s3-deployment): rerun integration tests Co-authored-by: Elad Ben-Israel Co-authored-by: Eli Polonsky Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- packages/@aws-cdk/aws-s3-deployment/README.md | 2 +- .../aws-s3-deployment/lambda/src/index.py | 5 +- .../aws-s3-deployment/lambda/test/aws | 2 +- .../aws-s3-deployment/lambda/test/test.py | 58 ++++----- ...bucket-deployment-cloudfront.expected.json | 18 +-- .../integ.bucket-deployment.expected.json | 122 ++++++++++++++++-- .../test/integ.bucket-deployment.ts | 11 ++ .../test/test.bucket-deployment.ts | 47 ++++++- 8 files changed, 210 insertions(+), 55 deletions(-) diff --git a/packages/@aws-cdk/aws-s3-deployment/README.md b/packages/@aws-cdk/aws-s3-deployment/README.md index aaa698bf42fb5..0bb95c52fc333 100644 --- a/packages/@aws-cdk/aws-s3-deployment/README.md +++ b/packages/@aws-cdk/aws-s3-deployment/README.md @@ -96,7 +96,7 @@ new s3deploy.BucketDeployment(this, 'DeployWebsite', { sources: [s3deploy.Source.asset('./website-dist')], destinationBucket: websiteBucket, destinationKeyPrefix: 'web/static', // optional prefix in destination bucket - userMetadata: { "A": "1", "b": "2" }, // user-defined metadata + metadata: { A: "1", b: "2" }, // user-defined metadata // system-defined metadata contentType: "text/html", diff --git a/packages/@aws-cdk/aws-s3-deployment/lambda/src/index.py b/packages/@aws-cdk/aws-s3-deployment/lambda/src/index.py index 140be5452e0c1..4daff5f3bce5d 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lambda/src/index.py +++ b/packages/@aws-cdk/aws-s3-deployment/lambda/src/index.py @@ -163,8 +163,9 @@ def create_metadata_args(raw_user_metadata, raw_system_metadata): system_metadata = { format_system_metadata_key(k): v for k, v in raw_system_metadata.items() } user_metadata = { format_user_metadata_key(k): v for k, v in raw_user_metadata.items() } - system_args = [f"--{k} '{v}'" for k, v in system_metadata.items()] - user_args = ["--metadata", f"'{json.dumps(user_metadata)}'"] if len(user_metadata) > 0 else [] + flatten = lambda l: [item for sublist in l for item in sublist] + system_args = flatten([[f"--{k}", v] for k, v in system_metadata.items()]) + user_args = ["--metadata", json.dumps(user_metadata, separators=(',', ':'))] if len(user_metadata) > 0 else [] return system_args + user_args + ["--metadata-directive", "REPLACE"] diff --git a/packages/@aws-cdk/aws-s3-deployment/lambda/test/aws b/packages/@aws-cdk/aws-s3-deployment/lambda/test/aws index fe6ec780abc7c..1796d021f650b 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lambda/test/aws +++ b/packages/@aws-cdk/aws-s3-deployment/lambda/test/aws @@ -24,4 +24,4 @@ if sys.argv[2] == "sync": sys.argv[4] = "contents.zip" with open("./aws.out", "a") as myfile: - myfile.write(" ".join(sys.argv[1:]) + "\n") + myfile.write(json.dumps(sys.argv[1:]) + "\n") diff --git a/packages/@aws-cdk/aws-s3-deployment/lambda/test/test.py b/packages/@aws-cdk/aws-s3-deployment/lambda/test/test.py index 63231fbd8d0cc..30ac3ba26ada7 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lambda/test/test.py +++ b/packages/@aws-cdk/aws-s3-deployment/lambda/test/test.py @@ -33,8 +33,8 @@ def test_create_update(self): }) self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_create_update_multiple_sources(self): @@ -47,9 +47,9 @@ def test_create_update_multiple_sources(self): # Note: these are different files in real-life. For testing purposes, we hijack # the command to output a static filename, archive.zip self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_create_with_backslash_prefix_same_as_no_prefix(self): @@ -61,8 +61,8 @@ def test_create_with_backslash_prefix_same_as_no_prefix(self): }) self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) @@ -75,8 +75,8 @@ def test_create_update_with_dest_key(self): }) self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_create_update_with_metadata(self): @@ -90,8 +90,8 @@ def test_create_update_with_metadata(self): }) self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:/// --content-type 'text/html' --content-language 'en' --metadata '{\"x-amzn-meta-best\": \"game\"}' --metadata-directive REPLACE" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///", "--content-type", "text/html", "--content-language", "en", "--metadata", "{\"x-amzn-meta-best\":\"game\"}", "--metadata-directive", "REPLACE"] ) def test_delete_no_retain(self): @@ -102,7 +102,7 @@ def test_delete_no_retain(self): "RetainOnDelete": "false" }, physical_id="") - self.assertAwsCommands("s3 rm s3:/// --recursive") + self.assertAwsCommands(["s3", "rm", "s3:///", "--recursive"]) def test_delete_with_dest_key(self): invoke_handler("Delete", { @@ -113,7 +113,7 @@ def test_delete_with_dest_key(self): "RetainOnDelete": "false" }, physical_id="") - self.assertAwsCommands("s3 rm s3:/// --recursive") + self.assertAwsCommands(["s3", "rm", "s3:///", "--recursive"]) def test_delete_with_retain_explicit(self): invoke_handler("Delete", { @@ -146,7 +146,7 @@ def test_delete_with_retain_explicitly_false(self): }, physical_id="") self.assertAwsCommands( - "s3 rm s3:/// --recursive" + ["s3", "rm", "s3:///", "--recursive"] ) # @@ -163,8 +163,8 @@ def test_update_same_dest(self): }, physical_id="") self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_update_same_dest_cf_invalidate(self): @@ -244,8 +244,8 @@ def test_update_new_dest_retain(self): }, physical_id="") self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_update_new_dest_no_retain(self): @@ -261,9 +261,9 @@ def test_update_new_dest_no_retain(self): }, physical_id="") self.assertAwsCommands( - "s3 rm s3:/// --recursive", - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "rm", "s3:///", "--recursive"], + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_update_new_dest_retain_implicit(self): @@ -277,8 +277,8 @@ def test_update_new_dest_retain_implicit(self): }, physical_id="") self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_update_new_dest_prefix_no_retain(self): @@ -294,9 +294,9 @@ def test_update_new_dest_prefix_no_retain(self): }, physical_id="") self.assertAwsCommands( - "s3 rm s3:/// --recursive", - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "rm", "s3:///", "--recursive"], + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) def test_update_new_dest_prefix_retain_implicit(self): @@ -310,8 +310,8 @@ def test_update_new_dest_prefix_retain_implicit(self): }, physical_id="") self.assertAwsCommands( - "s3 cp s3:/// archive.zip", - "s3 sync --delete contents.zip s3:///" + ["s3", "cp", "s3:///", "archive.zip"], + ["s3", "sync", "--delete", "contents.zip", "s3:///"] ) # @@ -386,7 +386,7 @@ def read_aws_out(): return [] with open("aws.out") as f: - return f.read().splitlines() + return [json.loads(l) for l in f.read().splitlines()] # # invokes the handler under test diff --git a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json index d930d5c249986..cd76f93ae2e36 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json +++ b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json @@ -248,7 +248,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3Bucket1FAE0333" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31" }, "S3Key": { "Fn::Join": [ @@ -261,7 +261,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96" } ] } @@ -274,7 +274,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96" } ] } @@ -301,17 +301,17 @@ } }, "Parameters": { - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3Bucket1FAE0333": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31": { "Type": "String", - "Description": "S3 bucket for asset \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "S3 bucket for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96": { "Type": "String", - "Description": "S3 key for asset version \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "S3 key for asset version \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412ArtifactHashA605283F": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffArtifactHash08605F5E": { "Type": "String", - "Description": "Artifact hash for asset \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "Artifact hash for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3Bucket9CD8B20A": { "Type": "String", diff --git a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json index e23193ac884b1..628b948fbd440 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json +++ b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json @@ -241,6 +241,39 @@ ] } ] + }, + { + "Action": [ + "s3:GetObject*", + "s3:GetBucket*", + "s3:List*", + "s3:DeleteObject*", + "s3:PutObject*", + "s3:Abort*" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::GetAtt": [ + "Destination3E3DC043D", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "Destination3E3DC043D", + "Arn" + ] + }, + "/*" + ] + ] + } + ] } ], "Version": "2012-10-17" @@ -258,7 +291,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3Bucket1FAE0333" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31" }, "S3Key": { "Fn::Join": [ @@ -271,7 +304,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96" } ] } @@ -284,7 +317,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3" + "Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96" } ] } @@ -371,20 +404,91 @@ }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" + }, + "Destination3E3DC043D": { + "Type": "AWS::S3::Bucket", + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "DeployWithMetadataCustomResourceA73C95DC": { + "Type": "Custom::CDKBucketDeployment", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536", + "Arn" + ] + }, + "SourceBucketNames": [ + { + "Ref": "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3Bucket9CD8B20A" + } + ], + "SourceObjectKeys": [ + { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3VersionKeyA58D380C" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3VersionKeyA58D380C" + } + ] + } + ] + } + ] + ] + } + ], + "DestinationBucketName": { + "Ref": "Destination3E3DC043D" + }, + "RetainOnDelete": false, + "UserMetadata": { + "x-amzn-meta-a": "aaa", + "x-amzn-meta-b": "bbb", + "x-amzn-meta-c": "ccc" + }, + "SystemMetadata": { + "cache-control": "public, max-age=60", + "content-type": "text/html" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" } }, "Parameters": { - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3Bucket1FAE0333": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31": { "Type": "String", - "Description": "S3 bucket for asset \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "S3 bucket for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412S3VersionKeyE18B22C3": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96": { "Type": "String", - "Description": "S3 key for asset version \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "S3 key for asset version \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, - "AssetParameters53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412ArtifactHashA605283F": { + "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffArtifactHash08605F5E": { "Type": "String", - "Description": "Artifact hash for asset \"53a43f436014c307dccbd4ca1172459431a2a8dee8a2c318ee65991c2a8d4412\"" + "Description": "Artifact hash for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\"" }, "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3Bucket9CD8B20A": { "Type": "String", diff --git a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.ts b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.ts index 1b2f01ade9b5e..1a07c8c8d67bf 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.ts +++ b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.ts @@ -27,6 +27,17 @@ class TestBucketDeployment extends cdk.Stack { destinationKeyPrefix: 'deploy/here/', retainOnDelete: false, // default is true, which will block the integration test cleanup }); + + const bucket3 = new s3.Bucket(this, 'Destination3'); + + new s3deploy.BucketDeployment(this, 'DeployWithMetadata', { + sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))], + destinationBucket: bucket3, + retainOnDelete: false, // default is true, which will block the integration test cleanup + cacheControl: [s3deploy.CacheControl.setPublic(), s3deploy.CacheControl.maxAge(cdk.Duration.minutes(1))], + contentType: 'text/html', + metadata: { A: 'aaa', B: 'bbb', C: 'ccc' } + }); } } diff --git a/packages/@aws-cdk/aws-s3-deployment/test/test.bucket-deployment.ts b/packages/@aws-cdk/aws-s3-deployment/test/test.bucket-deployment.ts index db5ef5b5024ea..47753923a84dd 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/test.bucket-deployment.ts +++ b/packages/@aws-cdk/aws-s3-deployment/test/test.bucket-deployment.ts @@ -218,6 +218,7 @@ export = { retainOnDelete: true, }); + // THEN expect(stack).to(haveResource('Custom::CDKBucketDeployment', { RetainOnDelete: true })); @@ -225,7 +226,7 @@ export = { test.done(); }, - 'object metadata can be given'(test: Test) { + 'user metadata is correctly transformed'(test: Test) { // GIVEN const stack = new cdk.Stack(); const bucket = new s3.Bucket(stack, 'Dest'); @@ -234,12 +235,15 @@ export = { new s3deploy.BucketDeployment(stack, 'Deploy', { sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website.zip'))], destinationBucket: bucket, - metadata: { "A": "1", "b": "2" }, + metadata: { + A: '1', + B: '2' + } }); // THEN expect(stack).to(haveResource('Custom::CDKBucketDeployment', { - UserMetadata: { 'x-amzn-meta-a': '1', 'x-amzn-meta-b': '2' } + UserMetadata: { 'x-amzn-meta-a': '1', 'x-amzn-meta-b': '2' }, })); test.done(); @@ -263,7 +267,7 @@ export = { serverSideEncryptionCustomerAlgorithm: "rot13", websiteRedirectLocation: "example", cacheControl: [s3deploy.CacheControl.setPublic(), s3deploy.CacheControl.maxAge(cdk.Duration.hours(1))], - expires: s3deploy.Expires.after(cdk.Duration.hours(12)), + expires: s3deploy.Expires.after(cdk.Duration.hours(12)) }); // THEN @@ -285,6 +289,41 @@ export = { test.done(); }, + 'expires type has correct values'(test: Test) { + test.equal(s3deploy.Expires.atDate(new Date('Sun, 26 Jan 2020 00:53:20 GMT')).value, 'Sun, 26 Jan 2020 00:53:20 GMT'); + test.equal(s3deploy.Expires.atTimestamp(1580000000000).value, 'Sun, 26 Jan 2020 00:53:20 GMT'); + test.ok(Math.abs(new Date(s3deploy.Expires.after(cdk.Duration.minutes(10)).value).getTime() - (Date.now() + 600000)) < 15000, "Expires.after accurate to within 15 seconds"); + test.equal(s3deploy.Expires.fromString('Tue, 04 Feb 2020 08:45:33 GMT').value, 'Tue, 04 Feb 2020 08:45:33 GMT'); + + test.done(); + }, + + 'cache control type has correct values'(test: Test) { + test.equal(s3deploy.CacheControl.mustRevalidate().value, 'must-revalidate'); + test.equal(s3deploy.CacheControl.noCache().value, 'no-cache'); + test.equal(s3deploy.CacheControl.noTransform().value, 'no-transform'); + test.equal(s3deploy.CacheControl.setPublic().value, 'public'); + test.equal(s3deploy.CacheControl.setPrivate().value, 'private'); + test.equal(s3deploy.CacheControl.proxyRevalidate().value, 'proxy-revalidate'); + test.equal(s3deploy.CacheControl.maxAge(cdk.Duration.minutes(1)).value, 'max-age=60'); + test.equal(s3deploy.CacheControl.sMaxAge(cdk.Duration.minutes(1)).value, 's-max-age=60'); + test.equal(s3deploy.CacheControl.fromString('only-if-cached').value, 'only-if-cached'); + + test.done(); + }, + + 'storage class type has correct values'(test: Test) { + test.equal(s3deploy.StorageClass.STANDARD, 'STANDARD'); + test.equal(s3deploy.StorageClass.REDUCED_REDUNDANCY, 'REDUCED_REDUNDANCY'); + test.equal(s3deploy.StorageClass.STANDARD_IA, 'STANDARD_IA'); + test.equal(s3deploy.StorageClass.ONEZONE_IA, 'ONEZONE_IA'); + test.equal(s3deploy.StorageClass.INTELLIGENT_TIERING, 'INTELLIGENT_TIERING'); + test.equal(s3deploy.StorageClass.GLACIER, 'GLACIER'); + test.equal(s3deploy.StorageClass.DEEP_ARCHIVE, 'DEEP_ARCHIVE'); + + test.done(); + }, + 'server side encryption type has correct values'(test: Test) { test.equal(s3deploy.ServerSideEncryption.AES_256, 'AES256'); test.equal(s3deploy.ServerSideEncryption.AWS_KMS, 'aws:kms');