|
@@ -118,3 +118,18 @@ func TestExec(t *testing.T) {
|
|
assert.Assert(t, is.Contains(out, "PWD=/tmp"), "exec command not running in expected /tmp working directory")
|
|
assert.Assert(t, is.Contains(out, "PWD=/tmp"), "exec command not running in expected /tmp working directory")
|
|
assert.Assert(t, is.Contains(out, "FOO=BAR"), "exec command not running with expected environment variable FOO")
|
|
assert.Assert(t, is.Contains(out, "FOO=BAR"), "exec command not running with expected environment variable FOO")
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func TestExecUser(t *testing.T) {
|
|
|
|
+ skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.39"), "broken in earlier versions")
|
|
|
|
+ skip.If(t, testEnv.OSType == "windows", "FIXME. Probably needs to wait for container to be in running state.")
|
|
|
|
+ defer setupTest(t)()
|
|
|
|
+ ctx := context.Background()
|
|
|
|
+ client := testEnv.APIClient()
|
|
|
|
+
|
|
|
|
+ cID := container.Run(t, ctx, client, container.WithTty(true), container.WithUser("1:1"))
|
|
|
|
+
|
|
|
|
+ result, err := container.Exec(ctx, client, cID, []string{"id"})
|
|
|
|
+ assert.NilError(t, err)
|
|
|
|
+
|
|
|
|
+ assert.Assert(t, is.Contains(result.Stdout(), "uid=1(daemon) gid=1(daemon)"), "exec command not running as uid/gid 1")
|
|
|
|
+}
|