@@ -292,6 +292,25 @@ func TestExternalAuthYAMLConfig(t *testing.T) {
292
292
require .NoError (t , err , "read testdata file %q" , name )
293
293
return string (data )
294
294
}
295
+ githubCfg := codersdk.ExternalAuthConfig {
296
+ Type : "github" ,
297
+ ClientID : "client_id" ,
298
+ ClientSecret : "client_secret" ,
299
+ ID : "id" ,
300
+ AuthURL : "https://example.com/auth" ,
301
+ TokenURL : "https://example.com/token" ,
302
+ ValidateURL : "https://example.com/validate" ,
303
+ AppInstallURL : "https://example.com/install" ,
304
+ AppInstallationsURL : "https://example.com/installations" ,
305
+ NoRefresh : true ,
306
+ Scopes : []string {"user:email" , "read:org" },
307
+ ExtraTokenKeys : []string {"extra" , "token" },
308
+ DeviceFlow : true ,
309
+ DeviceCodeURL : "https://example.com/device" ,
310
+ Regex : "^https://example.com/.*$" ,
311
+ DisplayName : "GitHub" ,
312
+ DisplayIcon : "/static/icons/github.svg" ,
313
+ }
295
314
296
315
testCases := []struct {
297
316
Name string
@@ -300,27 +319,15 @@ func TestExternalAuthYAMLConfig(t *testing.T) {
300
319
}{
301
320
{
302
321
Name : "GitHub" ,
303
- YAML : file (t , "githubcfg.yaml" ),
322
+ // Just load the GitHub config twice to test loading 2
323
+ YAML : func () string {
324
+ f := file (t , "githubcfg.yaml" )
325
+ lines := strings .SplitN (f , "\n " , 2 )
326
+ // Append github config twice
327
+ return f + "\n " + lines [1 ]
328
+ }(),
304
329
Expected : []codersdk.ExternalAuthConfig {
305
- {
306
- Type : "github" ,
307
- ClientID : "client_id" ,
308
- ClientSecret : "client_secret" ,
309
- ID : "id" ,
310
- AuthURL : "https://example.com/auth" ,
311
- TokenURL : "https://example.com/token" ,
312
- ValidateURL : "https://example.com/validate" ,
313
- AppInstallURL : "https://example.com/install" ,
314
- AppInstallationsURL : "https://example.com/installations" ,
315
- NoRefresh : true ,
316
- Scopes : []string {"user:email" , "read:org" },
317
- ExtraTokenKeys : []string {"extra" , "token" },
318
- DeviceFlow : true ,
319
- DeviceCodeURL : "https://example.com/device" ,
320
- Regex : "^https://example.com/.*$" ,
321
- DisplayName : "GitHub" ,
322
- DisplayIcon : "/static/icons/github.svg" ,
323
- },
330
+ githubCfg , githubCfg ,
324
331
},
325
332
},
326
333
}
0 commit comments