-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor/fix S3 express integrations
- Loading branch information
Showing
3 changed files
with
126 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
services/s3/common/test/aws/sdk/kotlin/services/s3/express/ChecksumRemovalTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package aws.sdk.kotlin.services.s3.express | ||
|
||
import aws.smithy.kotlin.runtime.http.DeferredHeadersBuilder | ||
import aws.smithy.kotlin.runtime.http.HeadersBuilder | ||
import kotlin.test.Test | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertTrue | ||
|
||
class ChecksumRemovalTest { | ||
@Test | ||
fun removeChecksumHeaders() { | ||
val headers = HeadersBuilder() | ||
|
||
headers.append("x-amz-checksum-crc32", "foo") | ||
headers.append("x-amz-checksum-sha256", "bar") | ||
|
||
assertTrue( | ||
headers.contains("x-amz-checksum-crc32"), | ||
) | ||
assertTrue( | ||
headers.contains("x-amz-checksum-sha256"), | ||
) | ||
|
||
headers.removeChecksumHeaders() | ||
|
||
assertFalse( | ||
headers.contains("x-amz-checksum-crc32"), | ||
) | ||
assertFalse( | ||
headers.contains("x-amz-checksum-sha256"), | ||
) | ||
} | ||
|
||
@Test | ||
fun removeChecksumTrailingHeaders() { | ||
val trailingHeaders = DeferredHeadersBuilder() | ||
|
||
trailingHeaders.add("x-amz-checksum-crc32", "foo") | ||
trailingHeaders.add("x-amz-checksum-sha256", "bar") | ||
|
||
assertTrue( | ||
trailingHeaders.contains("x-amz-checksum-crc32"), | ||
) | ||
assertTrue( | ||
trailingHeaders.contains("x-amz-checksum-sha256"), | ||
) | ||
|
||
trailingHeaders.removeChecksumTrailingHeaders() | ||
|
||
assertFalse( | ||
trailingHeaders.contains("x-amz-checksum-crc32"), | ||
) | ||
assertFalse( | ||
trailingHeaders.contains("x-amz-checksum-sha256"), | ||
) | ||
} | ||
|
||
@Test | ||
fun removeChecksumTrailingHeadersFromXAmzTrailer() { | ||
val headers = HeadersBuilder() | ||
|
||
headers.append("x-amz-trailer", "x-amz-checksum-crc32") | ||
headers.append("x-amz-trailer", "x-amz-trailing-header") | ||
|
||
val xAmzTrailer = headers.getAll("x-amz-trailer") | ||
|
||
assertTrue( | ||
xAmzTrailer?.contains("x-amz-checksum-crc32") ?: false, | ||
) | ||
assertTrue( | ||
xAmzTrailer?.contains("x-amz-trailing-header") ?: false, | ||
) | ||
|
||
headers.removeChecksumTrailingHeadersFromXAmzTrailer() | ||
|
||
assertFalse( | ||
xAmzTrailer?.contains("x-amz-checksum-crc32") ?: false, | ||
) | ||
assertTrue( | ||
xAmzTrailer?.contains("x-amz-trailing-header") ?: false, | ||
) | ||
} | ||
} |