Skip to content

Commit e210cdb

Browse files
committed
Make test parse 2 configs
1 parent 56ef00f commit e210cdb

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

cli/testdata/server-config.yaml.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ client:
440440
# Support links to display in the top right drop down menu.
441441
# (default: <unset>, type: struct[[]codersdk.LinkConfig])
442442
supportLinks: []
443+
# External Authentication providers.
444+
# (default: <unset>, type: struct[[]codersdk.ExternalAuthConfig])
445+
externalAuthProviders: []
443446
# Hostname of HTTPS server that runs https://github.com/coder/wgtunnel. By
444447
# default, this will pick the best available wgtunnel server hosted by Coder. e.g.
445448
# "tunnel.example.com".

codersdk/deployment_test.go

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,25 @@ func TestExternalAuthYAMLConfig(t *testing.T) {
292292
require.NoError(t, err, "read testdata file %q", name)
293293
return string(data)
294294
}
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+
}
295314

296315
testCases := []struct {
297316
Name string
@@ -300,27 +319,15 @@ func TestExternalAuthYAMLConfig(t *testing.T) {
300319
}{
301320
{
302321
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+
}(),
304329
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,
324331
},
325332
},
326333
}

0 commit comments

Comments
 (0)