@@ -53,6 +53,10 @@ var userJSONUniverseDomain = []byte(`{
5353 "universe_domain": "example.com"
5454}` )
5555
56+ var universeDomain = "example.com"
57+
58+ var universeDomain2 = "apis-tpclp.goog"
59+
5660func TestCredentialsFromJSONWithParams_SA (t * testing.T ) {
5761 ctx := context .Background ()
5862 scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -72,6 +76,26 @@ func TestCredentialsFromJSONWithParams_SA(t *testing.T) {
7276 }
7377}
7478
79+ func TestCredentialsFromJSONWithParams_SA_Params_UniverseDomain (t * testing.T ) {
80+ ctx := context .Background ()
81+ scope := "https://www.googleapis.com/auth/cloud-platform"
82+ params := CredentialsParams {
83+ Scopes : []string {scope },
84+ UniverseDomain : universeDomain2 ,
85+ }
86+ creds , err := CredentialsFromJSONWithParams (ctx , saJSONJWT , params )
87+ if err != nil {
88+ t .Fatal (err )
89+ }
90+
91+ if want := "fake_project" ; creds .ProjectID != want {
92+ t .Fatalf ("got %q, want %q" , creds .ProjectID , want )
93+ }
94+ if creds .UniverseDomain () != universeDomain2 {
95+ t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), universeDomain2 )
96+ }
97+ }
98+
7599func TestCredentialsFromJSONWithParams_SA_UniverseDomain (t * testing.T ) {
76100 ctx := context .Background ()
77101 scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -86,8 +110,28 @@ func TestCredentialsFromJSONWithParams_SA_UniverseDomain(t *testing.T) {
86110 if want := "fake_project" ; creds .ProjectID != want {
87111 t .Fatalf ("got %q, want %q" , creds .ProjectID , want )
88112 }
89- if want := "example.com" ; creds .UniverseDomain () != want {
90- t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), want )
113+ if creds .UniverseDomain () != universeDomain {
114+ t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), universeDomain )
115+ }
116+ }
117+
118+ func TestCredentialsFromJSONWithParams_SA_UniverseDomain_Params_UniverseDomain (t * testing.T ) {
119+ ctx := context .Background ()
120+ scope := "https://www.googleapis.com/auth/cloud-platform"
121+ params := CredentialsParams {
122+ Scopes : []string {scope },
123+ UniverseDomain : universeDomain2 ,
124+ }
125+ creds , err := CredentialsFromJSONWithParams (ctx , saJSONJWTUniverseDomain , params )
126+ if err != nil {
127+ t .Fatal (err )
128+ }
129+
130+ if want := "fake_project" ; creds .ProjectID != want {
131+ t .Fatalf ("got %q, want %q" , creds .ProjectID , want )
132+ }
133+ if creds .UniverseDomain () != universeDomain2 {
134+ t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), universeDomain2 )
91135 }
92136}
93137
@@ -107,6 +151,23 @@ func TestCredentialsFromJSONWithParams_User(t *testing.T) {
107151 }
108152}
109153
154+ func TestCredentialsFromJSONWithParams_User_Params_UniverseDomain (t * testing.T ) {
155+ ctx := context .Background ()
156+ scope := "https://www.googleapis.com/auth/cloud-platform"
157+ params := CredentialsParams {
158+ Scopes : []string {scope },
159+ UniverseDomain : universeDomain2 ,
160+ }
161+ creds , err := CredentialsFromJSONWithParams (ctx , userJSON , params )
162+ if err != nil {
163+ t .Fatal (err )
164+ }
165+
166+ if want := "googleapis.com" ; creds .UniverseDomain () != want {
167+ t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), want )
168+ }
169+ }
170+
110171func TestCredentialsFromJSONWithParams_User_UniverseDomain (t * testing.T ) {
111172 ctx := context .Background ()
112173 scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -122,3 +183,20 @@ func TestCredentialsFromJSONWithParams_User_UniverseDomain(t *testing.T) {
122183 t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), want )
123184 }
124185}
186+
187+ func TestCredentialsFromJSONWithParams_User_UniverseDomain_Params_UniverseDomain (t * testing.T ) {
188+ ctx := context .Background ()
189+ scope := "https://www.googleapis.com/auth/cloud-platform"
190+ params := CredentialsParams {
191+ Scopes : []string {scope },
192+ UniverseDomain : universeDomain2 ,
193+ }
194+ creds , err := CredentialsFromJSONWithParams (ctx , userJSONUniverseDomain , params )
195+ if err != nil {
196+ t .Fatal (err )
197+ }
198+
199+ if want := "googleapis.com" ; creds .UniverseDomain () != want {
200+ t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), want )
201+ }
202+ }
0 commit comments