Skip to content

Commit

Permalink
moshi config was incorrect for successful user password auth reponse …
Browse files Browse the repository at this point in the history
…- certain fields are null
  • Loading branch information
time4tea committed Jul 24, 2023
1 parent 42476af commit d4adc9e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ data class InitiateAuth(
@JsonSerializable
data class AuthInitiated(
val AuthenticationResult: AuthenticationResult,
val ChallengeName: ChallengeName,
val ChallengeName: ChallengeName?,
val ChallengeParameters: Map<String, String>,
val Session: Session
val Session: Session?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.http4k.connect.amazon.cognito

import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import org.http4k.connect.amazon.cognito.action.AuthInitiated
import org.http4k.connect.amazon.cognito.model.AccessToken
import org.http4k.connect.amazon.cognito.model.IdToken
import org.http4k.connect.amazon.cognito.model.RefreshToken
import org.junit.jupiter.api.Test

class ActualCognitoResponsesTest {

val factory = CognitoMoshi

@Test
fun `deserialising a user password response with no challenges requested`() {
val response = factory.asA<AuthInitiated>("""{"AuthenticationResult":
{"AccessToken":"access-token",
"ExpiresIn":3600,
"IdToken":"id-token",
"RefreshToken":"refresh-token",
"TokenType":"Bearer"},
"ChallengeParameters":{}}
""".trimIndent())
assertThat(response.AuthenticationResult.AccessToken, equalTo(AccessToken.of("access-token")))
assertThat(response.AuthenticationResult.ExpiresIn, equalTo(3600))
assertThat(response.AuthenticationResult.IdToken, equalTo(IdToken.of("id-token")))
assertThat(response.AuthenticationResult.RefreshToken, equalTo(RefreshToken.of("refresh-token")))
assertThat(response.AuthenticationResult.TokenType, equalTo("Bearer"))
assertThat(response.ChallengeParameters, equalTo(mapOf()))
}
}

0 comments on commit d4adc9e

Please sign in to comment.