diff --git a/google/cloud/internal/populate_rest_options.cc b/google/cloud/internal/populate_rest_options.cc index e7d8a47217792..7d5cef2950381 100644 --- a/google/cloud/internal/populate_rest_options.cc +++ b/google/cloud/internal/populate_rest_options.cc @@ -18,6 +18,7 @@ #include "google/cloud/internal/make_status.h" #include "google/cloud/internal/populate_common_options.h" #include "google/cloud/internal/rest_options.h" +#include "google/cloud/internal/service_endpoint.h" #include "google/cloud/rest_options.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -35,7 +36,7 @@ Options PopulateRestOptions(Options opts) { } if (!opts.has()) { opts.set( - "https://longrunning.googleapis.com"); + UniverseDomainEndpoint("https://longrunning.googleapis.com", opts)); } if (opts.has()) { auto& endpoint = opts.lookup(); diff --git a/google/cloud/internal/populate_rest_options_test.cc b/google/cloud/internal/populate_rest_options_test.cc index 402805fb06dfa..c95ce83c097cb 100644 --- a/google/cloud/internal/populate_rest_options_test.cc +++ b/google/cloud/internal/populate_rest_options_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "google/cloud/internal/populate_rest_options.h" +#include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/internal/credentials_impl.h" #include "google/cloud/internal/rest_options.h" @@ -20,8 +21,11 @@ #include "google/cloud/rest_options.h" #include "google/cloud/testing_util/credentials.h" #include "google/cloud/testing_util/scoped_environment.h" +#include "google/cloud/universe_domain_options.h" #include #include +#include +#include namespace google { namespace cloud { @@ -31,6 +35,7 @@ namespace { using ::google::cloud::testing_util::ScopedEnvironment; using ::google::cloud::testing_util::TestCredentialsVisitor; +using ::testing::Eq; TEST(PopulateRestOptions, EndpointOption) { struct TestCase { @@ -83,16 +88,32 @@ TEST(PopulateRestOptions, CustomCredentials) { TEST(PopulateRestOptions, LongrunningEndpointOption) { using ::google::cloud::rest_internal::LongrunningEndpointOption; - auto options = Options{}; - options = PopulateRestOptions(std::move(options)); - EXPECT_EQ(options.get(), - "https://longrunning.googleapis.com"); + + Options options = PopulateRestOptions(Options{}); + EXPECT_THAT(options.get(), + Eq("https://longrunning.googleapis.com")); + + options = PopulateRestOptions( + Options{}.set("spanner.googleapis.com")); + EXPECT_THAT(options.get(), + Eq("https://longrunning.googleapis.com")); options = - Options{}.set("https://foo.googleapis.com"); - options = PopulateRestOptions(std::move(options)); - EXPECT_EQ(options.get(), - "https://foo.googleapis.com"); + PopulateRestOptions(Options{}.set("my-ud.net")); + EXPECT_THAT(options.get(), + Eq("https://longrunning.my-ud.net")); + + options = PopulateRestOptions( + Options{}.set("https://foo.googleapis.com")); + EXPECT_THAT(options.get(), + Eq("https://foo.googleapis.com")); + + options = PopulateRestOptions( + Options{} + .set("https://foo.googleapis.com") + .set("my-ud.net")); + EXPECT_THAT(options.get(), + Eq("https://foo.googleapis.com")); } TEST(PopulateRestOptions, TracingOptions) {