diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
index 71c6f02..1715255 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
@@ -75,9 +75,9 @@ function testDiscovery() {
$identity = url('openid-test/yadis/xrds/dummy-user', array('absolute' => TRUE, 'fragment' => $this->randomName()));
// Tell openid_test.module to respond with this identifier. If the fragment
// part is present in the identifier, it should be retained.
- variable_set('openid_test_response', array('openid.claimed_id' => $identity));
+ state()->set('openid_test.response', array('openid.claimed_id' => $identity));
$this->addIdentity(url('openid-test/yadis/xrds/server', array('absolute' => TRUE)), 2, 'http://specs.openid.net/auth/2.0/identifier_select', $identity);
- variable_set('openid_test_response', array());
+ state()->set('openid_test.response', array());
// Identifier is the URL of an HTML page that is sent with an HTTP header
// that contains the URL of an XRDS document.
@@ -94,7 +94,7 @@ function testDiscovery() {
$this->addIdentity('@example*résumé;%25', 2, 'http://example.com/xrds', 'http://example.com/user');
// Make sure that unverified CanonicalID are not trusted.
- variable_set('openid_test_canonical_id_status', 'bad value');
+ state()->set('openid_test.canonical_id_status', 'bad value');
$this->addIdentity('@example*résumé;%25', 2, FALSE, FALSE);
// HTML-based discovery:
@@ -140,20 +140,20 @@ function testLogin() {
// 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);
- $response = variable_get('openid_test_hook_openid_response_response');
- $account = variable_get('openid_test_hook_openid_response_account');
+ $response = state()->get('openid_test.hook_openid_response_response');
+ $account = state()->get('openid_test.hook_openid_response_account');
$this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.');
$this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().');
$this->drupalLogout();
// Test logging in via the login block on the front page.
- variable_del('openid_test_hook_openid_response_response');
- variable_del('openid_test_hook_openid_response_account');
+ state()->delete('openid_test.hook_openid_response_response');
+ state()->delete('openid_test.hook_openid_response_account');
$this->submitLoginForm($identity);
$this->assertLink(t('Log out'), 0, 'User was logged in.');
- $response = variable_get('openid_test_hook_openid_response_response');
- $account = variable_get('openid_test_hook_openid_response_account');
+ $response = state()->get('openid_test.hook_openid_response_response');
+ $account = state()->get('openid_test.hook_openid_response_account');
$this->assertEqual($response['openid.claimed_id'], $identity, 'hook_openid_response() was invoked.');
$this->assertEqual($account->uid, $this->web_user->uid, 'Proper user object passed to hook_openid_response().');
@@ -179,11 +179,11 @@ function testLogin() {
// Tell openid_test.module to alter the checkid_setup request.
$new_identity = 'http://example.com/' . $this->randomName();
- variable_set('openid_test_identity', $new_identity);
- variable_set('openid_test_request_alter', array('checkid_setup' => array('openid.identity' => $new_identity)));
+ state()->set('openid_test.identity', $new_identity);
+ state()->set('openid_test.request_alter', array('checkid_setup' => array('openid.identity' => $new_identity)));
$this->submitLoginForm($identity);
$this->assertLink(t('Log out'), 0, 'User was logged in.');
- $response = variable_get('openid_test_hook_openid_response_response');
+ $response = state()->get('openid_test.hook_openid_response_response');
$this->assertEqual($response['openid.identity'], $new_identity, 'hook_openid_request_alter() were invoked.');
$this->drupalLogout();
@@ -292,7 +292,7 @@ function testBlockedUserLogin() {
*/
function addIdentity($identity, $version = 2, $local_id = 'http://example.com/xrds', $claimed_id = NULL) {
// Tell openid_test.module to only accept this OP-Local Identifier.
- variable_set('openid_test_identity', $local_id);
+ state()->set('openid_test.identity', $local_id);
$edit = array('openid_identifier' => $identity);
$this->drupalPost('user/' . $this->web_user->uid . '/openid', $edit, t('Add an OpenID'));
@@ -342,14 +342,14 @@ function addRedirectedIdentity($identity, $version = 2, $local_id = 'http://exam
// Identifier, we insert the same identifier also to the provider response,
// but provider could further change the Claimed ID actually (e.g. it could
// add unique fragment).
- variable_set('openid_test_redirect_url', $identity);
- variable_set('openid_test_response', array('openid.claimed_id' => $identity));
+ state()->set('openid_test.redirect_url', $identity);
+ state()->set('openid_test.response', array('openid.claimed_id' => $identity));
$this->addIdentity(url('openid-test/redirect/' . $redirects, array('absolute' => TRUE)), $version, $local_id, $claimed_id);
// Clean up.
- variable_del('openid_test_redirect_url');
- variable_del('openid_test_response');
+ state()->delete('openid_test.redirect_url');
+ state()->delete('openid_test.response');
}
/**
@@ -361,12 +361,12 @@ function testSignatureValidation() {
$identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
// Respond with an invalid signature.
- variable_set('openid_test_response', array('openid.sig' => 'this-is-an-invalid-signature'));
+ state()->set('openid_test.response', array('openid.sig' => 'this-is-an-invalid-signature'));
$this->submitLoginForm($identity);
$this->assertRaw('OpenID login failed.');
// Do not sign the mandatory field openid.assoc_handle.
- variable_set('openid_test_response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce'));
+ state()->set('openid_test.response', array('openid.signed' => 'op_endpoint,claimed_id,identity,return_to,response_nonce'));
$this->submitLoginForm($identity);
$this->assertRaw('OpenID login failed.');
@@ -385,7 +385,7 @@ function testSignatureValidation() {
'openid.signed' => implode(',', $keys_to_sign),
);
$response['openid.sig'] = _openid_signature($association, $response, $keys_to_sign);
- variable_set('openid_test_response', $response);
+ state()->set('openid_test.response', $response);
$this->submitLoginForm($identity);
$this->assertNoRaw('OpenID login failed.');
$this->assertFieldByName('name', '', 'No username was supplied by provider.');
@@ -397,7 +397,7 @@ function testSignatureValidation() {
'openid.sreg.nickname' => 'john',
'openid.sreg.email' => 'john@example.com',
);
- variable_set('openid_test_response', $response);
+ state()->set('openid_test.response', $response);
$this->submitLoginForm($identity);
$this->assertNoRaw('OpenID login failed.');
$this->assertFieldByName('name', 'john', 'Username was supplied by provider.');
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
index debb9cd..494b835 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDRegistrationTest.php
@@ -45,7 +45,7 @@ function testRegisterUserWithEmailVerification() {
variable_set('date_default_timezone', 'Europe/Brussels');
// Tell openid_test.module to respond with these SREG fields.
- variable_set('openid_test_response', array(
+ state()->set('openid_test.response', array(
'openid.sreg.nickname' => 'john',
'openid.sreg.email' => 'john@example.com',
'openid.sreg.language' => 'pt-BR',
@@ -102,7 +102,7 @@ function testRegisterUserWithoutEmailVerification() {
variable_set('date_default_timezone', 'Europe/Brussels');
// Tell openid_test.module to respond with these SREG fields.
- variable_set('openid_test_response', array(
+ state()->set('openid_test.response', array(
'openid.sreg.nickname' => 'john',
'openid.sreg.email' => 'john@example.com',
'openid.sreg.language' => 'pt-BR',
@@ -144,7 +144,7 @@ function testRegisterUserWithInvalidSreg() {
// Tell openid_test.module to respond with these SREG fields.
$web_user = $this->drupalCreateUser(array());
- variable_set('openid_test_response', array(
+ state()->set('openid_test.response', array(
'openid.sreg.nickname' => $web_user->name,
'openid.sreg.email' => 'mail@invalid#',
'openid.sreg.timezone' => 'Foo/Bar',
@@ -158,11 +158,11 @@ function testRegisterUserWithInvalidSreg() {
$this->assertRaw(t('Account registration using the information provided by your OpenID provider failed due to the reasons listed below. Complete the registration by filling out the form below. If you already have an account, you can log in now and add your OpenID under "My account".', array('@login' => url('user/login'))), 'User was asked to complete the registration process manually.');
$this->assertRaw(t('The name %name is already taken.', array('%name' => $web_user->name)), 'Form validation error for username was displayed.');
$this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'mail@invalid#')), 'Form validation error for e-mail address was displayed.');
- $this->assertTrue(variable_get('openid_test_hook_openid_response_response'), 'hook_openid_response() was invoked.');
- $this->assertFalse(variable_get('openid_test_hook_openid_response_account', TRUE), 'No user object passed to hook_openid_response().');
+ $this->assertTrue(state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was invoked.');
+ $this->assertFalse(state()->get('openid_test.hook_openid_response_account'), 'No user object passed to hook_openid_response().');
// Enter username and e-mail address manually.
- variable_del('openid_test_hook_openid_response_response');
+ state()->delete('openid_test.hook_openid_response_response');
$edit = array('name' => 'john', 'mail' => 'john@example.com');
$this->drupalPost(NULL, $edit, t('Create new account'));
$this->assertRaw(t('Once you have verified your e-mail address, you may log in via OpenID.'), 'User was asked to verify e-mail address.');
@@ -176,7 +176,7 @@ function testRegisterUserWithInvalidSreg() {
// Follow the one-time login that was sent in the welcome e-mail.
$this->drupalGet($reset_url);
$this->drupalPost(NULL, array(), t('Log in'));
- $this->assertFalse(variable_get('openid_test_hook_openid_response_response'), 'hook_openid_response() was not invoked.');
+ $this->assertFalse(state()->get('openid_test.hook_openid_response_response'), 'hook_openid_response() was not invoked.');
// The user is taken to user/%uid/edit.
$this->assertFieldByName('mail', 'john@example.com', 'User was registered with right e-mail address.');
@@ -233,7 +233,7 @@ function testRegisterUserWithAXButNoSREG() {
variable_set('date_default_timezone', 'Europe/Brussels');
// Tell openid_test.module to respond with these AX fields.
- variable_set('openid_test_response', array(
+ state()->set('openid_test.response', array(
'openid.ns.ext123' => 'http://openid.net/srv/ax/1.0',
'openid.ext123.type.mail456' => 'http://axschema.org/contact/email',
'openid.ext123.value.mail456' => 'john@example.com',
diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module
index 5fe64cf..9aa5023 100644
--- a/core/modules/openid/tests/openid_test.module
+++ b/core/modules/openid/tests/openid_test.module
@@ -108,7 +108,7 @@ function openid_test_yadis_xrds() {
$output .= '
-
+
xri://@
http://example.com/user
@@ -226,12 +226,12 @@ function openid_test_endpoint() {
*/
function openid_test_redirect($count = 0) {
if ($count == 0) {
- $url = variable_get('openid_test_redirect_url', '');
+ $url = state()->get('openid_test.redirect_url');
}
else {
$url = url('openid-test/redirect/' . --$count, array('absolute' => TRUE));
}
- $http_response_code = variable_get('openid_test_redirect_http_reponse_code', 301);
+ $http_response_code = state()->get('openid_test.redirect_http_response_code') ?: 301;
return new RedirectResponse($url, $http_response_code);
}
@@ -303,9 +303,10 @@ function _openid_test_endpoint_associate() {
function _openid_test_endpoint_authenticate() {
module_load_include('inc', 'openid');
- $expected_identity = variable_get('openid_test_identity');
+ $expected_identity = state()->get('openid_test.identity');
if ($expected_identity && $_REQUEST['openid_identity'] != $expected_identity) {
- $response = variable_get('openid_test_response', array()) + array(
+ $response = state()->get('openid_test.response') ?: array();
+ $response += array(
'openid.ns' => OPENID_NS_2_0,
'openid.mode' => 'error',
'openid.error' => 'Unexpted identity',
@@ -317,7 +318,8 @@ function _openid_test_endpoint_authenticate() {
$nonce = _openid_nonce();
// Generate response containing the user's identity.
- $response = variable_get('openid_test_response', array()) + array(
+ $response = state()->get('openid_test.response') ?: array();
+ $response += array(
'openid.ns' => OPENID_NS_2_0,
'openid.mode' => 'id_res',
'openid.op_endpoint' => url('openid-test/endpoint', array('absolute' => TRUE)),
@@ -357,7 +359,7 @@ function _openid_test_endpoint_authenticate() {
* Implements hook_openid_request_alter().
*/
function openid_test_openid_request_alter(&$request, $service) {
- $parameters = variable_get('openid_test_request_alter', array());
+ $parameters = state()->get('openid_test.request_alter');
if (isset($parameters[$request['openid.mode']])) {
$request = $parameters[$request['openid.mode']] + $request;
}
@@ -367,6 +369,6 @@ function openid_test_openid_request_alter(&$request, $service) {
* Implements hook_openid_response().
*/
function openid_test_openid_response($response, $account) {
- variable_set('openid_test_hook_openid_response_response', $response);
- variable_set('openid_test_hook_openid_response_account', $account ? $account : FALSE);
+ state()->set('openid_test.hook_openid_response_response', $response);
+ state()->set('openid_test.hook_openid_response_account', $account ? $account : FALSE);
}