-
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.
Added tests for unsupported signing algorithm interceptor
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...st/aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptorTest.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,62 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.sdk.kotlin.runtime.http.interceptors | ||
|
||
import aws.smithy.kotlin.runtime.auth.awssigning.UnsupportedSigningAlgorithm | ||
import aws.smithy.kotlin.runtime.client.ResponseInterceptorContext | ||
import aws.smithy.kotlin.runtime.client.SdkClientOption | ||
import aws.smithy.kotlin.runtime.http.request.HttpRequest | ||
import aws.smithy.kotlin.runtime.http.response.HttpResponse | ||
import aws.smithy.kotlin.runtime.operation.ExecutionContext | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFails | ||
|
||
class UnsupportedSigningAlgorithmInterceptorTest { | ||
@Test | ||
fun testUnsupportedSigningAlgorithmSigV4a() = runTest { | ||
val exception = assertFails { | ||
UnsupportedSigningAlgorithmInterceptor() | ||
.modifyBeforeCompletion( | ||
context( | ||
Result.failure( | ||
UnsupportedSigningAlgorithm( | ||
"SIGV4A support is not yet implemented for the default signer.", | ||
true, | ||
), | ||
), | ||
), | ||
) | ||
} | ||
|
||
assertEquals(UnsupportedSigningAlgorithm::class, exception::class) | ||
assertEquals("SIGV4A support is not yet implemented for the default signer.", exception.message) | ||
} | ||
|
||
@Test | ||
fun testUnsupportedSigningAlgorithmNotSigV4aNoException() = runTest { | ||
UnsupportedSigningAlgorithmInterceptor() | ||
.modifyBeforeCompletion( | ||
context( | ||
Result.failure( | ||
UnsupportedSigningAlgorithm( | ||
"SIGV5 support is not yet implemented for the default signer.", | ||
false, | ||
), | ||
), | ||
), | ||
) | ||
} | ||
} | ||
|
||
private fun context(response: Result<Any>) = | ||
object : ResponseInterceptorContext<Any, Any, HttpRequest?, HttpResponse?> { | ||
override val executionContext = ExecutionContext.build { attributes[SdkClientOption.OperationName] = "test" } | ||
override val request = Unit | ||
override val response = response | ||
override val protocolRequest = HttpRequest { } | ||
override val protocolResponse = null | ||
} |
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