fix(appconfig): default omitted configuration profile type (#7037)

This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-31 05:09:39 -04:00
1 parent 9be236e289
commit 9f0856c691
6 files changed
+80 -7

No files matched your search

@@ -204,13 +204,30 @@ class AppConfigResourceFieldsIntegrationTest {
}
@Test
void profileCreatedWithoutTypeReturnsNoType() {
void profileCreatedWithoutTypeDefaultsToFreeform() {
String applicationId = createApplication("untyped-profile-app");
String profileId = given()
.contentType(ContentType.JSON)
.body("{\"Name\":\"untyped\",\"LocationUri\":\"hosted\"}")
.when().post("/applications/" + applicationId + "/configurationprofiles")
.then().statusCode(201)
.body("Type", equalTo("AWS.Freeform"))
.extract().path("Id");
given()
.when().get("/applications/" + applicationId + "/configurationprofiles/" + profileId)
.then().statusCode(200)
.body("Type", equalTo("AWS.Freeform"));
}
@Test
void nonHostedProfileWithoutTypeRemainsUntyped() {
String applicationId = createApplication("external-profile-app");
String profileId = given()
.contentType(ContentType.JSON)
.body("{\"Name\":\"external\",\"LocationUri\":\"ssm-parameter://configuration\"}")
.when().post("/applications/" + applicationId + "/configurationprofiles")
.then().statusCode(201)
.body("Type", nullValue())
.extract().path("Id");
@@ -220,6 +237,23 @@ class AppConfigResourceFieldsIntegrationTest {
.body("Type", nullValue());
}
@Test
void explicitNullTypeUsesOnlyTheHostedDefault() {
String applicationId = createApplication("null-type-app");
for (String location : List.of("hosted", "ssm-parameter://configuration")) {
String profileId = given()
.contentType(ContentType.JSON)
.body("{\"Name\":\"null-type\",\"LocationUri\":\"" + location + "\",\"Type\":null}")
.when().post("/applications/" + applicationId + "/configurationprofiles")
.then().statusCode(201)
.body("Type", "hosted".equals(location) ? equalTo("AWS.Freeform") : nullValue())
.extract().path("Id");
given().get("/applications/" + applicationId + "/configurationprofiles/" + profileId)
.then().statusCode(200)
.body("Type", "hosted".equals(location) ? equalTo("AWS.Freeform") : nullValue());
}
}
private static String createApplication(String name) {
return given()
.contentType(ContentType.JSON)
@@ -107,6 +107,26 @@ class AppConfigServiceTest {
service = new AppConfigService(storageFactory, mock(EmulatorConfig.class));
}
@Test
void onlyHostedProfilesReceiveTheOmittedTypeDefault() {
assertEquals("AWS.Freeform", service.createConfigurationProfile("app",
Map.of("Name", "hosted", "LocationUri", "hosted")).getType());
assertNull(service.createConfigurationProfile("app",
Map.of("Name", "external", "LocationUri", "ssm-parameter://configuration")).getType());
}
@Test
void nonHostedProfilesRetainAnExplicitType() {
assertEquals("AWS.Freeform", service.createConfigurationProfile("app",
Map.of("Name", "explicit", "LocationUri", "ssm-parameter://configuration",
"Type", "AWS.Freeform")).getType());
}
@Test
void readingLegacyProfilesDoesNotBackfillType() {
assertNull(service.getConfigurationProfile("app", "profile").getType());
}
@Test
void listDeploymentsReturnsDescendingPages() {
deploymentStore.put("app::env::1", deployment("app", "env", 1));
@@ -80,7 +80,7 @@ class CloudFormationAppConfigIntegrationTest {
appconfig().get(profilePath).then().statusCode(200)
.body("Name", equalTo("settings"), "LocationUri", equalTo("hosted"), "Type", equalTo("AWS.Freeform"));
appconfig().get("/applications/" + app + "/configurationprofiles/" + physicalIds.get("Untyped"))
.then().statusCode(200).body("Type", nullValue());
.then().statusCode(200).body("Type", equalTo("AWS.Freeform"));
appconfig().get("/deploymentstrategies/" + strategy).then().statusCode(200)
.body("Name", equalTo("gradual"), "DeploymentDurationInMinutes", equalTo(0),
"FinalBakeTimeInMinutes", equalTo(0), "GrowthFactor", equalTo(100f),
@@ -266,13 +266,13 @@ class AppConfigCfnProvisionerTest {
}
@Test
void aProfileWithoutTypeHasNoneAndAddingOneReplacesIt() {
void aProfileWithoutTypeDefaultsToFreeformAndChangingItReplacesIt() {
String appId = create(APPLICATION, props("Name", "orders")).getPhysicalId();
StackResource profile = create(PROFILE, props("ApplicationId", appId, "Name", "settings",
"LocationUri", "hosted"));
String oldId = profile.getPhysicalId();
assertEquals(oldId, profile.getAttributes().get("ConfigurationProfileId"));
assertNull(service.getConfigurationProfile(appId, oldId).getType());
assertEquals("AWS.Freeform", service.getConfigurationProfile(appId, oldId).getType());
update(profile, props("ApplicationId", appId, "Name", "flags", "LocationUri", "hosted",
"Type", "AWS.AppConfig.FeatureFlags"));