function SecureSiteTest::testGuestFirstUnclean in Secure Site 5
Same name and namespace in other branches
- 6 tests/securesite.test \SecureSiteTest::testGuestFirstUnclean()
Check that users get the correct page after previously logging in as a guest and not forcing a guest logout
File
- tests/
securesite.test, line 259 - Secure Site module unit tests
Class
- SecureSiteTest
- Unit tests for the Secure Site module
Code
function testGuestFirstUnclean() {
$realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));
$privileged_user = $this
->drupalCreateUserRolePerm(array(
'access content',
'access secured pages',
));
// Login as a guest first
$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: Guest First Unclean') . ': %s');
$this
->assertAuthentication('Basic');
$this
->assertRealm($realm);
$this
->authenticate('foo', 'bar');
$this
->assertResponse('200');
$this
->assertNoAuthentication();
$this
->assertText('User login');
// Now, restart (since logout isn't possible for guests) and login as a
// privileged user
$this
->restart();
$this
->drupalGet(url(NULL, NULL, NULL, TRUE));
$this
->assertResponse('200');
$this
->assertNoAuthentication();
$this
->assertText('User login');
$this
->drupalLoginUser($privileged_user);
$this
->assertResponse('200');
$this
->assertNoAuthentication();
$this
->assertNoText('User login');
}