Search in sources :

Example 71 with Claim

use of com.auth0.android.jwt.Claim in project java-jwt by auth0.

the class JsonNodeClaimTest method shouldGetNullListIfNullValue.

@Test
public void shouldGetNullListIfNullValue() {
    JsonNode value = mapper.valueToTree(null);
    Claim claim = claimFromNode(value);
    assertThat(claim.asList(String.class), is(nullValue()));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 72 with Claim

use of com.auth0.android.jwt.Claim in project java-jwt by auth0.

the class JsonNodeClaimTest method shouldGetArrayValue.

@Test
public void shouldGetArrayValue() {
    JsonNode value = mapper.valueToTree(new String[] { "string1", "string2" });
    Claim claim = claimFromNode(value);
    assertThat(claim.asArray(String.class), is(notNullValue()));
    assertThat(claim.asArray(String.class), is(arrayContaining("string1", "string2")));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 73 with Claim

use of com.auth0.android.jwt.Claim in project java-jwt by auth0.

the class JsonNodeClaimTest method shouldReturnNonNullClaimWhenParsingStringValue.

@Test
public void shouldReturnNonNullClaimWhenParsingStringValue() {
    JsonNode value = mapper.valueToTree("");
    Claim claim = claimFromNode(value);
    assertThat(claim, is(notNullValue()));
    assertThat(claim, is(instanceOf(JsonNodeClaim.class)));
    assertThat(claim.isNull(), is(false));
    assertThat(claim.isMissing(), is(false));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 74 with Claim

use of com.auth0.android.jwt.Claim in project java-jwt by auth0.

the class JsonNodeClaimTest method shouldGetListValue.

@Test
public void shouldGetListValue() {
    JsonNode value = mapper.valueToTree(Arrays.asList("string1", "string2"));
    Claim claim = claimFromNode(value);
    assertThat(claim.asList(String.class), is(notNullValue()));
    assertThat(claim.asList(String.class), is(hasItems("string1", "string2")));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Example 75 with Claim

use of com.auth0.android.jwt.Claim in project java-jwt by auth0.

the class JsonNodeClaimTest method shouldReturnNonNullClaimWhenParsingList.

@Test
public void shouldReturnNonNullClaimWhenParsingList() {
    JsonNode value = mapper.valueToTree(new ArrayList<String>());
    Claim claim = claimFromNode(value);
    assertThat(claim, is(notNullValue()));
    assertThat(claim, is(instanceOf(JsonNodeClaim.class)));
    assertThat(claim.isNull(), is(false));
    assertThat(claim.isMissing(), is(false));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Claim(com.auth0.jwt.interfaces.Claim) Test(org.junit.Test)

Aggregations

Claim (com.auth0.jwt.interfaces.Claim)110 Test (org.junit.Test)67 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)62 JsonNode (com.fasterxml.jackson.databind.JsonNode)42 Algorithm (com.auth0.jwt.algorithms.Algorithm)24 Date (java.util.Date)24 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)21 RSAPublicKey (java.security.interfaces.RSAPublicKey)21 Test (org.junit.jupiter.api.Test)18 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)17 JWTVerifier (com.auth0.jwt.JWTVerifier)15 JwksTestKeySource (org.sdase.commons.server.auth.service.testsources.JwksTestKeySource)14 JsonObject (com.google.gson.JsonObject)10 HashMap (java.util.HashMap)9 UserPojo (com.auth0.jwt.UserPojo)8 IOException (java.io.IOException)8 Map (java.util.Map)8 TestingProcessManager (io.supertokens.test.TestingProcessManager)7 NullClaim (com.auth0.jwt.impl.NullClaim)5 JWT (com.auth0.jwt.JWT)4