File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -528,9 +528,9 @@ private function restoreHash(): void
528
528
}
529
529
530
530
/**
531
- * Generates (Regenerate ) the CSRF Hash.
531
+ * Generates (Regenerates ) the CSRF Hash.
532
532
*/
533
- protected function generateHash (): string
533
+ public function generateHash (): string
534
534
{
535
535
$ this ->hash = bin2hex (random_bytes (static ::CSRF_HASH_BYTES ));
536
536
Original file line number Diff line number Diff line change @@ -243,6 +243,32 @@ public function testRegenerateWithFalseSecurityRegenerateProperty()
243
243
$ this ->assertSame ($ oldHash , $ newHash );
244
244
}
245
245
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
+
246
272
public function testRegenerateWithTrueSecurityRegenerateProperty ()
247
273
{
248
274
$ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
You can’t perform that action at this time.
0 commit comments