OpenIDFunctionalTestCase::addIdentity

7 openid.test OpenIDFunctionalTestCase::addIdentity($identity, $version = 2, $local_id = 'http://example.com/xrds', $claimed_id = NULL)
8 openid.test OpenIDFunctionalTestCase::addIdentity($identity, $version = 2, $local_id = 'http://example.com/xrds', $claimed_id = NULL)

Add OpenID identity to user's profile.

Parameters

$identity: The User-supplied Identifier.

$version: The protocol version used by the service.

$local_id: The expected OP-Local Identifier found during discovery.

$claimed_id: The expected Claimed Identifier returned by the OpenID Provider, or FALSE if the discovery is expected to fail.

File

modules/openid/openid.test, line 277
Tests for openid.module.

Code

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);

  $edit = array('openid_identifier' => $identity);
  $this->drupalPost('user/' . $this->web_user->uid . '/openid', $edit, t('Add an OpenID'));

  if ($claimed_id === FALSE) {
    $this->assertRaw(t('Sorry, that is not a valid OpenID. Ensure you have spelled your ID correctly.'), t('Invalid identity was rejected.'));
    return;
  }

  // OpenID 1 used a HTTP redirect, OpenID 2 uses a HTML form that is submitted automatically using JavaScript.
  if ($version == 2) {
    // 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'));
  }

  if (!isset($claimed_id)) {
    $claimed_id = $identity;
  }
  $this->assertRaw(t('Successfully added %identity', array('%identity' => $claimed_id)), t('Identity %identity was added.', array('%identity' => $identity)));
}
Login or register to post comments