1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 19:25:44 +00:00
rke/util/util_test.go
2021-11-19 22:39:56 +01:00

20 lines
838 B
Go

package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRemoveZFromBinds(t *testing.T) {
binds := []string{"/etc/kubernetes:/etc/kubernetes:z", "/var/log/kube-audit:/var/log/kube-audit:rw,z", "/var/lib/test:/var/lib/test:Z,ro", "/usr/local/lib/test:/usr/local/lib/test:ro,z,noexec", "/etc/normalz:/etc/normalz"}
expectedBinds := []string{"/etc/kubernetes:/etc/kubernetes", "/var/log/kube-audit:/var/log/kube-audit:rw", "/var/lib/test:/var/lib/test:ro", "/usr/local/lib/test:/usr/local/lib/test:ro,noexec", "/etc/normalz:/etc/normalz"}
removedBinds := RemoveZFromBinds(binds)
assert.ElementsMatch(t, expectedBinds, removedBinds)
emptyBinds, expectedEmptyBinds := []string{}, []string{}
removedEmptyBinds := RemoveZFromBinds(emptyBinds)
assert.ElementsMatch(t, expectedEmptyBinds, removedEmptyBinds)
}