File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -528,9 +528,9 @@ private function restoreHash(): void
528528 }
529529
530530 /**
531- * Generates (Regenerate ) the CSRF Hash.
531+ * Generates (Regenerates ) the CSRF Hash.
532532 */
533- protected function generateHash (): string
533+ public function generateHash (): string
534534 {
535535 $ this ->hash = bin2hex (random_bytes (static ::CSRF_HASH_BYTES ));
536536
Original file line number Diff line number Diff line change @@ -243,6 +243,32 @@ public function testRegenerateWithFalseSecurityRegenerateProperty()
243243 $ this ->assertSame ($ oldHash , $ newHash );
244244 }
245245
246+ public function testRegenerateWithFalseSecurityRegeneratePropertyManually ()
247+ {
248+ $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
249+ $ _POST ['csrf_test_name ' ] = '8b9218a55906f9dcc1dc263dce7f005a ' ;
250+ $ _COOKIE ['csrf_cookie_name ' ] = '8b9218a55906f9dcc1dc263dce7f005a ' ;
251+
252+ $ config = new SecurityConfig ();
253+ $ config ->regenerate = false ;
254+ Factories::injectMock ('config ' , 'Security ' , $ config );
255+
256+ $ security = new MockSecurity (new MockAppConfig ());
257+ $ request = new IncomingRequest (
258+ new MockAppConfig (),
259+ new URI ('http://badurl.com ' ),
260+ null ,
261+ new UserAgent ()
262+ );
263+
264+ $ oldHash = $ security ->getHash ();
265+ $ security ->verify ($ request );
266+ $ security ->generateHash ();
267+ $ newHash = $ security ->getHash ();
268+
269+ $ this ->assertNotSame ($ oldHash , $ newHash );
270+ }
271+
246272 public function testRegenerateWithTrueSecurityRegenerateProperty ()
247273 {
248274 $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
You can’t perform that action at this time.
0 commit comments