0

[google-apis] Stop re-including google_api_keys-inc.cc in tests

Instead of including google_api_keys-inc.cc multiple times in the tests,
we can now construct ApiKeyCache instance in a test and re-assign the
global pointer to it.

Bug: 367764868
Change-Id: I7a229aed2357de4e61a318fd7da9a0b63020697c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5878080
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1358788}
This commit is contained in:
Alex Ilin
2024-09-23 14:09:40 +00:00
committed by Chromium LUCI CQ
parent df6c719341
commit c8f909854f
7 changed files with 241 additions and 281 deletions

@ -163,7 +163,7 @@ component("google_apis") {
"gaia/oauth_multilogin_result.h",
"gaia/oauth_request_signer.cc",
"gaia/oauth_request_signer.h",
"google_api_keys-inc.cc",
"google_api_keys.cc",
"google_api_keys.h",
"google_api_keys_utils.cc",
"google_api_keys_utils.h",

@ -7,8 +7,12 @@
#pragma allow_unsafe_buffers
#endif
#include "google_apis/google_api_keys.h"
#include <string>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/version_info/channel.h"
#include "build/branding_buildflags.h"
@ -17,7 +21,6 @@
#include "google_apis/api_key_cache.h"
#include "google_apis/buildflags.h"
#include "google_apis/default_api_keys.h"
#include "google_apis/google_api_keys.h"
#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#include "google_apis/internal/google_chrome_api_keys.h"
@ -26,38 +29,42 @@
namespace google_apis {
const char kAPIKeysDevelopersHowToURL[] =
"https://www.chromium.org/developers/how-tos/api-keys";
std::atomic<::google_apis::ApiKeyCache*> g_api_key_cache_instance = nullptr;
namespace {
// Import `GetDefaultApiKeysFromDefinedValues()` definition based on the current
// preprocessor directives.
#include "google_apis/default_api_keys-inc.cc"
::google_apis::ApiKeyCache& CreateLeakyApiKeyCacheInstance() {
static ::base::NoDestructor<::google_apis::ApiKeyCache> instance(
std::atomic<ApiKeyCache*> g_api_key_cache_instance = nullptr;
ApiKeyCache& CreateLeakyApiKeyCacheInstance() {
static base::NoDestructor<ApiKeyCache> instance(
GetDefaultApiKeysFromDefinedValues());
// `g_api_key_cache_instance` is always assigned to the same value but it
// might happen simultaneously from multiple threads, so use atomics.
::google_apis::ApiKeyCache* expected = nullptr;
ApiKeyCache* expected = nullptr;
g_api_key_cache_instance.compare_exchange_strong(expected, instance.get());
return *instance.get();
}
::google_apis::ApiKeyCache& GetApiKeyCacheInstance() {
ApiKeyCache& GetApiKeyCacheInstance() {
if (!g_api_key_cache_instance) {
return CreateLeakyApiKeyCacheInstance();
}
return *g_api_key_cache_instance;
}
} // namespace
const char kAPIKeysDevelopersHowToURL[] =
"https://www.chromium.org/developers/how-tos/api-keys";
bool HasAPIKeyConfigured() {
return GetApiKeyCacheInstance().HasAPIKeyConfigured();
}
const std::string& GetAPIKey(::version_info::Channel channel) {
return channel == ::version_info::Channel::STABLE
const std::string& GetAPIKey(version_info::Channel channel) {
return channel == version_info::Channel::STABLE
? GetAPIKey()
: GetApiKeyCacheInstance().api_key_non_stable();
}
@ -112,21 +119,20 @@ bool HasOAuthClientConfigured() {
return GetApiKeyCacheInstance().HasOAuthClientConfigured();
}
const std::string& GetOAuth2ClientID(::google_apis::OAuth2Client client) {
const std::string& GetOAuth2ClientID(OAuth2Client client) {
return GetApiKeyCacheInstance().GetClientID(client);
}
const std::string& GetOAuth2ClientSecret(::google_apis::OAuth2Client client) {
const std::string& GetOAuth2ClientSecret(OAuth2Client client) {
return GetApiKeyCacheInstance().GetClientSecret(client);
}
#if BUILDFLAG(IS_IOS)
void SetOAuth2ClientID(::google_apis::OAuth2Client client,
const std::string& client_id) {
void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id) {
GetApiKeyCacheInstance().SetClientID(client, client_id);
}
void SetOAuth2ClientSecret(::google_apis::OAuth2Client client,
void SetOAuth2ClientSecret(OAuth2Client client,
const std::string& client_secret) {
GetApiKeyCacheInstance().SetClientSecret(client, client_secret);
}
@ -140,4 +146,15 @@ bool IsGoogleChromeAPIKeyUsed() {
#endif
}
base::ScopedClosureRunner SetScopedApiKeyCacheForTesting(
ApiKeyCache* api_key_cache) {
ApiKeyCache* previous_value =
g_api_key_cache_instance.exchange(api_key_cache);
return base::ScopedClosureRunner(base::BindOnce(
[](ApiKeyCache* previous_value) {
g_api_key_cache_instance = previous_value;
},
previous_value));
}
} // namespace google_apis

@ -5,11 +5,10 @@
#ifndef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#define GOOGLE_APIS_GOOGLE_API_KEYS_H_
// If you add more includes to this file, you also need to add them to
// google_api_keys_unittest.cc.
#include <string>
#include "base/component_export.h"
#include "base/functional/callback_helpers.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "google_apis/buildflags.h"
@ -66,6 +65,8 @@ enum class Channel;
namespace google_apis {
class ApiKeyCache;
COMPONENT_EXPORT(GOOGLE_APIS) extern const char kAPIKeysDevelopersHowToURL[];
// Returns true if no dummy API key is set.
@ -168,6 +169,12 @@ void SetOAuth2ClientSecret(OAuth2Client client,
// Google Chrome.
COMPONENT_EXPORT(GOOGLE_APIS) bool IsGoogleChromeAPIKeyUsed();
// Sets a testing global instance of `ApiKeyCache` and returns a scoped object
// that will restore the previous value once destroyed.
COMPONENT_EXPORT(GOOGLE_APIS)
base::ScopedClosureRunner
SetScopedApiKeyCacheForTesting(ApiKeyCache* api_key_cache);
} // namespace google_apis
#endif // GOOGLE_APIS_GOOGLE_API_KEYS_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Unit tests for implementation of google_api_keys namespace.
// Unit tests for implementation of google_apis/google_api_keys.h.
//
// Because the file deals with a lot of preprocessor defines and
// optionally includes an internal header, the way we test is by
@ -26,28 +26,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#import "third_party/ocmock/OCMock/OCMock.h"
// We need to include everything included by google_api_keys.cc once
// at global scope so that things like STL and classes from base don't
// get defined when we re-include the google_api_keys.cc file
// below. We used to include that file in its entirety here, but that
// can cause problems if the linker decides the version of symbols
// from that file included here is the "right" version.
#include <stddef.h>
#include <string>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/stringize_macros.h"
#include "base/version_info/channel.h"
#include "google_apis/gaia/gaia_config.h"
#include "google_apis/google_api_keys_mac.h"
#include "google_apis/google_api_keys_utils.h"
// After this test, for the remainder of this compilation unit, we
// need official keys to not be used.
// We need official keys to not be used.
#undef BUILDFLAG_INTERNAL_CHROMIUM_BRANDING
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING
#define BUILDFLAG_INTERNAL_CHROMIUM_BRANDING() (1)
@ -59,7 +38,7 @@
namespace override_some_keys_info_plist {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -78,16 +57,11 @@ namespace override_some_keys_info_plist {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_some_keys_info_plist
TEST_F(GoogleAPIKeysTest, OverrideSomeKeysUsingInfoPlist) {
namespace testcase = override_some_keys_info_plist::google_apis;
id mock_bundle = [OCMockObject mockForClass:[NSBundle class]];
[[[mock_bundle stub] andReturn:@"plist-API_KEY"]
objectForInfoDictionaryKey:@"GOOGLE_API_KEY"];
@ -96,24 +70,30 @@ TEST_F(GoogleAPIKeysTest, OverrideSomeKeysUsingInfoPlist) {
[[[mock_bundle stub] andReturn:nil] objectForInfoDictionaryKey:[OCMArg any]];
base::apple::SetOverrideFrameworkBundle(mock_bundle);
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
google_apis::ApiKeyCache api_key_cache(
override_some_keys_info_plist::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
// Once the keys have been configured, the bundle isn't used anymore.
base::apple::SetOverrideFrameworkBundle(nil);
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_EQ("plist-API_KEY", api_key);
EXPECT_EQ("plist-ID_MAIN", id_main);
@ -129,7 +109,7 @@ TEST_F(GoogleAPIKeysTest, OverrideSomeKeysUsingInfoPlist) {
namespace override_apikey_from_plist_with_feature {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -148,42 +128,32 @@ namespace override_apikey_from_plist_with_feature {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_apikey_from_plist_with_feature
TEST_F(GoogleAPIKeysTest, OverrideAPIKeyFromPlistWithFeature) {
namespace testcase = override_apikey_from_plist_with_feature::google_apis;
id mock_bundle = [OCMockObject mockForClass:[NSBundle class]];
[[[mock_bundle stub] andReturn:@"plist-API_KEY"]
objectForInfoDictionaryKey:@"GOOGLE_API_KEY"];
[[[mock_bundle stub] andReturn:nil] objectForInfoDictionaryKey:[OCMArg any]];
base::apple::SetOverrideFrameworkBundle(mock_bundle);
static int test_iteration = 0;
test_iteration++;
// Use base::test::ScopedFeatureList::InitFromCommandLine() to enable the
// feature to avoid exposing the feature flag in the header file and exposing
// it as a component exported symbol.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitFromCommandLine(
"OverrideAPIKey<foo.bar:api_key/feature-API_KEY", "");
scoped_feature_list.InitAndEnableFeatureWithParameters(
google_apis::kOverrideAPIKeyFeature, {{"api_key", "feature-API_KEY"}});
base::HistogramTester tester;
EXPECT_EQ("feature-API_KEY", testcase::GetAPIKey());
// |g_api_key_cache| is loaded only once, so the histogram is only logged
// during the first iteration of the test.
if (test_iteration == 1) {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 1, 1);
} else {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 0, 0);
}
google_apis::ApiKeyCache api_key_cache(
override_apikey_from_plist_with_feature::
GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_EQ("feature-API_KEY", google_apis::GetAPIKey());
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 1, 1);
// Once the keys have been configured, the bundle isn't used anymore.
base::apple::SetOverrideFrameworkBundle(nil);

@ -7,7 +7,7 @@
#pragma allow_unsafe_buffers
#endif
// Unit tests for implementation of google_api_keys namespace.
// Unit tests for functions in google_apis/google_api_keys.h.
//
// Because the file deals with a lot of preprocessor defines and
// optionally includes an internal header, the way we test is by
@ -30,35 +30,8 @@
#include "google_apis/gaia/gaia_switches.h"
#include "google_apis/google_api_keys.h"
#include "google_apis/google_api_keys_utils.h"
// The Win builders fail (with a linker crash) when trying to link unit_tests,
// and the Android builders complain about multiply defined symbols (likely they
// don't do name decoration as well as the Mac and Linux linkers). Building and
// running on other platforms should provide plenty of coverage since there are
// no platform-specific bits in this code.
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN)
// We need to include everything included by google_api_keys.cc once
// at global scope so that things like STL and classes from base don't
// get defined when we re-include the google_api_keys.cc file
// below. We used to include that file in its entirety here, but that
// can cause problems if the linker decides the version of symbols
// from that file included here is the "right" version.
#include <stddef.h>
#include <string>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/stringize_macros.h"
#include "base/version_info/channel.h"
#if BUILDFLAG(IS_APPLE)
#include "google_apis/google_api_keys_mac.h"
#endif
GoogleAPIKeysTest::GoogleAPIKeysTest() : env_(base::Environment::Create()) {
static_assert(9 == 3 + 2 * google_apis::CLIENT_NUM_ITEMS,
"Unexpected number of key entries.");
@ -120,7 +93,7 @@ base::FilePath GetTestFilePath(const std::string& relative_path) {
namespace official_build {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -139,28 +112,37 @@ namespace official_build {
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#undef GOOGLE_APIS_INTERNAL_METRICS_SIGNING_KEY_H_
#include "google_apis/internal/google_chrome_api_keys.h"
#include "google_apis/internal/metrics_signing_key.h"
// This file must be included after the internal files defining official keys.
#include "google_apis/default_api_keys-inc.cc"
} // namespace official_build
TEST_F(GoogleAPIKeysTest, OfficialKeys) {
namespace testcase = official_build::google_apis;
google_apis::ApiKeyCache api_key_cache(
official_build::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_NE(0u, api_key.size());
EXPECT_NE(DUMMY_API_TOKEN, api_key);
@ -192,8 +174,7 @@ TEST_F(GoogleAPIKeysTest, OfficialKeys) {
EXPECT_NE(DUMMY_API_TOKEN, secret_remoting_host);
EXPECT_NE(kDummyToken, secret_remoting_host);
}
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) ||
// defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#endif // defined(USE_OFFICIAL_GOOGLE_API_KEYS)
// After this test, for the remainder of this compilation unit, we
// need official keys to not be used.
@ -207,7 +188,7 @@ TEST_F(GoogleAPIKeysTest, OfficialKeys) {
namespace default_keys {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -218,32 +199,32 @@ namespace default_keys {
#undef GOOGLE_DEFAULT_CLIENT_ID
#undef GOOGLE_DEFAULT_CLIENT_SECRET
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#undef GOOGLE_APIS_INTERNAL_METRICS_SIGNING_KEY_H_
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace default_keys
TEST_F(GoogleAPIKeysTest, DefaultKeys) {
namespace testcase = default_keys::google_apis;
google_apis::ApiKeyCache api_key_cache(
default_keys::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_FALSE(testcase::HasAPIKeyConfigured());
EXPECT_FALSE(testcase::HasOAuthClientConfigured());
EXPECT_FALSE(google_apis::HasAPIKeyConfigured());
EXPECT_FALSE(google_apis::HasOAuthClientConfigured());
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_EQ(kDummyToken, api_key);
EXPECT_EQ(kDummyToken, id_main);
@ -258,7 +239,7 @@ TEST_F(GoogleAPIKeysTest, DefaultKeys) {
namespace override_some_keys {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -272,31 +253,32 @@ namespace override_some_keys {
#define GOOGLE_API_KEY "API_KEY override"
#define GOOGLE_CLIENT_ID_REMOTING "CLIENT_ID_REMOTING override"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_some_keys
TEST_F(GoogleAPIKeysTest, OverrideSomeKeys) {
namespace testcase = override_some_keys::google_apis;
google_apis::ApiKeyCache api_key_cache(
override_some_keys::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_FALSE(testcase::HasOAuthClientConfigured());
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_FALSE(google_apis::HasOAuthClientConfigured());
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_EQ("API_KEY override", api_key);
EXPECT_EQ(kDummyToken, id_main);
@ -311,7 +293,7 @@ TEST_F(GoogleAPIKeysTest, OverrideSomeKeys) {
namespace override_all_keys {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -330,31 +312,32 @@ namespace override_all_keys {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_all_keys
TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
namespace testcase = override_all_keys::google_apis;
google_apis::ApiKeyCache api_key_cache(
override_all_keys::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_EQ("API_KEY", api_key);
EXPECT_EQ("ID_MAIN", id_main);
@ -369,7 +352,7 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
namespace override_api_key_via_feature_without_param {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -382,42 +365,32 @@ namespace override_api_key_via_feature_without_param {
#define GOOGLE_API_KEY "API_KEY"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_api_key_via_feature_without_param
TEST_F(GoogleAPIKeysTest, OverrideApiKeyViaFeatureWithNoParamIsIgnored) {
namespace testcase = override_api_key_via_feature_without_param::google_apis;
static int test_iteration = 0;
test_iteration++;
// Use base::test::ScopedFeatureList::InitFromCommandLine() to enable the
// feature to avoid exposing the feature flag in the header file and exposing
// it as a component exported symbol.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitFromCommandLine("OverrideAPIKey", "");
scoped_feature_list.InitAndEnableFeature(google_apis::kOverrideAPIKeyFeature);
base::HistogramTester tester;
EXPECT_EQ("API_KEY", testcase::GetAPIKey());
// |g_api_key_cache| is loaded only once, so the histogram is only logged
// during the first iteration of the test.
if (test_iteration == 1) {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 0, 1);
} else {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 0, 0);
}
google_apis::ApiKeyCache api_key_cache(
override_api_key_via_feature_without_param::
GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_EQ("API_KEY", google_apis::GetAPIKey());
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 0, 1);
}
// Override API key via an experiment feature.
namespace override_api_key_via_feature {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -430,34 +403,24 @@ namespace override_api_key_via_feature {
#define GOOGLE_API_KEY "API_KEY"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_api_key_via_feature
TEST_F(GoogleAPIKeysTest, OverrideApiKeyViaFeature) {
namespace testcase = override_api_key_via_feature::google_apis;
static int test_iteration = 0;
test_iteration++;
// Use base::test::ScopedFeatureList::InitFromCommandLine() to enable the
// feature to avoid exposing the feature flag in the header file and exposing
// it as a component exported symbol.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitFromCommandLine(
"OverrideAPIKey<foo.bar:api_key/API_KEY2", "");
scoped_feature_list.InitAndEnableFeatureWithParameters(
google_apis::kOverrideAPIKeyFeature, {{"api_key", "API_KEY2"}});
base::HistogramTester tester;
EXPECT_EQ("API_KEY2", testcase::GetAPIKey());
// |g_api_key_cache| is loaded only once, so the histogram is only logged
// during the first iteration of the test.
if (test_iteration == 1) {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 1, 1);
} else {
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 0, 0);
}
google_apis::ApiKeyCache api_key_cache(
override_api_key_via_feature::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_EQ("API_KEY2", google_apis::GetAPIKey());
tester.ExpectUniqueSample("Signin.APIKeyMatchesFeatureOnStartup", 1, 1);
}
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
@ -467,7 +430,7 @@ TEST_F(GoogleAPIKeysTest, OverrideApiKeyViaFeature) {
namespace override_all_keys_env {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -486,16 +449,11 @@ namespace override_all_keys_env {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_all_keys_env
TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
namespace testcase = override_all_keys_env::google_apis;
std::unique_ptr<base::Environment> env(base::Environment::Create());
env->SetVar("GOOGLE_API_KEY", "env-API_KEY");
env->SetVar("GOOGLE_CLIENT_ID_MAIN", "env-ID_MAIN");
@ -505,23 +463,29 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
env->SetVar("GOOGLE_CLIENT_SECRET_REMOTING", "env-SECRET_REMOTING");
env->SetVar("GOOGLE_CLIENT_SECRET_REMOTING_HOST", "env-SECRET_REMOTING_HOST");
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
google_apis::ApiKeyCache api_key_cache(
override_all_keys_env::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
// It's important that the first call to Get() only happen after the
// environment variables have been set.
std::string api_key = testcase::GetAPIKey();
std::string id_main = testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string api_key = google_apis::GetAPIKey();
std::string id_main =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
std::string secret_main =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
std::string id_remoting =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING);
std::string secret_remoting =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING);
std::string id_remoting_host =
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST);
std::string secret_remoting_host =
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST);
EXPECT_EQ("env-API_KEY", api_key);
EXPECT_EQ("env-ID_MAIN", id_main);
@ -540,7 +504,7 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
namespace override_all_keys_setters {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -559,56 +523,56 @@ namespace override_all_keys_setters {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_all_keys_setters
TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingSetters) {
namespace testcase = override_all_keys_setters::google_apis;
google_apis::ApiKeyCache api_key_cache(
override_all_keys_setters::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
std::string api_key("setter-API_KEY");
testcase::SetAPIKey(api_key);
google_apis::SetAPIKey(api_key);
std::string id_main("setter-ID_MAIN");
std::string secret_main("setter-SECRET_MAIN");
testcase::SetOAuth2ClientID(google_apis::CLIENT_MAIN, id_main);
testcase::SetOAuth2ClientSecret(google_apis::CLIENT_MAIN, secret_main);
google_apis::SetOAuth2ClientID(google_apis::CLIENT_MAIN, id_main);
google_apis::SetOAuth2ClientSecret(google_apis::CLIENT_MAIN, secret_main);
std::string id_remoting("setter-ID_REMOTING");
std::string secret_remoting("setter-SECRET_REMOTING");
testcase::SetOAuth2ClientID(google_apis::CLIENT_REMOTING, id_remoting);
testcase::SetOAuth2ClientSecret(google_apis::CLIENT_REMOTING,
secret_remoting);
google_apis::SetOAuth2ClientID(google_apis::CLIENT_REMOTING, id_remoting);
google_apis::SetOAuth2ClientSecret(google_apis::CLIENT_REMOTING,
secret_remoting);
std::string id_remoting_host("setter-ID_REMOTING_HOST");
std::string secret_remoting_host("setter-SECRET_REMOTING_HOST");
testcase::SetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST,
id_remoting_host);
testcase::SetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST,
secret_remoting_host);
google_apis::SetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST,
id_remoting_host);
google_apis::SetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST,
secret_remoting_host);
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
EXPECT_EQ(api_key, testcase::GetAPIKey(::version_info::Channel::STABLE));
EXPECT_EQ(api_key, testcase::GetAPIKey());
EXPECT_EQ(api_key, google_apis::GetAPIKey(::version_info::Channel::STABLE));
EXPECT_EQ(api_key, google_apis::GetAPIKey());
EXPECT_EQ(id_main, testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN));
EXPECT_EQ(id_main, google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN));
EXPECT_EQ(secret_main,
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN));
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN));
EXPECT_EQ(id_remoting,
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING));
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING));
EXPECT_EQ(secret_remoting,
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING));
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING));
EXPECT_EQ(id_remoting_host,
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST));
EXPECT_EQ(secret_remoting_host,
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST));
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST));
EXPECT_EQ(secret_remoting_host, google_apis::GetOAuth2ClientSecret(
google_apis::CLIENT_REMOTING_HOST));
}
#endif // BUILDFLAG(IS_IOS)
@ -617,7 +581,7 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingSetters) {
namespace override_all_keys_config {
// We start every test by creating a clean environment for the
// preprocessor defines used in google_api_keys.cc
// preprocessor defines used in define_baked_in_api_keys-inc.cc
#undef GOOGLE_API_KEY
#undef GOOGLE_CLIENT_ID_MAIN
#undef GOOGLE_CLIENT_SECRET_MAIN
@ -636,44 +600,43 @@ namespace override_all_keys_config {
#define GOOGLE_CLIENT_ID_REMOTING_HOST "ID_REMOTING_HOST"
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST "SECRET_REMOTING_HOST"
// Undef include guard so things get defined again, within this namespace.
#undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
#undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
#include "google_apis/google_api_keys-inc.cc"
#include "google_apis/default_api_keys-inc.cc"
} // namespace override_all_keys_config
TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingConfig) {
namespace testcase = override_all_keys_config::google_apis;
auto command_line = std::make_unique<base::test::ScopedCommandLine>();
command_line->GetProcessCommandLine()->AppendSwitchPath(
"gaia-config", GetTestFilePath("api_keys.json"));
GaiaConfig::ResetInstanceForTesting();
EXPECT_TRUE(testcase::HasAPIKeyConfigured());
EXPECT_TRUE(testcase::HasOAuthClientConfigured());
google_apis::ApiKeyCache api_key_cache(
override_all_keys_config::GetDefaultApiKeysFromDefinedValues());
auto scoped_override =
google_apis::SetScopedApiKeyCacheForTesting(&api_key_cache);
EXPECT_TRUE(google_apis::HasAPIKeyConfigured());
EXPECT_TRUE(google_apis::HasOAuthClientConfigured());
EXPECT_EQ("config-API_KEY",
testcase::GetAPIKey(::version_info::Channel::STABLE));
EXPECT_EQ("config-API_KEY", testcase::GetAPIKey());
google_apis::GetAPIKey(version_info::Channel::STABLE));
EXPECT_EQ("config-API_KEY", google_apis::GetAPIKey());
EXPECT_EQ("config-ID_MAIN",
testcase::GetOAuth2ClientID(google_apis::CLIENT_MAIN));
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN));
EXPECT_EQ("config-SECRET_MAIN",
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN));
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN));
EXPECT_EQ("config-ID_REMOTING",
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING));
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING));
EXPECT_EQ("config-SECRET_REMOTING",
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING));
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING));
EXPECT_EQ("config-ID_REMOTING_HOST",
testcase::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST));
EXPECT_EQ("config-SECRET_REMOTING_HOST",
testcase::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST));
google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING_HOST));
EXPECT_EQ(
"config-SECRET_REMOTING_HOST",
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING_HOST));
// It's important to reset the global config state for other tests running in
// the same process.
command_line.reset();
GaiaConfig::ResetInstanceForTesting();
}
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN)

@ -13,15 +13,15 @@ namespace google_apis {
namespace {
BASE_FEATURE(kOverrideAPIKeyFeature,
"OverrideAPIKey",
base::FEATURE_DISABLED_BY_DEFAULT);
const base::FeatureParam<std::string> kOverrideAPIKeyFeatureParam{
&kOverrideAPIKeyFeature, /*name=*/"api_key", /*default_value=*/""};
} // namespace
BASE_FEATURE(kOverrideAPIKeyFeature,
"OverrideAPIKey",
base::FEATURE_DISABLED_BY_DEFAULT);
std::string GetAPIKeyOverrideViaFeature() {
if (base::FeatureList::IsEnabled(kOverrideAPIKeyFeature)) {
std::string override_api_key = kOverrideAPIKeyFeatureParam.Get();

@ -8,9 +8,12 @@
#include <string>
#include "base/component_export.h"
#include "base/feature_list.h"
namespace google_apis {
COMPONENT_EXPORT(GOOGLE_APIS) BASE_DECLARE_FEATURE(kOverrideAPIKeyFeature);
// Returns an API key that can be used to override the API key and that is
// configured via an experimental feature.
COMPONENT_EXPORT(GOOGLE_APIS)