diff options
author | Joas Schilling <coding@schilljs.com> | 2024-11-27 09:26:26 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-11-28 12:18:30 +0100 |
commit | 1909b981a4b3db83edfcd76fb4b6730a0cc8da81 (patch) | |
tree | 1cdf62eb69c03acf153427af05eeebf6f7a06a96 /tests/lib/AppFramework | |
parent | 14f7e566c4cfca78d22706321b8f0b6cf4878ddb (diff) | |
download | nextcloud-server-1909b981a4b3db83edfcd76fb4b6730a0cc8da81.tar.gz nextcloud-server-1909b981a4b3db83edfcd76fb4b6730a0cc8da81.zip |
fix(controller): Fix false booleans in multipart/form-data
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/AppFramework')
-rw-r--r-- | tests/lib/AppFramework/Http/DispatcherTest.php | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 94bcfcc4af2..7415ecd9486 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -328,7 +328,7 @@ class DispatcherTest extends \Test\TestCase { $this->dispatcherPassthrough(); $response = $this->dispatcher->dispatch($controller, 'exec'); - $this->assertEquals('[3,true,4,1]', $response[3]); + $this->assertEquals('[3,false,4,1]', $response[3]); } @@ -361,7 +361,7 @@ class DispatcherTest extends \Test\TestCase { $this->dispatcherPassthrough(); $response = $this->dispatcher->dispatch($controller, 'exec'); - $this->assertEquals('[3,true,4,7]', $response[3]); + $this->assertEquals('[3,false,4,7]', $response[3]); } @@ -471,6 +471,41 @@ class DispatcherTest extends \Test\TestCase { $this->assertEquals('{"text":[3,false,4,1]}', $response[3]); } + public function testResponseTransformedBySendingMultipartFormData(): void { + $this->request = new Request( + [ + 'post' => [ + 'int' => '3', + 'bool' => 'false', + 'double' => 1.2, + ], + 'server' => [ + 'HTTP_ACCEPT' => 'application/text, test', + 'HTTP_CONTENT_TYPE' => 'multipart/form-data' + ], + 'method' => 'POST' + ], + $this->createMock(IRequestId::class), + $this->createMock(IConfig::class) + ); + $this->dispatcher = new Dispatcher( + $this->http, $this->middlewareDispatcher, $this->reflector, + $this->request, + $this->config, + \OC::$server->getDatabaseConnection(), + $this->logger, + $this->eventLogger, + $this->container + ); + $controller = new TestController('app', $this->request); + + // reflector is supposed to be called once + $this->dispatcherPassthrough(); + $response = $this->dispatcher->dispatch($controller, 'exec'); + + $this->assertEquals('{"text":[3,false,4,1]}', $response[3]); + } + public function testResponsePrimarilyTransformedByParameterFormat(): void { $this->request = new Request( @@ -506,7 +541,7 @@ class DispatcherTest extends \Test\TestCase { $this->dispatcherPassthrough(); $response = $this->dispatcher->dispatch($controller, 'exec'); - $this->assertEquals('{"text":[3,true,4,1]}', $response[3]); + $this->assertEquals('{"text":[3,false,4,1]}', $response[3]); } |