You are here

function SecureSiteTest::testLoginUnprivilegedHTTP in Secure Site 5

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

Check that unprivileged users get HTTP Auth when accessing secure pages

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testLoginUnprivilegedHTTP() {
  $realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));
  $unprivileged_user = $this
    ->drupalCreateUserRolePerm(array(
    'access content',
  ));
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);
  $this
    ->drupalVariableSet('securesite_filter_pages', '');
  $this
    ->drupalGet(url(NULL, NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('Login: Unprivileged HTTP Auth') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
  $this
    ->authenticate($unprivileged_user->name, $unprivileged_user->pass_raw);
  $this
    ->assertResponse('401');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
  $this
    ->drupalGet(url('logout', NULL, NULL, TRUE));
  $this
    ->assertResponse('401');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
}