@@ -82,6 +82,7 @@ public class FirebaseAuthIT {
82
82
private static final JsonFactory jsonFactory = ApiClientUtils .getDefaultJsonFactory ();
83
83
private static final HttpTransport transport = ApiClientUtils .getDefaultTransport ();
84
84
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" ;
85
86
86
87
private static final FirebaseAuth auth = FirebaseAuth .getInstance (
87
88
IntegrationTestUtils .ensureDefaultApp ());
@@ -868,6 +869,31 @@ public void testGenerateSignInWithEmailLink() throws Exception {
868
869
assertTrue (auth .getUser (user .getUid ()).isEmailVerified ());
869
870
}
870
871
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
+
871
897
@ Test
872
898
public void testOidcProviderConfigLifecycle () throws Exception {
873
899
// Create provider config
0 commit comments