Skip to content

Commit 645b40a

Browse files
committed
Added test cases to differentiate thrown exception
1 parent 208d7b6 commit 645b40a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/src/test/java/com/auth0/jwt/algorithms/ECDSAAlgorithmTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ public void emptyECDSA256SignatureShouldFailTokenVerification() throws Exception
13701370
@Test
13711371
public void signatureWithAllZerosShouldFail() throws Exception {
13721372
exception.expect(SignatureException.class);
1373+
exception.expectMessage("Invalid Signature: All Zeros.");
13731374

13741375
ECPublicKey pubKey = (ECPublicKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_256, "EC");
13751376

@@ -1381,6 +1382,7 @@ public void signatureWithAllZerosShouldFail() throws Exception {
13811382
@Test
13821383
public void signatureWithRZeroShouldFail() throws Exception {
13831384
exception.expect(SignatureException.class);
1385+
exception.expectMessage("Invalid Signature: All Zeros for R value.");
13841386

13851387
ECPublicKey publicKey = (ECPublicKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_256, "EC");
13861388
ECPrivateKey privateKey = (ECPrivateKey) readPrivateKeyFromFile(PRIVATE_KEY_FILE_256, "EC");
@@ -1406,6 +1408,7 @@ public void signatureWithRZeroShouldFail() throws Exception {
14061408
@Test
14071409
public void signatureWithSZeroShouldFail() throws Exception {
14081410
exception.expect(SignatureException.class);
1411+
exception.expectMessage("Invalid Signature: All Zeros for S value.");
14091412

14101413
ECPublicKey publicKey = (ECPublicKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_256, "EC");
14111414
ECPrivateKey privateKey = (ECPrivateKey) readPrivateKeyFromFile(PRIVATE_KEY_FILE_256, "EC");
@@ -1431,6 +1434,7 @@ public void signatureWithSZeroShouldFail() throws Exception {
14311434
@Test
14321435
public void signatureWithRValueNotLessThanOrderShouldFail() throws Exception {
14331436
exception.expect(SignatureException.class);
1437+
exception.expectMessage("The difference between R value and order should be greater than one.");
14341438

14351439
ECPublicKey publicKey = (ECPublicKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_256, "EC");
14361440
ECPrivateKey privateKey = (ECPrivateKey) readPrivateKeyFromFile(PRIVATE_KEY_FILE_256, "EC");
@@ -1448,6 +1452,7 @@ public void signatureWithRValueNotLessThanOrderShouldFail() throws Exception {
14481452
@Test
14491453
public void signatureWithSValueNotLessThanOrderShouldFail() throws Exception {
14501454
exception.expect(SignatureException.class);
1455+
exception.expectMessage("The difference between S value and order should be greater than one.");
14511456

14521457
ECPublicKey publicKey = (ECPublicKey) readPublicKeyFromFile(PUBLIC_KEY_FILE_256, "EC");
14531458
ECPrivateKey privateKey = (ECPrivateKey) readPrivateKeyFromFile(PRIVATE_KEY_FILE_256, "EC");

0 commit comments

Comments
 (0)