function SecureSiteTest::testGuestUserLogout in Secure Site 5
Same name and namespace in other branches
- 6 tests/securesite.test \SecureSiteTest::testGuestUserLogout()
Check that guests are logged out if user had logged in after being a guest
File
- tests/
securesite.test, line 370 - Secure Site module unit tests
Class
- SecureSiteTest
- Unit tests for the Secure Site module
Code
function testGuestUserLogout() {
$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_BLACKLIST);
$this
->drupalVariableSet('securesite_filter_pages', 'user*');
$this
->drupalVariableSet('securesite_guest_name', 'foo');
$this
->drupalVariableSet('securesite_guest_pass', 'bar');
$this
->drupalGet(url('user/login', NULL, NULL, TRUE));
$this
->assertResponse('401', t('Guest Mode: Guest and User Logout') . ': %s');
$this
->assertAuthentication('Basic');
$this
->assertRealm($realm);
$this
->authenticate('foo', 'bar');
$this
->assertResponse('200');
$this
->assertNoAuthentication();
// Now, login as a privileged user
$this
->assertText('User account');
$this
->drupalLoginUser($privileged_user);
$this
->assertResponse('200');
$this
->assertNoAuthentication();
$this
->assertNoText('User login');
// Now, logout should trigger an auth dialog
$this
->drupalGet(url('logout', NULL, NULL, TRUE));
$this
->assertResponse('401');
$this
->assertAuthentication('Basic');
$this
->assertRealm($realm);
}