Skip to content

Commit ee1fcca

Browse files
authored
Merge pull request #394 from IABTechLab/aul-UID2-5175-human-readable-dates-in-encryption-key-list
Using human readable dates
2 parents 0c1a13f + 46e0503 commit ee1fcca

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/main/java/com/uid2/admin/model/CloudEncryptionKeySummary.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.uid2.shared.model.CloudEncryptionKey;
55

6+
import java.time.Instant;
7+
68
public record CloudEncryptionKeySummary(
7-
@JsonProperty int id,
8-
@JsonProperty int siteId,
9-
@JsonProperty long activates,
10-
@JsonProperty long created
9+
@JsonProperty int id,
10+
@JsonProperty int siteId,
11+
@JsonProperty String activates,
12+
@JsonProperty String created
1113
) {
1214
public static CloudEncryptionKeySummary fromFullKey(CloudEncryptionKey key) {
13-
return new CloudEncryptionKeySummary(key.getId(), key.getSiteId(), key.getActivates(), key.getCreated());
15+
return new CloudEncryptionKeySummary(
16+
key.getId(),
17+
key.getSiteId(),
18+
toIsoTimestamp(key.getActivates()),
19+
toIsoTimestamp(key.getCreated())
20+
);
21+
}
22+
23+
private static String toIsoTimestamp(Long epochSeconds) {
24+
return Instant.ofEpochSecond(epochSeconds).toString();
1425
}
1526
}

src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@ public void testList_noAccess(Vertx vertx, VertxTestContext testContext) {
5353
public void testList_withKeys(Vertx vertx, VertxTestContext testContext) {
5454
fakeAuth(Role.MAINTAINER);
5555

56-
CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, 100, 100, "secret 1");
57-
CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, 200, 100, "secret 2");
56+
var date1EpochSeconds = 100;
57+
var date2EpochSeconds = 200;
58+
var date1Iso = "1970-01-01T00:01:40Z";
59+
var date2Iso = "1970-01-01T00:03:20Z";
60+
61+
CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, date1EpochSeconds, date1EpochSeconds, "secret 1");
62+
CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, date2EpochSeconds, date1EpochSeconds, "secret 2");
5863

5964
setCloudEncryptionKeys(key1, key2);
6065

6166
var expected = new CloudEncryptionKeyListResponse(List.of(
62-
new CloudEncryptionKeySummary(1, 2, 100, 100),
63-
new CloudEncryptionKeySummary(2, 2, 200, 100)
67+
new CloudEncryptionKeySummary(1, 2, date1Iso, date1Iso),
68+
new CloudEncryptionKeySummary(2, 2, date2Iso, date1Iso)
6469
));
6570

6671
get(vertx, testContext, Endpoints.CLOUD_ENCRYPTION_KEY_LIST, response -> {

0 commit comments

Comments
 (0)