You are here

function SecureSiteTest::testUserAgentSafari in Secure Site 5

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

Check that the realm is correct when using the HTTP Auth method with Safari's User Agent string

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

function testUserAgentSafari() {
  $realm = variable_get('securesite_realm', variable_get('site_name', 'Drupal'));

  // Send the Safari 3.1 User-Agent header
  $this
    ->drupalVariableSet('securesite_enabled', SECURESITE_AUTH);
  $this
    ->drupalVariableSet('securesite_filter_pages_type', SECURESITE_WHITELIST);
  $this
    ->drupalVariableSet('securesite_filter_pages', '');
  $this
    ->addHeader('User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; en-us) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13');
  $this
    ->drupalGet(url(NULL, NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('User Agent: Safari') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm(new PatternExpectation("/{$realm} - \\d\\d\\d*/"));
}