Skip to content

Commit 3f8954c

Browse files
authored
impl(universe_domain): update implementation to reflect testing results (#13530)
1 parent 39fdf04 commit 3f8954c

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

google/cloud/internal/compute_engine_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::string GceMetadataScheme() { return "http"; }
2525

2626
std::string GceMetadataHostname() {
2727
return google::cloud::internal::GetEnv(GceMetadataHostnameEnvVar())
28-
.value_or("metadata.google.internal.");
28+
.value_or("metadata.google.internal");
2929
}
3030

3131
} // namespace internal

google/cloud/internal/compute_engine_util_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEST(ComputeEngineUtilTest, CanOverrideGceMetadataHostname) {
3333
// If not overridden for testing, we should get the actual hostname.
3434
google::cloud::testing_util::ScopedEnvironment gce_metadata_hostname_unset(
3535
GceMetadataHostnameEnvVar(), {});
36-
EXPECT_EQ(std::string("metadata.google.internal."), GceMetadataHostname());
36+
EXPECT_EQ(std::string("metadata.google.internal"), GceMetadataHostname());
3737
}
3838

3939
} // namespace

google/cloud/internal/oauth2_compute_engine_credentials.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,11 @@ StatusOr<std::string> ComputeEngineCredentials::RetrieveUniverseDomain(
263263
}
264264
return AsStatus(std::move(**response));
265265
}
266-
auto metadata = ParseMetadataServerResponse(**response);
267-
if (!metadata) return std::move(metadata).status();
268-
universe_domain_ = std::move(metadata->universe_domain);
266+
267+
auto payload =
268+
rest_internal::ReadAll((std::move(**response)).ExtractPayload());
269+
if (!payload.ok()) return payload.status();
270+
universe_domain_ = *std::move(payload);
269271
return *universe_domain_;
270272
}
271273

google/cloud/internal/oauth2_compute_engine_credentials_test.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ auto expected_universe_domain_request = []() {
430430
};
431431

432432
TEST(ComputeEngineCredentialsTest, UniverseDomainSuccess) {
433-
auto const universe_domain_resp = std::string{R"""({
434-
"universe_domain": "my-ud.net"
435-
})"""};
433+
auto const universe_domain_resp = std::string{R"""(my-ud.net)"""};
436434

437435
auto client = std::make_unique<MockRestClient>();
438436
EXPECT_CALL(*client, Get(_, expected_universe_domain_request()))

google/cloud/internal/unified_rest_credentials_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ TEST(UnifiedRestCredentialsTest, AdcIsComputeEngine) {
245245
auto client = std::make_unique<MockRestClient>();
246246
auto expected_request = AllOf(
247247
Property(&RestRequest::path,
248-
absl::StrCat("http://metadata.google.internal./",
248+
absl::StrCat("http://metadata.google.internal/",
249249
"computeMetadata/v1/instance/service-accounts/",
250250
"default/")),
251251
Property(&RestRequest::headers,
@@ -259,7 +259,7 @@ TEST(UnifiedRestCredentialsTest, AdcIsComputeEngine) {
259259
auto client = std::make_unique<MockRestClient>();
260260
auto expected_request = AllOf(
261261
Property(&RestRequest::path,
262-
absl::StrCat("http://metadata.google.internal./",
262+
absl::StrCat("http://metadata.google.internal/",
263263
"computeMetadata/v1/instance/service-accounts/",
264264
"default/", "token")),
265265
Property(&RestRequest::headers,

0 commit comments

Comments
 (0)