Skip to content

Commit

Permalink
move passwordless invalid credentials errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Nov 11, 2020
1 parent 71194ff commit 778348a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ public boolean isMultifactorTokenInvalid() {
/// When MFA code sent is invalid or expired
public boolean isMultifactorCodeInvalid() {
return "a0.mfa_invalid_code".equals(code)
|| "invalid_grant".equals(code) && "Invalid otp_code.".equals(description)
|| "invalid_grant".equals(code) && "Wrong phone number or verification code.".equals(description)
|| "invalid_grant".equals(code) && "Wrong email or verification code.".equals(description);
|| "invalid_grant".equals(code) && "Invalid otp_code.".equals(description);
}

/// When password used for SignUp does not match connection's strength requirements.
Expand All @@ -228,7 +226,10 @@ public boolean isRuleError() {

/// When username and/or password used for authentication are invalid
public boolean isInvalidCredentials() {
return "invalid_user_password".equals(code) || "invalid_grant".equals(code) && "Wrong email or password.".equals(description);
return "invalid_user_password".equals(code)
|| "invalid_grant".equals(code) && "Wrong email or password.".equals(description)
|| "invalid_grant".equals(code) && "Wrong phone number or verification code.".equals(description)
|| "invalid_grant".equals(code) && "Wrong email or verification code.".equals(description);
}

/// When authenticating with web-based authentication and the resource server denied access per OAuth2 spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,6 @@ public void shouldHaveInvalidMultifactorCodeOnOIDCMode() {
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCodePhoneOTP() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong phone number or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCodeEmailOTP() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong email or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCode() {
values.put(CODE_KEY, "a0.mfa_invalid_code");
Expand Down Expand Up @@ -290,6 +274,22 @@ public void shouldHaveOIDCInvalidCredentials() {
assertThat(ex.isInvalidCredentials(), is(true));
}

@Test
public void shouldHaveInvalidCredentialsOnPhonePasswordless() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong phone number or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isInvalidCredentials(), is(true));
}

@Test
public void shouldHaveInvalidCredentialsOnEmailPasswordless() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong email or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isInvalidCredentials(), is(true));
}

@Test
public void shouldHaveAccessDenied() {
values.put(CODE_KEY, "access_denied");
Expand Down

0 comments on commit 778348a

Please sign in to comment.