You are here

function SecureSiteTest::testRepeatLoginSecureFirst in Secure Site 5

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

Check that login works normally after previous login and logout when first securing <front>, then not

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testRepeatLoginSecureFirst() {
  $realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));
  $privileged_user = $this
    ->drupalCreateUserRolePerm(array(
    'access content',
    'access secured pages',
  ));

  // Login, logout, then login and logout again
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);
  $this
    ->drupalVariableSet('securesite_filter_pages', '');
  $this
    ->drupalGet(url('<front>', NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('Repeat Login: Secure First') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
  $this
    ->authenticate($privileged_user->name, $privileged_user->pass_raw);
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
  $this
    ->drupalGet(url('logout', NULL, NULL, TRUE));
  $this
    ->assertResponse('401');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
  $this
    ->drupalVariableSet('securesite_filter_pages', "<front>\nuser");
  $this
    ->drupalGet(url('<front>', NULL, NULL, TRUE));
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
  $this
    ->drupalLoginUser($privileged_user);
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
  $this
    ->drupalGet(url('logout', NULL, NULL, TRUE));
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
}