summaryrefslogtreecommitdiffstats
path: root/Http/Tests/Firewall
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2014-04-22 10:11:06 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2014-04-22 10:11:06 +0200
commit013e84fe863ea6de2f314ae5b813e9fc51aabe55 (patch)
tree9adda823f62d198ab187c1b7398ea8b377b44cac /Http/Tests/Firewall
parentc70001ec82326f9581814ac002af6b904d24c4cd (diff)
parent8fe3c7d8710f0eab18a505122a8839a8bce9815c (diff)
downloadsymfony-security-013e84fe863ea6de2f314ae5b813e9fc51aabe55.zip
symfony-security-013e84fe863ea6de2f314ae5b813e9fc51aabe55.tar.gz
symfony-security-013e84fe863ea6de2f314ae5b813e9fc51aabe55.tar.bz2
Merge branch '2.3' into 2.4
* 2.3: fix docblock Fixed incompatibility of x509 auth with nginx [Process] Setting STDIN while running should not be possible [FrameworkBundle] improve English in RouterMatchCommand [Doctrine Bridge] simplify session handler by using main connection Conflicts: src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Diffstat (limited to 'Http/Tests/Firewall')
-rw-r--r--Http/Tests/Firewall/X509AuthenticationListenerTest.php51
1 files changed, 33 insertions, 18 deletions
diff --git a/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/Http/Tests/Firewall/X509AuthenticationListenerTest.php
index 7725f4b..7eefb30 100644
--- a/Http/Tests/Firewall/X509AuthenticationListenerTest.php
+++ b/Http/Tests/Firewall/X509AuthenticationListenerTest.php
@@ -35,11 +35,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);
@@ -57,9 +53,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());
@@ -67,11 +92,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);
@@ -91,13 +112,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);