|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Emarref\Jwt\HeaderParameter; |
|
4
|
|
|
|
|
5
|
|
|
class FactoryTest extends \PHPUnit_Framework_TestCase |
|
6
|
|
|
{ |
|
7
|
|
|
private static $classMap = [ |
|
8
|
|
|
Algorithm::NAME => 'Emarref\Jwt\HeaderParameter\Algorithm', |
|
9
|
|
|
ContentType::NAME => 'Emarref\Jwt\HeaderParameter\ContentType', |
|
10
|
|
|
Critical::NAME => 'Emarref\Jwt\HeaderParameter\Critical', |
|
11
|
|
|
JsonWebKey::NAME => 'Emarref\Jwt\HeaderParameter\JsonWebKey', |
|
12
|
|
|
JwkSetUrl::NAME => 'Emarref\Jwt\HeaderParameter\JwkSetUrl', |
|
13
|
|
|
KeyId::NAME => 'Emarref\Jwt\HeaderParameter\KeyId', |
|
14
|
|
|
Type::NAME => 'Emarref\Jwt\HeaderParameter\Type', |
|
15
|
|
|
X509CertificateChain::NAME => 'Emarref\Jwt\HeaderParameter\X509CertificateChain', |
|
16
|
|
|
X509CertificateSha1Thumbprint::NAME => 'Emarref\Jwt\HeaderParameter\X509CertificateSha1Thumbprint', |
|
17
|
|
|
X509CertificateSha256Thumbprint::NAME => 'Emarref\Jwt\HeaderParameter\X509CertificateSha256Thumbprint', |
|
18
|
|
|
X509Url::NAME => 'Emarref\Jwt\HeaderParameter\X509Url', |
|
19
|
|
|
]; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var Factory |
|
23
|
|
|
*/ |
|
24
|
|
|
private $factory; |
|
25
|
|
|
|
|
26
|
|
|
public function setUp() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->factory = new Factory(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testGetAlgorithm() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->assertInstanceOf(self::$classMap[Algorithm::NAME], $this->factory->get(Algorithm::NAME)); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testGetContentType() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->assertInstanceOf(self::$classMap[ContentType::NAME], $this->factory->get(ContentType::NAME)); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testGetCritical() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->assertInstanceOf(self::$classMap[Critical::NAME], $this->factory->get(Critical::NAME)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetJsonWebKey() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->assertInstanceOf(self::$classMap[JsonWebKey::NAME], $this->factory->get(JsonWebKey::NAME)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testGetJwkSetUrl() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->assertInstanceOf(self::$classMap[JwkSetUrl::NAME], $this->factory->get(JwkSetUrl::NAME)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testGetKeyId() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->assertInstanceOf(self::$classMap[KeyId::NAME], $this->factory->get(KeyId::NAME)); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testGetType() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->assertInstanceOf(self::$classMap[Type::NAME], $this->factory->get(Type::NAME)); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function testGetX509CertificateChain() |
|
67
|
|
|
{ |
|
68
|
|
|
$this->assertInstanceOf(self::$classMap[X509CertificateChain::NAME], $this->factory->get(X509CertificateChain::NAME)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function testGetX509CertificateSha1Thumbprint() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->assertInstanceOf(self::$classMap[X509CertificateSha1Thumbprint::NAME], $this->factory->get(X509CertificateSha1Thumbprint::NAME)); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function testGetX509CertificateSha256Thumbprint() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->assertInstanceOf(self::$classMap[X509CertificateSha256Thumbprint::NAME], $this->factory->get(X509CertificateSha256Thumbprint::NAME)); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function testGetX509Url() |
|
82
|
|
|
{ |
|
83
|
|
|
$this->assertInstanceOf(self::$classMap[X509Url::NAME], $this->factory->get(X509Url::NAME)); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function testGetCustom() |
|
87
|
|
|
{ |
|
88
|
|
|
$this->assertInstanceOf('Emarref\Jwt\HeaderParameter\Custom', $this->factory->get('foo')); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|