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

@@ -667,9 +667,10 @@ class AppConfigTest {
assertThat(deployment.configurationName()).isEqualTo("service-settings");
assertThat(deployment.configurationLocationUri()).isEqualTo("ssm-parameter://service-settings");
// AWS documents no default Type: a profile created without one reports none.
// A hosted profile without an explicit Type defaults to freeform.
assertThat(appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
.applicationId(monitoredAppId).name("untyped").locationUri("hosted").build()).type()).isNull();
.applicationId(monitoredAppId).name("untyped").locationUri("hosted").build()).type())
.isEqualTo("AWS.Freeform");
} finally {
try {
appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(monitoredAppId).build());
@@ -747,4 +748,21 @@ class AppConfigTest {
}
}
}
@Test
@DisplayName("A non-hosted profile without a type stays untyped")
void nonHostedProfileWithoutTypeStaysUntyped() {
String applicationId = appConfig.createApplication(CreateApplicationRequest.builder()
.name(TestFixtures.uniqueName("external-profile")).build()).id();
try {
CreateConfigurationProfileResponse profile = appConfig.createConfigurationProfile(
CreateConfigurationProfileRequest.builder().applicationId(applicationId)
.name("external").locationUri("ssm-parameter://configuration").build());
assertThat(profile.type()).isNull();
assertThat(appConfig.getConfigurationProfile(GetConfigurationProfileRequest.builder()
.applicationId(applicationId).configurationProfileId(profile.id()).build()).type()).isNull();
} finally {
appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(applicationId).build());
}
}
}
@@ -252,7 +252,8 @@ public class AppConfigService {
profile.setName((String) request.get("Name"));
profile.setDescription((String) request.get("Description"));
profile.setLocationUri((String) request.get("LocationUri"));
profile.setType((String) request.get("Type"));
String type = (String) request.get("Type");
profile.setType(type == null && "hosted".equals(profile.getLocationUri()) ? "AWS.Freeform" : type);
profileStore.put(profile.getId(), profile);
return profile;
}
@@ -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"));