KeychainTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS
  4. *
  5. * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
  6. */
  7. namespace Lcobucci\JWT\Signer;
  8. /**
  9. * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
  10. * @since 2.1.0
  11. */
  12. class KeychainTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @test
  16. *
  17. * @uses Lcobucci\JWT\Signer\Key
  18. *
  19. * @covers Lcobucci\JWT\Signer\Keychain::getPrivateKey
  20. */
  21. public function getPrivateKeyShouldReturnAKey()
  22. {
  23. $keychain = new Keychain();
  24. $key = $keychain->getPrivateKey('testing', 'test');
  25. $this->assertInstanceOf(Key::class, $key);
  26. $this->assertAttributeEquals('testing', 'content', $key);
  27. $this->assertAttributeEquals('test', 'passphrase', $key);
  28. }
  29. /**
  30. * @test
  31. *
  32. * @uses Lcobucci\JWT\Signer\Key
  33. *
  34. * @covers Lcobucci\JWT\Signer\Keychain::getPublicKey
  35. */
  36. public function getPublicKeyShouldReturnAValidResource()
  37. {
  38. $keychain = new Keychain();
  39. $key = $keychain->getPublicKey('testing');
  40. $this->assertInstanceOf(Key::class, $key);
  41. $this->assertAttributeEquals('testing', 'content', $key);
  42. $this->assertAttributeEquals(null, 'passphrase', $key);
  43. }
  44. }