You are here

function OpenIDTestCase::testOpenidSignature in Drupal 7

Test _openid_signature().

File

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

Class

OpenIDTestCase
Test internal helper functions.

Code

function testOpenidSignature() {

  // Test that signature is calculated according to OpenID Authentication 2.0,
  // section 6.1. In the following array, only the two first entries should be
  // included in the calculation, because the substring following the period
  // is mentioned in the third argument for _openid_signature(). The last
  // entry should not be included, because it does not start with "openid.".
  $response = array(
    'openid.foo' => 'abc1',
    'openid.bar' => 'abc2',
    'openid.baz' => 'abc3',
    'foobar.foo' => 'abc4',
  );
  $association = new stdClass();
  $association->mac_key = "";
  $this
    ->assertEqual(_openid_signature($association, $response, array(
    'foo',
    'bar',
  )), 'QnKZQzSFstT+GNiJDFOptdcZjrc=', 'Expected signature calculated.');
}