[Security] Fix return type declarations
This commit is contained in:
parent
c1b7118d7c
commit
e0d79f71ed
@ -58,7 +58,7 @@ class ArgumentMetadata
|
|||||||
*
|
*
|
||||||
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
|
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,9 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
|||||||
|
|
||||||
class DaoAuthenticationProviderTest extends TestCase
|
class DaoAuthenticationProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
|
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||||
|
@ -62,6 +62,9 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
|
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
namespace Symfony\Component\Security\Guard\Tests\Provider;
|
namespace Symfony\Component\Security\Guard\Tests\Provider;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
||||||
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
|
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
|
||||||
|
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
|
||||||
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
|
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
|
||||||
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class GuardAuthenticationProviderTest extends TestCase
|
|||||||
->with($enteredCredentials, $mockedUser)
|
->with($enteredCredentials, $mockedUser)
|
||||||
// authentication works!
|
// authentication works!
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$authedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
|
||||||
$authenticatorB->expects($this->once())
|
$authenticatorB->expects($this->once())
|
||||||
->method('createAuthenticatedToken')
|
->method('createAuthenticatedToken')
|
||||||
->with($mockedUser, $providerKey)
|
->with($mockedUser, $providerKey)
|
||||||
@ -130,7 +130,7 @@ class GuardAuthenticationProviderTest extends TestCase
|
|||||||
->with($enteredCredentials, $mockedUser)
|
->with($enteredCredentials, $mockedUser)
|
||||||
// authentication works!
|
// authentication works!
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
|
||||||
$authenticatorB->expects($this->once())
|
$authenticatorB->expects($this->once())
|
||||||
->method('createAuthenticatedToken')
|
->method('createAuthenticatedToken')
|
||||||
->with($mockedUser, $providerKey)
|
->with($mockedUser, $providerKey)
|
||||||
|
@ -31,7 +31,7 @@ interface AuthenticationSuccessHandlerInterface
|
|||||||
* is called by authentication listeners inheriting from
|
* is called by authentication listeners inheriting from
|
||||||
* AbstractAuthenticationListener.
|
* AbstractAuthenticationListener.
|
||||||
*
|
*
|
||||||
* @return Response never null
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\Authentication;
|
namespace Symfony\Component\Security\Http\Tests\Authentication;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
@ -62,7 +63,7 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testRedirect()
|
public function testRedirect()
|
||||||
{
|
{
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/login');
|
||||||
$this->httpUtils->expects($this->once())
|
$this->httpUtils->expects($this->once())
|
||||||
->method('createRedirectResponse')->with($this->request, '/login')
|
->method('createRedirectResponse')->with($this->request, '/login')
|
||||||
->willReturn($response);
|
->willReturn($response);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
|
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
|
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
|
||||||
@ -21,7 +22,7 @@ class FormAuthenticationEntryPointTest extends TestCase
|
|||||||
public function testStart()
|
public function testStart()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
|
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/the/login/path');
|
||||||
|
|
||||||
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||||
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
||||||
|
@ -72,6 +72,9 @@ class ExceptionListenerTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testExceptionWhenEntryPointReturnsBadValue()
|
public function testExceptionWhenEntryPointReturnsBadValue()
|
||||||
{
|
{
|
||||||
$event = $this->createEvent(new AuthenticationException());
|
$event = $this->createEvent(new AuthenticationException());
|
||||||
|
@ -122,6 +122,9 @@ class LogoutListenerTest extends TestCase
|
|||||||
$listener->handle($event);
|
$listener->handle($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testSuccessHandlerReturnsNonResponse()
|
public function testSuccessHandlerReturnsNonResponse()
|
||||||
{
|
{
|
||||||
$this->expectException('RuntimeException');
|
$this->expectException('RuntimeException');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
@ -40,6 +41,10 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
->method('checkRequestPath')
|
->method('checkRequestPath')
|
||||||
->willReturn(true)
|
->willReturn(true)
|
||||||
;
|
;
|
||||||
|
$httpUtils
|
||||||
|
->method('createRedirectResponse')
|
||||||
|
->willReturn(new RedirectResponse('/hello'))
|
||||||
|
;
|
||||||
|
|
||||||
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
|
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
|
||||||
$failureHandler
|
$failureHandler
|
||||||
@ -52,7 +57,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
$authenticationManager
|
$authenticationManager
|
||||||
->expects($ok ? $this->once() : $this->never())
|
->expects($ok ? $this->once() : $this->never())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->willReturn(new Response())
|
->willReturnArgument(0)
|
||||||
;
|
;
|
||||||
|
|
||||||
$listener = new UsernamePasswordFormAuthenticationListener(
|
$listener = new UsernamePasswordFormAuthenticationListener(
|
||||||
@ -61,7 +66,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
|
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
|
||||||
$httpUtils,
|
$httpUtils,
|
||||||
'TheProviderKey',
|
'TheProviderKey',
|
||||||
$this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
|
new DefaultAuthenticationSuccessHandler($httpUtils),
|
||||||
$failureHandler,
|
$failureHandler,
|
||||||
['require_previous_session' => false]
|
['require_previous_session' => false]
|
||||||
);
|
);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\Logout;
|
namespace Symfony\Component\Security\Http\Tests\Logout;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
|
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
|
||||||
|
|
||||||
class DefaultLogoutSuccessHandlerTest extends TestCase
|
class DefaultLogoutSuccessHandlerTest extends TestCase
|
||||||
@ -20,7 +20,7 @@ class DefaultLogoutSuccessHandlerTest extends TestCase
|
|||||||
public function testLogout()
|
public function testLogout()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/dashboard');
|
||||||
|
|
||||||
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
||||||
$httpUtils->expects($this->once())
|
$httpUtils->expects($this->once())
|
||||||
|
@ -39,6 +39,9 @@ class AbstractRememberMeServicesTest extends TestCase
|
|||||||
$this->assertNull($service->autoLogin(new Request()));
|
$this->assertNull($service->autoLogin(new Request()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
|
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('RuntimeException');
|
$this->expectException('RuntimeException');
|
||||||
|
Reference in New Issue
Block a user