1 | <?php |
||
7 | class JwtWrapperSecretTest extends JwtWrapperHashTest |
||
8 | { |
||
9 | /** |
||
10 | * @throws \ByJG\Util\JwtWrapperException |
||
11 | */ |
||
12 | protected function setUp() |
||
13 | { |
||
14 | $private = <<<TEXT |
||
15 | -----BEGIN RSA PRIVATE KEY----- |
||
16 | MIIEpQIBAAKCAQEA5PMdWRa+rUJmg6QMNAPIXa+BJVN7W0vxPN3WTK/OIv5gxgmj |
||
17 | 2inHGGc6f90TW/to948LnqGtcD3CD9KsI55MubafwBYjcds1o9opZ0vYwwdIV80c |
||
18 | OVZX1IUZFTbnyyKcXeFmKt49A52haCiy4iNxcRK38tOCApjZySx/NzMDeaXuWe+1 |
||
19 | nd3pbgYa/I8MkECa5EyabhZJPJo9fGoSZIklNnyq4TfAUSwl+KN/zjj3CXad1oDT |
||
20 | 7XDDgMJDUu/Vxs7h3CQI9zILSYcL9zwttbLnJW1WcLlAAIaAfABtSZboznsStMnY |
||
21 | to01wVknXKyERFs7FLHYqKQANIvRhFTptsehowIDAQABAoIBAEkJkaQ5EE0fcKqw |
||
22 | K8BwMHxKn81zi1e9q1C6iEHgl8csFV03+BCB4WTUkaH2udVPJ9ZJyPArLbQvz3fS |
||
23 | wl1+g4V/UAksRtRslPkXgLvWQ2k8KoTwBv/3nn9Kkozk/h8chHuii0BDs30yzSn4 |
||
24 | SdDAc9EZopsRhFklv9xgmJjYalRk02OLck73G+d6MpDqX56o2UA/lf6i9MV19KWP |
||
25 | HYip7CAN+i6k8gA0KPHwr76ehgQ6YHtSntkWS8RfVI8fLUB1UlT3HmLgUBNXMWkQ |
||
26 | ZZbvXtNOt6NtW/WIAHEYeE9jmFgrpW5jKJSLn5iGVPFZwJIZXRPyELEs9NHWkS6e |
||
27 | GmdzxnECgYEA8+m05B/tmeZOuMrPVJV9g+aBDcuxmW+sdLRch+ccSmx4ZNQOLVoU |
||
28 | klYgTZq/a1O4ENq0h2WgccNlRHdcH4sXMBvLalA/tFhZMUuA/KXWyZ1F0hBnjHVF |
||
29 | cj1alHCqh+9qJDGdn4mxSmrp8p0rfeWgBwlFtJEJmjjDWDCtVY+JZcsCgYEA8EuV |
||
30 | WF/ilgDjgC4jMCYNuO0oFGBbtNP17PuU3kh8W+joqK/nufZ3NLy1WrDIpqa9YPex |
||
31 | 328Nnjljf5GJWSdMchAp82waLzl7FaaBTY0iyFAK4J0jfC/fVLx82+wpM3utDnh8 |
||
32 | 9x5iIboO5U7uEJ7k8X2p64GoprlKJSRmGAJ7eIkCgYEAw5IsXI3NMY0cqcbUHvoO |
||
33 | PehgqfMdX+3O1XSYjM+eO35lulLdWzfTLtKn7BGcUi46dCkofzfZQd5uIEukLhaU |
||
34 | bRqcK45UxgHg4kmsDufaJKZaCWjl3hVZrZPMQSFlWsF41bSCshzxbr3y/3lOGhA4 |
||
35 | E+w3W+S/Uk0ZNGkzUltYy6kCgYEA0gRNeBr9z7rhG4O3j3qC3dCxCfYZ0Na8hy5v |
||
36 | M0PJJQ9QYTa04iyOjVItcyE1jaoHtLtoA+9syJBB7RoHIBufzcVg1Pbzf7jOYeLP |
||
37 | +jbTYp3Kk/vjKsQwfj/rJM+oRu3eF9qo5dbxT6btI++zVGV7lbEOFN6Sx30EV6gT |
||
38 | bwKkZXkCgYEAnEtN43xL8bRFybMc1ZJErjc0VocnoQxCHm7LuAtLOEUw6CwwFj9Q |
||
39 | GOl+GViVuDHUNQvURLn+6gg4tAemYlob912xIPaU44+lZzTMHBOJBGMJKi8WogKi |
||
40 | V5+cz9l31uuAgNfjL63jZPaAzKs8Zx6R3O5RuezympwijCIGWILbO2Q= |
||
41 | -----END RSA PRIVATE KEY----- |
||
42 | TEXT; |
||
43 | $public = <<<TEXT |
||
44 | -----BEGIN PUBLIC KEY----- |
||
45 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5PMdWRa+rUJmg6QMNAPI |
||
46 | Xa+BJVN7W0vxPN3WTK/OIv5gxgmj2inHGGc6f90TW/to948LnqGtcD3CD9KsI55M |
||
47 | ubafwBYjcds1o9opZ0vYwwdIV80cOVZX1IUZFTbnyyKcXeFmKt49A52haCiy4iNx |
||
48 | cRK38tOCApjZySx/NzMDeaXuWe+1nd3pbgYa/I8MkECa5EyabhZJPJo9fGoSZIkl |
||
49 | Nnyq4TfAUSwl+KN/zjj3CXad1oDT7XDDgMJDUu/Vxs7h3CQI9zILSYcL9zwttbLn |
||
50 | JW1WcLlAAIaAfABtSZboznsStMnYto01wVknXKyERFs7FLHYqKQANIvRhFTptseh |
||
51 | owIDAQAB |
||
52 | -----END PUBLIC KEY----- |
||
53 | TEXT; |
||
54 | |||
55 | $this->jwtKey = new \ByJG\Util\JwtRsaKey($private, $public); |
||
56 | |||
57 | unset($_SERVER["HTTP_AUTHORIZATION"]); |
||
58 | $this->object = new JwtWrapper($this->server, $this->jwtKey); |
||
59 | } |
||
60 | |||
61 | |||
62 | /** |
||
63 | * @throws \ByJG\Util\JwtWrapperException |
||
64 | * @expectedException \Firebase\JWT\SignatureInvalidException |
||
65 | */ |
||
66 | public function testTokenWrongSecret() |
||
67 | { |
||
68 | $jwt = $this->object->createJwtData($this->dataToToken); |
||
69 | $token = $this->object->generateToken($jwt); |
||
70 | |||
71 | $private = <<<TEXT |
||
72 | -----BEGIN RSA PRIVATE KEY----- |
||
73 | MIIEpgIBAAKCAQEA9QTmRYW+S+9QeylWIz3cAMAjaIsJeO32/2IKYS54BBgd9xYp |
||
74 | ByUUabiua8YvKwv5lmWv2P/llzUQz5ppU1nkiZljeofkEmxdxKTaLhX5Cd4WZteC |
||
75 | Ef3SfAY3XMoCeNfXFqKt53SAULH2Ao0HzS+tXdru+dES1uD3jcIDMcD+vbQPhDos |
||
76 | XM96b95Wmi9O5OBbNmZQsBcqv4Ixd8KXokWuNm3Pyo1oa6nCEk08H2wx/26zQ/Jf |
||
77 | 3TsVJ+jYd0UgKsfQxtMU2tMIvJV8bzjS++HHhd/O/oW8go0AAOuSygoPWE0y88dA |
||
78 | H3bHiWlpRupT8ENCYeMpObpTRXsAFwUn49iofQIDAQABAoIBAQC7vFhP9q0bc6+f |
||
79 | 3slgUVqLvKykwrusS/EQNuerFLbitDPpibJABjpA0z/Z1k1310IS6bE2PMSG+iL6 |
||
80 | Xt7K/bqtb7kYPp0TPLMQJBwEadOaqu9RN1kzPd+UJhMvZp1ESGVGs7k5+jsDGYhc |
||
81 | 5gCPSDO3ETRAd+DOgitME9bsvWqyoI/frI/pFy7Ts4CxoyPgXE1uSZB0D7yPRa3u |
||
82 | IQ/VX0tBCPx84+81wMdaYGyhVKfa+K/rK9bMvt8xYz/OALRxHLoM157Rmi2HpB90 |
||
83 | 2H9N4OnW8NdzdQvAT2PAFYicjEbTszNQ3y8e/WQH+OvpfPW1UpH842D4z2swAfbN |
||
84 | CU+MLeVlAoGBAPxg6fnKxQpa1oNUgka+MdkJSLTxDUA8YA2Si8hbaVm8TluZJR4x |
||
85 | CR5c4ElQauSM1X72pqUAdu29wzW67Cy/mXhlCBHm03rnZVVVsmcf/yRLLTHhstmM |
||
86 | qaXvh08zSb11BUPLp9Alfrsdduzwz4CiKfiaRvFBdphvctzmlVZFszm/AoGBAPiI |
||
87 | 85FMtNi7ImzPbpKaJvjYppW6MdDIPd9rQLh0oWxxAZtodZm8MfmXEqAzWq0Nxq4C |
||
88 | UyCcp4s6hL1GaTi+R2LcWj0ZxRqYwykRVnptZL9CXzek3lngX5yxOvIV4fHkIIvf |
||
89 | DKviEQi6kzqLJqRKBiSxp/HmnO+ekF07F1lQ31TDAoGBANxBDBFW+A1oZ2uoFiX9 |
||
90 | GO3L32siMClOR5mwulM6C8Anyc7A4ZbuvoGEFq2FBDTAABbU1WyM8j3bbYD3x+Pp |
||
91 | tttOePN+mjPZvCL0LkU3tGiNPz0YNwkLbIcHevQQ05sHhHe9RZAvGOHd/gscwksF |
||
92 | u1Fd+unT8tdn9Dt69PucyqRrAoGBAJfCeIgWwK8+xayPlUMrofR9xmrTASwtuao9 |
||
93 | QY3gmdkvv/13cafoRNPVLehos0vMh68leEEHpz7bAsbYwdOGTOzPBMMegz7UXQcs |
||
94 | sROczNIE40OFBsj2uythBU9hkVA1LrJ6BrDGIASmeNRct8HF+a5aVOTfHqEqv5hO |
||
95 | RtmhCl4lAoGBANqI7xQvrP/OWJIZlHahnQbcrcBgsD6IM3kIKdR4s3R08ce20so/ |
||
96 | M1wHFjLKjlHJ6GqeP1y1RV7Ej4kK9vrEz5OYoJlQnjhU2LdREfVdhzuy9tgiW1EW |
||
97 | mSSFNrpqXwau5wBYZsR7aukXroAMp9ZyUhDjvMP0e4Nh+dajyBBQv5WE |
||
98 | -----END RSA PRIVATE KEY----- |
||
99 | TEXT; |
||
100 | $public = <<<TEXT |
||
101 | -----BEGIN PUBLIC KEY----- |
||
102 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9QTmRYW+S+9QeylWIz3c |
||
103 | AMAjaIsJeO32/2IKYS54BBgd9xYpByUUabiua8YvKwv5lmWv2P/llzUQz5ppU1nk |
||
104 | iZljeofkEmxdxKTaLhX5Cd4WZteCEf3SfAY3XMoCeNfXFqKt53SAULH2Ao0HzS+t |
||
105 | Xdru+dES1uD3jcIDMcD+vbQPhDosXM96b95Wmi9O5OBbNmZQsBcqv4Ixd8KXokWu |
||
106 | Nm3Pyo1oa6nCEk08H2wx/26zQ/Jf3TsVJ+jYd0UgKsfQxtMU2tMIvJV8bzjS++HH |
||
107 | hd/O/oW8go0AAOuSygoPWE0y88dAH3bHiWlpRupT8ENCYeMpObpTRXsAFwUn49io |
||
108 | fQIDAQAB |
||
109 | -----END PUBLIC KEY----- |
||
110 | TEXT; |
||
111 | |||
112 | $jwtWrapper = new JwtWrapper($this->server, \ByJG\Util\JwtRsaKey::getInstance($private, $public)); |
||
113 | |||
114 | $jwtWrapper->extractData($token); |
||
115 | } |
||
116 | } |
||
117 |