From f12318546f0d70ddf06768e435d6c813cf9418e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 12 Oct 2026 01:28:01 +0200 Subject: [PATCH] Fix `execCreate()` to send numeric `$user` as string --- src/Client.php | 2 +- tests/ClientTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 3064342..bd03c67 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1280,7 +1280,7 @@ public function execCreate($container, $cmd, $tty = false, $stdin = false, $stdo 'AttachStdin' => !!$stdin, 'AttachStdout' => !!$stdout, 'AttachStderr' => !!$stderr, - 'User' => $user, + 'User' => (string) $user, 'Privileged' => !!$privileged, ) )->then(array($this->parser, 'expectJson')); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 8f3ff1b..7a06f78 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -655,6 +655,15 @@ public function testExecCreateStringCommand() $this->expectPromiseResolveWith($json, $this->client->execCreate(123, 'env')); } + public function testExecCreateWithNumericUser() + { + $json = array(); + $this->browser->expects($this->once())->method('post')->with('containers/123/exec', $this->anything(), '{"Cmd":["env"],"Tty":false,"AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"User":"1000","Privileged":false}')->willReturn(\React\Promise\resolve($this->createResponseJson($json))); + $this->parser->expects($this->once())->method('expectJson')->willReturn($json); + + $this->expectPromiseResolveWith($json, $this->client->execCreate(123, array('env'), false, false, true, true, 1000)); + } + public function testExecDetached() { $body = '';