diff --git a/pom.xml b/pom.xml
index 42b4c56..bb8b105 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
21
21
- 7.21.7
+ 8.0.6
jar
diff --git a/src/test/java/app/common/HttpClient.java b/src/test/java/app/common/HttpClient.java
index d883e12..a9becc6 100644
--- a/src/test/java/app/common/HttpClient.java
+++ b/src/test/java/app/common/HttpClient.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import okhttp3.*;
+import java.util.Map;
import java.util.Objects;
public final class HttpClient {
@@ -65,11 +66,15 @@ private static String createErrorMessage(HttpMethod method, String url, int code
private HttpClient() {
}
- public static String get(String url, String bearerToken) throws Exception {
- Request request = buildRequest(HttpMethod.GET, url, null, bearerToken);
+ public static String get(String url, String bearerToken, Map additionalHeaders) throws Exception {
+ Request request = buildRequest(HttpMethod.GET, url, null, bearerToken, additionalHeaders);
return execute(request, HttpMethod.GET);
}
+ public static String get(String url, String bearerToken) throws Exception {
+ return get(url, bearerToken, null);
+ }
+
public static String get(String url) throws Exception {
return get(url, null);
}
@@ -89,6 +94,10 @@ public static String execute(Request request, HttpMethod method) throws Exceptio
}
private static Request buildRequest(HttpMethod method, String url, String body, String bearerToken) {
+ return buildRequest(method, url, body, bearerToken, null);
+ }
+
+ private static Request buildRequest(HttpMethod method, String url, String body, String bearerToken, Map additionalHeaders) {
Request.Builder requestBuilder = new Request.Builder()
.url(url);
@@ -96,6 +105,12 @@ private static Request buildRequest(HttpMethod method, String url, String body,
requestBuilder = requestBuilder.addHeader("Authorization", "Bearer " + bearerToken);
}
+ if (additionalHeaders != null) {
+ for (Map.Entry header : additionalHeaders.entrySet()) {
+ requestBuilder = requestBuilder.addHeader(header.getKey(), header.getValue());
+ }
+ }
+
return (switch (method) {
case GET -> requestBuilder.get();
case POST -> requestBuilder.post(RequestBody.create(body, JSON));
diff --git a/src/test/java/app/component/Core.java b/src/test/java/app/component/Core.java
index 6dfc222..83f09a9 100644
--- a/src/test/java/app/component/Core.java
+++ b/src/test/java/app/component/Core.java
@@ -5,6 +5,9 @@
import app.common.Mapper;
import com.fasterxml.jackson.databind.JsonNode;
+import java.util.HashMap;
+import java.util.Map;
+
public class Core extends App {
private static final String CORE_API_TOKEN = EnvUtil.getEnv("UID2_E2E_CORE_API_TOKEN");
private static final String OPTOUT_TO_CALL_CORE_API_TOKEN = EnvUtil.getEnv("UID2_E2E_OPTOUT_TO_CALL_CORE_API_TOKEN");
@@ -25,7 +28,13 @@ public JsonNode attest(String attestationRequest) throws Exception {
}
public JsonNode getWithCoreApiToken(String path) throws Exception {
- String response = HttpClient.get(getBaseUrl() + path, CORE_API_TOKEN);
+ return getWithCoreApiToken(path, "0.0.0");
+ }
+
+ public JsonNode getWithCoreApiToken(String path, String operatorVersion) throws Exception {
+ Map headers = new HashMap<>();
+ headers.put("X-UID2-AppVersion", "uid2-operator=" + operatorVersion);
+ String response = HttpClient.get(getBaseUrl() + path, CORE_API_TOKEN, headers);
return Mapper.OBJECT_MAPPER.readTree(response);
}
diff --git a/src/test/java/suite/core/CoreRefreshTest.java b/src/test/java/suite/core/CoreRefreshTest.java
index 9f14f2c..e7eb077 100644
--- a/src/test/java/suite/core/CoreRefreshTest.java
+++ b/src/test/java/suite/core/CoreRefreshTest.java
@@ -13,14 +13,27 @@
public class CoreRefreshTest {
@ParameterizedTest(name = "Refresh test - UrlPath: {1} - JsonPath: {2}")
- @MethodSource({"suite.core.TestData#refreshArgs"})
+ @MethodSource({"suite.core.TestData#refreshArgs", "suite.core.TestData#refreshArgsEncrypted"})
public void testLocationRefresh_Public_Success(Core core, String urlPath, String jsonPath) throws Exception {
- JsonNode response = core.getWithCoreApiToken(urlPath);
+ JsonNode response = core.getWithCoreApiToken(urlPath, "5.0.1");
assertAll("testLocationRefresh_Public_Success has version and location",
() -> assertNotNull(response),
() -> assertNotEquals("", response.at("/version").asText(), "Version was empty"),
- () -> assertNotEquals("", response.at("/" + jsonPath + "/location").asText(), "/" + jsonPath + "/location was empty"));
+ () -> assertNotEquals("", response.at("/" + jsonPath + "/location").asText(), "/" + jsonPath + "/location was empty"),
+ () -> assertFalse(response.at("/" + jsonPath + "/location").asText().contains("encrypted")));
+ }
+
+ @ParameterizedTest(name = "Refresh test - UrlPath: {1} - JsonPath: {2}")
+ @MethodSource({"suite.core.TestData#refreshArgsEncrypted"})
+ public void testLocationRefreshCloudEncryption_Public_Success(Core core, String urlPath, String jsonPath) throws Exception {
+ JsonNode response = core.getWithCoreApiToken(urlPath, "10000.0.1");
+
+ assertAll("testLocationRefresh_Public_Success has version and location",
+ () -> assertNotNull(response),
+ () -> assertNotEquals("", response.at("/version").asText(), "Version was empty"),
+ () -> assertNotEquals("", response.at("/" + jsonPath + "/location").asText(), "/" + jsonPath + "/location was empty"),
+ () -> assertTrue(response.at("/" + jsonPath + "/location").asText().contains("encrypted")));
}
@ParameterizedTest(name = "Refresh test - UrlPath: {1} - CollectionName: {2}")
@@ -42,6 +55,26 @@ public void testCollectionRefresh_Public_Success(Core core, String urlPath, Stri
}
}
+ @ParameterizedTest(name = "Refresh test - UrlPath: {1} - CollectionName: {2}")
+ @MethodSource({"suite.core.TestData#collectionEndpointArgs"})
+ public void testCollectionRefreshCloud_Encryption_Public_Success(Core core, String urlPath, String collectionName) throws Exception {
+ JsonNode response = core.getWithCoreApiToken(urlPath, "10000.0.1");
+
+ assertAll("testCollectionRefresh_Public_Success has version and collection",
+ () -> assertNotNull(response, "Response should not be null"),
+ () -> assertNotEquals("", response.at("/version").asText(), "Version was empty"),
+ () -> assertNotNull(response.at("/" + collectionName), "Collection should not be null")
+ );
+
+ ArrayNode nodes = (ArrayNode) response.at("/" + collectionName);
+ for (JsonNode node : nodes) {
+ assertTrue(JsonAssert.hasContentInFields(
+ node, List.of("/effective", "/expires", "/location", "/size")
+ ), "Collection node was missing expected content");
+ assertTrue(node.get("location").asText().contains("encrypted"));
+ }
+ }
+
@ParameterizedTest(name = "Refresh test - UrlPath: {1} - JsonPath: {2}")
@MethodSource({"suite.core.TestData#optOutRefreshArgs"})
public void testOptOut_LocationRefresh_Public_Success(Core core, String urlPath, String jsonPath) throws Exception {
diff --git a/src/test/java/suite/core/TestData.java b/src/test/java/suite/core/TestData.java
index 9a8604c..262ac3d 100644
--- a/src/test/java/suite/core/TestData.java
+++ b/src/test/java/suite/core/TestData.java
@@ -27,7 +27,19 @@ public static Set refreshArgs() {
for (Core core : cores) {
args.add(Arguments.of(core, "/key/acl/refresh", "keys_acl"));
args.add(Arguments.of(core, "/key/refresh", "keys"));
+ }
+
+ return args;
+ }
+
+ public static Set refreshArgsEncrypted() {
+ Set cores = AppsMap.getApps(Core.class);
+ Set args = new HashSet<>();
+ for (Core core : cores) {
+ args.add(Arguments.of(core, "/key/keyset/refresh", "keysets"));
+ args.add(Arguments.of(core, "/key/keyset-keys/refresh", "keyset_keys"));
args.add(Arguments.of(core, "/clients/refresh", "client_keys"));
+ args.add(Arguments.of(core, "/sites/refresh", "sites"));
args.add(Arguments.of(core, "/client_side_keypairs/refresh", "client_side_keypairs"));
}