|
3 | 3 | import com.auth0.jwt.algorithms.Algorithm; |
4 | 4 | import com.auth0.jwt.interfaces.ECDSAKeyProvider; |
5 | 5 | import com.auth0.jwt.interfaces.RSAKeyProvider; |
6 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
7 | 6 | import com.fasterxml.jackson.databind.ObjectMapper; |
8 | 7 | import com.fasterxml.jackson.databind.node.ObjectNode; |
9 | 8 | import org.junit.Rule; |
@@ -974,7 +973,7 @@ public void withPayloadShouldSupportJsonValueWithNestedDataStructure() { |
974 | 973 | .sign(Algorithm.HMAC256("secret")); |
975 | 974 |
|
976 | 975 | assertThat(jwt, is(notNullValue())); |
977 | | - String[] parts = jwt.split("\\."); |
| 976 | + String[] parts = jwt.split("\\.") ; |
978 | 977 | String payloadJson = new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8); |
979 | 978 |
|
980 | 979 | assertThat(payloadJson, JsonMatcher.hasEntry("stringClaim", stringClaim)); |
@@ -1014,16 +1013,21 @@ public void shouldCreatePayloadWithNullForList() { |
1014 | 1013 |
|
1015 | 1014 | @Test |
1016 | 1015 | public void shouldPreserveInsertionOrder() throws Exception { |
1017 | | - List<String> headerInsertionOrder = new ArrayList<>(); |
| 1016 | + String taxonomyJson = "{\"class\": \"mammalia\", \"order\": \"carnivora\", \"family\": \"canidae\", \"genus\": \"vulpes\"}"; |
| 1017 | + List<String> taxonomyClaims = Arrays.asList("class", "order", "family", "genus"); |
| 1018 | + List<String> headerInsertionOrder = new ArrayList<>(taxonomyClaims); |
1018 | 1019 | Map<String, Object> header = new LinkedHashMap<>(); |
1019 | 1020 | for (int i = 0; i < 10; i++) { |
1020 | 1021 | String key = "h" + i; |
1021 | 1022 | header.put(key, "v" + 1); |
1022 | 1023 | headerInsertionOrder.add(key); |
1023 | 1024 | } |
1024 | 1025 |
|
1025 | | - List<String> payloadInsertionOrder = new ArrayList<>(); |
1026 | | - JWTCreator.Builder builder = JWTCreator.init().withHeader(header); |
| 1026 | + List<String> payloadInsertionOrder = new ArrayList<>(taxonomyClaims); |
| 1027 | + JWTCreator.Builder builder = JWTCreator.init() |
| 1028 | + .withHeader(taxonomyJson) |
| 1029 | + .withHeader(header) |
| 1030 | + .withPayload(taxonomyJson); |
1027 | 1031 | for (int i = 0; i < 10; i++) { |
1028 | 1032 | String name = "c" + i; |
1029 | 1033 | builder = builder.withClaim(name, "v" + i); |
|
0 commit comments