From 55545b5de66aac6b9e40a19ed41e24ba29cd5dec Mon Sep 17 00:00:00 2001 From: Allen Sanborn Date: Sun, 1 Nov 2026 05:46:59 -0600 Subject: [PATCH] fix(backup): keep a plan rule's TargetLogicallyAirGappedBackupVaultArn (#7176) CreateBackupPlan and UpdateBackupPlan accept Rules[].TargetLogicallyAirGappedBackupVaultArn (BackupRuleInput) and GetBackupPlan returns it on BackupRule, but the rule model had no such field, so Jackson's ignoreUnknown dropped it on read. Add it, omitted from the response when the request did not set it. --- .../services/backup/model/BackupRule.java | 8 +++++ .../backup/BackupIntegrationTest.java | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupRule.java b/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupRule.java index 3ba221ac1e..0fc3496289 100644 --- a/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupRule.java +++ b/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupRule.java @@ -1,6 +1,7 @@ package io.github.hectorvent.floci.services.backup.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.quarkus.runtime.annotations.RegisterForReflection; @@ -19,6 +20,10 @@ public class BackupRule { @JsonProperty("TargetBackupVaultName") private String targetBackupVaultName; + @JsonProperty("TargetLogicallyAirGappedBackupVaultArn") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String targetLogicallyAirGappedBackupVaultArn; + @JsonProperty("ScheduleExpression") private String scheduleExpression; @@ -54,6 +59,9 @@ public class BackupRule { public String getTargetBackupVaultName() { return targetBackupVaultName; } public void setTargetBackupVaultName(String targetBackupVaultName) { this.targetBackupVaultName = targetBackupVaultName; } + public String getTargetLogicallyAirGappedBackupVaultArn() { return targetLogicallyAirGappedBackupVaultArn; } + public void setTargetLogicallyAirGappedBackupVaultArn(String targetLogicallyAirGappedBackupVaultArn) { this.targetLogicallyAirGappedBackupVaultArn = targetLogicallyAirGappedBackupVaultArn; } + public String getScheduleExpression() { return scheduleExpression; } public void setScheduleExpression(String scheduleExpression) { this.scheduleExpression = scheduleExpression; } diff --git a/src/test/java/io/github/hectorvent/floci/services/backup/BackupIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/backup/BackupIntegrationTest.java index 8a93bebdae..20f17f2a17 100644 --- a/src/test/java/io/github/hectorvent/floci/services/backup/BackupIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/backup/BackupIntegrationTest.java @@ -1989,4 +1989,36 @@ class BackupIntegrationTest { backupService.deleteRecoveryPoint(vault, point, "us-east-1"); backupService.deleteBackupVault(vault, "us-east-1"); } + + @Test + void ruleKeepsTargetLogicallyAirGappedBackupVaultArn() { + String airGapped = "arn:aws:backup:us-east-1:000000000000:backup-vault:air-gapped"; + String rule = """ + {"RuleName": "%s", "TargetBackupVaultName": "%s", "ScheduleExpression": "cron(0 12 * * ? *)"%s}"""; + String withArn = rule.formatted("air", VAULT_NAME, + ", \"TargetLogicallyAirGappedBackupVaultArn\": \"" + airGapped + "\""); + String without = rule.formatted("plain", VAULT_NAME, ""); + String id = given().header("Authorization", AUTH).contentType("application/json") + .body("{\"BackupPlan\": {\"BackupPlanName\": \"air-gapped-plan\", \"Rules\": [" + + withArn + ", " + without + "]}}") + .when().put("/backup/plans/").then().statusCode(200) + .extract().path("BackupPlanId"); + given().header("Authorization", AUTH).when().get("/backup/plans/" + id + "/").then().statusCode(200) + .body("BackupPlan.Rules[0].TargetLogicallyAirGappedBackupVaultArn", equalTo(airGapped)) + .body("BackupPlan.Rules[1]", not(hasKey("TargetLogicallyAirGappedBackupVaultArn"))); + + // UpdateBackupPlan swaps which rule carries it; GetBackupPlan must reflect the update. + String updatedWith = rule.formatted("plain", VAULT_NAME, + ", \"TargetLogicallyAirGappedBackupVaultArn\": \"" + airGapped + "-2\""); + String updatedWithout = rule.formatted("air", VAULT_NAME, ""); + given().header("Authorization", AUTH).contentType("application/json") + .body("{\"BackupPlan\": {\"BackupPlanName\": \"air-gapped-plan\", \"Rules\": [" + + updatedWithout + ", " + updatedWith + "]}}") + .when().post("/backup/plans/" + id).then().statusCode(200); + given().header("Authorization", AUTH).when().get("/backup/plans/" + id + "/").then().statusCode(200) + .body("BackupPlan.Rules[0].RuleName", equalTo("air")) + .body("BackupPlan.Rules[0]", not(hasKey("TargetLogicallyAirGappedBackupVaultArn"))) + .body("BackupPlan.Rules[1].TargetLogicallyAirGappedBackupVaultArn", equalTo(airGapped + "-2")); + given().header("Authorization", AUTH).when().delete("/backup/plans/" + id); + } }