X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=auth-token-fetch%2Fconfig_test.go;fp=auth-token-fetch%2Fconfig_test.go;h=0dd1d3590af6aa9836e82b4c92e3ee0501da0a81;hb=4d78fcc20a2c156edd686270e83e3e8182ef7951;hp=92a63d891929e0d1d9166504038758c07a508361;hpb=844931b62f35ce6ee2d9dc7274573fc54e14407a;p=nonrtric.git diff --git a/auth-token-fetch/config_test.go b/auth-token-fetch/config_test.go index 92a63d89..0dd1d359 100644 --- a/auth-token-fetch/config_test.go +++ b/auth-token-fetch/config_test.go @@ -61,3 +61,38 @@ func TestNew_envVarsSetConfigContainSetValues(t *testing.T) { assertions.Equal(&wantConfig, got) } + +func TestNew_defaultValues(t *testing.T) { + assertions := require.New(t) + + wantConfig := Config{ + LogLevel: log.InfoLevel, + CertPath: "security/tls.crt", + KeyPath: "security/tls.key", + AuthServiceUrl: "https://localhost:39687/example-singlelogin-sever/login", + GrantType: "", + ClientSecret: "", + ClientId: "", + AuthTokenOutputFileName: "/tmp/authToken.txt", + CACertsPath: "", + RefreshMarginSeconds: 5, + } + got := NewConfig() + assertions.Equal(nil, validateConfiguration(got)) + + assertions.Equal(&wantConfig, got) +} + +func TestNew_invalidValues(t *testing.T) { + assertions := require.New(t) + + os.Setenv("LOG_LEVEL", "Junk") + os.Setenv("REFRESH_MARGIN_SECONDS", "Junk") + t.Cleanup(func() { + os.Clearenv() + }) + + got := NewConfig() + assertions.Equal(log.InfoLevel, got.LogLevel) + assertions.Equal(5, got.RefreshMarginSeconds) +}