-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest): support generateIdToken in impersonation url (#14853)
- Loading branch information
Showing
2 changed files
with
34 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,19 @@ auto constexpr kFullValidConfig = R"""({ | |
"type": "impersonated_service_account" | ||
})"""; | ||
|
||
auto constexpr kFullValidConfigNoAction = R"""({ | ||
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]", | ||
"delegates": [ | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"quota_project_id": "my-project", | ||
"source_credentials": { | ||
"type": "authorized_user" | ||
}, | ||
"type": "impersonated_service_account" | ||
})"""; | ||
|
||
TEST(ParseImpersonatedServiceAccountCredentials, Success) { | ||
auto actual = | ||
ParseImpersonatedServiceAccountCredentials(kFullValidConfig, "test-data"); | ||
|
@@ -146,6 +159,19 @@ TEST(ImpersonateServiceAccountCredentialsTest, Basic) { | |
ASSERT_THAT(token, StatusIs(StatusCode::kPermissionDenied)); | ||
} | ||
|
||
TEST(ParseImpersonatedServiceAccountCredentialsWithoutAction, Success) { | ||
auto actual = ParseImpersonatedServiceAccountCredentials( | ||
kFullValidConfigNoAction, "test-data"); | ||
ASSERT_STATUS_OK(actual); | ||
EXPECT_EQ(actual->service_account, "[email protected]"); | ||
EXPECT_THAT(actual->delegates, | ||
ElementsAre("[email protected]", | ||
"[email protected]")); | ||
EXPECT_THAT(actual->quota_project_id, Optional<std::string>("my-project")); | ||
EXPECT_THAT(actual->source_credentials, | ||
AllOf(HasSubstr("type"), HasSubstr("authorized_user"))); | ||
} | ||
|
||
} // namespace | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace oauth2_internal | ||
|