File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,11 +300,10 @@ public function getScriptNonce(): string
300300 */
301301 public function finalize (ResponseInterface $ response )
302302 {
303- if ($ this ->autoNonce === false ) {
304- return ;
303+ if ($ this ->autoNonce ) {
304+ $ this -> generateNonces ( $ response ) ;
305305 }
306306
307- $ this ->generateNonces ($ response );
308307 $ this ->buildHeaders ($ response );
309308 }
310309
Original file line number Diff line number Diff line change @@ -533,6 +533,9 @@ public function testBodyScriptNonceDisableAutoNonce()
533533 $ csp ->finalize ($ response );
534534
535535 $ this ->assertStringContainsString ('{csp-script-nonce} ' , $ response ->getBody ());
536+
537+ $ result = new \CodeIgniter \Test \TestResponse ($ response );
538+ $ result ->assertHeader ('Content-Security-Policy ' );
536539 }
537540
538541 public function testBodyStyleNonceDisableAutoNonce ()
@@ -549,6 +552,9 @@ public function testBodyStyleNonceDisableAutoNonce()
549552 $ csp ->finalize ($ response );
550553
551554 $ this ->assertStringContainsString ('{csp-style-nonce} ' , $ response ->getBody ());
555+
556+ $ result = new \CodeIgniter \Test \TestResponse ($ response );
557+ $ result ->assertHeader ('Content-Security-Policy ' );
552558 }
553559
554560 /**
You can’t perform that action at this time.
0 commit comments