@@ -35,11 +35,7 @@ public function testGetPreAuthenticatedData($user, $credentials)
35
35
36
36
$ authenticationManager = $ this ->getMock ('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface ' );
37
37
38
- $ listener = new X509AuthenticationListener (
39
- $ context ,
40
- $ authenticationManager ,
41
- 'TheProviderKey '
42
- );
38
+ $ listener = new X509AuthenticationListener ($ context , $ authenticationManager , 'TheProviderKey ' );
43
39
44
40
$ method = new \ReflectionMethod ($ listener , 'getPreAuthenticatedData ' );
45
41
$ method ->setAccessible (true );
@@ -56,22 +52,47 @@ public static function dataProviderGetPreAuthenticatedData()
56
52
);
57
53
}
58
54
55
+ /**
56
+ * @dataProvider dataProviderGetPreAuthenticatedDataNoUser
57
+ */
58
+ public function testGetPreAuthenticatedDataNoUser ($ emailAddress )
59
+ {
60
+ $ credentials = 'CN=Sample certificate DN/emailAddress= ' .$ emailAddress ;
61
+ $ request = new Request (array (), array (), array (), array (), array (), array ('SSL_CLIENT_S_DN ' => $ credentials ));
62
+
63
+ $ context = $ this ->getMock ('Symfony\Component\Security\Core\SecurityContextInterface ' );
64
+
65
+ $ authenticationManager = $ this ->getMock ('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface ' );
66
+
67
+ $ listener = new X509AuthenticationListener ($ context , $ authenticationManager , 'TheProviderKey ' );
68
+
69
+ $ method = new \ReflectionMethod ($ listener , 'getPreAuthenticatedData ' );
70
+ $ method ->setAccessible (true );
71
+
72
+ $ result = $ method ->invokeArgs ($ listener , array ($ request ));
73
+ $ this ->assertSame ($ result , array ($ emailAddress , $ credentials ));
74
+ }
75
+
76
+ public static function dataProviderGetPreAuthenticatedDataNoUser ()
77
+ {
78
+ return array (
79
+ 'basicEmailAddress ' => array ('cert@example.com ' ),
80
+ 'emailAddressWithPlusSign ' => array ('cert+something@example.com ' ),
81
+ );
82
+ }
83
+
59
84
/**
60
85
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
61
86
*/
62
- public function testGetPreAuthenticatedDataNoUser ()
87
+ public function testGetPreAuthenticatedDataNoData ()
63
88
{
64
89
$ request = new Request (array (), array (), array (), array (), array (), array ());
65
90
66
91
$ context = $ this ->getMock ('Symfony\Component\Security\Core\SecurityContextInterface ' );
67
92
68
93
$ authenticationManager = $ this ->getMock ('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface ' );
69
94
70
- $ listener = new X509AuthenticationListener (
71
- $ context ,
72
- $ authenticationManager ,
73
- 'TheProviderKey '
74
- );
95
+ $ listener = new X509AuthenticationListener ($ context , $ authenticationManager , 'TheProviderKey ' );
75
96
76
97
$ method = new \ReflectionMethod ($ listener , 'getPreAuthenticatedData ' );
77
98
$ method ->setAccessible (true );
@@ -91,13 +112,7 @@ public function testGetPreAuthenticatedDataWithDifferentKeys()
91
112
92
113
$ authenticationManager = $ this ->getMock ('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface ' );
93
114
94
- $ listener = new X509AuthenticationListener (
95
- $ context ,
96
- $ authenticationManager ,
97
- 'TheProviderKey ' ,
98
- 'TheUserKey ' ,
99
- 'TheCredentialsKey '
100
- );
115
+ $ listener = new X509AuthenticationListener ($ context , $ authenticationManager , 'TheProviderKey ' , 'TheUserKey ' , 'TheCredentialsKey ' );
101
116
102
117
$ method = new \ReflectionMethod ($ listener , 'getPreAuthenticatedData ' );
103
118
$ method ->setAccessible (true );
0 commit comments