From a1080170eefb4250a7ae96d472aec679abee8fc1 Mon Sep 17 00:00:00 2001 From: "Andreas Goelzer (NuoDB)" <139239314+agoelzer@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:45:55 -0400 Subject: [PATCH] [HELM-422] validate helm `archiveType` value (#360) * [HELM-422] validate helm `archiveType` value * use enum value instead --------- Co-authored-by: Andreas Goelzer --- stable/database/values.schema.json | 24 ++++++++++ test/integration/template_database_test.go | 54 ++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 stable/database/values.schema.json diff --git a/stable/database/values.schema.json b/stable/database/values.schema.json new file mode 100644 index 000000000..70fa19bc5 --- /dev/null +++ b/stable/database/values.schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "required": [ + "database" + ], + "properties": { + "database": { + "type": "object", + "required": [ + "archiveType" + ], + "properties": { + "archiveType": { + "type": "string", + "enum": [ + "", + "lsa" + ] + } + } + } + } +} \ No newline at end of file diff --git a/test/integration/template_database_test.go b/test/integration/template_database_test.go index 8cbb646c8..92e4ab31d 100644 --- a/test/integration/template_database_test.go +++ b/test/integration/template_database_test.go @@ -251,6 +251,60 @@ func TestDatabaseNodePortServiceRenders(t *testing.T) { } } +func TestDatabaseInvalidArchiveType(t *testing.T) { + // Path to the helm chart we will test + helmChartPath := testlib.DATABASE_HELM_CHART_PATH + + options := &helm.Options{ + SetValues: map[string]string{ + "cloud.provider": "amazon", + "database.te.externalAccess.enabled": "true", + "database.te.externalAccess.type": "NodePort", + "database.te.externalAccess.internalIP": "true", + "database.archiveType": "invalid", + }, + } + + _, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"}) + assert.Contains(t, err.Error(), "database.archiveType must be one of the following:") +} + +func TestDatabaseLsaArchiveType(t *testing.T) { + // Path to the helm chart we will test + helmChartPath := testlib.DATABASE_HELM_CHART_PATH + + options := &helm.Options{ + SetValues: map[string]string{ + "cloud.provider": "amazon", + "database.te.externalAccess.enabled": "true", + "database.te.externalAccess.type": "NodePort", + "database.te.externalAccess.internalIP": "true", + "database.archiveType": "lsa", + }, + } + + _, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"}) + assert.Nil(t, err) +} + +func TestDatabaseEmptyArchiveType(t *testing.T) { + // Path to the helm chart we will test + helmChartPath := testlib.DATABASE_HELM_CHART_PATH + + options := &helm.Options{ + SetValues: map[string]string{ + "cloud.provider": "amazon", + "database.te.externalAccess.enabled": "true", + "database.te.externalAccess.type": "NodePort", + "database.te.externalAccess.internalIP": "true", + "database.archiveType": "", + }, + } + + _, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"}) + assert.Nil(t, err) +} + func TestDatabaseStatefulSet(t *testing.T) { // Path to the helm chart we will test helmChartPath := testlib.DATABASE_HELM_CHART_PATH