Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
  • Loading branch information
kfox1111 committed Dec 18, 2024
1 parent 232e8f6 commit 6367e22
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions support/oidc-discovery-provider/config_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ var (
address = "unix:///some/socket/path"
}
`
minimalEnvServerAPIConfig = `
domains = ["${SPIFFE_TRUST_DOMAIN}"]
acme {
email = "admin@@{SPIFFE_TRUST_DOMAIN}"
tos_accepted = true
}
server_api {
address = "unix:///some/socket/path"
}
`

serverAPIConfig = &ServerAPIConfig{
Address: "unix:///some/socket/path",
Expand Down
18 changes: 18 additions & 0 deletions support/oidc-discovery-provider/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ func TestLoadConfig(t *testing.T) {
require.Error(err)
require.Contains(err.Error(), "unable to load configuration:")

err = os.WriteFile(confPath, []byte(minimalEnvServerAPIConfig), 0600)
require.NoError(err)

os.Setenv("SPIFFE_TRUST_DOMAIN", "domain.test")
config, err := LoadConfig(confPath, true)
require.NoError(err)

require.Equal(&Config{
LogLevel: defaultLogLevel,
Domains: []string{"domain.test"},
ACME: &ACMEConfig{
CacheDir: defaultCacheDir,
Email: "admin@domain.test",
ToSAccepted: true,
},
ServerAPI: serverAPIConfig,
}, config)

err = os.WriteFile(confPath, []byte(minimalServerAPIConfig), 0600)
require.NoError(err)

Expand Down
12 changes: 12 additions & 0 deletions support/oidc-discovery-provider/config_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ var (
}
}
`
minimalEnvServerAPIConfig = `
domains = ["${SPIFFE_TRUST_DOMAIN}"]
acme {
email = "admin@${SPIFFE_TRUST_DOMAIN}"
tos_accepted = true
}
server_api {
experimental {
named_pipe_name = "\\name\\for\\server\\api"
}
}
`

serverAPIConfig = &ServerAPIConfig{
Experimental: experimentalServerAPIConfig{
Expand Down

0 comments on commit 6367e22

Please sign in to comment.