MCPcopy
hub / github.com/moby/moby / TestExecWithGroupAdd

Function TestExecWithGroupAdd

integration/container/exec_test.go:420–433  ·  view source on GitHub ↗

Test that additional groups set with `--group-add` are kept on exec when the container also has a user set. (regression test for https://github.com/moby/moby/issues/46712)

(t *testing.T)

Source from the content-addressed store, hash-verified

418// also has a user set.
419// (regression test for https://github.com/moby/moby/issues/46712)
420func TestExecWithGroupAdd(t *testing.T) {
421 skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME. Probably needs to wait for container to be in running state.")
422
423 ctx := setupTest(t)
424 apiClient := testEnv.APIClient()
425
426 cID := container.Run(ctx, t, apiClient, container.WithTty(true), container.WithUser("root:root"), container.WithAdditionalGroups("staff", "wheel", "audio", "777"), container.WithCmd("sleep", "5"))
427
428 result, err := container.Exec(ctx, apiClient, cID, []string{"id"})
429 assert.NilError(t, err)
430
431 const expected = "uid=0(root) gid=0(root) groups=0(root),10(wheel),29(audio),50(staff),777"
432 assert.Check(t, is.Equal(strings.TrimSpace(result.Stdout()), expected), "exec command not keeping additional groups w/ user")
433}

Callers

nothing calls this directly

Calls 11

RunFunction · 0.92
WithTtyFunction · 0.92
WithUserFunction · 0.92
WithAdditionalGroupsFunction · 0.92
WithCmdFunction · 0.92
ExecFunction · 0.92
APIClientMethod · 0.80
CheckMethod · 0.80
EqualMethod · 0.80
setupTestFunction · 0.70
StdoutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…