You are here

public function SecuritytxtModuleDisabledTestCase::testPageAccess in Security.txt 7

Test page access for various users.

File

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

Class

SecuritytxtModuleDisabledTestCase
Test case with the Security.txt module disabled.

Code

public function testPageAccess() {

  // Anonymous user page access.
  $this
    ->drupalGet(self::SECURITY_TXT_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_SIG_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_SIGN_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::HELP_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::SECURITY_TXT_HELP_PATH);
  $this
    ->assertResponse(403);

  // Authenticated user page access.
  $this
    ->drupalLogin($this->authenticatedUser);
  $this
    ->drupalGet(self::SECURITY_TXT_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_SIG_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_SIGN_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::HELP_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalGet(self::SECURITY_TXT_HELP_PATH);
  $this
    ->assertResponse(403);
  $this
    ->drupalLogout();

  // Administrator user page access.
  $this
    ->drupalLogin($this->administratorUser);
  $this
    ->drupalGet(self::SECURITY_TXT_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_SIG_PATH);
  $this
    ->assertResponse(404);
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_PATH);
  $this
    ->assertResponse(200);
  $this
    ->assertTitle(t('System | Drupal'));
  $this
    ->drupalGet(self::SECURITY_TXT_CONF_SIGN_PATH);
  $this
    ->assertResponse(200);
  $this
    ->assertTitle(t('System | Drupal'));
  $this
    ->drupalGet(self::HELP_PATH);
  $this
    ->assertResponse(200);
  $this
    ->assertTitle(t('Help | Drupal'));
  $this
    ->assertNoLink(t('Security.txt'));
  $this
    ->drupalGet(self::SECURITY_TXT_HELP_PATH);
  $this
    ->assertResponse(200);
  $this
    ->assertTitle(t('Help | Drupal'));
  $this
    ->assertNoText(t('The Security.txt module provides an implementation of the new'));
  $this
    ->drupalLogout();
}