Updating interface method per suggestion - makes sense to me, Request is redundant

This commit is contained in:
Ryan Weaver 2015-05-18 08:48:41 -04:00
parent c73c32e674
commit eb158cbdb3
3 changed files with 9 additions and 9 deletions

View File

@ -74,11 +74,11 @@ class GuardAuthenticationListener implements ListenerInterface
$request = $event->getRequest(); $request = $event->getRequest();
try { try {
if (null !== $this->logger) { if (null !== $this->logger) {
$this->logger->info('Calling getCredentialsFromRequest on guard configurator', array('firewall_key' => $this->providerKey, 'authenticator' => get_class($guardAuthenticator))); $this->logger->info('Calling getCredentials on guard configurator.', array('firewall_key' => $this->providerKey, 'authenticator' => get_class($guardAuthenticator)));
} }
// allow the authenticator to fetch authentication info from the request // allow the authenticator to fetch authentication info from the request
$credentials = $guardAuthenticator->getCredentialsFromRequest($request); $credentials = $guardAuthenticator->getCredentials($request);
// allow null to be returned to skip authentication // allow null to be returned to skip authentication
if (null === $credentials) { if (null === $credentials) {

View File

@ -44,13 +44,13 @@ interface GuardAuthenticatorInterface extends AuthenticationEntryPointInterface
* *
* @return mixed|null * @return mixed|null
*/ */
public function getCredentialsFromRequest(Request $request); public function getCredentials(Request $request);
/** /**
* Return a UserInterface object based on the credentials OR throw * Return a UserInterface object based on the credentials OR throw
* an AuthenticationException. * an AuthenticationException.
* *
* The *credentials* are the return value from getCredentialsFromRequest() * The *credentials* are the return value from getCredentials()
* *
* @param mixed $credentials * @param mixed $credentials
* @param UserProviderInterface $userProvider * @param UserProviderInterface $userProvider

View File

@ -38,7 +38,7 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$credentials = array('username' => 'weaverryan', 'password' => 'all_your_base'); $credentials = array('username' => 'weaverryan', 'password' => 'all_your_base');
$authenticator $authenticator
->expects($this->once()) ->expects($this->once())
->method('getCredentialsFromRequest') ->method('getCredentials')
->with($this->equalTo($this->request)) ->with($this->equalTo($this->request))
->will($this->returnValue($credentials)); ->will($this->returnValue($credentials));
@ -87,7 +87,7 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$authenticator $authenticator
->expects($this->once()) ->expects($this->once())
->method('getCredentialsFromRequest') ->method('getCredentials')
->with($this->equalTo($this->request)) ->with($this->equalTo($this->request))
->will($this->returnValue(array('username' => 'anything_not_empty'))); ->will($this->returnValue(array('username' => 'anything_not_empty')));
@ -130,7 +130,7 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$authException = new AuthenticationException('Get outta here crazy user with a bad password!'); $authException = new AuthenticationException('Get outta here crazy user with a bad password!');
$authenticator $authenticator
->expects($this->once()) ->expects($this->once())
->method('getCredentialsFromRequest') ->method('getCredentials')
->will($this->throwException($authException)); ->will($this->throwException($authException));
// this is not called // this is not called
@ -162,11 +162,11 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$authenticatorA $authenticatorA
->expects($this->once()) ->expects($this->once())
->method('getCredentialsFromRequest') ->method('getCredentials')
->will($this->returnValue(null)); ->will($this->returnValue(null));
$authenticatorB $authenticatorB
->expects($this->once()) ->expects($this->once())
->method('getCredentialsFromRequest') ->method('getCredentials')
->will($this->returnValue(null)); ->will($this->returnValue(null));
// this is not called // this is not called