Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(appconfig): add DeleteConfigurationProfile/DeleteHostedConfigurationVersion/ListDeploymentStrategies/DeleteDeploymentStrategy (#2280)

sheldon-nadarajah-sftbe625023eb70
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java
index 6081ab3bde..3de8626a3a 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java
@@ -334,4 +334,126 @@ class AppConfigTest {
ListTagsForResourceRequest.builder().resourceArn(arn).build());
assertThat(listed.tags()).isNotNull();
}
+
+ @Test
+ @Order(52)
+ @DisplayName("DeleteConfigurationProfile / DeleteHostedConfigurationVersion / ListDeploymentStrategies / DeleteDeploymentStrategy")
+ void deleteAndListOperationsPreviouslyReturnedNoSuchBucket() {
+ // These four operations had no route at all, so the request fell through to S3's
+ // generic path-style catch-all and returned a raw S3 NoSuchBucket 404 instead of a real
+ // AppConfig response. Exercised via the SDK (not raw HTTP) so a regression here surfaces
+ // as an SDK-level exception, matching how a real caller would hit it.
+ String delAppId = appConfig.createApplication(CreateApplicationRequest.builder()
+ .name("delete-ops-app")
+ .build()).id();
+ try {
+ String delProfileId = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
+ .applicationId(delAppId)
+ .name("delete-ops-profile")
+ .locationUri("hosted")
+ .type("AWS.Freeform")
+ .build()).id();
+
+ appConfig.createHostedConfigurationVersion(CreateHostedConfigurationVersionRequest.builder()
+ .applicationId(delAppId)
+ .configurationProfileId(delProfileId)
+ .contentType("application/json")
+ .content(SdkBytes.fromUtf8String("{\"throwaway\": true}"))
+ .build());
+
+ appConfig.deleteHostedConfigurationVersion(DeleteHostedConfigurationVersionRequest.builder()
+ .applicationId(delAppId)
+ .configurationProfileId(delProfileId)
+ .versionNumber(1)
+ .build());
+ assertThrows(ResourceNotFoundException.class, () -> appConfig.getHostedConfigurationVersion(
+ GetHostedConfigurationVersionRequest.builder()
+ .applicationId(delAppId).configurationProfileId(delProfileId).versionNumber(1).build()));
+
+ appConfig.deleteConfigurationProfile(DeleteConfigurationProfileRequest.builder()
+ .applicationId(delAppId)
+ .configurationProfileId(delProfileId)
+ .build());
+ assertThrows(ResourceNotFoundException.class, () -> appConfig.getConfigurationProfile(
+ GetConfigurationProfileRequest.builder()
+ .applicationId(delAppId).configurationProfileId(delProfileId).build()));
+
+ String delStrategyId = appConfig.createDeploymentStrategy(CreateDeploymentStrategyRequest.builder()
+ .name("delete-ops-strategy")
+ .deploymentDurationInMinutes(0)
+ .growthFactor(100f)
+ .finalBakeTimeInMinutes(0)
+ .build()).id();
+
+ ListDeploymentStrategiesResponse listed = appConfig.listDeploymentStrategies(
+ ListDeploymentStrategiesRequest.builder().build());
+ assertThat(listed.items())
+ .extracting(strategy -> strategy.id())
+ .contains("AppConfig.AllAtOnce", "AppConfig.Linear50PercentEvery30Seconds",
+ "AppConfig.Canary10Percent20Minutes", delStrategyId);
+
+ appConfig.deleteDeploymentStrategy(DeleteDeploymentStrategyRequest.builder()
+ .deploymentStrategyId(delStrategyId).build());
+ assertThrows(ResourceNotFoundException.class, () -> appConfig.getDeploymentStrategy(
+ GetDeploymentStrategyRequest.builder().deploymentStrategyId(delStrategyId).build()));
+ } finally {
+ try {
+ appConfig.deleteApplication(DeleteApplicationRequest.builder()
+ .applicationId(delAppId).build());
+ } catch (Exception e) {
+ System.err.println("Best-effort cleanup for delete-ops-app failed: " + e.getMessage());
+ }
+ }
+ }
+
+ @Test
+ @Order(53)
+ @DisplayName("DeleteConfigurationProfile rejects a profile that belongs to a different application")
+ void deleteConfigurationProfileRejectsWrongApplication() {
+ String ownerAppId = appConfig.createApplication(CreateApplicationRequest.builder()
+ .name("profile-owner-app").build()).id();
+ String otherAppId = appConfig.createApplication(CreateApplicationRequest.builder()
+ .name("profile-other-app").build()).id();
+ try {
+ String profileId = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
+ .applicationId(ownerAppId)
+ .name("owned-profile")
+ .locationUri("hosted")
+ .type("AWS.Freeform")
+ .build()).id();
+
+ // Addressing the owner's profile through a DIFFERENT application's path must not
+ // delete it - only "not found", never a real cross-application deletion.
+ assertThrows(ResourceNotFoundException.class, () -> appConfig.deleteConfigurationProfile(
+ DeleteConfigurationProfileRequest.builder()
+ .applicationId(otherAppId).configurationProfileId(profileId).build()));
+
+ assertThat(appConfig.getConfigurationProfile(GetConfigurationProfileRequest.builder()
+ .applicationId(ownerAppId).configurationProfileId(profileId).build()).id())
+ .isEqualTo(profileId);
+ } finally {
+ try {
+ appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(ownerAppId).build());
+ } catch (Exception e) {
+ System.err.println("Best-effort cleanup for profile-owner-app failed: " + e.getMessage());
+ }
+ try {
+ appConfig.deleteApplication(DeleteApplicationRequest.builder().applicationId(otherAppId).build());
+ } catch (Exception e) {
+ System.err.println("Best-effort cleanup for profile-other-app failed: " + e.getMessage());
+ }
+ }
+ }
+
+ @Test
+ @Order(54)
+ @DisplayName("DeleteDeploymentStrategy rejects a predefined strategy")
+ void deleteDeploymentStrategyRejectsPredefined() {
+ assertThrows(software.amazon.awssdk.services.appconfig.model.BadRequestException.class, () -> appConfig.deleteDeploymentStrategy(
+ DeleteDeploymentStrategyRequest.builder().deploymentStrategyId("AppConfig.AllAtOnce").build()));
+
+ assertThat(appConfig.getDeploymentStrategy(GetDeploymentStrategyRequest.builder()
+ .deploymentStrategyId("AppConfig.AllAtOnce").build()).id())
+ .isEqualTo("AppConfig.AllAtOnce");
+ }
}
diff --git a/docs/services/appconfig.md b/docs/services/appconfig.md
index c54687c5c2..b2c23f6873 100644
--- a/docs/services/appconfig.md
+++ b/docs/services/appconfig.md
@@ -18,10 +18,14 @@ The management plane allows you to create and manage applications, environments,
- `CreateConfigurationProfile`
- `GetConfigurationProfile`
- `ListConfigurationProfiles`
+- `DeleteConfigurationProfile`
- `CreateHostedConfigurationVersion`
- `GetHostedConfigurationVersion`
+- `DeleteHostedConfigurationVersion`
- `CreateDeploymentStrategy`
- `GetDeploymentStrategy`
+- `ListDeploymentStrategies`
+- `DeleteDeploymentStrategy`
- `StartDeployment`
- `GetDeployment`
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java
index bfcac1bac0..d96cec673d 100644
--- a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java
@@ -118,6 +118,13 @@ public class AppConfigController {
return Response.ok(root).build();
}
+ @DELETE
+ @Path("/applications/{appId}/configurationprofiles/{profileId}")
+ public Response deleteConfigurationProfile(@PathParam("appId") String appId, @PathParam("profileId") String profileId) {
+ service.deleteConfigurationProfile(appId, profileId);
+ return Response.noContent().build();
+ }
+
// ──────────────────────────── Hosted Configuration Version ────────────────────────────
@GET
@@ -152,6 +159,15 @@ public class AppConfigController {
return versionResponse(version, 200);
}
+ @DELETE
+ @Path("/applications/{appId}/configurationprofiles/{profileId}/hostedconfigurationversions/{versionNumber}")
+ public Response deleteHostedConfigurationVersion(@PathParam("appId") String appId,
+ @PathParam("profileId") String profileId,
+ @PathParam("versionNumber") int versionNumber) {
+ service.deleteHostedConfigurationVersion(appId, profileId, versionNumber);
+ return Response.noContent().build();
+ }
+
private Response versionResponse(HostedConfigurationVersion v, int status) {
Response.ResponseBuilder rb = Response.status(status).entity(v.getContent());
rb.header("Application-Id", v.getApplicationId());
@@ -179,6 +195,28 @@ public class AppConfigController {
return Response.ok(service.getDeploymentStrategy(id)).build();
}
+ @GET
+ @Path("/deploymentstrategies")
+ public Response listDeploymentStrategies() {
+ List<DeploymentStrategy> items = service.listDeploymentStrategies();
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode arr = root.putArray("Items");
+ items.forEach(arr::addPOJO);
+ return Response.ok(root).build();
+ }
+
+ // AWS's own API model spells this path "deployementstrategies" (extra "e") - every other
+ // deployment-strategy operation correctly uses "deploymentstrategies". Confirmed against the
+ // real API reference (both the Request Syntax and Sample Request sections agree) and
+ // reproduced against the real AWS SDK for Java v2, which sends the misspelled path literally -
+ // matching that typo, not "fixing" it, is what real AWS wire-protocol compatibility means here.
+ @DELETE
+ @Path("/deployementstrategies/{id}")
+ public Response deleteDeploymentStrategy(@PathParam("id") String id) {
+ service.deleteDeploymentStrategy(id);
+ return Response.noContent().build();
+ }
+
// ──────────────────────────── Deployment ────────────────────────────
@POST
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java
index af62d76458..e93ce0e412 100644
--- a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java
@@ -111,6 +111,28 @@ public class AppConfigService {
.toList();
}
+ public void deleteConfigurationProfile(String appId, String profileId) {
+ // Unlike deleteApplication (a single, unscoped ID), a profile is nested under an
+ // application - a mismatched appId must not be able to delete another application's
+ // profile just because its bare profileId is guessed/known. A profileId that doesn't
+ // exist at all is still an idempotent no-op, matching deleteApplication's convention;
+ // only an existing-but-wrongly-scoped one is rejected.
+ profileStore.get(profileId).ifPresent(profile -> {
+ if (!profile.getApplicationId().equals(appId)) {
+ throw new AwsException("ResourceNotFoundException", "Configuration profile not found in this application", 404);
+ }
+ });
+ // A hosted configuration version isn't independently addressable outside its profile's
+ // lifecycle - cascade the delete so a caller can't still fetch versions for a profile
+ // that's supposedly gone.
+ String versionPrefix = appId + "::" + profileId + "::";
+ versionStore.keys().stream()
+ .filter(k -> k.startsWith(versionPrefix))
+ .toList()
+ .forEach(versionStore::delete);
+ profileStore.delete(profileId);
+ }
+
// ──────────────────────────── Hosted Configuration Version ────────────────────────────
public HostedConfigurationVersion createHostedConfigurationVersion(String appId, String profileId, byte[] content, String contentType, String description) {
@@ -153,6 +175,10 @@ public class AppConfigService {
.toList();
}
+ public void deleteHostedConfigurationVersion(String appId, String profileId, int versionNumber) {
+ versionStore.delete(appId + "::" + profileId + "::" + versionNumber);
+ }
+
// ──────────────────────────── Deployment Strategy ────────────────────────────
public DeploymentStrategy createDeploymentStrategy(Map<String, Object> request) {
@@ -176,6 +202,30 @@ public class AppConfigService {
return strategyStore.get(id).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment strategy not found", 404));
}
+ public List<DeploymentStrategy> listDeploymentStrategies() {
+ // Real AWS's ListDeploymentStrategies includes the predefined strategies alongside
+ // custom ones (confirmed via the API reference's own sample response) - the predefined
+ // ones aren't in strategyStore at all (see getDeploymentStrategy's builtinStrategy check
+ // above), so they need to be added explicitly here too.
+ List<DeploymentStrategy> result = new ArrayList<>(List.of(
+ builtinStrategy("AppConfig.AllAtOnce"),
+ builtinStrategy("AppConfig.Linear50PercentEvery30Seconds"),
+ builtinStrategy("AppConfig.Canary10Percent20Minutes")));
+ result.addAll(strategyStore.scan(k -> true));
+ return result;
+ }
+
+ public void deleteDeploymentStrategy(String id) {
+ // Predefined strategies aren't real stored resources (see builtinStrategy above) -
+ // silently no-op'ing here would report success for a delete that did nothing, and the
+ // "deleted" strategy would still show up in every subsequent Get/List call.
+ if (builtinStrategy(id) != null) {
+ throw new AwsException("BadRequestException",
+ "Predefined deployment strategy " + id + " cannot be deleted.", 400);
+ }
+ strategyStore.delete(id);
+ }
+
private static DeploymentStrategy builtinStrategy(String id) {
return switch (id) {
case "AppConfig.AllAtOnce" -> {
diff --git a/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java
index e5d90f7d5f..f4189724a2 100644
--- a/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java
@@ -406,4 +406,125 @@ class AppConfigIntegrationTest {
.header("Version-Label", equalTo(""))
.body(equalTo(""));
}
+
+ // ──────────────────────────── Delete/list operations that previously 404'd ────────────────────────────
+ // DeleteConfigurationProfile, DeleteHostedConfigurationVersion, ListDeploymentStrategies, and
+ // DeleteDeploymentStrategy had no route at all, so requests fell through to S3's generic
+ // path-style catch-all (GET/DELETE /{bucket}[/{key}]) and returned a misleading NoSuchBucket
+ // 404 instead of a real AppConfig response.
+
+ @Test @Order(26)
+ void deleteConfigurationProfileRemovesIt() {
+ String throwawayProfileId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"throwaway-profile\", \"LocationUri\": \"hosted\", \"Type\": \"AWS.Freeform\"}")
+ .when().post("/applications/" + appId + "/configurationprofiles")
+ .then()
+ .statusCode(201)
+ .extract().path("Id");
+
+ given()
+ .when().delete("/applications/" + appId + "/configurationprofiles/" + throwawayProfileId)
+ .then()
+ .statusCode(204);
+
+ given()
+ .when().get("/applications/" + appId + "/configurationprofiles/" + throwawayProfileId)
+ .then()
+ .statusCode(404);
+ }
+
+ @Test @Order(27)
+ void deleteHostedConfigurationVersionRemovesIt() {
+ String versionNumberHeader = given()
+ .header("Content-Type", "application/json")
+ .body("{\"throwaway\": true}".getBytes())
+ .when().post("/applications/" + appId + "/configurationprofiles/" + profileId + "/hostedconfigurationversions")
+ .then()
+ .statusCode(201)
+ .extract().header("Version-Number");
+ int versionNumber = Integer.parseInt(versionNumberHeader);
+
+ given()
+ .when().delete("/applications/" + appId + "/configurationprofiles/" + profileId
+ + "/hostedconfigurationversions/" + versionNumber)
+ .then()
+ .statusCode(204);
+
+ given()
+ .when().get("/applications/" + appId + "/configurationprofiles/" + profileId
+ + "/hostedconfigurationversions/" + versionNumber)
+ .then()
+ .statusCode(404);
+ }
+
+ @Test @Order(28)
+ void listDeploymentStrategiesIncludesBuiltinsAndCustom() {
+ given()
+ .when().get("/deploymentstrategies")
+ .then()
+ .statusCode(200)
+ .body("Items.Id", hasItems("AppConfig.AllAtOnce", "AppConfig.Linear50PercentEvery30Seconds",
+ "AppConfig.Canary10Percent20Minutes", strategyId));
+ }
+
+ @Test @Order(29)
+ void deleteDeploymentStrategyRemovesIt() {
+ String throwawayStrategyId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"throwaway-strategy\", \"DeploymentDurationInMinutes\": 0, \"GrowthFactor\": 100, \"FinalBakeTimeInMinutes\": 0}")
+ .when().post("/deploymentstrategies")
+ .then()
+ .statusCode(201)
+ .extract().path("Id");
+
+ // AWS's own API model spells DeleteDeploymentStrategy's path "deployementstrategies"
+ // (extra "e") - every other deployment-strategy operation correctly uses
+ // "deploymentstrategies". Confirmed against the real API reference and reproduced
+ // against the real AWS SDK for Java v2 (see AppConfigController#deleteDeploymentStrategy).
+ given()
+ .when().delete("/deployementstrategies/" + throwawayStrategyId)
+ .then()
+ .statusCode(204);
+
+ given()
+ .when().get("/deploymentstrategies/" + throwawayStrategyId)
+ .then()
+ .statusCode(404);
+
+ // Deleting an already-deleted (or never-existing) strategy is idempotent, matching
+ // DeleteApplication's existing convention - not an error.
+ given()
+ .when().delete("/deployementstrategies/" + throwawayStrategyId)
+ .then()
+ .statusCode(204);
+ }
+
+ @Test @Order(30)
+ void deleteConfigurationProfileUnderWrongApplicationIsRejectedNotDeleted() {
+ // emptyProfileId belongs to emptyAppId (created in @Order(25)), not appId - a caller
+ // guessing/reusing a profileId under the wrong application must not be able to delete it.
+ given()
+ .when().delete("/applications/" + appId + "/configurationprofiles/" + emptyProfileId)
+ .then()
+ .statusCode(404);
+
+ given()
+ .when().get("/applications/" + emptyAppId + "/configurationprofiles/" + emptyProfileId)
+ .then()
+ .statusCode(200);
+ }
+
+ @Test @Order(31)
+ void deleteDeploymentStrategyOnPredefinedStrategyIsRejected() {
+ given()
+ .when().delete("/deployementstrategies/AppConfig.AllAtOnce")
+ .then()
+ .statusCode(400);
+
+ given()
+ .when().get("/deploymentstrategies/AppConfig.AllAtOnce")
+ .then()
+ .statusCode(200);
+ }
}