Skip to content

Commit

Permalink
Query params auth request matching
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jun 24, 2024
1 parent f340925 commit 638b986
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/test/kotlin/com/vonage/client/kt/AbstractTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class AbstractTest {
}

protected enum class AuthType {
JWT, API_KEY_SECRET
JWT, API_KEY_SECRET_HEADER, API_KEY_SECRET_QUERY_PARAMS
}

protected fun baseMockRequest(
Expand All @@ -65,9 +65,14 @@ abstract class AbstractTest {
url equalTo expectedUrl
headers contains "User-Agent" like "vonage-java-sdk\\/.+ java\\/.+"
if (authType != null) {
headers contains "Authorization" like when (authType) {
AuthType.JWT -> "Bearer eyJ0eXBlIjoiSldUIiwiYWxnIjoiUlMyNTYifQ(\\..+){2}"
AuthType.API_KEY_SECRET -> "Basic $apiKeySecretEncoded"
val headerContainsAuth = headers contains "Authorization"
when (authType) {
AuthType.JWT -> headerContainsAuth like "Bearer eyJ0eXBlIjoiSldUIiwiYWxnIjoiUlMyNTYifQ(\\..+){2}"
AuthType.API_KEY_SECRET_HEADER -> headerContainsAuth equalTo "Basic $apiKeySecretEncoded"
AuthType.API_KEY_SECRET_QUERY_PARAMS -> {
headers contains "api_key" equalTo apiKey
headers contains "api_secret" equalTo apiSecret
}
}
}
if (contentType != null) {
Expand Down

0 comments on commit 638b986

Please sign in to comment.