summaryrefslogtreecommitdiffstats
path: root/tests/lib/appframework/http/DispatcherTest.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-09 11:41:48 +0100
committerLukas Reschke <lukas@owncloud.com>2015-02-09 11:53:11 +0100
commit770fa761b8bf8452ff17a2036ca8413e74935a3d (patch)
treeecce3b7443278b0ebdac588ba40840190a3aadcd /tests/lib/appframework/http/DispatcherTest.php
parent0e604aa875a677f76b2bf326631646ac31fbadbd (diff)
downloadnextcloud-server-770fa761b8bf8452ff17a2036ca8413e74935a3d.tar.gz
nextcloud-server-770fa761b8bf8452ff17a2036ca8413e74935a3d.zip
Respect `mod_unique_id` and refactor `OC_Request::getRequestId`
When `mod_unique_id` is enabled the ID generated by it will be used for logging. This allows for correlation of the Apache logs and the ownCloud logs. Testplan: - [ ] When `mod_unique_id` is enabled the request ID equals the one generated by `mod_unique_id`. - [ ] When `mod_unique_id` is not available the request ID is a 20 character long random string - [ ] The generated Id is stable over the lifespan of one request Changeset looks a little bit larger since I had to adjust every unit test using the HTTP\Request class for proper DI. Fixes https://github.com/owncloud/core/issues/13366
Diffstat (limited to 'tests/lib/appframework/http/DispatcherTest.php')
-rw-r--r--tests/lib/appframework/http/DispatcherTest.php132
1 files changed, 75 insertions, 57 deletions
diff --git a/tests/lib/appframework/http/DispatcherTest.php b/tests/lib/appframework/http/DispatcherTest.php
index 3933e00804b..832cd80e60a 100644
--- a/tests/lib/appframework/http/DispatcherTest.php
+++ b/tests/lib/appframework/http/DispatcherTest.php
@@ -276,13 +276,16 @@ class DispatcherTest extends \Test\TestCase {
public function testControllerParametersInjected() {
- $this->request = new Request(array(
- 'post' => array(
+ $this->request = new Request(
+ [
+ 'post' => [
'int' => '3',
'bool' => 'false'
- ),
- 'method' => 'POST'
- ));
+ ],
+ 'method' => 'POST'
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request
@@ -298,14 +301,17 @@ class DispatcherTest extends \Test\TestCase {
public function testControllerParametersInjectedDefaultOverwritten() {
- $this->request = new Request(array(
- 'post' => array(
- 'int' => '3',
- 'bool' => 'false',
- 'test2' => 7
- ),
- 'method' => 'POST'
- ));
+ $this->request = new Request(
+ [
+ 'post' => [
+ 'int' => '3',
+ 'bool' => 'false',
+ 'test2' => 7
+ ],
+ 'method' => 'POST',
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request
@@ -322,16 +328,19 @@ class DispatcherTest extends \Test\TestCase {
public function testResponseTransformedByUrlFormat() {
- $this->request = new Request(array(
- 'post' => array(
- 'int' => '3',
- 'bool' => 'false'
- ),
- 'urlParams' => array(
- 'format' => 'text'
- ),
- 'method' => 'GET'
- ));
+ $this->request = new Request(
+ [
+ 'post' => [
+ 'int' => '3',
+ 'bool' => 'false'
+ ],
+ 'urlParams' => [
+ 'format' => 'text'
+ ],
+ 'method' => 'GET'
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request
@@ -347,16 +356,19 @@ class DispatcherTest extends \Test\TestCase {
public function testResponseTransformsDataResponse() {
- $this->request = new Request(array(
- 'post' => array(
- 'int' => '3',
- 'bool' => 'false'
- ),
- 'urlParams' => array(
- 'format' => 'json'
- ),
- 'method' => 'GET'
- ));
+ $this->request = new Request(
+ [
+ 'post' => [
+ 'int' => '3',
+ 'bool' => 'false'
+ ],
+ 'urlParams' => [
+ 'format' => 'json'
+ ],
+ 'method' => 'GET'
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request
@@ -372,17 +384,20 @@ class DispatcherTest extends \Test\TestCase {
public function testResponseTransformedByAcceptHeader() {
- $this->request = new Request(array(
- 'post' => array(
- 'int' => '3',
- 'bool' => 'false'
- ),
- 'server' => array(
- 'HTTP_ACCEPT' => 'application/text, test',
- 'HTTP_CONTENT_TYPE' => 'application/x-www-form-urlencoded'
- ),
- 'method' => 'PUT'
- ));
+ $this->request = new Request(
+ [
+ 'post' => [
+ 'int' => '3',
+ 'bool' => 'false'
+ ],
+ 'server' => [
+ 'HTTP_ACCEPT' => 'application/text, test',
+ 'HTTP_CONTENT_TYPE' => 'application/x-www-form-urlencoded'
+ ],
+ 'method' => 'PUT'
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request
@@ -398,19 +413,22 @@ class DispatcherTest extends \Test\TestCase {
public function testResponsePrimarilyTransformedByParameterFormat() {
- $this->request = new Request(array(
- 'post' => array(
- 'int' => '3',
- 'bool' => 'false'
- ),
- 'get' => array(
- 'format' => 'text'
- ),
- 'server' => array(
- 'HTTP_ACCEPT' => 'application/json, test'
- ),
- 'method' => 'POST'
- ));
+ $this->request = new Request(
+ [
+ 'post' => [
+ 'int' => '3',
+ 'bool' => 'false'
+ ],
+ 'get' => [
+ 'format' => 'text'
+ ],
+ 'server' => [
+ 'HTTP_ACCEPT' => 'application/json, test'
+ ],
+ 'method' => 'POST'
+ ],
+ $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock()
+ );
$this->dispatcher = new Dispatcher(
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request