@@ -84,6 +84,30 @@ func TestTokenForHost(t *testing.T) {
84
84
wantToken : "yyyyyyyyyyyyyyyyyyyy" ,
85
85
wantSource : "oauth_token" ,
86
86
},
87
+ {
88
+ name : "token for tenant with GH_TOKEN, GITHUB_TOKEN, and config token" ,
89
+ host : "tenant.ghe.com" ,
90
+ ghToken : "GH_TOKEN" ,
91
+ githubToken : "GITHUB_TOKEN" ,
92
+ config : testHostsConfig (),
93
+ wantToken : "GH_TOKEN" ,
94
+ wantSource : "GH_TOKEN" ,
95
+ },
96
+ {
97
+ name : "token for tenant with GITHUB_TOKEN, and config token" ,
98
+ host : "tenant.ghe.com" ,
99
+ githubToken : "GITHUB_TOKEN" ,
100
+ config : testHostsConfig (),
101
+ wantToken : "GITHUB_TOKEN" ,
102
+ wantSource : "GITHUB_TOKEN" ,
103
+ },
104
+ {
105
+ name : "token for tenant with config token" ,
106
+ host : "tenant.ghe.com" ,
107
+ config : testHostsConfig (),
108
+ wantToken : "zzzzzzzzzzzzzzzzzzzz" ,
109
+ wantSource : "oauth_token" ,
110
+ },
87
111
}
88
112
89
113
for _ , tt := range tests {
@@ -171,7 +195,7 @@ func TestKnownHosts(t *testing.T) {
171
195
{
172
196
name : "includes authenticated hosts" ,
173
197
config : testHostsConfig (),
174
- wantHosts : []string {"github.com" , "enterprise.com" },
198
+ wantHosts : []string {"github.com" , "enterprise.com" , "tenant.ghe.com" },
175
199
},
176
200
{
177
201
name : "includes default host if environment auth token" ,
@@ -184,7 +208,7 @@ func TestKnownHosts(t *testing.T) {
184
208
config : testHostsConfig (),
185
209
ghHost : "test.com" ,
186
210
ghToken : "TOKEN" ,
187
- wantHosts : []string {"test.com" , "github.com" , "enterprise.com" },
211
+ wantHosts : []string {"test.com" , "github.com" , "enterprise.com" , "tenant.ghe.com" },
188
212
},
189
213
}
190
214
@@ -223,6 +247,11 @@ func TestIsEnterprise(t *testing.T) {
223
247
host : "mygithub.com" ,
224
248
wantOut : true ,
225
249
},
250
+ {
251
+ name : "tenant" ,
252
+ host : "tenant.ghe.com" ,
253
+ wantOut : false ,
254
+ },
226
255
}
227
256
228
257
for _ , tt := range tests {
@@ -259,6 +288,16 @@ func TestNormalizeHostname(t *testing.T) {
259
288
host : "mygithub.com" ,
260
289
wantHost : "mygithub.com" ,
261
290
},
291
+ {
292
+ name : "bare tenant" ,
293
+ host : "tenant.ghe.com" ,
294
+ wantHost : "tenant.ghe.com" ,
295
+ },
296
+ {
297
+ name : "subdomained tenant" ,
298
+ host : "api.tenant.ghe.com" ,
299
+ wantHost : "tenant.ghe.com" ,
300
+ },
262
301
}
263
302
264
303
for _ , tt := range tests {
@@ -296,6 +335,10 @@ hosts:
296
335
user: user2
297
336
oauth_token: yyyyyyyyyyyyyyyyyyyy
298
337
git_protocol: https
338
+ tenant.ghe.com:
339
+ user: user3
340
+ oauth_token: zzzzzzzzzzzzzzzzzzzz
341
+ git_protocol: https
299
342
`
300
343
return config .ReadFromString (data )
301
344
}
0 commit comments