forked from gruntwork-io/helm-kubernetes-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s_service_volume_secret_store_csi_template_test.go
53 lines (41 loc) · 1.7 KB
/
k8s_service_volume_secret_store_csi_template_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//go:build all || tpl
// +build all tpl
// NOTE: We use build flags to differentiate between template tests and integration tests so that you can conveniently
// run just the template tests. See the test README for more information.
package test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestK8SServiceDeploymentCheckSecretStoreCSIBlock(t *testing.T) {
t.Parallel()
deployment := renderK8SServiceDeploymentWithSetValues(
t,
map[string]string{
"secrets.dbsettings.as": "csi",
"secrets.dbsettings.mountPath": "/etc/db",
"secrets.dbsettings.readOnly": "true",
"secrets.dbsettings.csi.driver": "secrets-store.csi.k8s.io",
"secrets.dbsettings.csi.secretProviderClass": "secret-provider-class",
"secrets.dbsettings.items.host.envVarName": "DB_HOST",
"secrets.dbsettings.items.port.envVarName": "DB_PORT",
},
)
// Verify that there is only one container and only one volume
renderedPodContainers := deployment.Spec.Template.Spec.Containers
require.Equal(t, len(renderedPodContainers), 1)
renderedPodVolumes := deployment.Spec.Template.Spec.Volumes
require.Equal(t, len(renderedPodVolumes), 1)
podVolume := renderedPodVolumes[0]
// Check that the pod volume has a correct name
assert.Equal(t, podVolume.Name, "dbsettings-volume")
// Check that the pod volume has CSI block
assert.NotNil(t, podVolume.CSI)
// Check that the pod volume has correct CSI driver and attributes
assert.Equal(t, podVolume.CSI.Driver, "secrets-store.csi.k8s.io")
assert.NotNil(t, podVolume.CSI.VolumeAttributes)
assert.Equal(t, podVolume.CSI.VolumeAttributes, map[string]string{
"secretProviderClass": "secret-provider-class",
})
}