Skip to content

Commit

Permalink
[gaia] Introduce Gaia URLs config
Browse files Browse the repository at this point in the history
Currently, there are 5 different URL switches in
google_apis/gaia/gaia_switches.cc that need to be manually set to set
non-prod Gaia environment. This CL introduces a new command line switch
to rule them all:

--gaia-config=gaia_test.json

A JSON config file allows to override all URLs available in
google_apis/gaia/gaia_urls.h. For a format example take a look at
google_apis/test/data/gaia/all_urls.json.

The proposed design was chosen because of the following:
- It allows to override each individual URL separately without bloating
the command line. This can be useful for developers who run their own
test instances.
- It makes easy to hide test URLs used at Google in the internal repo.

Bug: 1072731
Change-Id: I3c32c53f9dc27b01ceab8ef57eb71c00d5df0977
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2166197
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771605}
  • Loading branch information
Alex Ilin authored and Commit Bot committed May 25, 2020
1 parent e05917f commit d84591a
Show file tree
Hide file tree
Showing 14 changed files with 893 additions and 86 deletions.
25 changes: 23 additions & 2 deletions google_apis/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ test("google_apis_unittests") {
"gaia/gaia_auth_fetcher_unittest.cc",
"gaia/gaia_auth_util_unittest.cc",
"gaia/gaia_oauth_client_unittest.cc",
"gaia/gaia_urls_unittest.cc",
"gaia/google_service_auth_error_unittest.cc",
"gaia/oauth2_access_token_fetcher_impl_unittest.cc",
"gaia/oauth2_access_token_manager_unittest.cc",
Expand All @@ -225,8 +226,6 @@ test("google_apis_unittests") {
"google_api_keys_unittest.h",
]

data = [ "test/" ]

configs += [ ":key_defines" ]

deps = [
Expand All @@ -241,6 +240,12 @@ test("google_apis_unittests") {
"//testing/gtest",
]

if (is_ios) {
deps += [ ":google_apis_unittest_bundle_data" ]
} else {
data = [ "test/" ]
}

if (enable_extensions) {
deps += [ "//google_apis/drive:drive_unittests" ]
}
Expand All @@ -253,3 +258,19 @@ test("google_apis_unittests") {
deps += [ "//third_party/ocmock" ]
}
}

bundle_data("google_apis_unittest_bundle_data") {
testonly = true
sources = [
"test/data/gaia/all_base_urls.json",
"test/data/gaia/all_urls.json",
"test/data/gaia/bad_url.json",
"test/data/gaia/bad_url_key.json",
"test/data/gaia/bad_urls_key.json",
"test/data/gaia/not_a_json.txt",
"test/data/gaia/one_base_url.json",
"test/data/gaia/one_url.json",
]
outputs = [ "{{bundle_resources_dir}}/" +
"{{source_root_relative_dir}}/{{source_file_part}}" ]
}
1 change: 1 addition & 0 deletions google_apis/gaia/gaia_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace switches {

const char kGaiaConfig[] = "gaia-config";
const char kGoogleUrl[] = "google-url";
const char kGaiaUrl[] = "gaia-url";
const char kGoogleApisUrl[] = "google-apis-url";
Expand Down
4 changes: 4 additions & 0 deletions google_apis/gaia/gaia_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

namespace switches {

// Specifies the path to a config file containing GAIA urls.
// See "google_apis/test/data/gaia/all_urls.json" for a format example.
extern const char kGaiaConfig[];

// Specifies the domain of the SAPISID cookie. The default value is
// "http://.google.com".
extern const char kGoogleUrl[];
Expand Down
Loading

0 comments on commit d84591a

Please sign in to comment.