2 // ========================LICENSE_START=================================
5 // Copyright (C) 2022: Nordix Foundation
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // ========================LICENSE_END===================================
27 log "github.com/sirupsen/logrus"
28 "github.com/stretchr/testify/require"
31 func TestNew_envVarsSetConfigContainSetValues(t *testing.T) {
32 assertions := require.New(t)
33 os.Setenv("LOG_LEVEL", "Debug")
34 os.Setenv("CERT_PATH", "CERT_PATH")
35 os.Setenv("CERT_KEY_PATH", "CERT_KEY_PATH")
36 os.Setenv("CREDS_GRANT_TYPE", "CREDS_GRANT_TYPE")
37 os.Setenv("CREDS_CLIENT_SECRET", "CREDS_CLIENT_SECRET")
38 os.Setenv("CREDS_CLIENT_ID", "CREDS_CLIENT_ID")
39 os.Setenv("OUTPUT_FILE", "OUTPUT_FILE")
40 os.Setenv("AUTH_SERVICE_URL", "AUTH_SERVICE_URL")
41 os.Setenv("REFRESH_MARGIN_SECONDS", "33")
47 LogLevel: log.DebugLevel,
48 CertPath: "CERT_PATH",
49 KeyPath: "CERT_KEY_PATH",
50 AuthServiceUrl: "AUTH_SERVICE_URL",
51 GrantType: "CREDS_GRANT_TYPE",
52 ClientSecret: "CREDS_CLIENT_SECRET",
53 ClientId: "CREDS_CLIENT_ID",
54 AuthTokenOutputFileName: "OUTPUT_FILE",
55 RefreshMarginSeconds: 33,
59 assertions.Equal(&wantConfig, got)