Add test for null user in ProcessConfig
@@ -3036,6 +3036,45 @@ public class DefaultDockerClientTest {
}
}
+ @Test
+ public void testExecInspectNoUser() throws Exception {
+ requireDockerApiVersionAtLeast("1.16", "Exec Inspect");
+
+ sut.pull(BUSYBOX_LATEST);
+
+ final ContainerConfig containerConfig = ContainerConfig.builder()
+ .image(BUSYBOX_LATEST)
+ .cmd("sh", "-c", "while :; do sleep 1; done")
+ .build();
+ final String containerName = randomName();
+ final ContainerCreation containerCreation = sut.createContainer(containerConfig, containerName);
+ final String containerId = containerCreation.id();
+
+ sut.startContainer(containerId);
+
+ final List<ExecCreateParam> createParams = newArrayList(
+ ExecCreateParam.attachStdout(),
+ ExecCreateParam.attachStderr(),
+ ExecCreateParam.attachStdin(),
+ ExecCreateParam.tty());
+
+ final ExecCreation execCreation = sut.execCreate(
+ containerId, new String[] {"sh", "-c", "exit 2"},
+ createParams.toArray(new ExecCreateParam[createParams.size()]));
+ final String execId = execCreation.id();
+
+ log.info("execId = {}", execId);
+ try (final LogStream stream = sut.execStart(execId)) {
+ stream.readFully();
+ }
+
+ final ExecState state = sut.execInspect(execId);
+ assertThat(state.id(), is(execId));
+
+ final ProcessConfig processConfig = state.processConfig();
+ assertThat(processConfig.user(), is(nullValue()));
+ }
+
@Test
public void testListContainers() throws Exception {
sut.pull(BUSYBOX_LATEST);
