@@ -8,18 +8,19 @@ package aws.sdk.kotlin.tests.codegen.checksums
88import aws.sdk.kotlin.runtime.auth.credentials.StaticCredentialsProvider
99import aws.sdk.kotlin.test.checksums.*
1010import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
11- import aws.smithy.kotlin.runtime.http.Headers
12- import aws.smithy.kotlin.runtime.http.HttpCall
13- import aws.smithy.kotlin.runtime.http.HttpStatusCode
11+ import aws.smithy.kotlin.runtime.http.*
1412import aws.smithy.kotlin.runtime.http.interceptors.ChecksumMismatchException
1513import aws.smithy.kotlin.runtime.http.response.HttpResponse
16- import aws.smithy.kotlin.runtime.http.toHttpBody
1714import aws.smithy.kotlin.runtime.httptest.TestEngine
15+ import aws.smithy.kotlin.runtime.io.SdkSource
16+ import aws.smithy.kotlin.runtime.io.source
1817import aws.smithy.kotlin.runtime.time.Instant
1918import kotlinx.coroutines.runBlocking
2019import kotlin.test.Test
2120import kotlin.test.assertFailsWith
2221
22+ private val responseBody = " Hello world"
23+
2324class SuccessfulChecksumResponseTest {
2425 @Test
2526 fun crc32 (): Unit = runBlocking {
@@ -31,7 +32,11 @@ class SuccessfulChecksumResponseTest {
3132 Headers {
3233 append(" x-amz-checksum-crc32" , " i9aeUg==" )
3334 },
34- " Hello world" .toHttpBody(),
35+ object : HttpBody .SourceContent () {
36+ override val isOneShot: Boolean = false
37+ override val contentLength: Long? = responseBody.length.toLong()
38+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
39+ },
3540 )
3641 val now = Instant .now()
3742 HttpCall (request, resp, now, now)
@@ -58,7 +63,11 @@ class SuccessfulChecksumResponseTest {
5863 Headers {
5964 append(" x-amz-checksum-crc32c" , " crUfeA==" )
6065 },
61- " Hello world" .toHttpBody(),
66+ object : HttpBody .SourceContent () {
67+ override val isOneShot: Boolean = false
68+ override val contentLength: Long? = responseBody.length.toLong()
69+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
70+ },
6271 )
6372 val now = Instant .now()
6473 HttpCall (request, resp, now, now)
@@ -85,7 +94,11 @@ class SuccessfulChecksumResponseTest {
8594 Headers {
8695 append(" x-amz-checksum-sha1" , " e1AsOh9IyGCa4hLN+2Od7jlnP14=" )
8796 },
88- " Hello world" .toHttpBody(),
97+ object : HttpBody .SourceContent () {
98+ override val isOneShot: Boolean = false
99+ override val contentLength: Long? = responseBody.length.toLong()
100+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
101+ },
89102 )
90103 val now = Instant .now()
91104 HttpCall (request, resp, now, now)
@@ -112,7 +125,11 @@ class SuccessfulChecksumResponseTest {
112125 Headers {
113126 append(" x-amz-checksum-sha256" , " ZOyIygCyaOW6GjVnihtTFtIS9PNmskdyMlNKiuyjfzw=" )
114127 },
115- " Hello world" .toHttpBody(),
128+ object : HttpBody .SourceContent () {
129+ override val isOneShot: Boolean = false
130+ override val contentLength: Long? = responseBody.length.toLong()
131+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
132+ },
116133 )
117134 val now = Instant .now()
118135 HttpCall (request, resp, now, now)
@@ -142,7 +159,11 @@ class FailedChecksumResponseTest {
142159 Headers {
143160 append(" x-amz-checksum-crc32" , " bm90LWEtY2hlY2tzdW0=" )
144161 },
145- " Hello world" .toHttpBody(),
162+ object : HttpBody .SourceContent () {
163+ override val isOneShot: Boolean = false
164+ override val contentLength: Long? = responseBody.length.toLong()
165+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
166+ },
146167 )
147168 val now = Instant .now()
148169 HttpCall (request, resp, now, now)
@@ -171,7 +192,11 @@ class FailedChecksumResponseTest {
171192 Headers {
172193 append(" x-amz-checksum-crc32c" , " bm90LWEtY2hlY2tzdW0=" )
173194 },
174- " Hello world" .toHttpBody(),
195+ object : HttpBody .SourceContent () {
196+ override val isOneShot: Boolean = false
197+ override val contentLength: Long? = responseBody.length.toLong()
198+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
199+ },
175200 )
176201 val now = Instant .now()
177202 HttpCall (request, resp, now, now)
@@ -200,7 +225,11 @@ class FailedChecksumResponseTest {
200225 Headers {
201226 append(" x-amz-checksum-sha1" , " bm90LWEtY2hlY2tzdW0=" )
202227 },
203- " Hello world" .toHttpBody(),
228+ object : HttpBody .SourceContent () {
229+ override val isOneShot: Boolean = false
230+ override val contentLength: Long? = responseBody.length.toLong()
231+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
232+ },
204233 )
205234 val now = Instant .now()
206235 HttpCall (request, resp, now, now)
@@ -229,7 +258,11 @@ class FailedChecksumResponseTest {
229258 Headers {
230259 append(" x-amz-checksum-sha256" , " bm90LWEtY2hlY2tzdW0=" )
231260 },
232- " Hello world" .toHttpBody(),
261+ object : HttpBody .SourceContent () {
262+ override val isOneShot: Boolean = false
263+ override val contentLength: Long? = responseBody.length.toLong()
264+ override fun readFrom (): SdkSource = responseBody.toByteArray().source()
265+ },
233266 )
234267 val now = Instant .now()
235268 HttpCall (request, resp, now, now)
0 commit comments