1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-01 23:16:22 +00:00

Do not rewrite SELinux labels on volume mounts

This commit is contained in:
Sebastiaan van Steenis
2021-03-16 10:54:01 +01:00
parent 6f1661aaa9
commit 0cea67e9ff
28 changed files with 681 additions and 250 deletions

19
util/util_test.go Normal file
View File

@@ -0,0 +1,19 @@
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)
}