|
@@ -66,13 +66,13 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
$this->session(['User' => ['id' => 1, 'username' => 'mark']]);
|
|
$this->session(['User' => ['id' => 1, 'username' => 'mark']]);
|
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
|
|
|
|
|
|
- $this->assertEquals('abc123', $request->header('X-CSRF-Token'));
|
|
|
|
|
- $this->assertEquals('tasks/add', $request->url);
|
|
|
|
|
- $this->assertArrayHasKey('split_token', $request->cookies);
|
|
|
|
|
- $this->assertEquals('def345', $request->cookies['split_token']);
|
|
|
|
|
- $this->assertEquals(['id' => '1', 'username' => 'mark'], $request->session()->read('User'));
|
|
|
|
|
- $this->assertEquals('foo', $request->env('PHP_AUTH_USER'));
|
|
|
|
|
- $this->assertEquals('bar', $request->env('PHP_AUTH_PW'));
|
|
|
|
|
|
|
+ $this->assertEquals('abc123', $request['environment']['HTTP_X_CSRF_TOKEN']);
|
|
|
|
|
+ $this->assertEquals('/tasks/add', $request['url']);
|
|
|
|
|
+ $this->assertArrayHasKey('split_token', $request['cookies']);
|
|
|
|
|
+ $this->assertEquals('def345', $request['cookies']['split_token']);
|
|
|
|
|
+ $this->assertEquals(['id' => '1', 'username' => 'mark'], $request['session']->read('User'));
|
|
|
|
|
+ $this->assertEquals('foo', $request['environment']['PHP_AUTH_USER']);
|
|
|
|
|
+ $this->assertEquals('bar', $request['environment']['PHP_AUTH_PW']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -85,9 +85,9 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
$this->enableCsrfToken();
|
|
$this->enableCsrfToken();
|
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
|
|
|
|
|
|
- $this->assertArrayHasKey('csrfToken', $request->cookies);
|
|
|
|
|
- $this->assertArrayHasKey('_csrfToken', $request->data);
|
|
|
|
|
- $this->assertSame($request->cookies['csrfToken'], $request->data['_csrfToken']);
|
|
|
|
|
|
|
+ $this->assertArrayHasKey('csrfToken', $request['cookies']);
|
|
|
|
|
+ $this->assertArrayHasKey('_csrfToken', $request['post']);
|
|
|
|
|
+ $this->assertSame($request['cookies']['csrfToken'], $request['post']['_csrfToken']);
|
|
|
|
|
|
|
|
$this->cookie('csrfToken', '');
|
|
$this->cookie('csrfToken', '');
|
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', [
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', [
|
|
@@ -95,8 +95,8 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
'title' => 'First post'
|
|
'title' => 'First post'
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- $this->assertSame('', $request->cookies['csrfToken']);
|
|
|
|
|
- $this->assertSame('fale', $request->data['_csrfToken']);
|
|
|
|
|
|
|
+ $this->assertSame('', $request['cookies']['csrfToken']);
|
|
|
|
|
+ $this->assertSame('fale', $request['post']['_csrfToken']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -109,10 +109,14 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
$this->enableCsrfToken();
|
|
$this->enableCsrfToken();
|
|
|
$first = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
$first = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
|
$second = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'Second post']);
|
|
$second = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'Second post']);
|
|
|
- $this->assertSame($first->cookies['csrfToken'], $second->data['_csrfToken'], 'Csrf token should match cookie');
|
|
|
|
|
$this->assertSame(
|
|
$this->assertSame(
|
|
|
- $first->data['_csrfToken'],
|
|
|
|
|
- $second->data['_csrfToken'],
|
|
|
|
|
|
|
+ $first['cookies']['csrfToken'],
|
|
|
|
|
+ $second['post']['_csrfToken'],
|
|
|
|
|
+ 'Csrf token should match cookie'
|
|
|
|
|
+ );
|
|
|
|
|
+ $this->assertSame(
|
|
|
|
|
+ $first['post']['_csrfToken'],
|
|
|
|
|
+ $second['post']['_csrfToken'],
|
|
|
'Tokens should be consistent per test method'
|
|
'Tokens should be consistent per test method'
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -128,8 +132,8 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
$value = 'I am a teapot';
|
|
$value = 'I am a teapot';
|
|
|
$this->cookie('csrfToken', $value);
|
|
$this->cookie('csrfToken', $value);
|
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
|
|
|
- $this->assertSame($value, $request->cookies['csrfToken'], 'Csrf token should match cookie');
|
|
|
|
|
- $this->assertSame($value, $request->data['_csrfToken'], 'Tokens should match');
|
|
|
|
|
|
|
+ $this->assertSame($value, $request['cookies']['csrfToken'], 'Csrf token should match cookie');
|
|
|
|
|
+ $this->assertSame($value, $request['post']['_csrfToken'], 'Tokens should match');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -141,8 +145,8 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
{
|
|
{
|
|
|
$request = $this->_buildRequest('/tasks/view?archived=yes', 'GET', []);
|
|
$request = $this->_buildRequest('/tasks/view?archived=yes', 'GET', []);
|
|
|
|
|
|
|
|
- $this->assertEquals('/tasks/view?archived=yes', $request->here());
|
|
|
|
|
- $this->assertEquals('yes', $request->query('archived'));
|
|
|
|
|
|
|
+ $this->assertEquals('/tasks/view', $request['url']);
|
|
|
|
|
+ $this->assertEquals('yes', $request['query']['archived']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -155,7 +159,7 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
Security::salt('abcdabcdabcdabcdabcdabcdabcdabcdabcd');
|
|
Security::salt('abcdabcdabcdabcdabcdabcdabcdabcdabcd');
|
|
|
$this->cookieEncrypted('KeyOfCookie', 'Encrypted with aes by default');
|
|
$this->cookieEncrypted('KeyOfCookie', 'Encrypted with aes by default');
|
|
|
$request = $this->_buildRequest('/tasks/view', 'GET', []);
|
|
$request = $this->_buildRequest('/tasks/view', 'GET', []);
|
|
|
- $this->assertStringStartsWith('Q2FrZQ==.', $request->cookies['KeyOfCookie']);
|
|
|
|
|
|
|
+ $this->assertStringStartsWith('Q2FrZQ==.', $request['cookies']['KeyOfCookie']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -188,9 +192,59 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
$this->assertNotEmpty($this->_response);
|
|
$this->assertNotEmpty($this->_response);
|
|
|
$this->assertInstanceOf('Cake\Network\Response', $this->_response);
|
|
$this->assertInstanceOf('Cake\Network\Response', $this->_response);
|
|
|
$this->assertEquals('This is a test', $this->_response->body());
|
|
$this->assertEquals('This is a test', $this->_response->body());
|
|
|
|
|
+ $this->assertHeader('X-Middleware', 'true');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Test that the PSR7 requests get query string data
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testQueryStringHttpServer()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->useHttpServer(true);
|
|
|
|
|
+
|
|
|
|
|
+ $this->configRequest(['headers' => ['Content-Type' => 'text/plain']]);
|
|
|
|
|
+ $this->get('/request_action/params_pass?q=query');
|
|
|
|
|
+ $this->assertResponseOk();
|
|
|
|
|
+ $this->assertResponseContains('"q":"query"');
|
|
|
|
|
+ $this->assertResponseContains('"contentType":"text\/plain"');
|
|
|
|
|
+ $this->assertHeader('X-Middleware', 'true');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test that the PSR7 requests get cookies
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testGetCookiesHttpServer()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->useHttpServer(true);
|
|
|
|
|
+
|
|
|
|
|
+ $this->configRequest(['cookies' => ['split_test' => 'abc']]);
|
|
|
|
|
+ $this->get('/request_action/cookie_pass');
|
|
|
|
|
+ $this->assertResponseOk();
|
|
|
|
|
+ $this->assertResponseContains('"split_test":"abc"');
|
|
|
|
|
+ $this->assertHeader('X-Middleware', 'true');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test that the PSR7 requests get post data
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testPostDataHttpServer()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->useHttpServer(true);
|
|
|
|
|
+
|
|
|
|
|
+ $this->post('/request_action/post_pass', ['title' => 'value']);
|
|
|
|
|
+ $data = json_decode($this->_response->body());
|
|
|
|
|
+ $this->assertEquals('value', $data->title);
|
|
|
|
|
+ $this->assertHeader('X-Middleware', 'true');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Test sending requests stores references to controller/view/layout.
|
|
* Test sending requests stores references to controller/view/layout.
|
|
|
*
|
|
*
|
|
|
* @return void
|
|
* @return void
|
|
@@ -216,9 +270,8 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
*/
|
|
*/
|
|
|
public function testRequestSetsPropertiesHttpServer()
|
|
public function testRequestSetsPropertiesHttpServer()
|
|
|
{
|
|
{
|
|
|
- $this->markTestIncomplete('not done');
|
|
|
|
|
- DispatcherFactory::clear();
|
|
|
|
|
$this->useHttpServer(true);
|
|
$this->useHttpServer(true);
|
|
|
|
|
+ DispatcherFactory::clear();
|
|
|
|
|
|
|
|
$this->post('/posts/index');
|
|
$this->post('/posts/index');
|
|
|
$this->assertInstanceOf('Cake\Controller\Controller', $this->_controller);
|
|
$this->assertInstanceOf('Cake\Controller\Controller', $this->_controller);
|
|
@@ -233,16 +286,6 @@ class IntegrationTestCaseTest extends IntegrationTestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Test that the PSR7 requests get post, cookies, and other request data passed along.
|
|
|
|
|
- *
|
|
|
|
|
- * @return void
|
|
|
|
|
- */
|
|
|
|
|
- public function testPsrRequestData()
|
|
|
|
|
- {
|
|
|
|
|
- $this->markTestIncomplete('not done');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
* Assert that the stored template doesn't change when cells are rendered.
|
|
* Assert that the stored template doesn't change when cells are rendered.
|
|
|
*
|
|
*
|
|
|
* @return void
|
|
* @return void
|