|
| 1 | +package tests |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + helmtests "github.com/airbytehq/airbyte-platform-internal/oss/charts/helm-tests" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestKeycloakDisabledCommunityEdition(t *testing.T) { |
| 11 | + opts := helmtests.BaseHelmOptions() |
| 12 | + opts.SetValues["global.edition"] = "community" |
| 13 | + opts.SetValues["keycloak.enabled"] = "false" |
| 14 | + |
| 15 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 16 | + assert.NoError(t, err) |
| 17 | + |
| 18 | + // Verify keycloak resources are not created when disabled or community edition |
| 19 | + helmtests.AssertNoResource(t, chartYaml.String(), "StatefulSet", "airbyte-keycloak") |
| 20 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-svc") |
| 21 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-headless-svc") |
| 22 | +} |
| 23 | + |
| 24 | +func TestKeycloakDisabledEnterpriseEdition(t *testing.T) { |
| 25 | + opts := helmtests.BaseHelmOptionsForEnterprise() |
| 26 | + opts.SetValues["keycloak.enabled"] = "false" |
| 27 | + |
| 28 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 29 | + assert.NoError(t, err) |
| 30 | + |
| 31 | + // Verify keycloak resources are not created when disabled even with enterprise edition |
| 32 | + helmtests.AssertNoResource(t, chartYaml.String(), "StatefulSet", "airbyte-keycloak") |
| 33 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-svc") |
| 34 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-headless-svc") |
| 35 | +} |
| 36 | + |
| 37 | +func TestKeycloakEnabledEnterpriseEdition(t *testing.T) { |
| 38 | + opts := helmtests.BaseHelmOptionsForEnterprise() |
| 39 | + opts.SetValues["keycloak.enabled"] = "true" |
| 40 | + |
| 41 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 42 | + assert.NoError(t, err) |
| 43 | + |
| 44 | + // Verify keycloak resources are created when enabled and enterprise edition |
| 45 | + assert.NotNil(t, helmtests.GetStatefulSet(chartYaml.String(), "airbyte-keycloak")) |
| 46 | + assert.NotNil(t, helmtests.GetService(chartYaml.String(), "airbyte-airbyte-keycloak-svc")) |
| 47 | + assert.NotNil(t, helmtests.GetService(chartYaml.String(), "airbyte-airbyte-keycloak-headless-svc")) |
| 48 | +} |
| 49 | + |
| 50 | +func TestKeycloakEnabledCommunityEdition(t *testing.T) { |
| 51 | + opts := helmtests.BaseHelmOptions() |
| 52 | + opts.SetValues["global.edition"] = "community" |
| 53 | + opts.SetValues["keycloak.enabled"] = "true" |
| 54 | + |
| 55 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 56 | + assert.NoError(t, err) |
| 57 | + |
| 58 | + // Verify keycloak resources are not created when community edition (even if enabled) |
| 59 | + helmtests.AssertNoResource(t, chartYaml.String(), "StatefulSet", "airbyte-keycloak") |
| 60 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-svc") |
| 61 | + helmtests.AssertNoResource(t, chartYaml.String(), "Service", "airbyte-airbyte-keycloak-headless-svc") |
| 62 | +} |
0 commit comments