From c958a7d442243a60350eaa1935369020a6a099b4 Mon Sep 17 00:00:00 2001 From: Ian Botsford <83236726+ianbotsf@users.noreply.github.com> Date: Fri, 11 Aug 2023 21:07:15 +0000 Subject: [PATCH] misc: add integration test for empty S3 object --- services/s3/e2eTest/src/S3IntegrationTest.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/services/s3/e2eTest/src/S3IntegrationTest.kt b/services/s3/e2eTest/src/S3IntegrationTest.kt index 051cc54f9cd..7e28e18b5fd 100644 --- a/services/s3/e2eTest/src/S3IntegrationTest.kt +++ b/services/s3/e2eTest/src/S3IntegrationTest.kt @@ -110,6 +110,25 @@ class S3BucketOpsIntegrationTest { assertEquals(contents, roundTrippedContents) } + @Test + fun testGetEmptyObject(): Unit = runBlocking { + // See https://github.com/awslabs/aws-sdk-kotlin/issues/1014 + val keyName = "get-empty-obj.txt" + + client.putObject { + bucket = testBucket + key = keyName + body = ByteStream.fromBytes(byteArrayOf()) + } + + val req = GetObjectRequest { + bucket = testBucket + key = keyName + } + val actualLength = client.getObject(req) { it.contentLength } + assertEquals(0, actualLength) + } + @Test fun testQueryParameterEncoding(): Unit = runBlocking { // see: https://github.com/awslabs/aws-sdk-kotlin/issues/448