Skip to content

Commit 5540996

Browse files
authored
Merge branch 'master' into JSON_UNESCAPED_SLASHES
2 parents 66c712d + 474047d commit 5540996

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/JWK.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Firebase\JWT;
44

55
use DomainException;
6+
use InvalidArgumentException;
67
use UnexpectedValueException;
78

89
/**

src/JWT.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Firebase\JWT;
44

5-
use \DomainException;
6-
use \InvalidArgumentException;
7-
use \UnexpectedValueException;
8-
use \DateTime;
5+
use DomainException;
6+
use InvalidArgumentException;
7+
use UnexpectedValueException;
8+
use DateTime;
99

1010
/**
1111
* JSON Web Token implementation, based on this spec:
@@ -62,6 +62,7 @@ class JWT
6262
*
6363
* @return object The JWT's payload as a PHP object
6464
*
65+
* @throws InvalidArgumentException Provided JWT was empty
6566
* @throws UnexpectedValueException Provided JWT was invalid
6667
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
6768
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'

tests/JWKTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ public function testParseJwkKeySet()
4343
self::$keys = $keys;
4444
}
4545

46+
public function testParseJwkKey_empty()
47+
{
48+
$this->setExpectedException('InvalidArgumentException', 'JWK must not be empty');
49+
50+
JWK::parseKeySet(array('keys' => array(array())));
51+
}
52+
53+
public function testParseJwkKeySet_empty()
54+
{
55+
$this->setExpectedException('InvalidArgumentException', 'JWK Set did not contain any keys');
56+
57+
JWK::parseKeySet(array('keys' => array()));
58+
}
59+
4660
/**
4761
* @depends testParseJwkKeySet
4862
*/

0 commit comments

Comments
 (0)