60
60
static const char kCustomPassword [] = " CustomPasswordGoesHere" ;
61
61
62
62
// Constants used during tests.
63
+ static const char kTestNonceBad [] = " testBadNonce" ;
63
64
static const char kTestPassword [] = " testEmailPassword123" ;
64
65
static const char kTestEmailBad [] =
" [email protected] " ;
65
66
static const char kTestPasswordBad [] = " badTestPassword" ;
@@ -882,7 +883,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
882
883
WaitForSignInFuture (
883
884
facebook_bad,
884
885
" Auth::SignInWithCredential() bad Facebook credentials" ,
885
- kAuthErrorInvalidProviderId , auth);
886
+ kAuthErrorInvalidCredential , auth);
886
887
}
887
888
888
889
// Use bad GitHub credentials. Should fail.
@@ -893,7 +894,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
893
894
auth->SignInWithCredential (git_hub_cred_bad);
894
895
WaitForSignInFuture (
895
896
git_hub_bad, " Auth::SignInWithCredential() bad GitHub credentials" ,
896
- kAuthErrorInvalidProviderId , auth);
897
+ kAuthErrorInvalidCredential , auth);
897
898
}
898
899
899
900
// Use bad Google credentials. Should fail.
@@ -969,7 +970,6 @@ extern "C" int common_main(int argc, const char* argv[]) {
969
970
}
970
971
}
971
972
#endif // TARGET_OS_IPHONE
972
-
973
973
// Use bad Twitter credentials. Should fail.
974
974
{
975
975
Credential twitter_cred_bad = TwitterAuthProvider::GetCredential (
@@ -978,7 +978,21 @@ extern "C" int common_main(int argc, const char* argv[]) {
978
978
auth->SignInWithCredential (twitter_cred_bad);
979
979
WaitForSignInFuture (
980
980
twitter_bad, " Auth::SignInWithCredential() bad Twitter credentials" ,
981
- kAuthErrorInvalidProviderId , auth);
981
+ kAuthErrorInvalidCredential , auth);
982
+ }
983
+
984
+ // Construct OAuthCredential with nonce & access token.
985
+ {
986
+ Credential nonce_credential_good =
987
+ OAuthProvider::GetCredential (kTestIdProviderIdBad , kTestIdTokenBad ,
988
+ kTestNonceBad , kTestAccessTokenBad );
989
+ }
990
+
991
+ // Construct OAuthCredential with nonce, null access token.
992
+ {
993
+ Credential nonce_credential_good = OAuthProvider::GetCredential (
994
+ kTestIdProviderIdBad , kTestIdTokenBad , kTestNonceBad ,
995
+ /* access_token=*/ nullptr );
982
996
}
983
997
984
998
// Use bad OAuth credentials. Should fail.
@@ -988,7 +1002,18 @@ extern "C" int common_main(int argc, const char* argv[]) {
988
1002
Future<User*> oauth_bad = auth->SignInWithCredential (oauth_cred_bad);
989
1003
WaitForSignInFuture (
990
1004
oauth_bad, " Auth::SignInWithCredential() bad OAuth credentials" ,
991
- kAuthErrorInvalidProviderId , auth);
1005
+ kAuthErrorFailure , auth);
1006
+ }
1007
+
1008
+ // Use bad OAuth credentials with nonce. Should fail.
1009
+ {
1010
+ Credential oauth_cred_bad =
1011
+ OAuthProvider::GetCredential (kTestIdProviderIdBad , kTestIdTokenBad ,
1012
+ kTestNonceBad , kTestAccessTokenBad );
1013
+ Future<User*> oauth_bad = auth->SignInWithCredential (oauth_cred_bad);
1014
+ WaitForSignInFuture (
1015
+ oauth_bad, " Auth::SignInWithCredential() bad OAuth credentials" ,
1016
+ kAuthErrorFailure , auth);
992
1017
}
993
1018
994
1019
// Test Auth::SendPasswordResetEmail().
@@ -1077,7 +1102,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
1077
1102
anonymous_user->LinkWithCredential (twitter_cred_bad);
1078
1103
WaitForFuture (link_bad_future,
1079
1104
" User::LinkWithCredential() with bad credential" ,
1080
- kAuthErrorInvalidProviderId );
1105
+ kAuthErrorInvalidCredential );
1081
1106
ExpectTrue (" Linking maintains user" ,
1082
1107
auth->current_user () == pre_link_user);
1083
1108
}
@@ -1094,7 +1119,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
1094
1119
auth->SignInWithCredential (twitter_cred_bad);
1095
1120
WaitForFuture (signin_bad_future,
1096
1121
" Auth::SignInWithCredential() with bad credential" ,
1097
- kAuthErrorInvalidProviderId , auth);
1122
+ kAuthErrorInvalidCredential , auth);
1098
1123
ExpectTrue (" Failed sign in maintains user" ,
1099
1124
auth->current_user () == pre_signin_user);
1100
1125
}
@@ -1270,7 +1295,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
1270
1295
LogMessage (" Setting up provider data" );
1271
1296
firebase::auth::FederatedOAuthProviderData provider_data;
1272
1297
provider_data.provider_id =
1273
- firebase::auth::GoogleAuthProvider::GetProviderId () ;
1298
+ firebase::auth::GoogleAuthProvider::kProviderId ;
1274
1299
provider_data.provider_id = " google.com" ;
1275
1300
provider_data.scopes = {
1276
1301
" https://www.googleapis.com/auth/fitness.activity.read" };
@@ -1299,7 +1324,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
1299
1324
// --- SignInWithProvider ---
1300
1325
firebase::auth::FederatedOAuthProviderData provider_data;
1301
1326
provider_data.provider_id =
1302
- firebase::auth::GoogleAuthProvider::GetProviderId () ;
1327
+ firebase::auth::GoogleAuthProvider::kProviderId ;
1303
1328
provider_data.custom_parameters = {{" req_id" , " 1234" }};
1304
1329
1305
1330
firebase::auth::FederatedOAuthProvider provider;
@@ -1321,7 +1346,7 @@ extern "C" int common_main(int argc, const char* argv[]) {
1321
1346
} else {
1322
1347
firebase::auth::FederatedOAuthProviderData provider_data;
1323
1348
provider_data.provider_id =
1324
- firebase::auth::GoogleAuthProvider::GetProviderId () ;
1349
+ firebase::auth::GoogleAuthProvider::kProviderId ;
1325
1350
provider_data.custom_parameters = {{" req_id" , " 1234" }};
1326
1351
1327
1352
firebase::auth::FederatedOAuthProvider provider;
0 commit comments