@@ -105,7 +105,12 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie()
105
105
$ this ->assertTrue ($ request ->attributes ->get (RememberMeServicesInterface::COOKIE_ATTR_NAME )->isCleared ());
106
106
}
107
107
108
- public function testAutoLogin ()
108
+ /**
109
+ * @dataProvider provideUsernamesForAutoLogin
110
+ *
111
+ * @param string $username
112
+ */
113
+ public function testAutoLogin ($ username )
109
114
{
110
115
$ user = $ this ->getMock ('Symfony\Component\Security\Core\User\UserInterface ' );
111
116
$ user
@@ -123,13 +128,13 @@ public function testAutoLogin()
123
128
$ userProvider
124
129
->expects ($ this ->once ())
125
130
->method ('loadUserByUsername ' )
126
- ->with ($ this ->equalTo (' foouser ' ))
131
+ ->with ($ this ->equalTo ($ username ))
127
132
->will ($ this ->returnValue ($ user ))
128
133
;
129
134
130
135
$ service = $ this ->getService ($ userProvider , array ('name ' => 'foo ' , 'always_remember_me ' => true , 'lifetime ' => 3600 ));
131
136
$ request = new Request ();
132
- $ request ->cookies ->set ('foo ' , $ this ->getCookie ('fooclass ' , ' foouser ' , time () + 3600 , 'foopass ' ));
137
+ $ request ->cookies ->set ('foo ' , $ this ->getCookie ('fooclass ' , $ username , time () + 3600 , 'foopass ' ));
133
138
134
139
$ returnedToken = $ service ->autoLogin ($ request );
135
140
@@ -138,6 +143,14 @@ public function testAutoLogin()
138
143
$ this ->assertEquals ('fookey ' , $ returnedToken ->getKey ());
139
144
}
140
145
146
+ public function provideUsernamesForAutoLogin ()
147
+ {
148
+ return array (
149
+ array ('foouser ' , 'Simple username ' ),
150
+ array ('foo ' .TokenBasedRememberMeServices::COOKIE_DELIMITER .'user ' , 'Username might contain the delimiter ' ),
151
+ );
152
+ }
153
+
141
154
public function testLogout ()
142
155
{
143
156
$ service = $ this ->getService (null , array ('name ' => 'foo ' , 'path ' => null , 'domain ' => null ));
0 commit comments