argo-cd/util/helm/cmd_test.go
Chetan Banavikalmutt 9476ab5e18
feat: add first class support to access repositories using proxy (#5581) (#6286)
* feat: add first class support to access repositories using proxy

Currently, users need to set the proxy URLs as env variables in the repo server. This is not user-friendly and also error-prone. This PR adds support to maintain proxy URLs along with repository configs in the argocd-cm. Argo CD uses this proxy to access your repository. In case the custom proxy is absent, it defaults to reading the proxy from the env variables.

Signed-off-by: Chetan Banavikalmutt <chetanrns1997@gmail.com>

* set both http & https proxy variables

Signed-off-by: Chetan Banavikalmutt <chetanrns1997@gmail.com>
2021-06-16 14:45:10 +02:00

54 lines
1.4 KiB
Go

package helm
import (
"log"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_cmd_redactor(t *testing.T) {
assert.Equal(t, "--foo bar", redactor("--foo bar"))
assert.Equal(t, "--username ******", redactor("--username bar"))
assert.Equal(t, "--password ******", redactor("--password bar"))
}
func TestCmd_template_kubeVersion(t *testing.T) {
cmd, err := NewCmdWithVersion(".", HelmV3, false, "")
assert.NoError(t, err)
s, err := cmd.template("testdata/redis", &TemplateOpts{
KubeVersion: "1.14",
})
assert.NoError(t, err)
assert.NotEmpty(t, s)
}
func TestNewCmd_helmV2(t *testing.T) {
cmd, err := NewCmd(".", "v2", "")
assert.NoError(t, err)
assert.Equal(t, "helm2", cmd.HelmVer.binaryName)
}
func TestNewCmd_helmV3(t *testing.T) {
cmd, err := NewCmd(".", "v3", "")
assert.NoError(t, err)
assert.Equal(t, "helm", cmd.HelmVer.binaryName)
}
func TestNewCmd_helmDefaultVersion(t *testing.T) {
cmd, err := NewCmd(".", "", "")
assert.NoError(t, err)
assert.Equal(t, "helm", cmd.HelmVer.binaryName)
}
func TestNewCmd_helmInvalidVersion(t *testing.T) {
_, err := NewCmd(".", "abcd", "")
log.Println(err)
assert.EqualError(t, err, "helm chart version 'abcd' is not supported")
}
func TestNewCmd_withProxy(t *testing.T) {
cmd, err := NewCmd(".", "", "https://proxy:8888")
assert.NoError(t, err)
assert.Equal(t, "https://proxy:8888", cmd.proxy)
}