You are here

function SecureSiteTest::testGuestLogin in Secure Site 5

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

Check that guests can login when guest mode is enabled (a username and password are set)

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testGuestLogin() {
  $realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);
  $this
    ->drupalVariableSet('securesite_filter_pages', '');
  $this
    ->drupalVariableSet('securesite_guest_name', 'foo');
  $this
    ->drupalVariableSet('securesite_guest_pass', 'bar');
  $this
    ->drupalGet(url(NULL, NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('Guest Mode: Login') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
  $this
    ->authenticate('foo', 'bar');
  $this
    ->assertResponse('200');
  $this
    ->assertNoAuthentication();

  // Age the session by 30 days to make sure it will be cleaned up and
  // restart the test browser
  $this
    ->ageCookies(3600 * 24 * 30);
  $this
    ->restart();

  // Now, check that HTTP Auth works normally
  $this
    ->drupalGet(url(NULL, NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('Guest Mode: Logout') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm($realm);
}