You are here

private function SecuritytxtModuleEnabledTestCase::checkSecurityTxtFile in Security.txt 7

Check security.txt file.

Check the existance and content of the security.txt file at .well-known/security.txt according to whether it has been enabled or not.

2 calls to SecuritytxtModuleEnabledTestCase::checkSecurityTxtFile()
SecuritytxtModuleEnabledTestCase::testConfigureForm in ./securitytxt.test
Test configure form.
SecuritytxtModuleEnabledTestCase::testPageAccess in ./securitytxt.test
Test page access for various users.

File

./securitytxt.test, line 439
Tests for securitytxt.module.

Class

SecuritytxtModuleEnabledTestCase
Test case with the Security.txt module enabled.

Code

private function checkSecurityTxtFile($enabled, $contact_email, $contact_phone, $contact_url, $encryption_key_url, $policy_url, $acknowledgement_url) {
  $this
    ->drupalGet(self::SECURITY_TXT_PATH);
  if ($enabled) {
    $this
      ->assertResponse(200);
    $this
      ->assertText('Contact: ' . $contact_email);
    $this
      ->assertText('Contact: ' . $contact_phone);
    $this
      ->assertText('Contact: ' . $contact_url);
    $this
      ->assertText('Encryption: ' . $encryption_key_url);
    $this
      ->assertText('Policy: ' . $policy_url);
    $this
      ->assertText('Acknowledgement: ' . $acknowledgement_url);
    $this
      ->assertText('Signature: ' . url(self::SECURITY_TXT_SIG_PATH, array(
      'absolute' => TRUE,
    )));
  }
  else {
    $this
      ->assertResponse(404);
  }
}