8000 [HttpFoundation] Same site cookie by cvilleger · Pull Request #17 · nicolas-grekas/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Same site cookie #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Prev Previous commit
Next Next commit
Add tests for cookie symfony vs php native
  • Loading branch information
cvilleger committed Apr 6, 2018
commit 1e85119a6aa7fa146d7956a67b5761469acd27d1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Array
(
[0] => Content-Type: text/plain; charset=utf-8
[1] => Cache-Control: no-cache, private
[2] => Date: Sat, 12 Nov 1955 20:04:00 GMT
[3] => Set-Cookie: https://blackfire.io/?*():@&+$/%#[]=https://blackfire.io/?*():@&+$/%#[]; path=/
[4] => Set-Cookie: https://blackfire.io/?*():@&+$/%#[]=https://blackfire.io/?*():@&+$/%#[]; path=/
)
shutdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Symfony\Component\HttpFoundation\Cookie;

/** @var \Symfony\Component\HttpFoundation\Response $r */
$r = require __DIR__ . '/common.inc';

$url = 'https://blackfire.io/?*():@&+$/%#[]';

$r->headers->setCookie(new Cookie($url, $url, 0, '/', null, false, false, true));
$r->sendHeaders();

setrawcookie($url, $url, 0, '/', null, false, false);
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Array
[0] => Content-Type: text/plain; charset=utf-8
[1] => Cache-Control: no-cache, private
[2] => Date: Sat, 12 Nov 1955 20:04:00 GMT
[3] => Set-Cookie: https%3A%2F%2Fblackfire.io%2F%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D=https%3A%2F%2Fblackfire.io%2F%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/; httponly
[3] => Set-Cookie: https://blackfire.io/?*():@&+$/%#[]=https%3A%2F%2Fblackfire.io%2F%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
[4] => Set-Cookie: https://blackfire.io/?*():@&+$/%#[]=https%3A%2F%2Fblackfire.io%2F%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
)
shutdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

$r = require __DIR__ . '/common.inc';

$r->headers->setCookie(new Cookie('https://blackfire.io/?*():@&+$/%#[]', 'https://blackfire.io/?*():@&+$/%#[]'));
$url = 'https://blackfire.io/?*():@&+$/%#[]';

$r->headers->setCookie(new Cookie($url, $url, 0, '', null, false, false));
$r->sendHeaders();

setcookie($url,$url, 0, '/');
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,15 @@ public static function tearDownAfterClass()
/**
* @dataProvider provideCookie
*/
public function testCookieSamesite($fixture)
public function testCookie($fixture)
{
$result = file_get_contents(sprintf('http://localhost:8054/%s.php', $fixture));
$result = file_get_contents(sprintf('http://localhost:8054/response-functional/%s.php', $fixture));
$this->assertStringEqualsFile(__DIR__.sprintf('/Fixtures/response-functional/%s.expected', $fixture), $result);
}

public function testCookieShouldThrowExceptionForInvalidName()
{
$result = file_get_contents('http://localhost:8054/response-functional/invalid_cookie_name.php');
$this->assertStringEqualsFile(__DIR__.'/Fixtures/response-functional/invalid_cookie_name.expected', $result);
}

public function testcookieShouldUrlEncode()
{
$url = 'https://blackfire.io/?*():@&+$/%#[]';
setcookie($url,$url);
//WIP
$result = file_get_contents('http://localhost:8054/response-functional/cookie_urlencode.php');
$this->assertStringEqualsFile(__DIR__.'/Fixtures/response-functional/cookie_urlencode.expected', $result);
}

public function provideCookie()
{
foreach (glob(__DIR__.'/Fixtures/response-functional/cookie_*.php') as $file) {
foreach (glob(__DIR__.'/Fixtures/response-functional/*.php') as $file) {
yield array(pathinfo($file, PATHINFO_FILENAME));
}
}
Expand Down
0