@@ -82,6 +82,7 @@ public class FirebaseAuthIT {
8282 private static final JsonFactory jsonFactory = ApiClientUtils .getDefaultJsonFactory ();
8383 private static final HttpTransport transport = ApiClientUtils .getDefaultTransport ();
8484 private static final String ACTION_LINK_CONTINUE_URL = "http://localhost/?a=1&b=2#c=3" ;
85+ private static final String INVALID_ACTION_LINK_CONTINUE_URL = "http://www.localhost/?a=1&b=2#c=3" ;
8586
8687 private static final FirebaseAuth auth = FirebaseAuth .getInstance (
8788 IntegrationTestUtils .ensureDefaultApp ());
@@ -868,6 +869,31 @@ public void testGenerateSignInWithEmailLink() throws Exception {
868869 assertTrue (auth .getUser (user .getUid ()).isEmailVerified ());
869870 }
870871
872+ @ Test
873+ public void testAuthErrorCodeParse () throws Exception {
874+ RandomUser user = UserTestUtils .generateRandomUserInfo ();
875+ temporaryUser .create (new UserRecord .CreateRequest ()
876+ .setUid (user .getUid ())
877+ .setEmail (user .getEmail ())
878+ .setEmailVerified (false )
879+ .setPassword ("password" ));
880+ try {
881+ auth .generateSignInWithEmailLink (user .getEmail (), ActionCodeSettings .builder ()
882+ .setUrl (INVALID_ACTION_LINK_CONTINUE_URL )
883+ .build ());
884+ fail ("No error thrown for invlaid custom hosting domain" );
885+ } catch (FirebaseAuthException e ) {
886+ assertEquals (
887+ "The domain of the continue URL is not whitelisted (UNAUTHORIZED_DOMAIN): Domain not "
888+ + "allowlisted by project" ,
889+ e .getMessage ());
890+ assertEquals (ErrorCode .INVALID_ARGUMENT , e .getErrorCode ());
891+ assertNotNull (e .getCause ());
892+ assertNotNull (e .getHttpResponse ());
893+ assertEquals (AuthErrorCode .UNAUTHORIZED_CONTINUE_URL , e .getAuthErrorCode ());
894+ }
895+ }
896+
871897 @ Test
872898 public void testOidcProviderConfigLifecycle () throws Exception {
873899 // Create provider config
0 commit comments