Skip to content

Commit

Permalink
Add more error cases to
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj committed Jun 20, 2023
1 parent ec0625a commit 58905f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public class AuthenticationException : Auth0Exception {
/// When MFA code sent is invalid or expired
public val isMultifactorCodeInvalid: Boolean
get() = "a0.mfa_invalid_code" == code || "invalid_grant" == code && "Invalid otp_code." == description
|| code == "invalid_grant" && description == "Invalid binding_code."
|| code == "invalid_grant" && description == "MFA Authorization rejected."

/// When password used for SignUp does not match connection's strength requirements.
public val isPasswordNotStrongEnough: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,26 @@ public class AuthenticationExceptionTest {
MatcherAssert.assertThat(ex.isMultifactorCodeInvalid, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveInvalidMultifactorCodeForWrongBindingCode() {
values[ERROR_KEY] = "invalid_grant"
values[ERROR_DESCRIPTION_KEY] = "Invalid binding_code."
val ex = AuthenticationException(
values
)
MatcherAssert.assertThat(ex.isMultifactorCodeInvalid, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveInvalidMultifactorCodeWhenAuthorizationRejected() {
values[ERROR_KEY] = "invalid_grant"
values[ERROR_DESCRIPTION_KEY] = "MFA Authorization rejected."
val ex = AuthenticationException(
values
)
MatcherAssert.assertThat(ex.isMultifactorCodeInvalid, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveInvalidMultifactorCode() {
values[CODE_KEY] = "a0.mfa_invalid_code"
Expand Down

0 comments on commit 58905f1

Please sign in to comment.