2020-07-22 11:15:48 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-10-26 15:20:04 +02:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2021-09-21 13:06:32 +02:00
|
|
|
"path"
|
2021-04-09 10:04:35 +02:00
|
|
|
"strings"
|
2020-07-22 11:15:48 +02:00
|
|
|
"testing"
|
|
|
|
|
2021-12-21 12:00:13 +02:00
|
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
|
2020-07-22 11:15:48 +02:00
|
|
|
"github.com/SAP/jenkins-library/pkg/config/mocks"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestVaultConfigLoad(t *testing.T) {
|
|
|
|
const secretName = "testSecret"
|
2021-09-21 13:06:32 +02:00
|
|
|
const secretNameOverrideKey = "mySecretVaultSecretName"
|
2020-07-22 11:15:48 +02:00
|
|
|
t.Parallel()
|
|
|
|
t.Run("Load secret from vault", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
2020-07-22 11:15:48 +02:00
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
2020-07-22 11:15:48 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
|
|
|
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
|
|
|
assert.Equal(t, "value1", stepConfig.Config[secretName])
|
|
|
|
})
|
|
|
|
|
2021-12-21 12:52:10 +02:00
|
|
|
t.Run("Load secret from Vault with path override", func(t *testing.T) {
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
secretNameOverrideKey: "overrideSecretName",
|
|
|
|
}}
|
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
|
|
|
|
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", "overrideSecretName")).Return(vaultData, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-07-22 11:15:48 +02:00
|
|
|
assert.Equal(t, "value1", stepConfig.Config[secretName])
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Secrets are not overwritten", func(t *testing.T) {
|
2021-02-15 10:48:51 +02:00
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
2021-02-15 10:48:51 +02:00
|
|
|
secretName: "preset value",
|
|
|
|
"vaultDisableOverwrite": true,
|
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
2021-02-15 10:48:51 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
2021-02-15 10:48:51 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
|
|
|
|
|
|
|
assert.Equal(t, "preset value", stepConfig.Config[secretName])
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Secrets can be overwritten", func(t *testing.T) {
|
2020-07-22 11:15:48 +02:00
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
|
|
|
secretName: "preset value",
|
2020-07-22 11:15:48 +02:00
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
2020-07-22 11:15:48 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-07-22 11:15:48 +02:00
|
|
|
|
2021-02-15 10:48:51 +02:00
|
|
|
assert.Equal(t, "value1", stepConfig.Config[secretName])
|
2020-07-22 11:15:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Error is passed through", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
2020-07-22 11:15:48 +02:00
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(nil, fmt.Errorf("test"))
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-07-22 11:15:48 +02:00
|
|
|
assert.Len(t, stepConfig.Config, 1)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Secret doesn't exist", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
2020-07-22 11:15:48 +02:00
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(nil, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-07-22 11:15:48 +02:00
|
|
|
assert.Len(t, stepConfig.Config, 1)
|
|
|
|
})
|
|
|
|
|
2020-11-06 18:54:01 +02:00
|
|
|
t.Run("Alias names should be considered", func(t *testing.T) {
|
|
|
|
aliasName := "alias"
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultPath": "team1",
|
2020-11-06 18:54:01 +02:00
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
param := stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)
|
2020-11-06 18:54:01 +02:00
|
|
|
addAlias(¶m, aliasName)
|
|
|
|
stepParams := []StepParameters{param}
|
|
|
|
vaultData := map[string]string{aliasName: "value1"}
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
2020-11-06 18:54:01 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
|
|
|
assert.Equal(t, "value1", stepConfig.Config[secretName])
|
|
|
|
})
|
|
|
|
|
2020-07-22 11:15:48 +02:00
|
|
|
t.Run("Search over multiple paths", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
2021-09-21 13:06:32 +02:00
|
|
|
"vaultBasePath": "team2",
|
|
|
|
"vaultPath": "team1",
|
2020-10-13 14:14:47 +02:00
|
|
|
}}
|
|
|
|
stepParams := []StepParameters{
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName),
|
2020-10-13 14:14:47 +02:00
|
|
|
}
|
2020-07-22 11:15:48 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(nil, nil)
|
|
|
|
vaultMock.On("GetKvSecret", path.Join("team2/GROUP-SECRETS", secretName)).Return(vaultData, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-07-22 11:15:48 +02:00
|
|
|
assert.Equal(t, "value1", stepConfig.Config[secretName])
|
|
|
|
})
|
|
|
|
|
2020-10-13 14:14:47 +02:00
|
|
|
t.Run("No BasePath is stepConfig.Configured", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecret", secretNameOverrideKey, secretName)}
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
2020-10-13 14:14:47 +02:00
|
|
|
assert.Equal(t, nil, stepConfig.Config[secretName])
|
|
|
|
vaultMock.AssertNotCalled(t, "GetKvSecret", mock.AnythingOfType("string"))
|
|
|
|
})
|
2020-07-22 11:15:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-26 15:20:04 +02:00
|
|
|
func TestVaultSecretFiles(t *testing.T) {
|
|
|
|
const secretName = "testSecret"
|
2021-09-21 13:06:32 +02:00
|
|
|
const secretNameOverrideKey = "mySecretVaultSecretName"
|
2020-10-26 15:20:04 +02:00
|
|
|
t.Run("Test Vault Secret File Reference", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecretFile", secretNameOverrideKey, secretName)}
|
2020-10-26 15:20:04 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
|
|
|
assert.NotNil(t, stepConfig.Config[secretName])
|
|
|
|
path := stepConfig.Config[secretName].(string)
|
|
|
|
contentByte, err := ioutil.ReadFile(path)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
content := string(contentByte)
|
|
|
|
assert.Equal(t, content, "value1")
|
|
|
|
})
|
|
|
|
|
|
|
|
os.RemoveAll(VaultSecretFileDirectory)
|
|
|
|
VaultSecretFileDirectory = ""
|
|
|
|
|
|
|
|
t.Run("Test temporary secret file cleanup", func(t *testing.T) {
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
}}
|
2021-09-21 13:06:32 +02:00
|
|
|
stepParams := []StepParameters{stepParam(secretName, "vaultSecretFile", secretNameOverrideKey, secretName)}
|
2020-10-26 15:20:04 +02:00
|
|
|
vaultData := map[string]string{secretName: "value1"}
|
|
|
|
assert.NoDirExists(t, VaultSecretFileDirectory)
|
2021-09-21 13:06:32 +02:00
|
|
|
vaultMock.On("GetKvSecret", path.Join("team1", secretName)).Return(vaultData, nil)
|
2020-10-26 15:20:04 +02:00
|
|
|
resolveAllVaultReferences(&stepConfig, vaultMock, stepParams)
|
|
|
|
assert.NotNil(t, stepConfig.Config[secretName])
|
|
|
|
path := stepConfig.Config[secretName].(string)
|
|
|
|
assert.DirExists(t, VaultSecretFileDirectory)
|
|
|
|
assert.FileExists(t, path)
|
|
|
|
RemoveVaultSecretFiles()
|
|
|
|
assert.NoFileExists(t, path)
|
|
|
|
assert.NoDirExists(t, VaultSecretFileDirectory)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-01-20 15:59:47 +02:00
|
|
|
func TestMixinVault(t *testing.T) {
|
|
|
|
vaultServerUrl := "https://testServer"
|
|
|
|
vaultPath := "testPath"
|
|
|
|
config := StepConfig{
|
|
|
|
Config: map[string]interface{}{},
|
|
|
|
HookConfig: nil,
|
|
|
|
}
|
|
|
|
general := map[string]interface{}{
|
|
|
|
"vaultPath": vaultPath,
|
|
|
|
}
|
|
|
|
steps := map[string]interface{}{
|
|
|
|
"vaultServerUrl": vaultServerUrl,
|
|
|
|
"unknownConfig": "test",
|
|
|
|
}
|
|
|
|
|
2021-09-21 13:06:32 +02:00
|
|
|
config.mixinVaultConfig(nil, general, steps)
|
2021-01-20 15:59:47 +02:00
|
|
|
|
|
|
|
assert.Contains(t, config.Config, "vaultServerUrl")
|
|
|
|
assert.Equal(t, vaultServerUrl, config.Config["vaultServerUrl"])
|
|
|
|
assert.Contains(t, config.Config, "vaultPath")
|
|
|
|
assert.Equal(t, vaultPath, config.Config["vaultPath"])
|
|
|
|
assert.NotContains(t, config.Config, "unknownConfig")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-21 13:06:32 +02:00
|
|
|
func stepParam(name, refType, vaultSecretNameProperty, defaultSecretNameName string) StepParameters {
|
2020-07-22 11:15:48 +02:00
|
|
|
return StepParameters{
|
2020-11-06 18:54:01 +02:00
|
|
|
Name: name,
|
|
|
|
Aliases: []Alias{},
|
2020-07-22 11:15:48 +02:00
|
|
|
ResourceRef: []ResourceReference{
|
2020-09-24 08:58:53 +02:00
|
|
|
{
|
2021-09-21 13:06:32 +02:00
|
|
|
Type: refType,
|
|
|
|
Name: vaultSecretNameProperty,
|
|
|
|
Default: defaultSecretNameName,
|
2020-07-22 11:15:48 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2020-11-06 18:54:01 +02:00
|
|
|
|
|
|
|
func addAlias(param *StepParameters, aliasName string) {
|
|
|
|
alias := Alias{Name: aliasName}
|
|
|
|
param.Aliases = append(param.Aliases, alias)
|
|
|
|
}
|
2021-04-09 10:04:35 +02:00
|
|
|
|
2021-08-11 16:20:08 +02:00
|
|
|
func TestResolveVaultTestCredentials(t *testing.T) {
|
|
|
|
t.Parallel()
|
2021-12-21 12:00:13 +02:00
|
|
|
t.Run("Default test credential prefix", func(t *testing.T) {
|
2021-08-11 16:20:08 +02:00
|
|
|
t.Parallel()
|
|
|
|
// init
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
envPrefix := "PIPER_TESTCREDENTIAL_"
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
"vaultTestCredentialPath": "appCredentials",
|
|
|
|
"vaultTestCredentialKeys": []interface{}{"appUser", "appUserPw"},
|
|
|
|
}}
|
|
|
|
|
|
|
|
defer os.Unsetenv("PIPER_TESTCREDENTIAL_APPUSER")
|
|
|
|
defer os.Unsetenv("PIPER_TESTCREDENTIAL_APPUSERPW")
|
|
|
|
|
|
|
|
// mock
|
|
|
|
vaultData := map[string]string{"appUser": "test-user", "appUserPw": "password1234"}
|
|
|
|
vaultMock.On("GetKvSecret", "team1/appCredentials").Return(vaultData, nil)
|
|
|
|
|
|
|
|
// test
|
|
|
|
resolveVaultTestCredentials(&stepConfig, vaultMock)
|
|
|
|
|
|
|
|
// assert
|
|
|
|
for k, v := range vaultData {
|
|
|
|
env := envPrefix + strings.ToUpper(k)
|
|
|
|
assert.NotEmpty(t, os.Getenv(env))
|
|
|
|
assert.Equal(t, os.Getenv(env), v)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-06-27 09:24:52 +02:00
|
|
|
// Test empty and non-empty custom general purpose credential prefix
|
|
|
|
envPrefixes := []string{"CUSTOM_MYCRED_", ""}
|
|
|
|
for _, envPrefix := range envPrefixes {
|
|
|
|
t.Run("Custom general purpose credential prefix along with fixed standard prefix", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
// init
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
standardEnvPrefix := "PIPER_VAULTCREDENTIAL_"
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
"vaultCredentialPath": "appCredentials",
|
|
|
|
"vaultCredentialKeys": []interface{}{"appUser", "appUserPw"},
|
|
|
|
"vaultCredentialEnvPrefix": envPrefix,
|
|
|
|
}}
|
|
|
|
|
|
|
|
defer os.Unsetenv(envPrefix + "APPUSER")
|
|
|
|
defer os.Unsetenv(envPrefix + "APPUSERPW")
|
|
|
|
defer os.Unsetenv("PIPER_VAULTCREDENTIAL_APPUSER")
|
|
|
|
defer os.Unsetenv("PIPER_VAULTCREDENTIAL_APPUSERPW")
|
|
|
|
|
|
|
|
// mock
|
|
|
|
vaultData := map[string]string{"appUser": "test-user", "appUserPw": "password1234"}
|
|
|
|
vaultMock.On("GetKvSecret", "team1/appCredentials").Return(vaultData, nil)
|
|
|
|
|
|
|
|
// test
|
|
|
|
resolveVaultCredentials(&stepConfig, vaultMock)
|
|
|
|
|
|
|
|
// assert
|
|
|
|
for k, v := range vaultData {
|
|
|
|
env := envPrefix + strings.ToUpper(k)
|
|
|
|
assert.NotEmpty(t, os.Getenv(env))
|
|
|
|
assert.Equal(t, os.Getenv(env), v)
|
|
|
|
standardEnv := standardEnvPrefix + strings.ToUpper(k)
|
|
|
|
assert.NotEmpty(t, os.Getenv(standardEnv))
|
|
|
|
assert.Equal(t, os.Getenv(standardEnv), v)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2021-12-21 12:00:13 +02:00
|
|
|
|
|
|
|
t.Run("Custom test credential prefix", func(t *testing.T) {
|
2021-08-11 16:20:08 +02:00
|
|
|
t.Parallel()
|
|
|
|
// init
|
|
|
|
vaultMock := &mocks.VaultMock{}
|
|
|
|
envPrefix := "CUSTOM_CREDENTIAL_"
|
|
|
|
stepConfig := StepConfig{Config: map[string]interface{}{
|
|
|
|
"vaultPath": "team1",
|
|
|
|
"vaultTestCredentialPath": "appCredentials",
|
|
|
|
"vaultTestCredentialKeys": []interface{}{"appUser", "appUserPw"},
|
|
|
|
"vaultTestCredentialEnvPrefix": envPrefix,
|
|
|
|
}}
|
|
|
|
|
|
|
|
defer os.Unsetenv("CUSTOM_CREDENTIAL_APPUSER")
|
|
|
|
defer os.Unsetenv("CUSTOM_CREDENTIAL_APPUSERPW")
|
|
|
|
|
|
|
|
// mock
|
|
|
|
vaultData := map[string]string{"appUser": "test-user", "appUserPw": "password1234"}
|
|
|
|
vaultMock.On("GetKvSecret", "team1/appCredentials").Return(vaultData, nil)
|
|
|
|
|
|
|
|
// test
|
|
|
|
resolveVaultTestCredentials(&stepConfig, vaultMock)
|
|
|
|
|
|
|
|
// assert
|
|
|
|
for k, v := range vaultData {
|
|
|
|
env := envPrefix + strings.ToUpper(k)
|
|
|
|
assert.NotEmpty(t, os.Getenv(env))
|
|
|
|
assert.Equal(t, os.Getenv(env), v)
|
|
|
|
}
|
|
|
|
})
|
2021-04-09 10:04:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_convertEnvVar(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
s string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty string",
|
|
|
|
args: args{""},
|
|
|
|
want: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "alphanumerical string",
|
|
|
|
args: args{"myApp1"},
|
|
|
|
want: "MYAPP1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "string with hyphen",
|
|
|
|
args: args{"my_App-1"},
|
|
|
|
want: "MY_APP_1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "string with special characters",
|
|
|
|
args: args{"my_App?-(1]"},
|
|
|
|
want: "MY_APP_1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
if got := convertEnvVar(tt.args.s); got != tt.want {
|
|
|
|
t.Errorf("convertEnvironment() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|