You are here

function SecureSiteTest::testAccessDenied in Secure Site 6

Same name and namespace in other branches
  1. 5 tests/securesite.test \SecureSiteTest::testAccessDenied()

Check that users get an access denied warning when accessing secured portions of the site if they've already logged in and don't have access to the secure portion

File

tests/securesite.test, line 206
Secure Site module unit tests

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testAccessDenied() {
  $privileged_user = $this
    ->drupalCreateUserRolePerm(array(
    'access content',
    'access secured pages',
  ));
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);
  $this
    ->drupalVariableSet('securesite_filter_pages', "<front>\nuser");
  $this
    ->drupalLoginUser($privileged_user);
  $this
    ->drupalGet(url('user/1', array(
    'absolute' => TRUE,
  )));
  $this
    ->assertResponse('403', t('Access Denied') . ': %s');
  $this
    ->assertWantedRaw('Access denied');
  $this
    ->drupalGet(url('logout', array(
    'absolute' => TRUE,
  )));
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
}