c2f079b4e3
* feat(helm): add helm chart backport to ce EE-1409 (#5425) * EE-1311 Helm Chart Backport from EE * backport to ce Co-authored-by: Matt Hook <hookenz@gmail.com> * feat(helm) helm chart backport from ee EE-1311 (#5436) * Add missing defaultHelmRepoUrl and mock testing * Backport EE-1477 * Backport updates to helm tests from EE * add https by default changes and ssl to tls renaming from EE * Port install integration test. Disabled by default to pass CI checks * merged changes from EE for the integration test * kube proxy whitelist updated to support internal helm install command Co-authored-by: zees-dev <dev.786zshan@gmail.com> * Pull in all changes from tech review in EE-943 * feat(helm): add helm chart backport to ce EE-1409 (#5425) * EE-1311 Helm Chart Backport from EE * backport to ce Co-authored-by: Matt Hook <hookenz@gmail.com> * Pull in all changes from tech review in EE-943 * added helm to sidebar after rebase, sync CE with EE * backport EE-1278, squashed, diffed, updated * helm install openapi spec update * resolved conflicts, updated code * - matching ee codebase at 0afe57034449ee0e9f333d92c252a13995a93019 - helm install using endpoint middleware - remove trailing slash from added/persisted helm repo urls * feat(helm) use libhelm url validator and improved path assembly EE-1554 (#5561) * feat(helm/userrepos) fix getting global repo for ordinary users EE-1562 (#5567) * feat(helm/userrepos) fix getting global repo for ordinary users EE-1562 * post review changes and further backported changes from EE * resolved conflicts, updated code * fixed helm_install handler unit test * user cannot add existing repo if suffix is '/' (#5571) * feat(helm/docs) fix broken swagger docs EE-1278 (#5572) * Fix swagger docs * minor correction * fix(helm): migrating code from user handler to helm handler (#5573) * - migrated user_helm_repos to helm endpoint handler - migrated api operations from user factory/service to helm factory/service - passing endpointId into helm service/factory as endpoint provider is deprecated * upgrade libhelm to hide secrets Co-authored-by: Matt Hook <hookenz@gmail.com> * removed duplicate file - due to merge conflict * dependency injection in helm factory Co-authored-by: Richard Wei <54336863+WaysonWei@users.noreply.github.com> Co-authored-by: Matt Hook <hookenz@gmail.com>
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package helm
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/portainer/libhelm/binary/test"
|
|
helper "github.com/portainer/portainer/api/internal/testhelpers"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_helmShow(t *testing.T) {
|
|
is := assert.New(t)
|
|
|
|
helmPackageManager := test.NewMockHelmBinaryPackageManager("")
|
|
h := NewTemplateHandler(helper.NewTestRequestBouncer(), helmPackageManager)
|
|
|
|
is.NotNil(h, "Handler should not fail")
|
|
|
|
commands := map[string]string{
|
|
"values": test.MockDataValues,
|
|
"chart": test.MockDataChart,
|
|
"readme": test.MockDataReadme,
|
|
}
|
|
|
|
for cmd, expect := range commands {
|
|
t.Run(cmd, func(t *testing.T) {
|
|
is.NotNil(h, "Handler should not fail")
|
|
|
|
repoUrlEncoded := url.QueryEscape("https://charts.bitnami.com/bitnami")
|
|
chart := "nginx"
|
|
req := httptest.NewRequest("GET", fmt.Sprintf("/templates/helm/%s?repo=%s&chart=%s", cmd, repoUrlEncoded, chart), nil)
|
|
rr := httptest.NewRecorder()
|
|
h.ServeHTTP(rr, req)
|
|
|
|
is.Equal(rr.Code, http.StatusOK, "Status should be 200 OK")
|
|
|
|
body, err := io.ReadAll(rr.Body)
|
|
is.NoError(err, "ReadAll should not return error")
|
|
is.EqualValues(string(body), expect, "Unexpected search response")
|
|
})
|
|
}
|
|
}
|