Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test only change - remove unnecessary throws clause from tests #535

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/test/java/com/auth0/jwt/ConcurrentVerifyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class ConcurrentVerifyTest {
private static ExecutorService executor;

@BeforeClass
public static void beforeAll() throws Exception {
public static void beforeAll() {
executor = Executors.newFixedThreadPool(THREAD_COUNT);
}

@AfterClass
public static void afterAll() throws Exception {
public static void afterAll() {
executor.shutdown();
}

Expand All @@ -68,7 +68,7 @@ private static class VerifyTask implements Callable<DecodedJWT> {
}

@Override
public DecodedJWT call() throws Exception {
public DecodedJWT call() {
DecodedJWT jwt = null;
try {
jwt = verifier.verify(token);
Expand Down
76 changes: 38 additions & 38 deletions lib/src/test/java/com/auth0/jwt/JWTCreatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class JWTCreatorTest {
public ExpectedException exception = ExpectedException.none();

@Test
public void shouldThrowWhenRequestingSignWithoutAlgorithm() throws Exception {
public void shouldThrowWhenRequestingSignWithoutAlgorithm() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("The Algorithm cannot be null");
JWTCreator.init()
Expand All @@ -40,7 +40,7 @@ public void shouldThrowWhenRequestingSignWithoutAlgorithm() throws Exception {

@SuppressWarnings("Convert2Diamond")
@Test
public void shouldAddHeaderClaim() throws Exception {
public void shouldAddHeaderClaim() {
Map<String, Object> header = new HashMap<String, Object>();
header.put("asd", 123);
String signed = JWTCreator.init()
Expand All @@ -54,7 +54,7 @@ public void shouldAddHeaderClaim() throws Exception {
}

@Test
public void shouldReturnBuilderIfNullMapIsProvided() throws Exception {
public void shouldReturnBuilderIfNullMapIsProvided() {
String signed = JWTCreator.init()
.withHeader(null)
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -63,7 +63,7 @@ public void shouldReturnBuilderIfNullMapIsProvided() throws Exception {
}

@Test
public void shouldOverwriteExistingHeaderIfHeaderMapContainsTheSameKey() throws Exception {
public void shouldOverwriteExistingHeaderIfHeaderMapContainsTheSameKey() {
Map<String, Object> header = new HashMap<String, Object>();
header.put(PublicClaims.KEY_ID, "xyz");

Expand All @@ -79,7 +79,7 @@ public void shouldOverwriteExistingHeaderIfHeaderMapContainsTheSameKey() throws
}

@Test
public void shouldOverwriteExistingHeadersWhenSettingSameHeaderKey() throws Exception {
public void shouldOverwriteExistingHeadersWhenSettingSameHeaderKey() {
Map<String, Object> header = new HashMap<String, Object>();
header.put(PublicClaims.KEY_ID, "xyz");

Expand All @@ -95,7 +95,7 @@ public void shouldOverwriteExistingHeadersWhenSettingSameHeaderKey() throws Exce
}

@Test
public void shouldRemoveHeaderIfTheValueIsNull() throws Exception {
public void shouldRemoveHeaderIfTheValueIsNull() {
Map<String, Object> header = new HashMap<String, Object>();
header.put(PublicClaims.KEY_ID, null);
header.put("test2", "isSet");
Expand All @@ -113,7 +113,7 @@ public void shouldRemoveHeaderIfTheValueIsNull() throws Exception {
}

@Test
public void shouldAddKeyId() throws Exception {
public void shouldAddKeyId() {
String signed = JWTCreator.init()
.withKeyId("56a8bd44da435300010000015f5ed")
.sign(Algorithm.HMAC256("secret"));
Expand Down Expand Up @@ -224,7 +224,7 @@ public void shouldNotOverwriteKeyIdIfAddedFromECDSAAlgorithms() throws Exception
}

@Test
public void shouldAddIssuer() throws Exception {
public void shouldAddIssuer() {
String signed = JWTCreator.init()
.withIssuer("auth0")
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -234,7 +234,7 @@ public void shouldAddIssuer() throws Exception {
}

@Test
public void shouldAddSubject() throws Exception {
public void shouldAddSubject() {
String signed = JWTCreator.init()
.withSubject("1234567890")
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -244,7 +244,7 @@ public void shouldAddSubject() throws Exception {
}

@Test
public void shouldAddAudience() throws Exception {
public void shouldAddAudience() {
String signed = JWTCreator.init()
.withAudience("Mark")
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -262,7 +262,7 @@ public void shouldAddAudience() throws Exception {
}

@Test
public void shouldAddExpiresAt() throws Exception {
public void shouldAddExpiresAt() {
String signed = JWTCreator.init()
.withExpiresAt(new Date(1477592000))
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -272,7 +272,7 @@ public void shouldAddExpiresAt() throws Exception {
}

@Test
public void shouldAddNotBefore() throws Exception {
public void shouldAddNotBefore() {
String signed = JWTCreator.init()
.withNotBefore(new Date(1477592000))
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -282,7 +282,7 @@ public void shouldAddNotBefore() throws Exception {
}

@Test
public void shouldAddIssuedAt() throws Exception {
public void shouldAddIssuedAt() {
String signed = JWTCreator.init()
.withIssuedAt(new Date(1477592000))
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -292,7 +292,7 @@ public void shouldAddIssuedAt() throws Exception {
}

@Test
public void shouldAddJWTId() throws Exception {
public void shouldAddJWTId() {
String signed = JWTCreator.init()
.withJWTId("jwt_id_123")
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -302,7 +302,7 @@ public void shouldAddJWTId() throws Exception {
}

@Test
public void shouldRemoveClaimWhenPassingNull() throws Exception {
public void shouldRemoveClaimWhenPassingNull() {
String signed = JWTCreator.init()
.withIssuer("iss")
.withIssuer(null)
Expand All @@ -313,7 +313,7 @@ public void shouldRemoveClaimWhenPassingNull() throws Exception {
}

@Test
public void shouldSetCorrectAlgorithmInTheHeader() throws Exception {
public void shouldSetCorrectAlgorithmInTheHeader() {
String signed = JWTCreator.init()
.sign(Algorithm.HMAC256("secret"));

Expand All @@ -324,7 +324,7 @@ public void shouldSetCorrectAlgorithmInTheHeader() throws Exception {
}

@Test
public void shouldSetDefaultTypeInTheHeader() throws Exception {
public void shouldSetDefaultTypeInTheHeader() {
String signed = JWTCreator.init()
.sign(Algorithm.HMAC256("secret"));

Expand All @@ -335,7 +335,7 @@ public void shouldSetDefaultTypeInTheHeader() throws Exception {
}

@Test
public void shouldSetCustomTypeInTheHeader() throws Exception {
public void shouldSetCustomTypeInTheHeader() {
Map<String, Object> header = Collections.singletonMap("typ", "passport");
String signed = JWTCreator.init()
.withHeader(header)
Expand All @@ -348,23 +348,23 @@ public void shouldSetCustomTypeInTheHeader() throws Exception {
}

@Test
public void shouldSetEmptySignatureIfAlgorithmIsNone() throws Exception {
public void shouldSetEmptySignatureIfAlgorithmIsNone() {
String signed = JWTCreator.init()
.sign(Algorithm.none());
assertThat(signed, is(notNullValue()));
assertThat(TokenUtils.splitToken(signed)[2], is(""));
}

@Test
public void shouldThrowOnNullCustomClaimName() throws Exception {
public void shouldThrowOnNullCustomClaimName() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("The Custom Claim's name can't be null.");
JWTCreator.init()
.withClaim(null, "value");
}

@Test
public void shouldAcceptCustomClaimOfTypeString() throws Exception {
public void shouldAcceptCustomClaimOfTypeString() {
String jwt = JWTCreator.init()
.withClaim("name", "value")
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -375,7 +375,7 @@ public void shouldAcceptCustomClaimOfTypeString() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeInteger() throws Exception {
public void shouldAcceptCustomClaimOfTypeInteger() {
String jwt = JWTCreator.init()
.withClaim("name", 123)
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -386,7 +386,7 @@ public void shouldAcceptCustomClaimOfTypeInteger() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeLong() throws Exception {
public void shouldAcceptCustomClaimOfTypeLong() {
String jwt = JWTCreator.init()
.withClaim("name", Long.MAX_VALUE)
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -397,7 +397,7 @@ public void shouldAcceptCustomClaimOfTypeLong() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeDouble() throws Exception {
public void shouldAcceptCustomClaimOfTypeDouble() {
String jwt = JWTCreator.init()
.withClaim("name", 23.45)
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -408,7 +408,7 @@ public void shouldAcceptCustomClaimOfTypeDouble() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeBoolean() throws Exception {
public void shouldAcceptCustomClaimOfTypeBoolean() {
String jwt = JWTCreator.init()
.withClaim("name", true)
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -419,7 +419,7 @@ public void shouldAcceptCustomClaimOfTypeBoolean() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeDate() throws Exception {
public void shouldAcceptCustomClaimOfTypeDate() {
Date date = new Date(1478891521000L);
String jwt = JWTCreator.init()
.withClaim("name", date)
Expand All @@ -431,7 +431,7 @@ public void shouldAcceptCustomClaimOfTypeDate() throws Exception {
}

@Test
public void shouldAcceptCustomArrayClaimOfTypeString() throws Exception {
public void shouldAcceptCustomArrayClaimOfTypeString() {
String jwt = JWTCreator.init()
.withArrayClaim("name", new String[]{"text", "123", "true"})
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -442,7 +442,7 @@ public void shouldAcceptCustomArrayClaimOfTypeString() throws Exception {
}

@Test
public void shouldAcceptCustomArrayClaimOfTypeInteger() throws Exception {
public void shouldAcceptCustomArrayClaimOfTypeInteger() {
String jwt = JWTCreator.init()
.withArrayClaim("name", new Integer[]{1, 2, 3})
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -453,7 +453,7 @@ public void shouldAcceptCustomArrayClaimOfTypeInteger() throws Exception {
}

@Test
public void shouldAcceptCustomArrayClaimOfTypeLong() throws Exception {
public void shouldAcceptCustomArrayClaimOfTypeLong() {
String jwt = JWTCreator.init()
.withArrayClaim("name", new Long[]{1L, 2L, 3L})
.sign(Algorithm.HMAC256("secret"));
Expand All @@ -464,7 +464,7 @@ public void shouldAcceptCustomArrayClaimOfTypeLong() throws Exception {
}

@Test
public void shouldAcceptCustomClaimOfTypeMap() throws Exception {
public void shouldAcceptCustomClaimOfTypeMap() {
Map<String, Object> data = new HashMap<>();
data.put("test1", "abc");
data.put("test2", "def");
Expand All @@ -478,7 +478,7 @@ public void shouldAcceptCustomClaimOfTypeMap() throws Exception {
}

@Test
public void shouldRefuseCustomClaimOfTypeUserPojo() throws Exception {
public void shouldRefuseCustomClaimOfTypeUserPojo() {
Map<String, Object> data = new HashMap<>();
data.put("test1", new UserPojo("Michael", 255));

Expand Down Expand Up @@ -598,7 +598,7 @@ public void shouldAcceptCustomListClaimOfBasicObjectTypes() throws Exception {
}

@Test
public void shouldAcceptCustomClaimForNullListItem() throws Exception {
public void shouldAcceptCustomClaimForNullListItem() {
Map<String, Object> data = new HashMap<>();
data.put("test1", Arrays.asList("a", null, "c"));

Expand Down Expand Up @@ -642,7 +642,7 @@ public void shouldAcceptCustomClaimWithNullListAndRemoveClaim() throws Exception
}

@Test
public void shouldRefuseCustomClaimForNullMapValue() throws Exception {
public void shouldRefuseCustomClaimForNullMapValue() {
Map<String, Object> data = new HashMap<>();
data.put("subKey", null);

Expand All @@ -654,7 +654,7 @@ public void shouldRefuseCustomClaimForNullMapValue() throws Exception {
}

@Test
public void shouldRefuseCustomClaimForNullMapKey() throws Exception {
public void shouldRefuseCustomClaimForNullMapKey() {
Map<String, Object> data = new HashMap<>();
data.put(null, "subValue");

Expand All @@ -667,7 +667,7 @@ public void shouldRefuseCustomClaimForNullMapKey() throws Exception {

@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void shouldRefuseCustomMapClaimForNonStringKey() throws Exception {
public void shouldRefuseCustomMapClaimForNonStringKey() {
Map data = new HashMap<>();
data.put(new Object(), "value");

Expand All @@ -679,7 +679,7 @@ public void shouldRefuseCustomMapClaimForNonStringKey() throws Exception {
}

@Test
public void shouldRefuseCustomListClaimForUnknownListElement() throws Exception {
public void shouldRefuseCustomListClaimForUnknownListElement() {
List<Object> list = Arrays.asList(new UserPojo("Michael", 255));

exception.expect(IllegalArgumentException.class);
Expand All @@ -690,7 +690,7 @@ public void shouldRefuseCustomListClaimForUnknownListElement() throws Exception
}

@Test
public void shouldRefuseCustomListClaimForUnknownListElementWrappedInAMap() throws Exception {
public void shouldRefuseCustomListClaimForUnknownListElementWrappedInAMap() {
List<Object> list = Arrays.asList(new UserPojo("Michael", 255));

Map<String, Object> data = new HashMap<>();
Expand All @@ -704,7 +704,7 @@ public void shouldRefuseCustomListClaimForUnknownListElementWrappedInAMap() thro
}

@Test
public void shouldRefuseCustomListClaimForUnknownArrayType() throws Exception {
public void shouldRefuseCustomListClaimForUnknownArrayType() {
List<Object> list = new ArrayList<>();
list.add(new Object[]{"test"});

Expand Down
Loading