You are here

function SecurePagesTestCase::_testPathNorms in Secure Pages 6

Same name and namespace in other branches
  1. 8 securepages.test \SecurePagesTestCase::_testPathNorms()
  2. 6.2 securepages.test \SecurePagesTestCase::_testPathNorms()
  3. 7 securepages.test \SecurePagesTestCase::_testPathNorms()

Test path normalization checks.

1 call to SecurePagesTestCase::_testPathNorms()
SecurePagesTestCase::testSecurePages in ./securepages.test
Runs all the test functions. These are run from a single outer function to avoid * multiple re-installs by simpletest.

File

./securepages.test, line 294
Provides SimpleTests for Secure Pages module.

Class

SecurePagesTestCase
@file Provides SimpleTests for Secure Pages module.

Code

function _testPathNorms() {
  variable_set('securepages_switch', TRUE);
  variable_set('securepages_pages', 'user');

  // Test mixed-case path.
  $this
    ->drupalGet('UsEr');
  $this
    ->assertUrl($this
    ->_toHTTPS(url('UsEr', array(
    'absolute' => TRUE,
  ))));
  $this
    ->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');

  // Test that a trailing slash will not force a protected form's action to
  // http.
  $https_path = $this
    ->_toHTTPS(url('user/', array(
    'absolute' => TRUE,
  )));

  // A http based 'user/' path will become 'user' when doing the redirect, so
  // best to ensure that the test gets the right conditions the path should be
  // https based.
  $this
    ->drupalGet($https_path);
  $this
    ->assertUrl($https_path);
  $this
    ->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');

  // Clean up.
  variable_del('securepages_switch');
  variable_del('securepages_pages');
}