mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(appconfigdata): honor requested poll interval (#3092)
This commit is contained in:
1 parent
64f06e090f
commit
8686651de1
6 files changed
+133
-14
No files matched your search
+69
-3
@@ -182,8 +182,8 @@ class AppConfigIntegrationTest {
|
||||
}
|
||||
|
||||
@Test @Order(12)
|
||||
@DisplayName("Poll interval: requested 60s but emulator returns 15s (known deviation from AWS)")
|
||||
void requiredMinimumPollIntervalIsStoredButNotEnforced() {
|
||||
@DisplayName("Poll interval: requested minimum is returned to the client")
|
||||
void requiredMinimumPollIntervalIsReturned() {
|
||||
intervalToken = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 60}")
|
||||
@@ -199,7 +199,7 @@ class AppConfigIntegrationTest {
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Next-Poll-Configuration-Token", notNullValue())
|
||||
.header("Next-Poll-Interval-In-Seconds", equalTo("15"))
|
||||
.header("Next-Poll-Interval-In-Seconds", equalTo("60"))
|
||||
.extract().header("Next-Poll-Configuration-Token");
|
||||
|
||||
given()
|
||||
@@ -210,6 +210,72 @@ class AppConfigIntegrationTest {
|
||||
.header("Next-Poll-Configuration-Token", notNullValue());
|
||||
}
|
||||
|
||||
@Test @Order(32)
|
||||
void requiredMinimumPollIntervalMustBeWithinAwsLimits() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 14}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test @Order(33)
|
||||
void requiredMinimumPollIntervalAcceptsAwsUpperBoundary() {
|
||||
String token = startSessionWithInterval(86400);
|
||||
|
||||
given()
|
||||
.queryParam("configuration_token", token)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Next-Poll-Interval-In-Seconds", equalTo("86400"));
|
||||
}
|
||||
|
||||
@Test @Order(34)
|
||||
void requiredMinimumPollIntervalRejectsValuesAboveAwsMaximum() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 86401}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test @Order(35)
|
||||
void requiredMinimumPollIntervalRejectsFractionalValues() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 60.5}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test @Order(36)
|
||||
void requiredMinimumPollIntervalRejectsOversizedValues() {
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 4294967296}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
private String startSessionWithInterval(int interval) {
|
||||
return given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": " + interval + "}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.extract().path("InitialConfigurationToken");
|
||||
}
|
||||
|
||||
// ──────────────────────────── Hosted Configuration Version list ────────────────────────────
|
||||
|
||||
@Test @Order(13)
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package io.github.hectorvent.floci.services.appconfig;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.services.appconfig.model.ConfigurationSession;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class ConfigurationSessionTest {
|
||||
@Test
|
||||
void legacySessionWithoutPollIntervalUsesAwsDefault() throws Exception {
|
||||
ConfigurationSession session = new ObjectMapper().readValue(
|
||||
"{\"id\":\"legacy\",\"applicationId\":\"app\",\"environmentId\":\"env\",\"configurationProfileId\":\"profile\"}",
|
||||
ConfigurationSession.class);
|
||||
|
||||
assertEquals(15, session.getRequiredMinimumPollIntervalInSeconds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidPersistedPollIntervalUsesAwsDefault() {
|
||||
assertEquals(15, AppConfigDataService.normalizePollInterval(0));
|
||||
assertEquals(15, AppConfigDataService.normalizePollInterval(86401));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user