You are here

function SecureSiteTest::testUserAgentOpera in Secure Site 5

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

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

File

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

Class

SecureSiteTest
Unit tests for the Secure Site module

Code

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

  // Send the Opera 9.51 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: Opera/9.51 (Windows NT 5.1; U; en)');
  $this
    ->drupalGet(url(NULL, NULL, NULL, TRUE));
  $this
    ->assertResponse('401', t('User Agent: Opera') . ': %s');
  $this
    ->assertAuthentication('Basic');
  $this
    ->assertRealm(new PatternExpectation("/{$realm} - \\d\\d\\d*/"));
}