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:
TiM authored and GitHub committed 2026-04-12 19:48:36 -05:00
1 parent 812ecf6880
commit 14d51a4093
2 files changed
+254 -2

No files matched your search

@@ -5,6 +5,7 @@ import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.appconfig.AppConfigClient;
import software.amazon.awssdk.services.appconfig.model.*;
import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
import software.amazon.awssdk.services.appconfigdata.model.BadRequestException;
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationRequest;
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationResponse;
import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSessionRequest;
@@ -12,6 +13,7 @@ import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSes
import java.nio.charset.StandardCharsets;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@DisplayName("AppConfig")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@@ -25,6 +27,11 @@ class AppConfigTest {
private static String configurationProfileId;
private static String deploymentStrategyId;
private static String configurationToken;
private static String secondConfigurationToken;
private static String intervalSessionToken;
private static String emptyAppId;
private static String emptyEnvId;
private static String emptyProfileId;
@BeforeAll
static void setup() {
@@ -146,5 +153,117 @@ class AppConfigTest {
assertThat(response.contentType()).startsWith("application/json");
assertThat(response.versionLabel()).isEqualTo("1");
assertThat(response.nextPollConfigurationToken()).isNotNull();
secondConfigurationToken = response.nextPollConfigurationToken();
}
@Test
@Order(9)
void staleConfigurationTokenIsRejected() {
assertThrows(BadRequestException.class, () -> appConfigData.getLatestConfiguration(
GetLatestConfigurationRequest.builder()
.configurationToken(configurationToken)
.build()));
}
@Test
@Order(10)
void invalidConfigurationTokenIsRejected() {
assertThrows(BadRequestException.class, () -> appConfigData.getLatestConfiguration(
GetLatestConfigurationRequest.builder()
.configurationToken("not-a-real-token")
.build()));
}
@Test
@Order(11)
void updatedDeploymentIsVisibleOnNextPollToken() {
CreateHostedConfigurationVersionResponse versionResponse = appConfig.createHostedConfigurationVersion(
CreateHostedConfigurationVersionRequest.builder()
.applicationId(applicationId)
.configurationProfileId(configurationProfileId)
.content(SdkBytes.fromString("{\"key\": \"value-2\"}", StandardCharsets.UTF_8))
.contentType("application/json")
.build());
assertThat(versionResponse.versionNumber()).isEqualTo(2);
appConfig.startDeployment(StartDeploymentRequest.builder()
.applicationId(applicationId)
.environmentId(environmentId)
.configurationProfileId(configurationProfileId)
.configurationVersion("2")
.deploymentStrategyId(deploymentStrategyId)
.build());
GetLatestConfigurationResponse response = appConfigData.getLatestConfiguration(GetLatestConfigurationRequest.builder()
.configurationToken(secondConfigurationToken)
.build());
assertThat(response.configuration().asString(StandardCharsets.UTF_8)).isEqualTo("{\"key\": \"value-2\"}");
assertThat(response.versionLabel()).isEqualTo("2");
}
@Test
@Order(12)
@DisplayName("Poll interval: requested 60s but emulator returns 15s (known deviation from AWS)")
void requiredMinimumPollIntervalIsAcceptedButNotEnforced() {
var sessionResponse = appConfigData.startConfigurationSession(StartConfigurationSessionRequest.builder()
.applicationIdentifier(applicationId)
.environmentIdentifier(environmentId)
.configurationProfileIdentifier(configurationProfileId)
.requiredMinimumPollIntervalInSeconds(60)
.build());
intervalSessionToken = sessionResponse.initialConfigurationToken();
GetLatestConfigurationResponse firstResponse = appConfigData.getLatestConfiguration(GetLatestConfigurationRequest.builder()
.configurationToken(intervalSessionToken)
.build());
// Emulator always returns 15s regardless of the requested interval.
// AWS would return the requested 60s. Pinning current emulator behavior.
assertThat(firstResponse.nextPollIntervalInSeconds()).isEqualTo(15);
assertThat(firstResponse.nextPollConfigurationToken()).isNotNull();
GetLatestConfigurationResponse secondResponse = appConfigData.getLatestConfiguration(GetLatestConfigurationRequest.builder()
.configurationToken(firstResponse.nextPollConfigurationToken())
.build());
assertThat(secondResponse.nextPollIntervalInSeconds()).isEqualTo(15);
assertThat(secondResponse.nextPollConfigurationToken()).isNotNull();
}
@Test
@Order(13)
void emptyConfigurationReturnsEmptyPayload() {
emptyAppId = appConfig.createApplication(CreateApplicationRequest.builder()
.name(TestFixtures.uniqueName("empty-app"))
.build()).id();
emptyEnvId = appConfig.createEnvironment(CreateEnvironmentRequest.builder()
.applicationId(emptyAppId)
.name("empty-env")
.build()).id();
emptyProfileId = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
.applicationId(emptyAppId)
.name("empty-config")
.locationUri("hosted")
.type("AWS.Freeform")
.build()).id();
String emptyToken = appConfigData.startConfigurationSession(StartConfigurationSessionRequest.builder()
.applicationIdentifier(emptyAppId)
.environmentIdentifier(emptyEnvId)
.configurationProfileIdentifier(emptyProfileId)
.build()).initialConfigurationToken();
GetLatestConfigurationResponse response = appConfigData.getLatestConfiguration(GetLatestConfigurationRequest.builder()
.configurationToken(emptyToken)
.build());
assertThat(response.configuration().asByteArray()).isEmpty();
assertThat(response.contentType()).isEqualTo("application/octet-stream");
// SDK deserializes the empty Version-Label header as null.
// The RestAssured internal test sees "" (raw HTTP header value).
assertThat(response.versionLabel()).isNull();
}
}