|
5 | 5 | namespace Marvin255\Jwt\Test\Signer; |
6 | 6 |
|
7 | 7 | use Marvin255\Jwt\Signer\Algorithm; |
| 8 | +use Marvin255\Jwt\Signer\AlgorithmType; |
| 9 | +use Marvin255\Jwt\Signer\HmacSha256Signer; |
| 10 | +use Marvin255\Jwt\Signer\HmacSha384Signer; |
| 11 | +use Marvin255\Jwt\Signer\HmacSha512Signer; |
| 12 | +use Marvin255\Jwt\Signer\NoneSigner; |
| 13 | +use Marvin255\Jwt\Signer\RsaSha256Signer; |
| 14 | +use Marvin255\Jwt\Signer\RsaSha384Signer; |
| 15 | +use Marvin255\Jwt\Signer\RsaSha512Signer; |
8 | 16 | use Marvin255\Jwt\Test\BaseCase; |
9 | 17 |
|
10 | 18 | /** |
@@ -33,4 +41,88 @@ public function provideGetPhpAlgName(): array |
33 | 41 | ], |
34 | 42 | ]; |
35 | 43 | } |
| 44 | + |
| 45 | + /** |
| 46 | + * @dataProvider provideGetImplementation |
| 47 | + */ |
| 48 | + public function testGetImplementation(Algorithm $alg, string $result): void |
| 49 | + { |
| 50 | + $this->assertSame($result, $alg->getImplementation()); |
| 51 | + } |
| 52 | + |
| 53 | + public function provideGetImplementation(): array |
| 54 | + { |
| 55 | + return [ |
| 56 | + 'NONE' => [ |
| 57 | + Algorithm::NONE, |
| 58 | + NoneSigner::class, |
| 59 | + ], |
| 60 | + 'HMAC_SHA_256' => [ |
| 61 | + Algorithm::HMAC_SHA_256, |
| 62 | + HmacSha256Signer::class, |
| 63 | + ], |
| 64 | + 'HMAC_SHA_384' => [ |
| 65 | + Algorithm::HMAC_SHA_384, |
| 66 | + HmacSha384Signer::class, |
| 67 | + ], |
| 68 | + 'HMAC_SHA_512' => [ |
| 69 | + Algorithm::HMAC_SHA_512, |
| 70 | + HmacSha512Signer::class, |
| 71 | + ], |
| 72 | + 'RSA_SHA_256' => [ |
| 73 | + Algorithm::RSA_SHA_256, |
| 74 | + RsaSha256Signer::class, |
| 75 | + ], |
| 76 | + 'RSA_SHA_384' => [ |
| 77 | + Algorithm::RSA_SHA_384, |
| 78 | + RsaSha384Signer::class, |
| 79 | + ], |
| 80 | + 'RSA_SHA_512' => [ |
| 81 | + Algorithm::RSA_SHA_512, |
| 82 | + RsaSha512Signer::class, |
| 83 | + ], |
| 84 | + ]; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * @dataProvider provideTestGetType |
| 89 | + */ |
| 90 | + public function testGetType(Algorithm $alg, AlgorithmType $result): void |
| 91 | + { |
| 92 | + $this->assertSame($result, $alg->getType()); |
| 93 | + } |
| 94 | + |
| 95 | + public function provideTestGetType(): array |
| 96 | + { |
| 97 | + return [ |
| 98 | + 'NONE' => [ |
| 99 | + Algorithm::NONE, |
| 100 | + AlgorithmType::NONE, |
| 101 | + ], |
| 102 | + 'HMAC_SHA_256' => [ |
| 103 | + Algorithm::HMAC_SHA_256, |
| 104 | + AlgorithmType::HMAC, |
| 105 | + ], |
| 106 | + 'HMAC_SHA_384' => [ |
| 107 | + Algorithm::HMAC_SHA_384, |
| 108 | + AlgorithmType::HMAC, |
| 109 | + ], |
| 110 | + 'HMAC_SHA_512' => [ |
| 111 | + Algorithm::HMAC_SHA_512, |
| 112 | + AlgorithmType::HMAC, |
| 113 | + ], |
| 114 | + 'RSA_SHA_256' => [ |
| 115 | + Algorithm::RSA_SHA_256, |
| 116 | + AlgorithmType::RSA, |
| 117 | + ], |
| 118 | + 'RSA_SHA_384' => [ |
| 119 | + Algorithm::RSA_SHA_384, |
| 120 | + AlgorithmType::RSA, |
| 121 | + ], |
| 122 | + 'RSA_SHA_512' => [ |
| 123 | + Algorithm::RSA_SHA_512, |
| 124 | + AlgorithmType::RSA, |
| 125 | + ], |
| 126 | + ]; |
| 127 | + } |
36 | 128 | } |
0 commit comments