Association.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 'PHPUnit.php';
  15. require_once 'Auth/OpenID/Association.php';
  16. class Tests_Auth_OpenID_Association extends PHPUnit_TestCase {
  17. function test_me()
  18. {
  19. $issued = time();
  20. $lifetime = 600;
  21. $assoc = new Auth_OpenID_Association('handle', 'secret', $issued,
  22. $lifetime, 'HMAC-SHA1');
  23. $s = $assoc->serialize();
  24. $assoc2 = Auth_OpenID_Association::deserialize(
  25. 'Auth_OpenID_Association', $s);
  26. if ($assoc2 === null) {
  27. $this->fail('deserialize returned null');
  28. } else {
  29. $this->assertTrue($assoc2->equal($assoc));
  30. }
  31. }
  32. function test_me256()
  33. {
  34. if(!Auth_OpenID_HMACSHA256_SUPPORTED) return;
  35. $issued = time();
  36. $lifetime = 600;
  37. $assoc = new Auth_OpenID_Association('handle', 'secret', $issued,
  38. $lifetime, 'HMAC-SHA256');
  39. $s = $assoc->serialize();
  40. $assoc2 = Auth_OpenID_Association::deserialize(
  41. 'Auth_OpenID_Association', $s);
  42. if ($assoc2 === null) {
  43. $this->fail('deserialize returned null');
  44. } else {
  45. $this->assertTrue($assoc2->equal($assoc));
  46. }
  47. }
  48. }
  49. ?>