Skip to content

Commit

Permalink
Set locale when formatting TimeClaim.
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphFlynn committed Aug 5, 2024
1 parent e1f7f1a commit 049d65b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.json.JSONObject;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
Expand All @@ -31,9 +30,10 @@
import static java.time.ZoneOffset.UTC;
import static java.util.Arrays.stream;
import static java.util.Collections.emptyList;
import static java.util.Locale.US;

public record TimeClaim(TimeClaimType type, String data, Long value) {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("EEE MMM dd yyyy HH:mm:ss").withZone(ZoneId.from(UTC));
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("EEE MMM dd yyyy HH:mm:ss").withLocale(US);

public String date() {
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package com.blackberry.jwteditor.presenter;

import com.blackberry.jwteditor.model.jose.TimeClaim;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -36,17 +35,16 @@ static Stream<Arguments> data() {
return Stream.of(
arguments(new TimeClaim(ISSUED_AT_TIME, "isogeny", null), "Issued At - invalid value: isogeny", true),
arguments(new TimeClaim(ISSUED_AT_TIME, "1516239022", 1516239022L), "Issued At - Thu Jan 18 2018 01:30:22", false),
arguments(new TimeClaim(ISSUED_AT_TIME, "1516239022", 2516239022L), "Issued At - Sun Sept 26 2049 03:17:02", true),
arguments(new TimeClaim(ISSUED_AT_TIME, "1516239022", 2516239022L), "Issued At - Sun Sep 26 2049 03:17:02", true),
arguments(new TimeClaim(NOT_BEFORE_TIME, "isogeny", null), "Not Before - invalid value: isogeny", true),
arguments(new TimeClaim(NOT_BEFORE_TIME, "1516239022", 1516239022L), "Not Before - Thu Jan 18 2018 01:30:22", false),
arguments(new TimeClaim(NOT_BEFORE_TIME, "1516239022", 2516239022L), "Not Before - Sun Sept 26 2049 03:17:02", true),
arguments(new TimeClaim(NOT_BEFORE_TIME, "1516239022", 2516239022L), "Not Before - Sun Sep 26 2049 03:17:02", true),
arguments(new TimeClaim(EXPIRATION_TIME, "isogeny", null), "Expiration Time - invalid value: isogeny", true),
arguments(new TimeClaim(EXPIRATION_TIME, "1516239022", 1516239022L), "Expiration Time - Thu Jan 18 2018 01:30:22", true),
arguments(new TimeClaim(EXPIRATION_TIME, "1516239022", 2516239022L), "Expiration Time - Sun Sept 26 2049 03:17:02", false)
arguments(new TimeClaim(EXPIRATION_TIME, "1516239022", 2516239022L), "Expiration Time - Sun Sep 26 2049 03:17:02", false)
);
}

@Disabled
@MethodSource("data")
@ParameterizedTest
void testInformationFromTimeClaims(TimeClaim timeClaim, String expectedText, boolean expectedIsWarning) {
Expand Down

0 comments on commit 049d65b

Please sign in to comment.