Skip to content

Commit b086066

Browse files
committed
remove environment-dependent CSP JSON test from ExceptionHandlerTest
1 parent e011848 commit b086066

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

tests/system/Debug/ExceptionHandlerTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
use App\Controllers\Home;
1717
use CodeIgniter\Exceptions\PageNotFoundException;
1818
use CodeIgniter\Exceptions\RuntimeException;
19-
use CodeIgniter\HTTP\IncomingRequest;
20-
use CodeIgniter\HTTP\Response;
2119
use CodeIgniter\Test\CIUnitTestCase;
2220
use CodeIgniter\Test\IniTestTrait;
2321
use CodeIgniter\Test\StreamFilterTrait;
24-
use Config\App;
2522
use Config\Exceptions as ExceptionsConfig;
2623
use Config\Services;
2724
use PHPUnit\Framework\Attributes\Group;
@@ -391,32 +388,4 @@ public function testSanitizeDataWithScalars(): void
391388
$this->assertFalse($sanitizeData(false));
392389
$this->assertNull($sanitizeData(null));
393390
}
394-
395-
public function testHandleJsonResponseWithCSPEnabledProducesValidJson(): void
396-
{
397-
$config = config(App::class);
398-
$config->CSPEnabled = true;
399-
400-
/** @var IncomingRequest $request */
401-
$request = service('incomingrequest', $config, false);
402-
$request->setHeader('accept', 'application/json');
403-
$response = new Response($config);
404-
$response->pretend();
405-
406-
$exception = new RuntimeException('Test exception');
407-
408-
ob_start();
409-
$this->handler->handle($exception, $request, $response, 500, EXIT_ERROR);
410-
$output = ob_get_clean();
411-
412-
$json = json_decode($output);
413-
$this->assertNotNull($json);
414-
415-
// Nonce placeholders must not appear in the output
416-
$this->assertStringNotContainsString('{csp-style-nonce}', (string) $output);
417-
$this->assertStringNotContainsString('{csp-script-nonce}', (string) $output);
418-
419-
// The nonce attribute values should be properly JSON-escaped
420-
$this->assertMatchesRegularExpression('/nonce=\\\\"[A-Za-z0-9+\/=]+\\\\"/', $output);
421-
}
422391
}

0 commit comments

Comments
 (0)