Skip to content

Commit

Permalink
Support impersonation for bootstrap requests (#12104) (#19992)
Browse files Browse the repository at this point in the history
[upstream:075e1514533b67c29fb661b7d07e050384dc6f56]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 23, 2024
1 parent de0a050 commit 02de6d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/12104.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
9 changes: 5 additions & 4 deletions google/acctest/bootstrap_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,11 @@ func BootstrapConfig(t *testing.T) *transport_tpg.Config {
}

config := &transport_tpg.Config{
Credentials: envvar.GetTestCredsFromEnv(),
Project: envvar.GetTestProjectFromEnv(),
Region: envvar.GetTestRegionFromEnv(),
Zone: envvar.GetTestZoneFromEnv(),
Credentials: envvar.GetTestCredsFromEnv(),
ImpersonateServiceAccount: envvar.GetTestImpersonateServiceAccountFromEnv(),
Project: envvar.GetTestProjectFromEnv(),
Region: envvar.GetTestRegionFromEnv(),
Zone: envvar.GetTestZoneFromEnv(),
}

transport_tpg.ConfigureBasePaths(config)
Expand Down
8 changes: 8 additions & 0 deletions google/envvar/envvar_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ var PapDescriptionEnvVars = []string{
"GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION",
}

var ImpersonateServiceAccountEnvVars = []string{
"GOOGLE_IMPERSONATE_SERVICE_ACCOUNT",
}

// AccTestPreCheck ensures at least one of the project env variables is set.
func GetTestProjectNumberFromEnv() string {
return transport_tpg.MultiEnvSearch(ProjectNumberEnvVars)
Expand Down Expand Up @@ -140,6 +144,10 @@ func GetTestZoneFromEnv() string {
return transport_tpg.MultiEnvSearch(ZoneEnvVars)
}

func GetTestImpersonateServiceAccountFromEnv() string {
return transport_tpg.MultiEnvSearch(ImpersonateServiceAccountEnvVars)
}

func GetTestCustIdFromEnv(t *testing.T) string {
SkipIfEnvNotSet(t, CustIdEnvVars...)
return transport_tpg.MultiEnvSearch(CustIdEnvVars)
Expand Down

0 comments on commit 02de6d5

Please sign in to comment.