diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-07-07 08:05:01 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-07-07 08:05:01 +0000 |
commit | ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2 (patch) | |
tree | 5561cfced677d44bff71b9b2955139cec9387226 /modules/openid | |
parent | a8812bb727a08296a2029fcb055767bc4b783fb0 (diff) | |
download | brdo-ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2.tar.gz brdo-ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2.tar.bz2 |
#363580 by rfay, chx, Berdir, Rob Loach, Gábor Hojtsy, Shawn DeArmond: Fixed OpenID login fails when in maintenance mode, and 403 errors on certain user paths for logged-in users.
Diffstat (limited to 'modules/openid')
-rw-r--r-- | modules/openid/openid.module | 10 | ||||
-rw-r--r-- | modules/openid/openid.test | 32 | ||||
-rw-r--r-- | modules/openid/tests/openid_test.module | 10 |
3 files changed, 52 insertions, 0 deletions
diff --git a/modules/openid/openid.module b/modules/openid/openid.module index 9a6e7edfb..99d37cf4c 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -39,6 +39,16 @@ function openid_menu() { } /** + * Implements hook_menu_site_status_alter(). + */ +function openid_menu_site_status_alter(&$menu_site_status, $path) { + // Allow access to openid/authenticate even if site is in offline mode. + if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'openid/authenticate') { + $menu_site_status = MENU_SITE_ONLINE; + } +} + +/** * Implements hook_help(). */ function openid_help($path, $arg) { diff --git a/modules/openid/openid.test b/modules/openid/openid.test index cf90161fd..68313ae7e 100644 --- a/modules/openid/openid.test +++ b/modules/openid/openid.test @@ -147,6 +147,38 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { } /** + * Test login using OpenID during maintenance mode. + */ + 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. + variable_set('maintenance_mode', 1); + + // Test logging in via the user/login page while the site is offline. + $edit = array('openid_identifier' => $identity); + $this->drupalPost('user/login', $edit, t('Log in')); + + // Check we are on the OpenID redirect form. + $this->assertTitle(t('OpenID redirect'), t('OpenID redirect page was displayed.')); + + // Submit form to the OpenID Provider Endpoint. + $this->drupalPost(NULL, array(), t('Send')); + + $this->assertLink($this->web_user->name, 0, t('User was logged in.')); + + // Verify user was redirected away from user/login to an accessible page. + $this->assertText(t('Operating in maintenance mode.')); + $this->assertResponse(200); + } + + /** * Test deleting an OpenID identity from a user's profile. */ function testDelete() { diff --git a/modules/openid/tests/openid_test.module b/modules/openid/tests/openid_test.module index 261a1aa1e..5beb5fa41 100644 --- a/modules/openid/tests/openid_test.module +++ b/modules/openid/tests/openid_test.module @@ -65,6 +65,16 @@ function openid_test_menu() { } /** + * Implements hook_menu_site_status_alter(). + */ +function openid_test_menu_site_status_alter(&$menu_site_status, $path) { + // Allow access to openid endpoint and identity even in offline mode. + if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && in_array($path, array('openid-test/yadis/xrds', 'openid-test/endpoint'))) { + $menu_site_status = MENU_SITE_ONLINE; + } +} + +/** * Menu callback; XRDS document that references the OP Endpoint URL. */ function openid_test_yadis_xrds() { |