You are here

function SecurePagesTestCase::_testPathNorms in Secure Pages 8

Same name and namespace in other branches
  1. 6.2 securepages.test \SecurePagesTestCase::_testPathNorms()
  2. 6 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 351
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('UsEr', array(
    'https' => TRUE,
    '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. 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('user/', array(
    'https' => TRUE,
    'absolute' => TRUE,
  ));
  $this
    ->assertUrl('user/', array(
    'https' => TRUE,
    'absolute' => TRUE,
  ));
  $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');
}