Skip to content

Commit

Permalink
Added tests for unsupported signing algorithm interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Jan 17, 2024
1 parent 01ba0b7 commit 84ab837
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ClientConfigIntegration : KotlinIntegration {
""".trimIndent()
}

// FIXME: default signer doesn't yet implement sigv4a
val DisableMrapProp: ConfigProperty = ConfigProperty {
name = "disableMrap"
useSymbolWithNullableBuilder(KotlinTypes.Boolean, "false")
Expand Down

0 comments on commit 84ab837

Please sign in to comment.