fixed detection of secure cookies received over https

BrowserKit's cookie handling only recognises a secure cookie if the
cookie option is set and the cookie was set over an https request.
The client was not passing the url into the cookiejar update code,
causing Cookie::isSecure() to always return false for every cookie.

Fixes symfony/symfony#7666
This commit is contained in:
Andrew Coulton 2013-04-14 00:07:46 +01:00 committed by Fabien Potencier
parent 1454af7235
commit c2bc707a4d
2 changed files with 10 additions and 1 deletions

View File

@ -266,7 +266,7 @@ abstract class Client
$response = $this->filterResponse($this->response);
$this->cookieJar->updateFromResponse($response);
$this->cookieJar->updateFromResponse($response, $uri);
$this->redirect = $response->getHeader('Location');

View File

@ -205,6 +205,15 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
}
public function testRequestSecureCookies()
{
$client = new TestClient();
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar; path=/; secure')));
$client->request('GET', 'https://www.example.com/foo/foobar');
$this->assertTrue($client->getCookieJar()->get('foo','/','www.example.com')->isSecure());
}
public function testClick()
{
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {