diff options
author | alcaeus <git@alcaeus.org> | 2014-04-20 13:12:50 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2014-04-22 09:12:31 +0200 |
commit | 8fe3c7d8710f0eab18a505122a8839a8bce9815c (patch) | |
tree | 151346eababea113f11125e84790be39a51ad56f /Tests/Http/Firewall | |
parent | 28fd9e9e753e8ad7384e0ba7baf0a82ff9c57e42 (diff) | |
download | symfony-security-8fe3c7d8710f0eab18a505122a8839a8bce9815c.zip symfony-security-8fe3c7d8710f0eab18a505122a8839a8bce9815c.tar.gz symfony-security-8fe3c7d8710f0eab18a505122a8839a8bce9815c.tar.bz2 |
Fixed incompatibility of x509 auth with nginx
Diffstat (limited to 'Tests/Http/Firewall')
-rw-r--r-- | Tests/Http/Firewall/X509AuthenticationListenerTest.php | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/Tests/Http/Firewall/X509AuthenticationListenerTest.php b/Tests/Http/Firewall/X509AuthenticationListenerTest.php index c48aeac..291f919 100644 --- a/Tests/Http/Firewall/X509AuthenticationListenerTest.php +++ b/Tests/Http/Firewall/X509AuthenticationListenerTest.php @@ -42,11 +42,7 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $listener = new X509AuthenticationListener( - $context, - $authenticationManager, - 'TheProviderKey' - ); + $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey'); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); @@ -64,9 +60,38 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase } /** + * @dataProvider dataProviderGetPreAuthenticatedDataNoUser + */ + public function testGetPreAuthenticatedDataNoUser($emailAddress) + { + $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress; + $request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials)); + + $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + + $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + + $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey'); + + $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); + $method->setAccessible(true); + + $result = $method->invokeArgs($listener, array($request)); + $this->assertSame($result, array($emailAddress, $credentials)); + } + + public static function dataProviderGetPreAuthenticatedDataNoUser() + { + return array( + 'basicEmailAddress' => array('cert@example.com'), + 'emailAddressWithPlusSign' => array('cert+something@example.com'), + ); + } + + /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ - public function testGetPreAuthenticatedDataNoUser() + public function testGetPreAuthenticatedDataNoData() { $request = new Request(array(), array(), array(), array(), array(), array()); @@ -74,11 +99,7 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $listener = new X509AuthenticationListener( - $context, - $authenticationManager, - 'TheProviderKey' - ); + $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey'); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); @@ -98,13 +119,7 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $listener = new X509AuthenticationListener( - $context, - $authenticationManager, - 'TheProviderKey', - 'TheUserKey', - 'TheCredentialsKey' - ); + $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey'); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); |