@@ -53,6 +53,10 @@ var userJSONUniverseDomain = []byte(`{
53
53
"universe_domain": "example.com"
54
54
}` )
55
55
56
+ var universeDomain = "example.com"
57
+
58
+ var universeDomain2 = "apis-tpclp.goog"
59
+
56
60
func TestCredentialsFromJSONWithParams_SA (t * testing.T ) {
57
61
ctx := context .Background ()
58
62
scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -72,6 +76,26 @@ func TestCredentialsFromJSONWithParams_SA(t *testing.T) {
72
76
}
73
77
}
74
78
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
+
75
99
func TestCredentialsFromJSONWithParams_SA_UniverseDomain (t * testing.T ) {
76
100
ctx := context .Background ()
77
101
scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -86,8 +110,28 @@ func TestCredentialsFromJSONWithParams_SA_UniverseDomain(t *testing.T) {
86
110
if want := "fake_project" ; creds .ProjectID != want {
87
111
t .Fatalf ("got %q, want %q" , creds .ProjectID , want )
88
112
}
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 )
91
135
}
92
136
}
93
137
@@ -107,6 +151,23 @@ func TestCredentialsFromJSONWithParams_User(t *testing.T) {
107
151
}
108
152
}
109
153
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
+
110
171
func TestCredentialsFromJSONWithParams_User_UniverseDomain (t * testing.T ) {
111
172
ctx := context .Background ()
112
173
scope := "https://www.googleapis.com/auth/cloud-platform"
@@ -122,3 +183,20 @@ func TestCredentialsFromJSONWithParams_User_UniverseDomain(t *testing.T) {
122
183
t .Fatalf ("got %q, want %q" , creds .UniverseDomain (), want )
123
184
}
124
185
}
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