Skip to content

Commit

Permalink
Fix errors when request data is a string and tokens are enabled.
Browse files Browse the repository at this point in the history
Refs #11325
  • Loading branch information
markstory committed Oct 14, 2017
1 parent 9a23bbe commit 92ab47e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -587,14 +587,17 @@ protected function _buildRequest($url, $method, $data)

$props = [
'url' => $url,
'post' => $this->_addTokens($tokenUrl, $data),
'cookies' => $this->_cookie,
'session' => $session,
'query' => $queryData
];
if (is_string($data)) {
$props['input'] = $data;
}
if (!isset($props['input'])) {
$props['post'] = $this->_addTokens($tokenUrl, $data);
}
$props['cookies'] = $this->_cookie;

$env = [
'REQUEST_METHOD' => $method,
'QUERY_STRING' => $query,
Expand Down
15 changes: 15 additions & 0 deletions tests/TestCase/TestSuite/IntegrationTestCaseTest.php
Expand Up @@ -361,6 +361,21 @@ public function testInputDataHttpServer()
$this->assertHeader('X-Middleware', 'true');
}

/**
* Test that the PSR7 requests receive encoded data.
*
* @return void
*/
public function testInputDataSecurityToken()
{
$this->useHttpServer(true);
$this->enableSecurityToken();

$this->post('/request_action/input_test', '{"hello":"world"}');
$this->assertSame('world', '' . $this->_response->getBody());
$this->assertHeader('X-Middleware', 'true');
}

/**
* Test that the PSR7 requests get cookies
*
Expand Down

0 comments on commit 92ab47e

Please sign in to comment.