MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / TestModifyHostConfigWithGroups

Function TestModifyHostConfigWithGroups

core/security_context_test.go:217–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

215}
216
217func TestModifyHostConfigWithGroups(t *testing.T) {
218 supplementalGroupsSC := &runtimeapi.LinuxContainerSecurityContext{}
219 supplementalGroupsSC.SupplementalGroups = []int64{2222}
220 supplementalGroupHC := &dockercontainer.HostConfig{}
221 supplementalGroupHC.GroupAdd = []string{"2222"}
222
223 testCases := []struct {
224 name string
225 securityContext *runtimeapi.LinuxContainerSecurityContext
226 expected *dockercontainer.HostConfig
227 }{
228 {
229 name: "nil",
230 securityContext: nil,
231 expected: &dockercontainer.HostConfig{},
232 },
233 {
234 name: "SupplementalGroup",
235 securityContext: supplementalGroupsSC,
236 expected: supplementalGroupHC,
237 },
238 }
239
240 for _, tc := range testCases {
241 dockerCfg := &dockercontainer.HostConfig{}
242 modifyHostConfig(tc.securityContext, dockerCfg, '=')
243 assert.Equal(t, tc.expected, dockerCfg, "[Test case %q]", tc.name)
244 }
245}
246
247func TestModifyHostConfigAndNamespaceOptionsForContainer(t *testing.T) {
248 sandboxID := "sandbox"

Callers

nothing calls this directly

Calls 1

modifyHostConfigFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…