mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(appconfig): edge case coverage for polling, deployments, empty configs (#365)
* test(appconfig): add edge case coverage for polling, deployments, empty configs Extends both AppConfigIntegrationTest (internal Quarkus) and the compat-suite AppConfigTest with five additional cases: - stale configuration token is rejected with BadRequestException once a newer next-poll token has been issued - syntactically invalid configuration token is rejected - updated deployment is visible when polling with the next-poll token (create v2 hosted config, start deployment, confirm response body flips to v2 payload and Version-Label header updates) - RequiredMinimumPollIntervalInSeconds is accepted in the start configuration session request but NOT enforced on subsequent polls (pins current Floci behavior per PLAN_FLOCI_2 Phase 1 decision: storing-but-not-enforcing is the behavior under test, enforcement would be a separate feature PR) - empty configuration profile (no hosted config version, no deployment) returns an empty octet-stream body with empty Version-Label No changes to AppConfigDataService or any main sources; this is test-only expansion over existing scaffolding. * fix(test): address review findings for AppConfig edge case tests Document poll-interval 15s as known emulator deviation (AWS returns the requested value, emulator always returns 15). Add explicit nextPollIntervalInSeconds() assertions to the SDK compat test. Clarify null vs "" Version-Label difference between SDK and HTTP transport layers.
This commit is contained in:
2 files changed
+254
-2
No files matched your search
+135
-2
@@ -4,6 +4,7 @@ import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.http.ContentType;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -21,6 +22,11 @@ class AppConfigIntegrationTest {
|
||||
private static String profileId;
|
||||
private static String strategyId;
|
||||
private static String configToken;
|
||||
private static String nextConfigToken;
|
||||
private static String intervalToken;
|
||||
private static String emptyAppId;
|
||||
private static String emptyEnvId;
|
||||
private static String emptyProfileId;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
@@ -112,7 +118,7 @@ class AppConfigIntegrationTest {
|
||||
|
||||
@Test @Order(8)
|
||||
void getLatestConfiguration() {
|
||||
given()
|
||||
nextConfigToken = given()
|
||||
.queryParam("configuration_token", configToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
@@ -120,6 +126,133 @@ class AppConfigIntegrationTest {
|
||||
.header("Content-Type", startsWith("application/json"))
|
||||
.header("Version-Label", equalTo("1"))
|
||||
.header("Next-Poll-Configuration-Token", notNullValue())
|
||||
.body("foo", equalTo("bar"));
|
||||
.header("Next-Poll-Interval-In-Seconds", equalTo("15"))
|
||||
.body("foo", equalTo("bar"))
|
||||
.extract().header("Next-Poll-Configuration-Token");
|
||||
}
|
||||
|
||||
@Test @Order(9)
|
||||
void staleConfigurationTokenIsRejected() {
|
||||
given()
|
||||
.queryParam("configuration_token", configToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("Invalid configuration token"));
|
||||
}
|
||||
|
||||
@Test @Order(10)
|
||||
void invalidConfigurationTokenIsRejected() {
|
||||
given()
|
||||
.queryParam("configuration_token", "not-a-real-token")
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("Invalid configuration token"));
|
||||
}
|
||||
|
||||
@Test @Order(11)
|
||||
void updatedDeploymentIsVisibleOnNextPollToken() {
|
||||
given()
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Description", "v2")
|
||||
.body("{\"foo\": \"baz\"}".getBytes())
|
||||
.when().post("/applications/" + appId + "/configurationprofiles/" + profileId + "/hostedconfigurationversions")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.header("Version-Number", equalTo("2"));
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ConfigurationProfileId\": \"" + profileId + "\", \"ConfigurationVersion\": \"2\", \"DeploymentStrategyId\": \"" + strategyId + "\"}")
|
||||
.when().post("/applications/" + appId + "/environments/" + envId + "/deployments")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("State", equalTo("COMPLETE"));
|
||||
|
||||
given()
|
||||
.queryParam("configuration_token", nextConfigToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Version-Label", equalTo("2"))
|
||||
.body("foo", equalTo("baz"));
|
||||
}
|
||||
|
||||
@Test @Order(12)
|
||||
@DisplayName("Poll interval: requested 60s but emulator returns 15s (known deviation from AWS)")
|
||||
void requiredMinimumPollIntervalIsStoredButNotEnforced() {
|
||||
intervalToken = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\", \"RequiredMinimumPollIntervalInSeconds\": 60}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("InitialConfigurationToken", notNullValue())
|
||||
.extract().path("InitialConfigurationToken");
|
||||
|
||||
String immediateNextToken = given()
|
||||
.queryParam("configuration_token", intervalToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Next-Poll-Configuration-Token", notNullValue())
|
||||
.header("Next-Poll-Interval-In-Seconds", equalTo("15"))
|
||||
.extract().header("Next-Poll-Configuration-Token");
|
||||
|
||||
given()
|
||||
.queryParam("configuration_token", immediateNextToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Next-Poll-Configuration-Token", notNullValue());
|
||||
}
|
||||
|
||||
@Test @Order(13)
|
||||
void emptyConfigurationReturnsEmptyPayload() {
|
||||
emptyAppId = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"Name\": \"empty-app\"}")
|
||||
.when().post("/applications")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.extract().path("Id");
|
||||
|
||||
emptyEnvId = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"Name\": \"empty-env\"}")
|
||||
.when().post("/applications/" + emptyAppId + "/environments")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.extract().path("Id");
|
||||
|
||||
emptyProfileId = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"Name\": \"empty-profile\", \"LocationUri\": \"hosted\", \"Type\": \"AWS.Freeform\"}")
|
||||
.when().post("/applications/" + emptyAppId + "/configurationprofiles")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.extract().path("Id");
|
||||
|
||||
String emptyToken = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"ApplicationIdentifier\": \"" + emptyAppId + "\", \"EnvironmentIdentifier\": \"" + emptyEnvId + "\", \"ConfigurationProfileIdentifier\": \"" + emptyProfileId + "\"}")
|
||||
.when().post("/configurationsessions")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.extract().path("InitialConfigurationToken");
|
||||
|
||||
given()
|
||||
.queryParam("configuration_token", emptyToken)
|
||||
.when().get("/configuration")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Type", equalTo("application/octet-stream"))
|
||||
// HTTP transport returns "" for empty Version-Label.
|
||||
// SDK deserializes this as null (see AppConfigTest).
|
||||
.header("Version-Label", equalTo(""))
|
||||
.body(equalTo(""));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user