From 352ba835115509d99688fdc8a1893010db3eade7 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 19 Jul 2023 16:40:42 -0700 Subject: [PATCH 01/18] add auth emulator support --- auth/src/android/auth_android.cc | 13 +++++++++++++ auth/src/desktop/auth_desktop.cc | 14 ++++++++++++++ auth/src/desktop/rpcs/auth_request.cc | 16 ++++++++++++++++ auth/src/desktop/rpcs/auth_request.h | 6 ++++++ auth/src/desktop/rpcs/create_auth_uri_request.cc | 7 ++----- auth/src/desktop/rpcs/delete_account_request.cc | 4 +--- .../src/desktop/rpcs/get_account_info_request.cc | 7 ++----- .../rpcs/get_oob_confirmation_code_request.cc | 7 ++----- auth/src/desktop/rpcs/reset_password_request.cc | 7 ++----- .../src/desktop/rpcs/set_account_info_request.cc | 7 ++----- .../src/desktop/rpcs/sign_up_new_user_request.cc | 7 ++----- .../src/desktop/rpcs/verify_assertion_request.cc | 7 ++----- .../desktop/rpcs/verify_custom_token_request.cc | 7 ++----- auth/src/desktop/rpcs/verify_password_request.cc | 7 ++----- auth/src/include/firebase/auth.h | 4 ++++ auth/src/ios/auth_ios.mm | 10 ++++++++++ 16 files changed, 82 insertions(+), 48 deletions(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 7b588dbb9b..f91f3cbf7d 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -53,6 +53,7 @@ using util::JniStringToString; X(RemoveIdTokenListener, "removeIdTokenListener", \ "(Lcom/google/firebase/auth/FirebaseAuth$IdTokenListener;)V"), \ X(SignOut, "signOut", "()V"), \ + X(UseEmulator, "useEmulator", "(Ljava/lang/String;I)V"),\ X(FetchSignInMethodsForEmail, "fetchSignInMethodsForEmail", \ "(Ljava/lang/String;)" \ "Lcom/google/android/gms/tasks/Task;"), \ @@ -774,6 +775,18 @@ void Auth::SignOut() { SetImplFromLocalRef(env, nullptr, &auth_data_->user_impl); } +void Auth::UseEmulator(const std::string host, uint32_t port) { + JNIEnv* env = Env(auth_data_); + jstring j_host = env->NewStringUTF(host.c_str()); + env->CallVoidMethod(AuthImpl(auth_data_), auth::GetMethodId(auth::kUseEmulator), j_host, port); + env->DeleteLocalRef(j_host); + firebase::util::CheckAndClearJniExceptions(env); +} + +std::string Auth::GetEmulatorUrl() { + return ""; +} + Future Auth::SendPasswordResetEmail(const char* email) { ReferenceCountedFutureImpl& futures = auth_data_->future_impl; const auto handle = futures.SafeAlloc(kAuthFn_SendPasswordResetEmail); diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index b0d5bcbd19..f3ae0f3105 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -54,6 +54,8 @@ namespace firebase { namespace auth { +static std::string g_emulator_host; +static uint32_t g_emulator_port; namespace { template @@ -644,6 +646,18 @@ void Auth::SignOut() { AuthenticationResult::SignOut(auth_data_); } +void Auth::UseEmulator(const std::string host, uint32_t port) { + g_emulator_host = host; + g_emulator_port = port; +} + +std::string Auth::GetEmulatorUrl() { + if (g_emulator_host.empty()) { + return ""; + } + return "https://" + g_emulator_host + ":" + std::to_string(g_emulator_port); +} + // AuthStateListener to wait for current_user_DEPRECATED() until persistent // cache load is finished. class CurrentUserBlockListener : public firebase::auth::AuthStateListener { diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index 4db7ac46ae..eee668527c 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -23,10 +23,13 @@ #include "app/src/heartbeat/heartbeat_controller_desktop.h" #include "app/src/include/firebase/app.h" #include "app/src/include/firebase/internal/mutex.h" +#include "firebase/auth.h" namespace firebase { namespace auth { +using ::firebase::auth::Auth; + // Key name for header when sending language code data. const char* kHeaderFirebaseLocale = "X-Firebase-Locale"; @@ -77,5 +80,18 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, } } +std::string AuthRequest::GetUrl() { + std::string emulator_url = ::firebase::auth::Auth::GetEmulatorUrl(); + if (emulator_url.empty()) { + std::string url(kServerURL); + url += kExtraPath; + return url; + } else { + std::string url(emulator_url); + url += kExtraPath; + return url; + } +} + } // namespace auth } // namespace firebase diff --git a/auth/src/desktop/rpcs/auth_request.h b/auth/src/desktop/rpcs/auth_request.h index 670571e5af..4d78fd27cc 100644 --- a/auth/src/desktop/rpcs/auth_request.h +++ b/auth/src/desktop/rpcs/auth_request.h @@ -28,6 +28,10 @@ namespace auth { // Key name for header when sending language code data. extern const char* kHeaderFirebaseLocale; +const char* const kServerURL = "https://www.googleapis.com"; + +const char* const kExtraPath = "/identitytoolkit/v3/relyingparty/"; + class AuthRequest : public firebase::rest::RequestJson { public: @@ -39,6 +43,8 @@ class AuthRequest bool deliver_heartbeat) : AuthRequest(app, reinterpret_cast(schema), deliver_heartbeat) {} + + std::string GetUrl(); }; } // namespace auth diff --git a/auth/src/desktop/rpcs/create_auth_uri_request.cc b/auth/src/desktop/rpcs/create_auth_uri_request.cc index 04ee9efc2e..f659483752 100644 --- a/auth/src/desktop/rpcs/create_auth_uri_request.cc +++ b/auth/src/desktop/rpcs/create_auth_uri_request.cc @@ -27,11 +27,8 @@ CreateAuthUriRequest::CreateAuthUriRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "createAuthUri?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "createAuthUri?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/delete_account_request.cc b/auth/src/desktop/rpcs/delete_account_request.cc index efe3935738..16b8829f66 100644 --- a/auth/src/desktop/rpcs/delete_account_request.cc +++ b/auth/src/desktop/rpcs/delete_account_request.cc @@ -26,10 +26,8 @@ DeleteAccountRequest::DeleteAccountRequest(::firebase::App& app, FIREBASE_ASSERT_RETURN_VOID(api_key); const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" "deleteAccount?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/get_account_info_request.cc b/auth/src/desktop/rpcs/get_account_info_request.cc index 0dad730f18..60b0c5ace1 100644 --- a/auth/src/desktop/rpcs/get_account_info_request.cc +++ b/auth/src/desktop/rpcs/get_account_info_request.cc @@ -39,11 +39,8 @@ GetAccountInfoRequest::GetAccountInfoRequest(::firebase::App& app, void GetAccountInfoRequest::SetUrl(const char* const api_key) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "getAccountInfo?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "getAccountInfo?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc b/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc index 3087837a6a..18a5bc2685 100644 --- a/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc +++ b/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc @@ -25,11 +25,8 @@ GetOobConfirmationCodeRequest::GetOobConfirmationCodeRequest( : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "getOobConfirmationCode?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "getOobConfirmationCode?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/reset_password_request.cc b/auth/src/desktop/rpcs/reset_password_request.cc index b8fc65654e..9777efd108 100644 --- a/auth/src/desktop/rpcs/reset_password_request.cc +++ b/auth/src/desktop/rpcs/reset_password_request.cc @@ -28,11 +28,8 @@ ResetPasswordRequest::ResetPasswordRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "resetPassword?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "resetPassword?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/set_account_info_request.cc b/auth/src/desktop/rpcs/set_account_info_request.cc index 48105661b1..60a6f42101 100644 --- a/auth/src/desktop/rpcs/set_account_info_request.cc +++ b/auth/src/desktop/rpcs/set_account_info_request.cc @@ -25,11 +25,8 @@ SetAccountInfoRequest::SetAccountInfoRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "setAccountInfo?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "setAccountInfo?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/sign_up_new_user_request.cc b/auth/src/desktop/rpcs/sign_up_new_user_request.cc index 5a098b4b10..cd541b33ee 100644 --- a/auth/src/desktop/rpcs/sign_up_new_user_request.cc +++ b/auth/src/desktop/rpcs/sign_up_new_user_request.cc @@ -53,11 +53,8 @@ SignUpNewUserRequest::SignUpNewUserRequest(::firebase::App& app, void SignUpNewUserRequest::SetUrl(const char* api_key) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "signupNewUser?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "signupNewUser?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/verify_assertion_request.cc b/auth/src/desktop/rpcs/verify_assertion_request.cc index 84dc5e4f70..9b717b11fb 100644 --- a/auth/src/desktop/rpcs/verify_assertion_request.cc +++ b/auth/src/desktop/rpcs/verify_assertion_request.cc @@ -26,11 +26,8 @@ VerifyAssertionRequest::VerifyAssertionRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "verifyAssertion?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "verifyAssertion?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/verify_custom_token_request.cc b/auth/src/desktop/rpcs/verify_custom_token_request.cc index 83754219f0..68ccc6942e 100644 --- a/auth/src/desktop/rpcs/verify_custom_token_request.cc +++ b/auth/src/desktop/rpcs/verify_custom_token_request.cc @@ -27,11 +27,8 @@ VerifyCustomTokenRequest::VerifyCustomTokenRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "verifyCustomToken?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "verifyCustomToken?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/desktop/rpcs/verify_password_request.cc b/auth/src/desktop/rpcs/verify_password_request.cc index bbfddfa338..8197623829 100644 --- a/auth/src/desktop/rpcs/verify_password_request.cc +++ b/auth/src/desktop/rpcs/verify_password_request.cc @@ -28,11 +28,8 @@ VerifyPasswordRequest::VerifyPasswordRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "https://www.googleapis.com/identitytoolkit/v3/relyingparty/" - "verifyPassword?key="; - std::string url; - url.reserve(strlen(api_host) + strlen(api_key)); + const char api_host[] = "verifyPassword?key="; + std::string url = GetUrl(); url.append(api_host); url.append(api_key); set_url(url.c_str()); diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index bec3ce8ff8..2032e1d22f 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -629,6 +629,10 @@ class Auth { /// to be called explicitly. void RemoveIdTokenListener(IdTokenListener* listener); #endif // not SWIG + + void UseEmulator(const std::string host, uint32_t port); + + static std::string GetEmulatorUrl(); /// Gets the App this auth object is connected to. App& app(); diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index b8b52573a1..b03a08cb74 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -663,6 +663,16 @@ void SignInResultCallback(FIRAuthDataResult *_Nullable auth_result, NSError *_Nu SetUserImpl(auth_data_, NULL); } +void Auth::UseEmulator(const std::string host, uint32_t port) { + [AuthImpl(auth_data_) useEmulatorWithHost:@(host.c_str()) + port:@(port) + ]; +} + +std::string Auth::GetEmulatorUrl() { + return ""; +} + Future Auth::SendPasswordResetEmail(const char *email) { ReferenceCountedFutureImpl &futures = auth_data_->future_impl; const auto handle = futures.SafeAlloc(kAuthFn_SendPasswordResetEmail); From 6ccf941436b3b5d53a3cf3c97744c548e9a93c7e Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Thu, 20 Jul 2023 11:47:27 -0700 Subject: [PATCH 02/18] fix ios number parse --- auth/src/ios/auth_ios.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index b03a08cb74..6b3257bf75 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -664,8 +664,9 @@ void SignInResultCallback(FIRAuthDataResult *_Nullable auth_result, NSError *_Nu } void Auth::UseEmulator(const std::string host, uint32_t port) { + NSUInteger ns_port = port; [AuthImpl(auth_data_) useEmulatorWithHost:@(host.c_str()) - port:@(port) + port:ns_port ]; } From b1a8d27734a32b0a12965fe80ff4d7dc49a8d476 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Fri, 21 Jul 2023 11:42:19 -0700 Subject: [PATCH 03/18] update the documentation part --- .gitignore | 2 ++ app/src/include/firebase/app.h | 3 --- auth/src/desktop/auth_desktop.cc | 2 +- auth/src/desktop/rpcs/auth_request.cc | 12 ++++++++---- auth/src/desktop/rpcs/auth_request.h | 6 ++++-- auth/src/include/firebase/auth.h | 6 ++++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index be6008e2cc..d86b432e3c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ gcs_key_file.json *_build/ cmake-build-*/ testing/test_framework/external/ +CMakeFiles/ +CMakeCache.txt # XCode user specific folders **/xcuserdata/ diff --git a/app/src/include/firebase/app.h b/app/src/include/firebase/app.h index f32f8bf33f..03f0ad2dde 100644 --- a/app/src/include/firebase/app.h +++ b/app/src/include/firebase/app.h @@ -571,11 +571,8 @@ class App { /// Get the App with the given name, or nullptr if none have been created. static App* GetInstance(const char* name); -#if !defined(DOXYGEN) - // Hidden from the public documentation for now /// Get all the apps, including the default one. static std::vector GetApps(); -#endif // !defined(DOXYGEN) #ifndef SWIG // diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index f3ae0f3105..03111d9df5 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -655,7 +655,7 @@ std::string Auth::GetEmulatorUrl() { if (g_emulator_host.empty()) { return ""; } - return "https://" + g_emulator_host + ":" + std::to_string(g_emulator_port); + return g_emulator_host + ":" + std::to_string(g_emulator_port) + "/"; } // AuthStateListener to wait for current_user_DEPRECATED() until persistent diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index eee668527c..415b717017 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -24,6 +24,7 @@ #include "app/src/include/firebase/app.h" #include "app/src/include/firebase/internal/mutex.h" #include "firebase/auth.h" +#include "firebase/log.h" namespace firebase { namespace auth { @@ -83,12 +84,15 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, std::string AuthRequest::GetUrl() { std::string emulator_url = ::firebase::auth::Auth::GetEmulatorUrl(); if (emulator_url.empty()) { - std::string url(kServerURL); - url += kExtraPath; + std::string url(kHttps); + url += kServerURL; + LogDebug("AuthRequest::GetUrl(Prod): %s", url.c_str()); return url; } else { - std::string url(emulator_url); - url += kExtraPath; + std::string url(kHttp); + url += emulator_url; + url += kServerURL; + LogDebug("AuthRequest::GetUrl(Emulator): %s", url.c_str()); return url; } } diff --git a/auth/src/desktop/rpcs/auth_request.h b/auth/src/desktop/rpcs/auth_request.h index 4d78fd27cc..d9924fd4ea 100644 --- a/auth/src/desktop/rpcs/auth_request.h +++ b/auth/src/desktop/rpcs/auth_request.h @@ -28,9 +28,11 @@ namespace auth { // Key name for header when sending language code data. extern const char* kHeaderFirebaseLocale; -const char* const kServerURL = "https://www.googleapis.com"; +const char* const kHttps = "https://"; -const char* const kExtraPath = "/identitytoolkit/v3/relyingparty/"; +const char* const kHttp = "http://"; + +const char* const kServerURL = "www.googleapis.com/identitytoolkit/v3/relyingparty/"; class AuthRequest : public firebase::rest::RequestJson { diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index 2032e1d22f..3cc0056655 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -630,9 +630,15 @@ class Auth { void RemoveIdTokenListener(IdTokenListener* listener); #endif // not SWIG +#if !defined(DOXYGEN) + // Hidden from the public documentation for now + + /// Configures Firebase Auth to connect to an emulated host instead of the remote backend. void UseEmulator(const std::string host, uint32_t port); + /// Get the emulator url static std::string GetEmulatorUrl(); +#endif // !defined(DOXYGEN) /// Gets the App this auth object is connected to. App& app(); From 64fd592446d96fce7e9ca337b79cfa7f1918f2d7 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Fri, 21 Jul 2023 14:40:45 -0700 Subject: [PATCH 04/18] reduce lint warning --- auth/src/desktop/auth_desktop.cc | 14 ++++++++------ auth/src/desktop/auth_desktop.h | 3 +++ auth/src/desktop/rpcs/auth_request.cc | 5 ++++- auth/src/desktop/rpcs/auth_request.h | 6 +++++- auth/src/include/firebase/auth.h | 3 ++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index 03111d9df5..e61801e642 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -54,8 +54,6 @@ namespace firebase { namespace auth { -static std::string g_emulator_host; -static uint32_t g_emulator_port; namespace { template @@ -647,15 +645,19 @@ void Auth::SignOut() { } void Auth::UseEmulator(const std::string host, uint32_t port) { - g_emulator_host = host; - g_emulator_port = port; + if (!auth_data_) return; + auto auth_impl = static_cast(auth_data_->auth_impl); + auth_impl->emulator_host = host; + auth_impl->emulator_port = port; } std::string Auth::GetEmulatorUrl() { - if (g_emulator_host.empty()) { + if (!auth_data_) return ""; + auto auth_impl = static_cast(auth_data_->auth_impl); + if (auth_impl->emulator_host.empty()) { return ""; } - return g_emulator_host + ":" + std::to_string(g_emulator_port) + "/"; + return auth_impl->emulator_host + ":" + std::to_string(auth_impl->emulator_port) + "/"; } // AuthStateListener to wait for current_user_DEPRECATED() until persistent diff --git a/auth/src/desktop/auth_desktop.h b/auth/src/desktop/auth_desktop.h index 6210d47712..9edd25532f 100644 --- a/auth/src/desktop/auth_desktop.h +++ b/auth/src/desktop/auth_desktop.h @@ -187,6 +187,9 @@ struct AuthImpl { // The current user language code. This can be set to the app’s current // language by calling SetLanguageCode. std::string language_code; + + std::string emulator_host; + int32_t emulator_port; }; // Constant, describing how often we automatically fetch a new auth token. diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index 415b717017..f47f403dbc 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -79,10 +79,13 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, } } } + + // Get emulator url + Auth* auth = Auth::GetAuth(&app); + emulator_url = auth->GetEmulatorUrl(); } std::string AuthRequest::GetUrl() { - std::string emulator_url = ::firebase::auth::Auth::GetEmulatorUrl(); if (emulator_url.empty()) { std::string url(kHttps); url += kServerURL; diff --git a/auth/src/desktop/rpcs/auth_request.h b/auth/src/desktop/rpcs/auth_request.h index d9924fd4ea..e80e37a6b8 100644 --- a/auth/src/desktop/rpcs/auth_request.h +++ b/auth/src/desktop/rpcs/auth_request.h @@ -17,6 +17,8 @@ #ifndef FIREBASE_AUTH_SRC_DESKTOP_RPCS_AUTH_REQUEST_H_ #define FIREBASE_AUTH_SRC_DESKTOP_RPCS_AUTH_REQUEST_H_ +#include + #include "app/rest/request_json.h" #include "app/src/include/firebase/app.h" #include "auth/request_generated.h" @@ -36,7 +38,7 @@ const char* const kServerURL = "www.googleapis.com/identitytoolkit/v3/relyingpar class AuthRequest : public firebase::rest::RequestJson { - public: +public: // App is a non-const parameter because this constructor might modify App's // internal HeartbeatController by logging or fetching heartbeats. AuthRequest(::firebase::App& app, const char* schema, bool deliver_heartbeat); @@ -47,6 +49,8 @@ class AuthRequest deliver_heartbeat) {} std::string GetUrl(); +private: + std::string emulator_url; }; } // namespace auth diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index 3cc0056655..b6c77b4180 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -18,6 +18,7 @@ #define FIREBASE_AUTH_SRC_INCLUDE_FIREBASE_AUTH_H_ #include +#include #include "firebase/app.h" #include "firebase/auth/user.h" @@ -637,7 +638,7 @@ class Auth { void UseEmulator(const std::string host, uint32_t port); /// Get the emulator url - static std::string GetEmulatorUrl(); + std::string GetEmulatorUrl(); #endif // !defined(DOXYGEN) /// Gets the App this auth object is connected to. From 4d012dc0d5a9d29400ffb765e65af3f695c31618 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Fri, 21 Jul 2023 14:42:35 -0700 Subject: [PATCH 05/18] more lint warnings --- auth/src/android/auth_android.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index f91f3cbf7d..3c71d6a08c 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -53,7 +53,7 @@ using util::JniStringToString; X(RemoveIdTokenListener, "removeIdTokenListener", \ "(Lcom/google/firebase/auth/FirebaseAuth$IdTokenListener;)V"), \ X(SignOut, "signOut", "()V"), \ - X(UseEmulator, "useEmulator", "(Ljava/lang/String;I)V"),\ + X(UseEmulator, "useEmulator", "(Ljava/lang/String;I)V"), \ X(FetchSignInMethodsForEmail, "fetchSignInMethodsForEmail", \ "(Ljava/lang/String;)" \ "Lcom/google/android/gms/tasks/Task;"), \ From ce63a9ec21930dcb0c2c9a2f283686e183906f57 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Mon, 24 Jul 2023 13:51:47 -0700 Subject: [PATCH 06/18] code format --- auth/src/android/auth_android.cc | 7 +++---- auth/src/desktop/auth_desktop.cc | 3 ++- auth/src/desktop/rpcs/auth_request.h | 8 +++++--- auth/src/desktop/rpcs/create_auth_uri_request.cc | 2 ++ auth/src/desktop/rpcs/delete_account_request.cc | 5 +++-- auth/src/desktop/rpcs/get_account_info_request.cc | 2 ++ .../src/desktop/rpcs/get_oob_confirmation_code_request.cc | 2 ++ auth/src/desktop/rpcs/reset_password_request.cc | 2 ++ auth/src/desktop/rpcs/set_account_info_request.cc | 2 ++ auth/src/desktop/rpcs/sign_up_new_user_request.cc | 2 ++ auth/src/desktop/rpcs/verify_assertion_request.cc | 2 ++ auth/src/desktop/rpcs/verify_custom_token_request.cc | 2 ++ auth/src/desktop/rpcs/verify_password_request.cc | 2 ++ auth/src/include/firebase/auth.h | 7 ++++--- auth/src/ios/auth_ios.mm | 8 ++------ 15 files changed, 37 insertions(+), 19 deletions(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 3c71d6a08c..24f31fce0a 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -778,14 +778,13 @@ void Auth::SignOut() { void Auth::UseEmulator(const std::string host, uint32_t port) { JNIEnv* env = Env(auth_data_); jstring j_host = env->NewStringUTF(host.c_str()); - env->CallVoidMethod(AuthImpl(auth_data_), auth::GetMethodId(auth::kUseEmulator), j_host, port); + env->CallVoidMethod(AuthImpl(auth_data_), + auth::GetMethodId(auth::kUseEmulator), j_host, port); env->DeleteLocalRef(j_host); firebase::util::CheckAndClearJniExceptions(env); } -std::string Auth::GetEmulatorUrl() { - return ""; -} +std::string Auth::GetEmulatorUrl() { return ""; } Future Auth::SendPasswordResetEmail(const char* email) { ReferenceCountedFutureImpl& futures = auth_data_->future_impl; diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index e61801e642..32c1b2f185 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -657,7 +657,8 @@ std::string Auth::GetEmulatorUrl() { if (auth_impl->emulator_host.empty()) { return ""; } - return auth_impl->emulator_host + ":" + std::to_string(auth_impl->emulator_port) + "/"; + return auth_impl->emulator_host + ":" + + std::to_string(auth_impl->emulator_port) + "/"; } // AuthStateListener to wait for current_user_DEPRECATED() until persistent diff --git a/auth/src/desktop/rpcs/auth_request.h b/auth/src/desktop/rpcs/auth_request.h index e80e37a6b8..6e6c37ebea 100644 --- a/auth/src/desktop/rpcs/auth_request.h +++ b/auth/src/desktop/rpcs/auth_request.h @@ -34,11 +34,12 @@ const char* const kHttps = "https://"; const char* const kHttp = "http://"; -const char* const kServerURL = "www.googleapis.com/identitytoolkit/v3/relyingparty/"; +const char* const kServerURL = + "www.googleapis.com/identitytoolkit/v3/relyingparty/"; class AuthRequest : public firebase::rest::RequestJson { -public: + public: // App is a non-const parameter because this constructor might modify App's // internal HeartbeatController by logging or fetching heartbeats. AuthRequest(::firebase::App& app, const char* schema, bool deliver_heartbeat); @@ -49,7 +50,8 @@ class AuthRequest deliver_heartbeat) {} std::string GetUrl(); -private: + + private: std::string emulator_url; }; diff --git a/auth/src/desktop/rpcs/create_auth_uri_request.cc b/auth/src/desktop/rpcs/create_auth_uri_request.cc index f659483752..e0de666b47 100644 --- a/auth/src/desktop/rpcs/create_auth_uri_request.cc +++ b/auth/src/desktop/rpcs/create_auth_uri_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/create_auth_uri_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" #include "app/src/log.h" diff --git a/auth/src/desktop/rpcs/delete_account_request.cc b/auth/src/desktop/rpcs/delete_account_request.cc index 16b8829f66..359fb0d74c 100644 --- a/auth/src/desktop/rpcs/delete_account_request.cc +++ b/auth/src/desktop/rpcs/delete_account_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/delete_account_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" @@ -25,8 +27,7 @@ DeleteAccountRequest::DeleteAccountRequest(::firebase::App& app, : AuthRequest(app, request_resource_data, true) { FIREBASE_ASSERT_RETURN_VOID(api_key); - const char api_host[] = - "deleteAccount?key="; + const char api_host[] = "deleteAccount?key="; std::string url = GetUrl(); url.append(api_host); url.append(api_key); diff --git a/auth/src/desktop/rpcs/get_account_info_request.cc b/auth/src/desktop/rpcs/get_account_info_request.cc index 60b0c5ace1..e5f6cd4e78 100644 --- a/auth/src/desktop/rpcs/get_account_info_request.cc +++ b/auth/src/desktop/rpcs/get_account_info_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/get_account_info_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" diff --git a/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc b/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc index 18a5bc2685..3a1805884c 100644 --- a/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc +++ b/auth/src/desktop/rpcs/get_oob_confirmation_code_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/get_oob_confirmation_code_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" diff --git a/auth/src/desktop/rpcs/reset_password_request.cc b/auth/src/desktop/rpcs/reset_password_request.cc index 9777efd108..a8c64d1ffe 100644 --- a/auth/src/desktop/rpcs/reset_password_request.cc +++ b/auth/src/desktop/rpcs/reset_password_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/reset_password_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" #include "app/src/log.h" diff --git a/auth/src/desktop/rpcs/set_account_info_request.cc b/auth/src/desktop/rpcs/set_account_info_request.cc index 60a6f42101..618cbef902 100644 --- a/auth/src/desktop/rpcs/set_account_info_request.cc +++ b/auth/src/desktop/rpcs/set_account_info_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/set_account_info_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" diff --git a/auth/src/desktop/rpcs/sign_up_new_user_request.cc b/auth/src/desktop/rpcs/sign_up_new_user_request.cc index cd541b33ee..bd8d5ed099 100644 --- a/auth/src/desktop/rpcs/sign_up_new_user_request.cc +++ b/auth/src/desktop/rpcs/sign_up_new_user_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/sign_up_new_user_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" diff --git a/auth/src/desktop/rpcs/verify_assertion_request.cc b/auth/src/desktop/rpcs/verify_assertion_request.cc index 9b717b11fb..cca72d5787 100644 --- a/auth/src/desktop/rpcs/verify_assertion_request.cc +++ b/auth/src/desktop/rpcs/verify_assertion_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/verify_assertion_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" diff --git a/auth/src/desktop/rpcs/verify_custom_token_request.cc b/auth/src/desktop/rpcs/verify_custom_token_request.cc index 68ccc6942e..af53e6f3f2 100644 --- a/auth/src/desktop/rpcs/verify_custom_token_request.cc +++ b/auth/src/desktop/rpcs/verify_custom_token_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/verify_custom_token_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" #include "app/src/log.h" diff --git a/auth/src/desktop/rpcs/verify_password_request.cc b/auth/src/desktop/rpcs/verify_password_request.cc index 8197623829..db840685a3 100644 --- a/auth/src/desktop/rpcs/verify_password_request.cc +++ b/auth/src/desktop/rpcs/verify_password_request.cc @@ -14,6 +14,8 @@ #include "auth/src/desktop/rpcs/verify_password_request.h" +#include + #include "app/src/assert.h" #include "app/src/include/firebase/app.h" #include "app/src/log.h" diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index b6c77b4180..8ee3a91260 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -17,8 +17,8 @@ #ifndef FIREBASE_AUTH_SRC_INCLUDE_FIREBASE_AUTH_H_ #define FIREBASE_AUTH_SRC_INCLUDE_FIREBASE_AUTH_H_ -#include #include +#include #include "firebase/app.h" #include "firebase/auth/user.h" @@ -630,11 +630,12 @@ class Auth { /// to be called explicitly. void RemoveIdTokenListener(IdTokenListener* listener); #endif // not SWIG - + #if !defined(DOXYGEN) // Hidden from the public documentation for now - /// Configures Firebase Auth to connect to an emulated host instead of the remote backend. + /// Configures Firebase Auth to connect to an emulated host instead of the + /// remote backend. void UseEmulator(const std::string host, uint32_t port); /// Get the emulator url diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index 6b3257bf75..c0badf5deb 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -665,14 +665,10 @@ void SignInResultCallback(FIRAuthDataResult *_Nullable auth_result, NSError *_Nu void Auth::UseEmulator(const std::string host, uint32_t port) { NSUInteger ns_port = port; - [AuthImpl(auth_data_) useEmulatorWithHost:@(host.c_str()) - port:ns_port - ]; + [AuthImpl(auth_data_) useEmulatorWithHost:@(host.c_str()) port:ns_port]; } -std::string Auth::GetEmulatorUrl() { - return ""; -} +std::string Auth::GetEmulatorUrl() { return ""; } Future Auth::SendPasswordResetEmail(const char *email) { ReferenceCountedFutureImpl &futures = auth_data_->future_impl; From 1e1a9ce72b9ff96cc5ef5b912a2f876c6e4871d3 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Mon, 24 Jul 2023 17:44:38 -0700 Subject: [PATCH 07/18] use environment to decide using emulator or not --- auth/src/android/auth_android.cc | 40 +++++++++++++++++++-------- auth/src/desktop/auth_desktop.cc | 17 ------------ auth/src/desktop/auth_desktop.h | 4 +-- auth/src/desktop/rpcs/auth_request.cc | 31 ++++++++++++++++----- auth/src/desktop/rpcs/auth_request.h | 4 +++ auth/src/include/firebase/auth.h | 11 -------- auth/src/ios/auth_ios.mm | 30 +++++++++++++++----- 7 files changed, 81 insertions(+), 56 deletions(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 24f31fce0a..1ad61b095a 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -17,6 +17,8 @@ #include #include +#include + #include "app/src/assert.h" #include "app/src/embedded_file.h" #include "app/src/include/firebase/internal/mutex.h" @@ -186,6 +188,31 @@ void UpdateCurrentUser(AuthData* auth_data) { } } +const char* const kEmulatorLocalHost = "10.0.2.2"; +const char* const kEmulatorPort = "9099"; +void CheckEmulator(AuthData* auth_data) { + JNIEnv* env = Env(auth_data); + + // Use emulator as long as this env variable is set, regardless its value. + if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { + LogDebug("Using Firestore Prod for testing."); + return; + } + + // Use AUTH_EMULATOR_PORT if it is set to non empty string, + // otherwise use the default port. + uint32_t port = std::stoi(kEmulatorPort); + if (std::getenv("AUTH_EMULATOR_PORT") != nullptr) { + port = std::stoi(std::getenv("AUTH_EMULATOR_PORT")); + } + + jstring j_host = env->NewStringUTF(kEmulatorLocalHost); + env->CallVoidMethod(AuthImpl(auth_data), + auth::GetMethodId(auth::kUseEmulator), j_host, port); + env->DeleteLocalRef(j_host); + firebase::util::CheckAndClearJniExceptions(env); +} + // Release cached Java classes. static void ReleaseClasses(JNIEnv* env) { ReleaseAuthClasses(env); @@ -270,6 +297,8 @@ void Auth::InitPlatformAuth(AuthData* auth_data) { // Ensure our User is in-line with underlying API's user. // It's possible for a user to already be logged-in on start-up. UpdateCurrentUser(auth_data); + + CheckEmulator(auth_data); } void Auth::DestroyPlatformAuth(AuthData* auth_data) { @@ -775,17 +804,6 @@ void Auth::SignOut() { SetImplFromLocalRef(env, nullptr, &auth_data_->user_impl); } -void Auth::UseEmulator(const std::string host, uint32_t port) { - JNIEnv* env = Env(auth_data_); - jstring j_host = env->NewStringUTF(host.c_str()); - env->CallVoidMethod(AuthImpl(auth_data_), - auth::GetMethodId(auth::kUseEmulator), j_host, port); - env->DeleteLocalRef(j_host); - firebase::util::CheckAndClearJniExceptions(env); -} - -std::string Auth::GetEmulatorUrl() { return ""; } - Future Auth::SendPasswordResetEmail(const char* email) { ReferenceCountedFutureImpl& futures = auth_data_->future_impl; const auto handle = futures.SafeAlloc(kAuthFn_SendPasswordResetEmail); diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index 32c1b2f185..b0d5bcbd19 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -644,23 +644,6 @@ void Auth::SignOut() { AuthenticationResult::SignOut(auth_data_); } -void Auth::UseEmulator(const std::string host, uint32_t port) { - if (!auth_data_) return; - auto auth_impl = static_cast(auth_data_->auth_impl); - auth_impl->emulator_host = host; - auth_impl->emulator_port = port; -} - -std::string Auth::GetEmulatorUrl() { - if (!auth_data_) return ""; - auto auth_impl = static_cast(auth_data_->auth_impl); - if (auth_impl->emulator_host.empty()) { - return ""; - } - return auth_impl->emulator_host + ":" + - std::to_string(auth_impl->emulator_port) + "/"; -} - // AuthStateListener to wait for current_user_DEPRECATED() until persistent // cache load is finished. class CurrentUserBlockListener : public firebase::auth::AuthStateListener { diff --git a/auth/src/desktop/auth_desktop.h b/auth/src/desktop/auth_desktop.h index 9edd25532f..2d407cab16 100644 --- a/auth/src/desktop/auth_desktop.h +++ b/auth/src/desktop/auth_desktop.h @@ -16,6 +16,7 @@ #define FIREBASE_AUTH_SRC_DESKTOP_AUTH_DESKTOP_H_ #include +#include #include "app/rest/request.h" #include "app/src/scheduler.h" @@ -187,9 +188,6 @@ struct AuthImpl { // The current user language code. This can be set to the app’s current // language by calling SetLanguageCode. std::string language_code; - - std::string emulator_host; - int32_t emulator_port; }; // Constant, describing how often we automatically fetch a new auth token. diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index f47f403dbc..8d58bed209 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -23,14 +23,11 @@ #include "app/src/heartbeat/heartbeat_controller_desktop.h" #include "app/src/include/firebase/app.h" #include "app/src/include/firebase/internal/mutex.h" -#include "firebase/auth.h" #include "firebase/log.h" namespace firebase { namespace auth { -using ::firebase::auth::Auth; - // Key name for header when sending language code data. const char* kHeaderFirebaseLocale = "X-Firebase-Locale"; @@ -41,6 +38,8 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, // dependencies upon other parts of this library. This complication is due to // the way the tests are currently configured where each library has minimal // dependencies. + + CheckEmulator(); static std::string auth_user_agent; // NOLINT static std::string extended_auth_user_agent; // NOLINT static Mutex* user_agent_mutex = new Mutex(); @@ -79,10 +78,6 @@ AuthRequest::AuthRequest(::firebase::App& app, const char* schema, } } } - - // Get emulator url - Auth* auth = Auth::GetAuth(&app); - emulator_url = auth->GetEmulatorUrl(); } std::string AuthRequest::GetUrl() { @@ -100,5 +95,27 @@ std::string AuthRequest::GetUrl() { } } +void AuthRequest::CheckEmulator() { + if (!emulator_url.empty()) { + LogDebug("Emulator Url already set: %s", emulator_url.c_str()); + return; + } + // Use emulator as long as this env variable is set, regardless its value. + if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { + LogDebug("Using Firestore Prod for testing."); + return; + } + + emulator_url.append(kEmulatorLocalHost); + emulator_url.append(":"); + // Use AUTH_EMULATOR_PORT if it is set to non empty string, + // otherwise use the default port. + if (std::getenv("AUTH_EMULATOR_PORT") == nullptr) { + emulator_url.append(kEmulatorPort); + } else { + emulator_url.append(std::getenv("AUTH_EMULATOR_PORT")); + } +} + } // namespace auth } // namespace firebase diff --git a/auth/src/desktop/rpcs/auth_request.h b/auth/src/desktop/rpcs/auth_request.h index 6e6c37ebea..88835e946c 100644 --- a/auth/src/desktop/rpcs/auth_request.h +++ b/auth/src/desktop/rpcs/auth_request.h @@ -37,6 +37,9 @@ const char* const kHttp = "http://"; const char* const kServerURL = "www.googleapis.com/identitytoolkit/v3/relyingparty/"; +const char* const kEmulatorLocalHost = "localhost"; +const char* const kEmulatorPort = "9099"; + class AuthRequest : public firebase::rest::RequestJson { public: @@ -52,6 +55,7 @@ class AuthRequest std::string GetUrl(); private: + void CheckEmulator(); std::string emulator_url; }; diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index 8ee3a91260..f9c8bfbf36 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -631,17 +631,6 @@ class Auth { void RemoveIdTokenListener(IdTokenListener* listener); #endif // not SWIG -#if !defined(DOXYGEN) - // Hidden from the public documentation for now - - /// Configures Firebase Auth to connect to an emulated host instead of the - /// remote backend. - void UseEmulator(const std::string host, uint32_t port); - - /// Get the emulator url - std::string GetEmulatorUrl(); -#endif // !defined(DOXYGEN) - /// Gets the App this auth object is connected to. App& app(); diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index c0badf5deb..e9fa1bbd56 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -41,6 +41,9 @@ @implementation FIRCPPAuthListenerHandle namespace firebase { namespace auth { +const char *const kEmulatorLocalHost = "localhost"; +const char *const kEmulatorPort = "9099"; + static const struct { int ios_error; AuthError cpp_error; @@ -154,6 +157,24 @@ void UpdateCurrentUser(AuthData *auth_data) { SetUserImpl(auth_data, user); } +void CheckEmulator(AuthData *auth_data) { + // Use emulator as long as this env variable is set, regardless its value. + if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { + LogDebug("Using Firestore Prod for testing."); + return; + } + + // Use AUTH_EMULATOR_PORT if it is set to non empty string, + // otherwise use the default port. + uint32_t port = std::stoi(kEmulatorPort); + if (std::getenv("AUTH_EMULATOR_PORT") != nullptr) { + port = std::stoi(std::getenv("AUTH_EMULATOR_PORT")); + } + + NSUInteger ns_port = port; + [AuthImpl(auth_data_) useEmulatorWithHost:@(kEmulatorLocalHost) port:ns_port]; +} + // Platform-specific method to initialize AuthData. void Auth::InitPlatformAuth(AuthData *auth_data) { FIRCPPAuthListenerHandle *listener_cpp_handle = [[FIRCPPAuthListenerHandle alloc] init]; @@ -191,6 +212,8 @@ void UpdateCurrentUser(AuthData *auth_data) { // It's possible for the user to be signed-in at creation, if the user signed-in during a // previous run, for example. UpdateCurrentUser(auth_data); + + CheckEmulator(auth_data); } // Platform-specific method to destroy the wrapped Auth class. @@ -663,13 +686,6 @@ void SignInResultCallback(FIRAuthDataResult *_Nullable auth_result, NSError *_Nu SetUserImpl(auth_data_, NULL); } -void Auth::UseEmulator(const std::string host, uint32_t port) { - NSUInteger ns_port = port; - [AuthImpl(auth_data_) useEmulatorWithHost:@(host.c_str()) port:ns_port]; -} - -std::string Auth::GetEmulatorUrl() { return ""; } - Future Auth::SendPasswordResetEmail(const char *email) { ReferenceCountedFutureImpl &futures = auth_data_->future_impl; const auto handle = futures.SafeAlloc(kAuthFn_SendPasswordResetEmail); From 14ebb5d546968cdbd8d910bf36e659d851ecbb85 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Mon, 24 Jul 2023 20:08:40 -0700 Subject: [PATCH 08/18] fix a typo --- auth/src/ios/auth_ios.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index e9fa1bbd56..3609fd8602 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -172,7 +172,7 @@ void CheckEmulator(AuthData *auth_data) { } NSUInteger ns_port = port; - [AuthImpl(auth_data_) useEmulatorWithHost:@(kEmulatorLocalHost) port:ns_port]; + [AuthImpl(auth_data) useEmulatorWithHost:@(kEmulatorLocalHost) port:ns_port]; } // Platform-specific method to initialize AuthData. From c2e952ac73d37f7d9647eaa87679743497a0863a Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Fri, 28 Jul 2023 11:40:15 -0700 Subject: [PATCH 09/18] add readme entry for FirebaseApp.GetApps() --- release_build_files/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 6264e109c0..a5597f489d 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -629,6 +629,7 @@ code. ## Release Notes ### Upcoming Release - Changes + - General: Add FirebaseApp.GetApps(), to return the list of firebase app. - Firestore: Add support for disjunctions in queries (OR queries) ([#1335](https://github.com/firebase/firebase-cpp-sdk/pull/1335)). From 9e5c7a8a50acbf9c47b69deaf64614b3f2359f6d Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Sat, 5 Aug 2023 23:47:13 -0700 Subject: [PATCH 10/18] update for review comment --- auth/src/android/auth_android.cc | 2 +- auth/src/desktop/rpcs/auth_request.cc | 4 +--- auth/src/ios/auth_ios.mm | 2 +- release_build_files/readme.md | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 1ad61b095a..2f8ccda645 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -195,7 +195,7 @@ void CheckEmulator(AuthData* auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); + LogDebug("Using Auth Prod for testing."); return; } diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index 8d58bed209..c9af69f789 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -84,13 +84,11 @@ std::string AuthRequest::GetUrl() { if (emulator_url.empty()) { std::string url(kHttps); url += kServerURL; - LogDebug("AuthRequest::GetUrl(Prod): %s", url.c_str()); return url; } else { std::string url(kHttp); url += emulator_url; url += kServerURL; - LogDebug("AuthRequest::GetUrl(Emulator): %s", url.c_str()); return url; } } @@ -102,7 +100,7 @@ void AuthRequest::CheckEmulator() { } // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); + LogDebug("Using Auth Prod for testing."); return; } diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index 3609fd8602..e66af55dd6 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -160,7 +160,7 @@ void UpdateCurrentUser(AuthData *auth_data) { void CheckEmulator(AuthData *auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); + LogDebug("Using Auth Prod for testing."); return; } diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 583b82a89e..8b72c83ce1 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -630,7 +630,7 @@ code. ### Upcoming Release - Changes - - General: Add FirebaseApp.GetApps(), to return the list of firebase app. + - General: Add FirebaseApp.GetApps(), to return the list of firebase::App` instances. - Firestore: Add support for disjunctions in queries (OR queries) ([#1335](https://github.com/firebase/firebase-cpp-sdk/pull/1335)). From 79ee455dfc94564c51baa4caedce39bb7a9569f1 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Sat, 5 Aug 2023 23:49:27 -0700 Subject: [PATCH 11/18] add missing ` --- release_build_files/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 8b72c83ce1..5de2377d63 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -630,7 +630,7 @@ code. ### Upcoming Release - Changes - - General: Add FirebaseApp.GetApps(), to return the list of firebase::App` instances. + - General: Add FirebaseApp.GetApps(), to return the list of `firebase::App` instances. - Firestore: Add support for disjunctions in queries (OR queries) ([#1335](https://github.com/firebase/firebase-cpp-sdk/pull/1335)). From 472fbb31f1ae081aa54d4519faba24db7eed4081 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 14:55:18 -0700 Subject: [PATCH 12/18] make json request always do restrict json --- app/rest/request_json.h | 6 +++++- auth/src/android/auth_android.cc | 6 ++++-- auth/src/desktop/rpcs/auth_request.cc | 7 +++---- auth/src/ios/auth_ios.mm | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/rest/request_json.h b/app/rest/request_json.h index 9f37830b27..d33c61b9c6 100644 --- a/app/rest/request_json.h +++ b/app/rest/request_json.h @@ -24,6 +24,7 @@ #include "app/src/assert.h" #include "flatbuffers/idl.h" #include "flatbuffers/stl_emulation.h" +#include "app/src/logger.h" namespace firebase { namespace rest { @@ -41,6 +42,7 @@ class RequestJson : public Request { explicit RequestJson(const char* schema) : application_data_(new FbsTypeT()) { flatbuffers::IDLOptions fbs_options; fbs_options.skip_unexpected_fields_in_json = true; + fbs_options.strict_json = true; parser_.reset(new flatbuffers::Parser(fbs_options)); bool parse_status = parser_->Parse(schema); @@ -66,7 +68,9 @@ class RequestJson : public Request { bool generate_status = GenerateText(*parser_, builder.GetBufferPointer(), &json); FIREBASE_ASSERT_RETURN_VOID(generate_status); - + if (options().verbose) { + LogInfo("RequestJson body: %s", json.c_str()); + } set_post_fields(json.c_str()); } diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 1ad61b095a..4672dac8bd 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -195,10 +195,12 @@ void CheckEmulator(AuthData* auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); - return; + LogDebug("Using Auth Prod for testing."); + return; } + LogDebug("Using Auth Emulator for testing."); + // Use AUTH_EMULATOR_PORT if it is set to non empty string, // otherwise use the default port. uint32_t port = std::stoi(kEmulatorPort); diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index 8d58bed209..5855e55ded 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -84,13 +84,12 @@ std::string AuthRequest::GetUrl() { if (emulator_url.empty()) { std::string url(kHttps); url += kServerURL; - LogDebug("AuthRequest::GetUrl(Prod): %s", url.c_str()); return url; } else { std::string url(kHttp); url += emulator_url; + url += "/"; url += kServerURL; - LogDebug("AuthRequest::GetUrl(Emulator): %s", url.c_str()); return url; } } @@ -102,10 +101,10 @@ void AuthRequest::CheckEmulator() { } // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); + LogDebug("Using Auth Prod."); return; } - + LogDebug("Using Auth Emulator."); emulator_url.append(kEmulatorLocalHost); emulator_url.append(":"); // Use AUTH_EMULATOR_PORT if it is set to non empty string, diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index 3609fd8602..e66af55dd6 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -160,7 +160,7 @@ void UpdateCurrentUser(AuthData *auth_data) { void CheckEmulator(AuthData *auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Firestore Prod for testing."); + LogDebug("Using Auth Prod for testing."); return; } From 5dfcd361f0b2a08e9f5c0cfa34db383a3d1bd9b3 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 15:04:09 -0700 Subject: [PATCH 13/18] add readme info --- release_build_files/readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 788ce32f29..4a0f5c5146 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -627,6 +627,11 @@ workflow use only during the development of your app, not for publicly shipping code. ## Release Notes +### Next Release +- Changes + - Auth: Add Firebase Emulator support. Can set environment attribute + USE_AUTH_EMULATOR=yes and/or AUTH_EMULATOR_PORT(default 9099) to enable + conneting to local Firebase Auth Emulator. ### 11.4.0 - Changes - General (Android): Update to Firebase Android BoM version 32.2.2. From f3894bf30639c88751a814a7f90aa753bbca015c Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 15:09:10 -0700 Subject: [PATCH 14/18] prepare for review --- app/rest/request_json.h | 4 ---- auth/src/android/auth_android.cc | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/rest/request_json.h b/app/rest/request_json.h index d33c61b9c6..c79b53fcc8 100644 --- a/app/rest/request_json.h +++ b/app/rest/request_json.h @@ -24,7 +24,6 @@ #include "app/src/assert.h" #include "flatbuffers/idl.h" #include "flatbuffers/stl_emulation.h" -#include "app/src/logger.h" namespace firebase { namespace rest { @@ -68,9 +67,6 @@ class RequestJson : public Request { bool generate_status = GenerateText(*parser_, builder.GetBufferPointer(), &json); FIREBASE_ASSERT_RETURN_VOID(generate_status); - if (options().verbose) { - LogInfo("RequestJson body: %s", json.c_str()); - } set_post_fields(json.c_str()); } diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 4672dac8bd..2616e08bf9 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -195,8 +195,8 @@ void CheckEmulator(AuthData* auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Auth Prod for testing."); - return; + LogDebug("Using Auth Prod for testing."); + return; } LogDebug("Using Auth Emulator for testing."); From e6c7bdbf1b8422dc237a5240490ea93d3ffe65bf Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 15:10:56 -0700 Subject: [PATCH 15/18] some minor tweak --- app/rest/request_json.h | 1 + release_build_files/readme.md | 1 + 2 files changed, 2 insertions(+) diff --git a/app/rest/request_json.h b/app/rest/request_json.h index c79b53fcc8..f01c114f4f 100644 --- a/app/rest/request_json.h +++ b/app/rest/request_json.h @@ -67,6 +67,7 @@ class RequestJson : public Request { bool generate_status = GenerateText(*parser_, builder.GetBufferPointer(), &json); FIREBASE_ASSERT_RETURN_VOID(generate_status); + set_post_fields(json.c_str()); } diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 4a0f5c5146..8285c04de6 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -632,6 +632,7 @@ code. - Auth: Add Firebase Emulator support. Can set environment attribute USE_AUTH_EMULATOR=yes and/or AUTH_EMULATOR_PORT(default 9099) to enable conneting to local Firebase Auth Emulator. + ### 11.4.0 - Changes - General (Android): Update to Firebase Android BoM version 32.2.2. From e08a598b6ebdceef64513cb9c3d271e25852b3ae Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 15:11:48 -0700 Subject: [PATCH 16/18] code format --- app/rest/request_json.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/rest/request_json.h b/app/rest/request_json.h index f01c114f4f..964ffbd529 100644 --- a/app/rest/request_json.h +++ b/app/rest/request_json.h @@ -67,7 +67,7 @@ class RequestJson : public Request { bool generate_status = GenerateText(*parser_, builder.GetBufferPointer(), &json); FIREBASE_ASSERT_RETURN_VOID(generate_status); - + set_post_fields(json.c_str()); } From fee091a20a86eed172ad1936e52c3fcd8e284bc2 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Wed, 9 Aug 2023 15:53:34 -0700 Subject: [PATCH 17/18] update review comments --- auth/src/android/auth_android.cc | 4 ++-- auth/src/desktop/rpcs/auth_request.cc | 6 +++--- auth/src/ios/auth_ios.mm | 4 ++-- release_build_files/readme.md | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index 2616e08bf9..965db474a4 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -195,11 +195,11 @@ void CheckEmulator(AuthData* auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Auth Prod for testing."); + LogInfo("Using Auth Prod for testing."); return; } - LogDebug("Using Auth Emulator for testing."); + LogInfo("Using Auth Emulator for testing."); // Use AUTH_EMULATOR_PORT if it is set to non empty string, // otherwise use the default port. diff --git a/auth/src/desktop/rpcs/auth_request.cc b/auth/src/desktop/rpcs/auth_request.cc index 41a7388d1a..77fb7ea07c 100644 --- a/auth/src/desktop/rpcs/auth_request.cc +++ b/auth/src/desktop/rpcs/auth_request.cc @@ -96,15 +96,15 @@ std::string AuthRequest::GetUrl() { void AuthRequest::CheckEmulator() { if (!emulator_url.empty()) { - LogDebug("Emulator Url already set: %s", emulator_url.c_str()); + LogInfo("Emulator Url already set: %s", emulator_url.c_str()); return; } // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Auth Prod for testing."); + LogInfo("Using Auth Prod for testing."); return; } - LogDebug("Using Auth Emulator."); + LogInfo("Using Auth Emulator."); emulator_url.append(kEmulatorLocalHost); emulator_url.append(":"); // Use AUTH_EMULATOR_PORT if it is set to non empty string, diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index e66af55dd6..323a1c633a 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -160,10 +160,10 @@ void UpdateCurrentUser(AuthData *auth_data) { void CheckEmulator(AuthData *auth_data) { // Use emulator as long as this env variable is set, regardless its value. if (std::getenv("USE_AUTH_EMULATOR") == nullptr) { - LogDebug("Using Auth Prod for testing."); + LogInfo("Using Auth Prod for testing."); return; } - + LogInfo("Using Auth Emulator."); // Use AUTH_EMULATOR_PORT if it is set to non empty string, // otherwise use the default port. uint32_t port = std::stoi(kEmulatorPort); diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 8285c04de6..9b03e10cdb 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -629,9 +629,9 @@ code. ## Release Notes ### Next Release - Changes - - Auth: Add Firebase Emulator support. Can set environment attribute - USE_AUTH_EMULATOR=yes and/or AUTH_EMULATOR_PORT(default 9099) to enable - conneting to local Firebase Auth Emulator. + - Auth: Add Firebase Auth Emulator support. Set the environment variable + USE_AUTH_EMULATOR=yes (and optionally AUTH_EMULATOR_PORT, default 9099) + to connect to the local Firebase Auth Emulator. ### 11.4.0 - Changes From ac867c1de52cfd2e21c2e700fad5778097d45ab7 Mon Sep 17 00:00:00 2001 From: Cynthia Jiang Date: Thu, 10 Aug 2023 14:25:23 -0700 Subject: [PATCH 18/18] update the unit test after request json change --- app/rest/tests/request_json_test.cc | 4 +- .../desktop/rpcs/create_auth_uri_test.cc | 4 +- .../tests/desktop/rpcs/delete_account_test.cc | 2 +- .../desktop/rpcs/get_account_info_test.cc | 2 +- .../rpcs/get_oob_confirmation_code_test.cc | 8 ++-- .../tests/desktop/rpcs/reset_password_test.cc | 4 +- auth/tests/desktop/rpcs/secure_token_test.cc | 4 +- .../desktop/rpcs/set_account_info_test.cc | 46 +++++++++---------- .../desktop/rpcs/sign_up_new_user_test.cc | 10 ++-- .../desktop/rpcs/verify_custom_token_test.cc | 4 +- .../desktop/rpcs/verify_password_test.cc | 6 +-- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/app/rest/tests/request_json_test.cc b/app/rest/tests/request_json_test.cc index 052549c493..058c925c6d 100644 --- a/app/rest/tests/request_json_test.cc +++ b/app/rest/tests/request_json_test.cc @@ -64,8 +64,8 @@ TEST(RequestJsonTest, UpdatePostFields) { request.set_token("abc"); EXPECT_EQ( "{\n" - " token: \"abc\",\n" - " number: 123\n" + " \"token\": \"abc\",\n" + " \"number\": 123\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/create_auth_uri_test.cc b/auth/tests/desktop/rpcs/create_auth_uri_test.cc index e46b5bb49a..91a393f441 100644 --- a/auth/tests/desktop/rpcs/create_auth_uri_test.cc +++ b/auth/tests/desktop/rpcs/create_auth_uri_test.cc @@ -36,8 +36,8 @@ TEST(CreateAuthUriTest, TestCreateAuthUriRequest) { request.options().url); EXPECT_EQ( "{\n" - " identifier: \"email\",\n" - " continueUri: \"http://localhost\"\n" + " \"identifier\": \"email\",\n" + " \"continueUri\": \"http://localhost\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/delete_account_test.cc b/auth/tests/desktop/rpcs/delete_account_test.cc index d24c72be6b..e6d8a98bcf 100644 --- a/auth/tests/desktop/rpcs/delete_account_test.cc +++ b/auth/tests/desktop/rpcs/delete_account_test.cc @@ -37,7 +37,7 @@ TEST(DeleteAccountTest, TestDeleteAccountRequest) { request.options().url); EXPECT_EQ( "{\n" - " idToken: \"token\"\n" + " \"idToken\": \"token\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/get_account_info_test.cc b/auth/tests/desktop/rpcs/get_account_info_test.cc index 4822bd2e9c..368b079b93 100644 --- a/auth/tests/desktop/rpcs/get_account_info_test.cc +++ b/auth/tests/desktop/rpcs/get_account_info_test.cc @@ -36,7 +36,7 @@ TEST(GetAccountInfoTest, TestGetAccountInfoRequest) { request.options().url); EXPECT_EQ( "{\n" - " idToken: \"token\"\n" + " \"idToken\": \"token\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/get_oob_confirmation_code_test.cc b/auth/tests/desktop/rpcs/get_oob_confirmation_code_test.cc index c6a20fd7e1..cf9717853d 100644 --- a/auth/tests/desktop/rpcs/get_oob_confirmation_code_test.cc +++ b/auth/tests/desktop/rpcs/get_oob_confirmation_code_test.cc @@ -40,8 +40,8 @@ TEST(GetOobConfirmationCodeTest, SendVerifyEmailRequest) { request->options().url); EXPECT_EQ( "{\n" - " idToken: \"token\",\n" - " requestType: \"VERIFY_EMAIL\"\n" + " \"idToken\": \"token\",\n" + " \"requestType\": \"VERIFY_EMAIL\"\n" "}\n", request->options().post_fields); } @@ -56,8 +56,8 @@ TEST(GetOobConfirmationCodeTest, SendPasswordResetEmailRequest) { request->options().url); EXPECT_EQ( "{\n" - " email: \"email\",\n" - " requestType: \"PASSWORD_RESET\"\n" + " \"email\": \"email\",\n" + " \"requestType\": \"PASSWORD_RESET\"\n" "}\n", request->options().post_fields); } diff --git a/auth/tests/desktop/rpcs/reset_password_test.cc b/auth/tests/desktop/rpcs/reset_password_test.cc index 480168b9d3..2901ca596e 100644 --- a/auth/tests/desktop/rpcs/reset_password_test.cc +++ b/auth/tests/desktop/rpcs/reset_password_test.cc @@ -35,8 +35,8 @@ TEST(ResetPasswordTest, TestResetPasswordRequest) { request.options().url); EXPECT_EQ( "{\n" - " oobCode: \"oob\",\n" - " newPassword: \"password\"\n" + " \"oobCode\": \"oob\",\n" + " \"newPassword\": \"password\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/secure_token_test.cc b/auth/tests/desktop/rpcs/secure_token_test.cc index 217b148d8a..ff6fd589c4 100644 --- a/auth/tests/desktop/rpcs/secure_token_test.cc +++ b/auth/tests/desktop/rpcs/secure_token_test.cc @@ -34,8 +34,8 @@ TEST(SecureTokenTest, TestSetRefreshRequest) { request.options().url); EXPECT_EQ( "{\n" - " grantType: \"refresh_token\",\n" - " refreshToken: \"token123\"\n" + " \"grantType\": \"refresh_token\",\n" + " \"refreshToken\": \"token123\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/set_account_info_test.cc b/auth/tests/desktop/rpcs/set_account_info_test.cc index 0a591ea44f..ce38726238 100644 --- a/auth/tests/desktop/rpcs/set_account_info_test.cc +++ b/auth/tests/desktop/rpcs/set_account_info_test.cc @@ -41,9 +41,9 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_UpdateEmail) { request->options().url); EXPECT_EQ( "{\n" - " email: \"fakeemail\",\n" - " returnSecureToken: true,\n" - " idToken: \"token\"\n" + " \"email\": \"fakeemail\",\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\"\n" "}\n", request->options().post_fields); } @@ -60,9 +60,9 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_UpdatePassword) { request->options().url); EXPECT_EQ( "{\n" - " password: \"fakepassword\",\n" - " returnSecureToken: true,\n" - " idToken: \"token\"\n" + " \"password\": \"fakepassword\",\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\"\n" "}\n", request->options().post_fields); } @@ -79,10 +79,10 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_UpdateProfile_Full) { request->options().url); EXPECT_EQ( "{\n" - " displayName: \"New Name\",\n" - " returnSecureToken: true,\n" - " idToken: \"token\",\n" - " photoUrl: \"new_url\"\n" + " \"displayName\": \"New Name\",\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\",\n" + " \"photoUrl\": \"new_url\"\n" "}\n", request->options().post_fields); } @@ -99,9 +99,9 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_UpdateProfile_Partial) { request->options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true,\n" - " idToken: \"token\",\n" - " photoUrl: \"new_url\"\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\",\n" + " \"photoUrl\": \"new_url\"\n" "}\n", request->options().post_fields); } @@ -117,9 +117,9 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_UpdateProfile_DeleteFields) { request->options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true,\n" - " idToken: \"token\",\n" - " deleteAttribute: [\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\",\n" + " \"deleteAttribute\": [\n" " \"DISPLAY_NAME\",\n" " \"PHOTO_URL\"\n" " ]\n" @@ -140,10 +140,10 @@ TEST(SetAccountInfoTest, request->options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true,\n" - " idToken: \"token\",\n" - " photoUrl: \"new_url\",\n" - " deleteAttribute: [\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\",\n" + " \"photoUrl\": \"new_url\",\n" + " \"deleteAttribute\": [\n" " \"DISPLAY_NAME\"\n" " ]\n" "}\n", @@ -162,9 +162,9 @@ TEST(SetAccountInfoTest, TestSetAccountInfoRequest_Unlink) { request->options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true,\n" - " idToken: \"token\",\n" - " deleteProvider: [\n" + " \"returnSecureToken\": true,\n" + " \"idToken\": \"token\",\n" + " \"deleteProvider\": [\n" " \"fakeprovider\"\n" " ]\n" "}\n", diff --git a/auth/tests/desktop/rpcs/sign_up_new_user_test.cc b/auth/tests/desktop/rpcs/sign_up_new_user_test.cc index 870deb0fd5..a7b3374bce 100644 --- a/auth/tests/desktop/rpcs/sign_up_new_user_test.cc +++ b/auth/tests/desktop/rpcs/sign_up_new_user_test.cc @@ -35,7 +35,7 @@ TEST(SignUpNewUserTest, TestAnonymousSignInRequest) { request.options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true\n" + " \"returnSecureToken\": true\n" "}\n", request.options().post_fields); } @@ -50,10 +50,10 @@ TEST(SignUpNewUserTest, TestEmailPasswordSignInRequest) { request.options().url); EXPECT_EQ( "{\n" - " email: \"e@mail\",\n" - " password: \"pwd\",\n" - " displayName: \"rabbit\",\n" - " returnSecureToken: true\n" + " \"email\": \"e@mail\",\n" + " \"password\": \"pwd\",\n" + " \"displayName\": \"rabbit\",\n" + " \"returnSecureToken\": true\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/verify_custom_token_test.cc b/auth/tests/desktop/rpcs/verify_custom_token_test.cc index 49241c9ef0..7d4341d37b 100644 --- a/auth/tests/desktop/rpcs/verify_custom_token_test.cc +++ b/auth/tests/desktop/rpcs/verify_custom_token_test.cc @@ -36,8 +36,8 @@ TEST(VerifyCustomTokenTest, TestVerifyCustomTokenRequest) { request.options().url); EXPECT_EQ( "{\n" - " returnSecureToken: true,\n" - " token: \"token123\"\n" + " \"returnSecureToken\": true,\n" + " \"token\": \"token123\"\n" "}\n", request.options().post_fields); } diff --git a/auth/tests/desktop/rpcs/verify_password_test.cc b/auth/tests/desktop/rpcs/verify_password_test.cc index 8fe1b1ee25..0383245467 100644 --- a/auth/tests/desktop/rpcs/verify_password_test.cc +++ b/auth/tests/desktop/rpcs/verify_password_test.cc @@ -35,9 +35,9 @@ TEST(VerifyPasswordTest, TestVerifyPasswordRequest) { request.options().url); EXPECT_EQ( "{\n" - " email: \"abc@email\",\n" - " password: \"pwd\",\n" - " returnSecureToken: true\n" + " \"email\": \"abc@email\",\n" + " \"password\": \"pwd\",\n" + " \"returnSecureToken\": true\n" "}\n", request.options().post_fields); }