Skip to content

Commit 22ed711

Browse files
committed
Add E2E test for remote config
1 parent 3d1617b commit 22ed711

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/test/java/app/component/Core.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,16 @@ public JsonNode getWithOptOutApiToken(String path) throws Exception {
4646
String response = HttpClient.get(getBaseUrl() + path, OPTOUT_API_KEY);
4747
return OBJECT_MAPPER.readTree(response);
4848
}
49+
50+
public JsonNode getOperatorConfig() throws Exception {
51+
return getOperatorConfig(false);
52+
}
53+
54+
public JsonNode getOperatorConfig(boolean encrypted) throws Exception {
55+
Map<String, String> headers = new HashMap<>();
56+
if (encrypted)
57+
headers.put("Encrypted", "true");
58+
String response = HttpClient.get(getBaseUrl() + "/operator/config", OPERATOR_API_KEY, headers);
59+
return OBJECT_MAPPER.readTree(response);
60+
}
4961
}

src/test/java/suite/core/CoreTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,46 @@ public void testAttest_ValidAttestationRequest(Core core) throws Exception {
7070
private static JsonObject getConfig() {
7171
return new JsonObject("{ \"aws_kms_jwt_signing_public_keys\": \"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmvwB41qI5Fe41PDbXqcX5uOvSvfKh8l9QV0O3M+NsB4lKqQEP0t1hfoiXTpOgKz1ArYxHsQ2LeXifX4uwEbYJFlpVM+tyQkTWQjBOw6fsLYK2Xk4X2ylNXUUf7x3SDiOVxyvTh3OZW9kqrDBN9JxSoraNLyfw0hhW0SHpfs699SehgbQ7QWep/gVlKRLIz0XAXaZNw24s79ORcQlrCE6YD0PgQmpI/dK5xMML82n6y3qcTlywlGaU7OGIMdD+CTXA3BcOkgXeqZTXNaX1u6jCTa1lvAczun6avp5VZ4TFiuPo+y4rJ3GU+14cyT5NckEcaTKSvd86UdwK5Id9tl3bQIDAQAB\"}");
7272
}
73+
74+
@ParameterizedTest(name = "/operator/config - {0}")
75+
@MethodSource({
76+
"suite.core.TestData#baseArgs"
77+
})
78+
public void testOpertorConfig_ValidRequest(Core core) throws Exception {
79+
JsonNode response = core.getOperatorConfig();
80+
81+
assertAll("testOpertorConfig_ValidRequest has valid response",
82+
() -> assertNotNull(response),
83+
() -> assertEquals(1, response.get("version").asInt()), // Changed to asInt()
84+
() -> {
85+
JsonNode runtimeConfig = response.get("runtime_config");
86+
assertNotNull(runtimeConfig, "runtime_config should not be null");
87+
assertEquals(3600, runtimeConfig.get("identity_token_expires_after_seconds").asInt(), "identity_token_expires_after_seconds");
88+
assertEquals(86400, runtimeConfig.get("refresh_token_expires_after_seconds").asInt(), "refresh_token_expires_after_seconds");
89+
assertEquals(900, runtimeConfig.get("refresh_identity_token_after_seconds").asInt(), "refresh_identity_token_after_seconds");
90+
assertEquals(2592000, runtimeConfig.get("sharing_token_expiry_seconds").asInt(), "sharing_token_expiry_seconds");
91+
}
92+
);
93+
}
94+
95+
@ParameterizedTest(name = "/operator/config - {0}")
96+
@MethodSource({
97+
"suite.core.TestData#baseArgs"
98+
})
99+
public void testOpertorConfig_ValidEncryptedRequest(Core core) throws Exception {
100+
JsonNode response = core.getOperatorConfig(true);
101+
102+
assertAll("testOpertorConfig_ValidEncryptedRequest has valid response",
103+
() -> assertNotNull(response),
104+
() -> assertEquals(1, response.get("version").asInt()), // Changed to asInt()
105+
() -> {
106+
JsonNode runtimeConfig = response.get("runtime_config");
107+
assertNotNull(runtimeConfig, "runtime_config should not be null");
108+
assertEquals(3600, runtimeConfig.get("identity_token_expires_after_seconds").asInt(), "identity_token_expires_after_seconds");
109+
assertEquals(86400, runtimeConfig.get("refresh_token_expires_after_seconds").asInt(), "refresh_token_expires_after_seconds");
110+
assertEquals(900, runtimeConfig.get("refresh_identity_token_after_seconds").asInt(), "refresh_identity_token_after_seconds");
111+
assertEquals(2592000, runtimeConfig.get("sharing_token_expiry_seconds").asInt(), "sharing_token_expiry_seconds");
112+
}
113+
);
114+
}
73115
}

0 commit comments

Comments
 (0)