diff --git a/src/main/java/com/uid2/admin/model/CloudEncryptionKeySummary.java b/src/main/java/com/uid2/admin/model/CloudEncryptionKeySummary.java index 89ef734d..a3c987b5 100644 --- a/src/main/java/com/uid2/admin/model/CloudEncryptionKeySummary.java +++ b/src/main/java/com/uid2/admin/model/CloudEncryptionKeySummary.java @@ -3,13 +3,24 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.uid2.shared.model.CloudEncryptionKey; +import java.time.Instant; + public record CloudEncryptionKeySummary( - @JsonProperty int id, - @JsonProperty int siteId, - @JsonProperty long activates, - @JsonProperty long created + @JsonProperty int id, + @JsonProperty int siteId, + @JsonProperty String activates, + @JsonProperty String created ) { public static CloudEncryptionKeySummary fromFullKey(CloudEncryptionKey key) { - return new CloudEncryptionKeySummary(key.getId(), key.getSiteId(), key.getActivates(), key.getCreated()); + return new CloudEncryptionKeySummary( + key.getId(), + key.getSiteId(), + toIsoTimestamp(key.getActivates()), + toIsoTimestamp(key.getCreated()) + ); + } + + private static String toIsoTimestamp(Long epochSeconds) { + return Instant.ofEpochSecond(epochSeconds).toString(); } } diff --git a/src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java b/src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java index 0adb109e..29ec58de 100644 --- a/src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java +++ b/src/test/java/com/uid2/admin/vertx/CloudEncryptionKeyServiceTest.java @@ -53,14 +53,19 @@ public void testList_noAccess(Vertx vertx, VertxTestContext testContext) { public void testList_withKeys(Vertx vertx, VertxTestContext testContext) { fakeAuth(Role.MAINTAINER); - CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, 100, 100, "secret 1"); - CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, 200, 100, "secret 2"); + var date1EpochSeconds = 100; + var date2EpochSeconds = 200; + var date1Iso = "1970-01-01T00:01:40Z"; + var date2Iso = "1970-01-01T00:03:20Z"; + + CloudEncryptionKey key1 = new CloudEncryptionKey(1, 2, date1EpochSeconds, date1EpochSeconds, "secret 1"); + CloudEncryptionKey key2 = new CloudEncryptionKey(2, 2, date2EpochSeconds, date1EpochSeconds, "secret 2"); setCloudEncryptionKeys(key1, key2); var expected = new CloudEncryptionKeyListResponse(List.of( - new CloudEncryptionKeySummary(1, 2, 100, 100), - new CloudEncryptionKeySummary(2, 2, 200, 100) + new CloudEncryptionKeySummary(1, 2, date1Iso, date1Iso), + new CloudEncryptionKeySummary(2, 2, date2Iso, date1Iso) )); get(vertx, testContext, Endpoints.CLOUD_ENCRYPTION_KEY_LIST, response -> {