github.com/kotalco/kotal@v0.3.0/controllers/shared/security_context_test.go (about) 1 package shared 2 3 import ( 4 "testing" 5 6 corev1 "k8s.io/api/core/v1" 7 ) 8 9 func TestSecurityContext(t *testing.T) { 10 var userId int64 = 1000 11 var groupId int64 = 3000 12 var fsGroupId int64 = 2000 13 var nonRoot = true 14 policy := corev1.FSGroupChangeOnRootMismatch 15 16 context := SecurityContext() 17 18 if *context.RunAsUser != userId { 19 t.Errorf("expected user id to be %d, got %d", userId, *context.RunAsUser) 20 } 21 22 if *context.RunAsGroup != groupId { 23 t.Errorf("expected group id to be %d, got %d", groupId, *context.RunAsGroup) 24 } 25 26 if *context.FSGroup != fsGroupId { 27 t.Errorf("expected fs group id to be %d, got %d", fsGroupId, *context.FSGroup) 28 } 29 30 if *context.RunAsNonRoot != nonRoot { 31 t.Errorf("expected non root to be %t, got %t", nonRoot, *context.RunAsNonRoot) 32 } 33 34 if *context.FSGroupChangePolicy != policy { 35 t.Errorf("expected fs group change policy to be %s, got %s", policy, *context.FSGroupChangePolicy) 36 } 37 38 }