public function BrowserTestBaseTest::testHtkey in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testHtkey()
- 9 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testHtkey()
Tests the protections provided by .htkey.
File
- core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php, line 620
Class
- BrowserTestBaseTest
- Tests BrowserTestBase functionality.
Namespace
Drupal\FunctionalTestsCode
public function testHtkey() {
// Remove the Simpletest private key file so we can test the protection
// against requests that forge a valid testing user agent to gain access
// to the installer.
// @see drupal_valid_test_ua()
// Not using File API; a potential error must trigger a PHP warning.
$install_url = Url::fromUri('base:core/install.php', [
'external' => TRUE,
'absolute' => TRUE,
])
->toString();
$this
->drupalGet($install_url);
$this
->assertSession()
->statusCodeEquals(200);
unlink($this->siteDirectory . '/.htkey');
$this
->drupalGet($install_url);
$this
->assertSession()
->statusCodeEquals(403);
}