function OpenIDFunctionalTest::testLoginMaintenanceMode

Test login using OpenID during maintenance mode.

File

drupal/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php, line 203
Definition of Drupal\openid\Tests\OpenIDFunctionalTest.

Class

OpenIDFunctionalTest
Test discovery and login using OpenID

Namespace

Drupal\openid\Tests

Code

function testLoginMaintenanceMode() {
  $this->web_user = $this
    ->drupalCreateUser(array(
    'access site in maintenance mode',
  ));
  $this
    ->drupalLogin($this->web_user);

  // Use a User-supplied Identity that is the URL of an XRDS document.
  $identity = url('openid-test/yadis/xrds', array(
    'absolute' => TRUE,
  ));
  $this
    ->addIdentity($identity);
  $this
    ->drupalLogout();

  // Enable maintenance mode.
  config('system.maintenance')
    ->set('enabled', TRUE)
    ->save();

  // Test logging in via the user/login/openid page while the site is offline.
  $edit = array(
    'openid_identifier' => $identity,
  );
  $this
    ->drupalPost('user/login/openid', $edit, t('Log in'));

  // Check we are on the OpenID redirect form.
  $this
    ->assertTitle(t('OpenID redirect'), 'OpenID redirect page was displayed.');

  // Submit form to the OpenID Provider Endpoint.
  $this
    ->drupalPost(NULL, array(), t('Send'));
  $this
    ->assertLink(t('Log out'), 0, 'User was logged in.');

  // Verify user was redirected away from user/login/openid to an accessible
  // page.
  $this
    ->assertText(t('Operating in maintenance mode.'));
  $this
    ->assertResponse(200);
}