Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c2632a

Browse filesBrowse files
lyrixxnicolas-grekas
authored andcommitted
[SecurityBundle] add tests with empty authenticator
1 parent 797450d commit 2c2632a
Copy full SHA for 2c2632a

File tree

5 files changed

+125
-0
lines changed
Filter options

5 files changed

+125
-0
lines changed
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
13+
14+
class AnonymousTest extends AbstractWebTestCase
15+
{
16+
public function testAnonymous()
17+
{
18+
$client = $this->createClient(['test_case' => 'Anonymous', 'root_config' => 'config.yml']);
19+
20+
$client->request('GET', '/');
21+
22+
$this->assertSame(401, $client->getResponse()->getStatusCode());
23+
}
24+
}
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AnonymousBundle;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
18+
use Symfony\Component\Security\Core\User\UserInterface;
19+
use Symfony\Component\Security\Core\User\UserProviderInterface;
20+
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
21+
22+
class AppCustomAuthenticator extends AbstractGuardAuthenticator
23+
{
24+
public function supports(Request $request)
25+
{
26+
return false;
27+
}
28+
29+
public function getCredentials(Request $request)
30+
{
31+
}
32+
33+
public function getUser($credentials, UserProviderInterface $userProvider)
34+
{
35+
}
36+
37+
public function checkCredentials($credentials, UserInterface $user)
38+
{
39+
}
40+
41+
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
42+
{
43+
}
44+
45+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
46+
{
47+
}
48+
49+
public function start(Request $request, AuthenticationException $authException = null)
50+
{
51+
return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED);
52+
}
53+
54+
public function supportsRememberMe()
55+
{
56+
}
57+
}
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
return [
13+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14+
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
15+
];
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
framework:
2+
secret: test
3+
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
4+
validation: { enabled: true, enable_annotations: true }
5+
csrf_protection: true
6+
form: true
7+
test: ~
8+
default_locale: en
9+
session:
10+
storage_id: session.storage.mock_file
11+
profiler: { only_exceptions: false }
12+
13+
services:
14+
Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AnonymousBundle\AppCustomAuthenticator: ~
15+
16+
security:
17+
firewalls:
18+
secure:
19+
pattern: ^/
20+
anonymous: false
21+
stateless: true
22+
guard:
23+
authenticators:
24+
- Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AnonymousBundle\AppCustomAuthenticator
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
main:
2+
path: /
3+
defaults:
4+
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction
5+
path: /app

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.