Association.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Tests for the Association implementation.
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * LICENSE: See the COPYING file included in this distribution.
  8. *
  9. * @package OpenID
  10. * @author JanRain, Inc. <openid@janrain.com>
  11. * @copyright 2005-2008 Janrain, Inc.
  12. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
  13. */
  14. require_once 'Auth/OpenID/Association.php';
  15. class Tests_Auth_OpenID_Association extends PHPUnit_Framework_TestCase {
  16. function test_me()
  17. {
  18. $issued = time();
  19. $lifetime = 600;
  20. $assoc = new Auth_OpenID_Association('handle', 'secret', $issued,
  21. $lifetime, 'HMAC-SHA1');
  22. $s = $assoc->serialize();
  23. $assoc2 = Auth_OpenID_Association::deserialize(
  24. 'Auth_OpenID_Association', $s);
  25. if ($assoc2 === null) {
  26. $this->fail('deserialize returned null');
  27. } else {
  28. $this->assertTrue($assoc2->equal($assoc));
  29. }
  30. }
  31. function test_me256()
  32. {
  33. if(!Auth_OpenID_HMACSHA256_SUPPORTED) return;
  34. $issued = time();
  35. $lifetime = 600;
  36. $assoc = new Auth_OpenID_Association('handle', 'secret', $issued,
  37. $lifetime, 'HMAC-SHA256');
  38. $s = $assoc->serialize();
  39. $assoc2 = Auth_OpenID_Association::deserialize(
  40. 'Auth_OpenID_Association', $s);
  41. if ($assoc2 === null) {
  42. $this->fail('deserialize returned null');
  43. } else {
  44. $this->assertTrue($assoc2->equal($assoc));
  45. }
  46. }
  47. }