8000 [Security] added more tests · symfony/symfony@022ac0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 022ac0b

Browse files
committed
[Security] added more tests
1 parent 9c7a140 commit 022ac0b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
16-
use Symfony\Component\HttpFoundation\Response;
1716
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;
1817
use Symfony\Component\Security\Http\HttpUtils;
1918

@@ -24,7 +23,9 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase
2423
*/
2524
public function testRequestRedirections(Request $request, $options, $redirectedUrl)
2625
{
27-
$httpUtils = new HttpUtils();
26+
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
27+
$urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('http://localhost/login'));
28+
$httpUtils = new HttpUtils($urlGenerator);
2829
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
2930
$handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options);
3031
if ($request->hasSession()) {
@@ -73,25 +74,30 @@ public function getRequestRedirections()
7374
'/admin/dashboard',
7475
),
7576
'target path as referer' => array(
76-
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/dashboard')),
77+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/dashboard')),
7778
array('use_referer' => true),
7879
'/dashboard',
7980
),
8081
'target path as referer is ignored if not configured' => array(
81-
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/dashboard')),
82+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/dashboard')),
8283
array(),
8384
'/',
8485
),
8586
'target path should be different than login URL' => array(
86-
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login')),
87+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login')),
8788
array('use_referer' => true, 'login_path' => '/login'),
8889
'/',
8990
),
9091
'target path should be different than login URL (query string does not matter)' => array(
91-
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login?t=1&p=2')),
92+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login?t=1&p=2')),
9293
array('use_referer' => true, 'login_path' => '/login'),
9394
'/',
9495
),
96+
'target path should be different than login URL (login_path as a route)' => array(
97+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login?t=1&p=2')),
98+
array('use_referer' => true, 'login_path' => 'login_route'),
99+
'/',
100+
),
95101
);
96102
}
97103
}

0 commit comments

Comments
 (0)
0