You are here

function SecureSiteTest::testLogoutUnsecure in Secure Site 5

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

Check that users are able to login and logout from unsecured portions of the site after using the normal Drupal login form

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testLogoutUnsecure() {
  $privileged_user = $this
    ->drupalCreateUserRolePerm(array(
    'access content',
    'access secured pages',
  ));
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);

  // '/user' has to be whitelisted because drupalLoginUser() goes there to
  // login
  $this
    ->drupalVariableSet('securesite_filter_pages', "<front>\nuser");
  $this
    ->drupalGet(url('<front>', NULL, NULL, TRUE));
  $this
    ->assertResponse('200', t('Logout: Unsecure') . ': %s');
  $this
    ->assertNoAuthentication();
  $this
    ->drupalLoginUser($privileged_user);
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
  $this
    ->drupalGet(url('logout', NULL, NULL, TRUE));
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();
}