-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
google/internal/externalaccount: update serviceAccountImpersonationRE…
… to support universe domain Change-Id: Iafe35c293209bd88997c876341ebde7ac9ecda93 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/557195 TryBot-Bypass: Cody Oss <[email protected]> Reviewed-by: Cody Oss <[email protected]> Auto-Submit: Cody Oss <[email protected]>
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -1021,3 +1021,37 @@ func TestRetrieveOutputFileSubjectTokenJwt(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestServiceAccountImpersonationRE(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
serviceAccountImpersonationURL string | ||
want string | ||
}{ | ||
{ | ||
name: "universe domain Google Default Universe (GDU) googleapis.com", | ||
serviceAccountImpersonationURL: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken", | ||
want: "[email protected]", | ||
}, | ||
{ | ||
name: "email does not match", | ||
serviceAccountImpersonationURL: "[email protected]", | ||
want: "", | ||
}, | ||
{ | ||
name: "universe domain non-GDU", | ||
serviceAccountImpersonationURL: "https://iamcredentials.apis-tpclp.goog/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken", | ||
want: "[email protected]", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
matches := serviceAccountImpersonationRE.FindStringSubmatch(tt.serviceAccountImpersonationURL) | ||
if matches == nil { | ||
if tt.want != "" { | ||
t.Errorf("%q: got nil, want %q", tt.name, tt.want) | ||
} | ||
} else if matches[1] != tt.want { | ||
t.Errorf("%q: got %q, want %q", tt.name, matches[1], tt.want) | ||
} | ||
} | ||
} |