Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ String buildMessage(AuthServiceErrorResponse response) {

/**
* JSON data binding for JSON error messages sent by Google identity toolkit service. These
* error messages take the form `{"error": {"message": "CODE: OPTIONAL DETAILS"}}`.
* error messages take the form `{"error": {"message": "CODE : OPTIONAL DETAILS"}}`.
*/
private static class AuthServiceErrorResponse {

Expand All @@ -196,7 +196,7 @@ public String getCode() {

int separator = message.indexOf(':');
if (separator != -1) {
return message.substring(0, separator);
return message.substring(0, separator).trim();
}

return message;
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/com/google/firebase/auth/FirebaseAuthIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class FirebaseAuthIT {
private static final JsonFactory jsonFactory = ApiClientUtils.getDefaultJsonFactory();
private static final HttpTransport transport = ApiClientUtils.getDefaultTransport();
private static final String ACTION_LINK_CONTINUE_URL = "http://localhost/?a=1&b=2#c=3";
private static final String INVALID_ACTION_LINK_CONTINUE_URL = "http://www.localhost/?a=1&b=2#c=3";

private static final FirebaseAuth auth = FirebaseAuth.getInstance(
IntegrationTestUtils.ensureDefaultApp());
Expand Down Expand Up @@ -868,6 +869,31 @@ public void testGenerateSignInWithEmailLink() throws Exception {
assertTrue(auth.getUser(user.getUid()).isEmailVerified());
}

@Test
public void testAuthErrorCodeParse() throws Exception {
RandomUser user = UserTestUtils.generateRandomUserInfo();
temporaryUser.create(new UserRecord.CreateRequest()
.setUid(user.getUid())
.setEmail(user.getEmail())
.setEmailVerified(false)
.setPassword("password"));
try {
auth.generateSignInWithEmailLink(user.getEmail(), ActionCodeSettings.builder()
.setUrl(INVALID_ACTION_LINK_CONTINUE_URL)
.build());
fail("No error thrown for invlaid custom hosting domain");
} catch (FirebaseAuthException e) {
assertEquals(
"The domain of the continue URL is not whitelisted (UNAUTHORIZED_DOMAIN): Domain not "
+ "allowlisted by project",
e.getMessage());
assertEquals(ErrorCode.INVALID_ARGUMENT, e.getErrorCode());
assertNotNull(e.getCause());
assertNotNull(e.getHttpResponse());
assertEquals(AuthErrorCode.UNAUTHORIZED_CONTINUE_URL, e.getAuthErrorCode());
}
}

@Test
public void testOidcProviderConfigLifecycle() throws Exception {
// Create provider config
Expand Down