@@ -80,7 +80,7 @@ public function testConsumeRememberMeCookieValid()
8080$ this ->tokenProvider ->expects ($ this ->any ())
8181 ->method ('loadTokenBySeries ' )
8282 ->with ('series1 ' )
83- ->willReturn (new PersistentToken (InMemoryUser::class,'wouter ' ,'series1 ' ,'tokenvalue ' ,new \DateTime ('-10 min ' )))
83+ ->willReturn (new PersistentToken (InMemoryUser::class,'wouter ' ,'series1 ' ,'tokenvalue ' ,$ lastUsed = new \DateTime ('-10 min ' )))
8484 ;
8585
8686$ this ->tokenProvider ->expects ($ this ->once ())->method ('updateToken ' )->with ('series1 ' );
@@ -98,11 +98,41 @@ public function testConsumeRememberMeCookieValid()
9898
9999$ this ->assertSame ($ rememberParts [0 ],$ cookieParts [0 ]);// class
100100$ this ->assertSame ($ rememberParts [1 ],$ cookieParts [1 ]);// identifier
101- $ this ->assertSame ( $ rememberParts [ 2 ], $ cookieParts [2 ]);// expire
101+ $ this ->assertEqualsWithDelta ( $ lastUsed -> getTimestamp () + 31536000 , ( int ) $ cookieParts [2 ], 2 );// expire
102102$ this ->assertNotSame ($ rememberParts [3 ],$ cookieParts [3 ]);// value
103103$ this ->assertSame (explode (': ' ,$ rememberParts [3 ])[0 ],explode (': ' ,$ cookieParts [3 ])[0 ]);// series
104104 }
105105
106+ public function testConsumeRememberMeCookieInvalidOwner ()
107+ {
108+ $ this ->tokenProvider ->expects ($ this ->any ())
109+ ->method ('loadTokenBySeries ' )
110+ ->with ('series1 ' )
111+ ->willReturn (new PersistentToken (InMemoryUser::class,'wouter ' ,'series1 ' ,'tokenvalue ' ,new \DateTime ('-10 min ' )))
112+ ;
113+
114+ $ rememberMeDetails =new RememberMeDetails (InMemoryUser::class,'jeremy ' ,360 ,'series1:tokenvalue ' );
115+
116+ $ this ->expectException (AuthenticationException::class);
117+ $ this ->expectExceptionMessage ('The cookie \'s hash is invalid. ' );
118+ $ this ->handler ->consumeRememberMeCookie ($ rememberMeDetails );
119+ }
120+
121+ public function testConsumeRememberMeCookieInvalidValue ()
122+ {
123+ $ this ->tokenProvider ->expects ($ this ->any ())
124+ ->method ('loadTokenBySeries ' )
125+ ->with ('series1 ' )
126+ ->willReturn (new PersistentToken (InMemoryUser::class,'wouter ' ,'series1 ' ,'tokenvalue ' ,new \DateTime ('-10 min ' )))
127+ ;
128+
129+ $ rememberMeDetails =new RememberMeDetails (InMemoryUser::class,'wouter ' ,360 ,'series1:tokenvalue:somethingelse ' );
130+
131+ $ this ->expectException (AuthenticationException::class);
132+ $ this ->expectExceptionMessage ('This token was already used. The account is possibly compromised. ' );
133+ $ this ->handler ->consumeRememberMeCookie ($ rememberMeDetails );
134+ }
135+
106136public function testConsumeRememberMeCookieValidByValidatorWithoutUpdate ()
107137 {
108138$ verifier =$ this ->createMock (TokenVerifierInterface::class);