Light, fluffy, and always free - The AWS Local Emulator alternative
feat(backup): add CreateLogicallyAirGappedBackupVault (#6015)
Allen Sanborn65e35adf547e
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BackupTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BackupTest.javaindex 2ee8b7ed58..46acf2d41f 100644--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BackupTest.java+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BackupTest.java@@ -429,4 +429,35 @@ class BackupTest {assertThatThrownBy(() -> backup.describeBackupVault(r -> r.backupVaultName(VAULT_NAME))).isInstanceOf(ResourceNotFoundException.class);}++ @Test+ @Order(90)+ @DisplayName("CreateLogicallyAirGappedBackupVault - DescribeBackupVault reports its type, state and retention")+ void logicallyAirGappedVaultRoundTrip() {+ String name = "compat-air-gapped-vault";+ try {+ CreateLogicallyAirGappedBackupVaultResponse created = backup.createLogicallyAirGappedBackupVault(r -> r+ .backupVaultName(name)+ .minRetentionDays(7L)+ .maxRetentionDays(30L)+ .backupVaultTags(Map.of("env", "compat-test")));+ assertThat(created.backupVaultName()).isEqualTo(name);+ assertThat(created.backupVaultArn()).endsWith(":backup-vault:" + name);+ assertThat(created.creationDate()).isNotNull();+ assertThat(created.vaultState()).isEqualTo(VaultState.AVAILABLE);++ DescribeBackupVaultResponse described = backup.describeBackupVault(r -> r.backupVaultName(name));+ assertThat(described.vaultType()).isEqualTo(VaultType.LOGICALLY_AIR_GAPPED_BACKUP_VAULT);+ assertThat(described.vaultState()).isEqualTo(VaultState.AVAILABLE);+ assertThat(described.minRetentionDays()).isEqualTo(7L);+ assertThat(described.maxRetentionDays()).isEqualTo(30L);++ assertThat(backup.listTags(r -> r.resourceArn(created.backupVaultArn())).tags())+ .containsEntry("env", "compat-test");+ } finally {+ backup.deleteBackupVault(r -> r.backupVaultName(name));+ }+ assertThatThrownBy(() -> backup.describeBackupVault(r -> r.backupVaultName(name)))+ .isInstanceOf(ResourceNotFoundException.class);+ }}diff --git a/docs/services/backup.md b/docs/services/backup.mdindex 29549ba0ac..ca6d9b0106 100644--- a/docs/services/backup.md+++ b/docs/services/backup.md@@ -13,7 +13,8 @@| `CreateBackupVault` | `PUT` | `/backup-vaults/{backupVaultName}` | Create a backup vault || `DescribeBackupVault` | `GET` | `/backup-vaults/{backupVaultName}` | Describe a backup vault || `DeleteBackupVault` | `DELETE` | `/backup-vaults/{backupVaultName}` | Delete an empty backup vault, locked or not |-| `ListBackupVaults` | `GET` | `/backup-vaults/` | List all backup vaults |+| `ListBackupVaults` | `GET` | `/backup-vaults/` | List all backup vaults; honours the `vaultType` filter |+| `CreateLogicallyAirGappedBackupVault` | `PUT` | `/logically-air-gapped-backup-vaults/{backupVaultName}` | Create a logically air-gapped vault, `AVAILABLE` at once; `DescribeBackupVault` reports its `VaultType`, `VaultState`, retention and a compliance lock whose `LockDate` is the creation date |### Backup Vault Access Policy@@ -191,7 +192,8 @@ Actual backup is simulated — no data is read from or written to the referenced- The access policy and notification configuration are **not** returned by`DescribeBackupVault`, matching AWS: each is reachable only through its own `Get`operation. The lock fields (`Locked`, `LockDate`, `MinRetentionDays`,- `MaxRetentionDays`) are on the vault, also matching AWS.+ `MaxRetentionDays`) are on the vault, also matching AWS. A standard vault reports+ `VaultType` `BACKUP_VAULT` in `DescribeBackupVault` and `ListBackupVaults`.## Configurationdiff --git a/docs/services/index.md b/docs/services/index.mdindex d4efb63ffd..23c40d15ed 100644--- a/docs/services/index.md+++ b/docs/services/index.md@@ -119,7 +119,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac| [AWS Marketplace](marketplace.md) | Marketplace Catalog API | REST JSON | 56 || [Control Tower](controltower.md) | `/list-landingzones`, `/get-landingzone`, `/create-landingzone`, `/*-baseline*` | REST JSON | 15 || [Managed Prometheus (AMP)](managed-prometheus.md) | `/workspaces/*`, `/workspaces/*/rulegroupsnamespaces/*`, `/tags/*` | REST JSON | 13 |-| [AWS Backup](backup.md) | `/backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 20 |+| [AWS Backup](backup.md) | `/backup-vaults/*`, `/logically-air-gapped-backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 35 || [AWS FIS](fis.md) | `/experimentTemplates/*`, `/experiments/*`, `/actions/*`, `/targetResourceTypes/*`, `/safetyLevers/*`, `/tags/*` | REST JSON | 26 || [CodeGuru Reviewer](codegurureviewer.md) | `/associations`, `/associations/{associationArn}`, `/tags/*` | REST JSON | 7 || [CodeArtifact](codeartifact.md) | `/v1/domain*`, `/v1/repository*`, `/v1/package`, `/v1/package/version*`, `/v1/tag*`, `/v1/authorization-token`, `/codeartifact/maven/*`, `/codeartifact/npm/*`, `/codeartifact/pypi/*` | REST JSON | 32 |diff --git a/src/main/java/io/github/hectorvent/floci/services/backup/BackupController.java b/src/main/java/io/github/hectorvent/floci/services/backup/BackupController.javaindex de87ee7cbb..41f0be9d78 100644--- a/src/main/java/io/github/hectorvent/floci/services/backup/BackupController.java+++ b/src/main/java/io/github/hectorvent/floci/services/backup/BackupController.java@@ -60,6 +60,29 @@ public class BackupController {return Response.status(200).entity(out).build();}+ @PUT+ @Path("/logically-air-gapped-backup-vaults/{backupVaultName}")+ public Response createLogicallyAirGappedBackupVault(@Context HttpHeaders headers,+ @PathParam("backupVaultName") String vaultName,+ String body) throws IOException {+ String region = regionResolver.resolveRegion(headers);+ JsonNode req = objectMapper.readTree(body == null || body.isBlank() ? "{}" : body);+ BackupVault vault = service.createLogicallyAirGappedBackupVault(vaultName,+ textOrNull(req, "EncryptionKeyArn"),+ textOrNull(req, "CreatorRequestId"),+ readStringMap(req, "BackupVaultTags"),+ longOrNull(req, "MinRetentionDays"),+ longOrNull(req, "MaxRetentionDays"),+ region);++ ObjectNode out = objectMapper.createObjectNode();+ out.put("BackupVaultName", vault.getBackupVaultName());+ out.put("BackupVaultArn", vault.getBackupVaultArn());+ out.put("CreationDate", vault.getCreationDate());+ out.put("VaultState", vault.getVaultState());+ return Response.status(200).entity(out).build();+ }+@GET@Path("/backup-vaults/{backupVaultName}")public Response describeBackupVault(@Context HttpHeaders headers,@@ -79,9 +102,10 @@ public class BackupController {@GET@Path("/backup-vaults/")- public Response listBackupVaults(@Context HttpHeaders headers) {+ public Response listBackupVaults(@Context HttpHeaders headers,+ @QueryParam("vaultType") String byVaultType) {String region = regionResolver.resolveRegion(headers);- List<BackupVault> vaults = service.listBackupVaults(region);+ List<BackupVault> vaults = service.listBackupVaults(region, byVaultType);ObjectNode out = objectMapper.createObjectNode();ArrayNode list = out.putArray("BackupVaultList");vaults.forEach(v -> list.add(vaultJson(v)));@@ -92,6 +116,11 @@ public class BackupController {private ObjectNode vaultJson(BackupVault vault) {ObjectNode node = objectMapper.valueToTree(vault);node.remove(BackupVault.VAULT_ID_FIELD);+ // AWS reports a standard vault as BACKUP_VAULT. Stored standard vaults (including ones+ // persisted before VaultType existed) leave it null, so it is filled here at read time.+ if (vault.getVaultType() == null) {+ node.put("VaultType", "BACKUP_VAULT");+ }return node;}diff --git a/src/main/java/io/github/hectorvent/floci/services/backup/BackupService.java b/src/main/java/io/github/hectorvent/floci/services/backup/BackupService.javaindex 74eb600808..daad128344 100644--- a/src/main/java/io/github/hectorvent/floci/services/backup/BackupService.java+++ b/src/main/java/io/github/hectorvent/floci/services/backup/BackupService.java@@ -91,6 +91,43 @@ public class BackupService {public BackupVault createBackupVault(String vaultName, String encryptionKeyArn,String creatorRequestId, Map<String, String> tags,String region) {+ return createVault(new BackupVault(), vaultName, encryptionKeyArn, creatorRequestId, tags, region);+ }++ /**+ * CreateLogicallyAirGappedBackupVault. Both retention values are "Required: Yes" in the+ * reference, and MinRetentionDays carries "The minimum value accepted is 7 days." The vault+ * shares the standard vault namespace and ARN shape, so DescribeBackupVault, DeleteBackupVault+ * and the tag operations reach it unchanged; what distinguishes it is VaultType, which the+ * Terraform provider checks on every read. Creation is synchronous here, so the vault is+ * AVAILABLE at once rather than passing through CREATING.+ */+ public BackupVault createLogicallyAirGappedBackupVault(String vaultName, String encryptionKeyArn,+ String creatorRequestId, Map<String, String> tags,+ Long minRetentionDays, Long maxRetentionDays,+ String region) {+ if (minRetentionDays == null) {+ throw new AwsException("MissingParameterValueException", "MinRetentionDays is required", 400);+ }+ if (maxRetentionDays == null) {+ throw new AwsException("MissingParameterValueException", "MaxRetentionDays is required", 400);+ }+ requireDayRange("MinRetentionDays", minRetentionDays, 7, null);+ requireDayRange("MaxRetentionDays", maxRetentionDays, minRetentionDays, null);+ BackupVault vault = new BackupVault();+ vault.setVaultType("LOGICALLY_AIR_GAPPED_BACKUP_VAULT");+ vault.setVaultState("AVAILABLE");+ // Retention is mandatory and fixed at creation, so the existing locked-vault enforcement+ // (backup-job lifecycle window, recovery-point deletion floor) applies to it as well.+ // createVault sets LockDate to the creation date: a compliance lock, never changeable.+ vault.setLocked(true);+ vault.setMinRetentionDays(minRetentionDays);+ vault.setMaxRetentionDays(maxRetentionDays);+ return createVault(vault, vaultName, encryptionKeyArn, creatorRequestId, tags, region);+ }++ private BackupVault createVault(BackupVault vault, String vaultName, String encryptionKeyArn,+ String creatorRequestId, Map<String, String> tags, String region) {String key = vaultKey(region, vaultName);// Check and write under one monitor. Unsynchronised, two creates of the same name can// both find the name free and both write, so AlreadyExistsException never fires and the@@ -108,11 +145,17 @@ public class BackupService {if (vaultStore.get(key).isPresent()) {throw new AwsException("AlreadyExistsException", "Backup vault already exists: " + vaultName, 400);}- BackupVault vault = new BackupVault();vault.setBackupVaultName(vaultName);vault.setBackupVaultArn(regionResolver.buildArn("backup", region, "backup-vault:" + vaultName));vault.setEncryptionKeyArn(encryptionKeyArn);- vault.setCreationDate(Instant.now().getEpochSecond());+ long now = Instant.now().getEpochSecond();+ vault.setCreationDate(now);+ // Only an air-gapped vault arrives here locked. AWS creates it with a compliance-mode+ // lock whose LockDate is the creation date, so the lock is immutable from the start;+ // a null LockDate would read as a governance lock that can still change.+ if (vault.isLocked()) {+ vault.setLockDate(now);+ }vault.setVaultId(UUID.randomUUID().toString());vault.setCreatorRequestId(creatorRequestId);vault.setNumberOfRecoveryPoints(0);@@ -164,9 +207,21 @@ public class BackupService {vaultStore.delete(vaultKey(region, vaultName));}- public List<BackupVault> listBackupVaults(String region) {+ public List<BackupVault> listBackupVaults(String region, String byVaultType) {String prefix = region + ":";- return vaultStore.scan(k -> k.startsWith(prefix));+ // A standard vault leaves VaultType unset; AWS reports it as BACKUP_VAULT.+ return vaultStore.scan(k -> k.startsWith(prefix)).stream()+ .filter(v -> byVaultType == null || byVaultType.equals(+ v.getVaultType() == null ? "BACKUP_VAULT" : v.getVaultType()))+ .toList();+ }++ private static void requireNotAirGapped(BackupVault vault, String action) {+ if (vault.getVaultType() != null) {+ throw new AwsException("InvalidRequestException",+ "Backup vault lock configuration cannot be " + action+ + " on a logically air-gapped vault: " + vault.getBackupVaultName(), 400);+ }}// ── Vault sub-resources: access policy, notifications, lock ────────────────@@ -353,6 +408,7 @@ public class BackupService {Long maxRetentionDays,Long changeableForDays) {BackupVault vault = describeBackupVault(vaultName, region);+ requireNotAirGapped(vault, "changed");if (vault.isLocked() && !lockIsStillChangeable(vault)) {throw new AwsException("InvalidRequestException","Backup vault lock is immutable and cannot be changed: " + vaultName, 400);@@ -412,6 +468,7 @@ public class BackupService {public void deleteBackupVaultLockConfiguration(String vaultName, String region) {BackupVault vault = describeBackupVault(vaultName, region);+ requireNotAirGapped(vault, "deleted");if (vault.isLocked() && !lockIsStillChangeable(vault)) {throw new AwsException("InvalidRequestException","Backup vault lock is immutable and cannot be deleted: " + vaultName, 400);@@ -735,9 +792,31 @@ public class BackupService {}private void completeJob(String jobId, String vaultName, String region, String notificationKey) {+ // Under the vault-name monitor, so the vault cannot be deleted or recreated between the+ // incarnation check and the recovery point landing in it.+ synchronized (lockFor(vaultKey(region, vaultName))) {+ completeJobLocked(jobId, vaultName, region, notificationKey);+ }+ }++ private void completeJobLocked(String jobId, String vaultName, String region, String notificationKey) {jobStore.get(jobId).ifPresent(job -> {if ("RUNNING".equals(job.getState())) {long now = Instant.now().getEpochSecond();+ // The recovery point belongs to the vault the job started in, not to whatever+ // vault holds the name now. A vault deleted mid-job (allowed: it held no recovery+ // point yet) and recreated unlocked would otherwise receive a recovery point its+ // creator's lock was meant to protect, deletable inside that lock's retention.+ boolean sameVault = vaultStore.get(vaultKey(region, vaultName))+ .map(v -> subResourceKey(region, v).equals(notificationKey))+ .orElse(false);+ if (!sameVault) {+ job.setState("FAILED");+ job.setStatusMessage("Backup vault was deleted before the job completed: " + vaultName);+ job.setCompletionDate(now);+ jobStore.put(jobId, job);+ return;+ }String rpArn = regionResolver.buildArn("backup", region,"recovery-point:" + UUID.randomUUID());diff --git a/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupVault.java b/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupVault.javaindex b637315aa6..ac47c8104b 100644--- a/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupVault.java+++ b/src/main/java/io/github/hectorvent/floci/services/backup/model/BackupVault.java@@ -65,6 +65,14 @@ public class BackupVault {public static final String VAULT_ID_FIELD = "FlociVaultId";+ // Stored only on logically air-gapped vaults; a standard vault leaves VaultType null and+ // BackupController reports it as BACKUP_VAULT. VaultState is set on air-gapped vaults only.+ @JsonProperty("VaultType")+ private String vaultType;++ @JsonProperty("VaultState")+ private String vaultState;+public BackupVault() {}public String getBackupVaultName() { return backupVaultName; }@@ -102,4 +110,10 @@ public class BackupVault {public Long getMaxRetentionDays() { return maxRetentionDays; }public void setMaxRetentionDays(Long maxRetentionDays) { this.maxRetentionDays = maxRetentionDays; }++ public String getVaultType() { return vaultType; }+ public void setVaultType(String vaultType) { this.vaultType = vaultType; }++ public String getVaultState() { return vaultState; }+ public void setVaultState(String vaultState) { this.vaultState = vaultState; }}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.javaindex 93499689ee..ad7b73cbb2 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@@ -719,7 +719,9 @@ class BackupIntegrationTest {.when().get("/backup-vaults/" + SUB_VAULT).then().statusCode(200).body("Locked", equalTo(false))- .body("$", not(hasKey("LockDate")));+ .body("$", not(hasKey("LockDate")))+ // A standard vault is stored with VaultType unset; AWS reports it as BACKUP_VAULT.+ .body("VaultType", equalTo("BACKUP_VAULT"));}@Test@@ -1689,7 +1691,8 @@ class BackupIntegrationTest {await().atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(100)).until(() -> { String b = receiveBody(sentinelQueue); return b != null && !b.isEmpty(); });- awaitJobCompleted(oldJob);+ // Its vault is gone, so the old job fails rather than completing into the replacement.+ awaitJobState(AUTH, oldJob, "FAILED");// The replacement's own job does publish; the old job must not have published too.String first = receiveBody(replacementQueue);@@ -1698,4 +1701,244 @@ class BackupIntegrationTest {assertThat(second == null ? "" : second, not(containsString("BackupJob ID : " + oldJob)));}+ // ── Logically air-gapped vault ─────────────────────────────────────────────++ private static final String AIR_GAPPED_VAULT = "air-gapped-vault";++ @Test+ @Order(190)+ void createLogicallyAirGappedBackupVault() {+ given()+ .header("Authorization", AUTH)+ .contentType("application/json")+ .body("{\"MinRetentionDays\":7,\"MaxRetentionDays\":30,"+ + "\"CreatorRequestId\":\"req-1\",\"BackupVaultTags\":{\"env\":\"airgap\"}}")+ .when()+ .put("/logically-air-gapped-backup-vaults/" + AIR_GAPPED_VAULT)+ .then()+ .statusCode(200)+ .body("BackupVaultName", equalTo(AIR_GAPPED_VAULT))+ .body("BackupVaultArn", endsWith(":backup-vault:" + AIR_GAPPED_VAULT))+ .body("CreationDate", notNullValue())+ .body("VaultState", equalTo("AVAILABLE"));+ }++ @Test+ @Order(191)+ void describeBackupVaultReportsTheAirGappedVaultTypeAndRetention() {+ // AWS creates the vault with a compliance-mode lock: LockDate equals CreationDate.+ long creationDate = given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().statusCode(200).extract().jsonPath().getLong("CreationDate");+ given()+ .header("Authorization", AUTH)+ .when()+ .get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then()+ .statusCode(200)+ .body("Locked", equalTo(true))+ .body("LockDate", equalTo((int) creationDate))+ .body("BackupVaultName", equalTo(AIR_GAPPED_VAULT))+ .body("VaultType", equalTo("LOGICALLY_AIR_GAPPED_BACKUP_VAULT"))+ .body("VaultState", equalTo("AVAILABLE"))+ .body("MinRetentionDays", equalTo(7))+ .body("MaxRetentionDays", equalTo(30))+ .body("CreatorRequestId", equalTo("req-1"));+ }++ @Test+ @Order(192)+ void airGappedVaultTagsAreReadableThroughListTags() {+ String arn = given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().statusCode(200).extract().path("BackupVaultArn");++ given().header("Authorization", AUTH)+ .when().get("/tags/" + arn)+ .then().statusCode(200).body("Tags.env", equalTo("airgap"));+ }++ @Test+ @Order(193)+ void createLogicallyAirGappedBackupVaultTwiceReturnsAlreadyExists() {+ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":7,\"MaxRetentionDays\":30}")+ .when().put("/logically-air-gapped-backup-vaults/" + AIR_GAPPED_VAULT)+ .then().statusCode(400).body("__type", equalTo("AlreadyExistsException"));+ }++ @Test+ @Order(194)+ void createLogicallyAirGappedBackupVaultValidatesRetention() {+ // Both retention values are "Required: Yes", and MinRetentionDays has a documented+ // floor: "The minimum value accepted is 7 days."+ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MaxRetentionDays\":30}")+ .when().put("/logically-air-gapped-backup-vaults/airgap-missing-min")+ .then().statusCode(400).body("__type", equalTo("MissingParameterValueException"));++ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":7}")+ .when().put("/logically-air-gapped-backup-vaults/airgap-missing-max")+ .then().statusCode(400).body("__type", equalTo("MissingParameterValueException"));++ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":6,\"MaxRetentionDays\":30}")+ .when().put("/logically-air-gapped-backup-vaults/airgap-min-too-low")+ .then().statusCode(400).body("__type", equalTo("InvalidParameterValueException"));++ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":30,\"MaxRetentionDays\":7}")+ .when().put("/logically-air-gapped-backup-vaults/airgap-max-below-min")+ .then().statusCode(400).body("__type", equalTo("InvalidParameterValueException"));++ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/airgap-missing-min")+ .then().statusCode(not(200));+ }++ @Test+ @Order(195)+ void airGappedVaultIsLockedSoRetentionEnforcementApplies() {+ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().statusCode(200).body("Locked", equalTo(true));+ }++ @Test+ @Order(196)+ void vaultLockCallsCannotChangeOrRemoveAirGappedRetention() {+ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":1,\"MaxRetentionDays\":2}")+ .when().put("/backup-vaults/" + AIR_GAPPED_VAULT + "/vault-lock")+ .then().statusCode(400).body("__type", equalTo("InvalidRequestException"));++ given().header("Authorization", AUTH)+ .when().delete("/backup-vaults/" + AIR_GAPPED_VAULT + "/vault-lock")+ .then().statusCode(400).body("__type", equalTo("InvalidRequestException"));++ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().body("MinRetentionDays", equalTo(7)).body("MaxRetentionDays", equalTo(30));+ }++ @Test+ @Order(197)+ void listBackupVaultsFiltersByVaultType() {+ given().header("Authorization", AUTH).queryParam("vaultType", "LOGICALLY_AIR_GAPPED_BACKUP_VAULT")+ .when().get("/backup-vaults/")+ .then().statusCode(200)+ .body("BackupVaultList.BackupVaultName", hasItem(AIR_GAPPED_VAULT))+ .body("BackupVaultList.BackupVaultName", not(hasItem("lock-enforcement-vault")));++ given().header("Authorization", AUTH).queryParam("vaultType", "BACKUP_VAULT")+ .when().get("/backup-vaults/")+ .then().statusCode(200)+ .body("BackupVaultList.BackupVaultName", hasItem("lock-enforcement-vault"))+ .body("BackupVaultList.BackupVaultName", not(hasItem(AIR_GAPPED_VAULT)));++ // The list members carry VaultType and the air-gapped LockDate too, not just Describe.+ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/")+ .then().statusCode(200)+ .body("BackupVaultList.find { it.BackupVaultName == 'lock-enforcement-vault' }.VaultType",+ equalTo("BACKUP_VAULT"))+ .body("BackupVaultList.find { it.BackupVaultName == '" + AIR_GAPPED_VAULT + "' }.VaultType",+ equalTo("LOGICALLY_AIR_GAPPED_BACKUP_VAULT"))+ .body("BackupVaultList.find { it.BackupVaultName == '" + AIR_GAPPED_VAULT + "' }.LockDate",+ notNullValue());+ }++ @Test+ @Order(198)+ void deleteBackupVaultRemovesTheAirGappedVault() {+ given().header("Authorization", AUTH)+ .when().delete("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().statusCode(204);++ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + AIR_GAPPED_VAULT)+ .then().body("__type", equalTo("ResourceNotFoundException"));+ }++ @Test+ @Order(199)+ void anAirGappedVaultRefusesToDeleteARecoveryPointInsideMinRetention() {+ // Same mechanism as aLockedVaultRefusesToDeleteARecoveryPointInsideMinRetention, but+ // the lock comes from creation alone: no PutBackupVaultLockConfiguration call. Asserting+ // Locked=true is not enough; this is the behaviour Locked is supposed to buy.+ String vault = "air-gapped-retention-vault";+ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":7,\"MaxRetentionDays\":30}")+ .when().put("/logically-air-gapped-backup-vaults/" + vault).then().statusCode(200);++ String jid = given().header("Authorization", AUTH).contentType("application/json")+ .body("""+ {+ "BackupVaultName": "%s",+ "ResourceArn": "%s",+ "IamRoleArn": "%s",+ "Lifecycle": {"DeleteAfterDays": 14}+ }+ """.formatted(vault, RESOURCE_ARN, IAM_ROLE))+ .when().put("/backup-jobs").then().statusCode(200).extract().path("BackupJobId");++ awaitJobCompleted(jid);+ String rpArn = given().header("Authorization", AUTH)+ .when().get("/backup-jobs/" + jid).then().statusCode(200)+ .body("State", equalTo("COMPLETED"))+ .extract().path("RecoveryPointArn");++ given().header("Authorization", AUTH)+ .when().delete("/backup-vaults/" + vault + "/recovery-points/" + rpArn)+ .then().statusCode(400)+ .body("__type", equalTo("InvalidRequestException"))+ .body("message", containsString("7"));++ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + vault + "/recovery-points/" + rpArn)+ .then().statusCode(200);+ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + vault)+ .then().statusCode(200).body("NumberOfRecoveryPoints", equalTo(1));+ }++ @Test+ @Order(200)+ void aJobWhoseAirGappedVaultWasReplacedDoesNotLandInTheReplacement() {+ // Delete is allowed mid-job (the vault holds no recovery point yet). If the job then+ // completed by NAME, its recovery point would land in an unlocked vault recreated under+ // that name and could be deleted inside the original vault's minimum retention.+ String vault = "air-gapped-replaced-vault";+ given().header("Authorization", AUTH).contentType("application/json")+ .body("{\"MinRetentionDays\":7,\"MaxRetentionDays\":30}")+ .when().put("/logically-air-gapped-backup-vaults/" + vault).then().statusCode(200);+ String oldJob = given().header("Authorization", AUTH).contentType("application/json")+ .body("""+ {"BackupVaultName": "%s", "ResourceArn": "%s", "IamRoleArn": "%s", "Lifecycle": {"DeleteAfterDays": 14}}+ """.formatted(vault, RESOURCE_ARN, IAM_ROLE))+ .when().put("/backup-jobs").then().statusCode(200).extract().path("BackupJobId");+ given().header("Authorization", AUTH)+ .when().delete("/backup-vaults/" + vault).then().statusCode(204);+ given().header("Authorization", AUTH).contentType("application/json").body("{}")+ .when().put("/backup-vaults/" + vault).then().statusCode(200);++ await().atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(25))+ .until(() -> {+ String state = given().header("Authorization", AUTH)+ .when().get("/backup-jobs/" + oldJob).then().statusCode(200).extract().path("State");+ return "FAILED".equals(state) || "COMPLETED".equals(state);+ });+ given().header("Authorization", AUTH)+ .when().get("/backup-jobs/" + oldJob).then().statusCode(200)+ .body("State", equalTo("FAILED"))+ .body("$", not(hasKey("RecoveryPointArn")));+ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + vault + "/recovery-points/").then().statusCode(200)+ .body("RecoveryPoints", empty());+ given().header("Authorization", AUTH)+ .when().get("/backup-vaults/" + vault).then().statusCode(200)+ .body("NumberOfRecoveryPoints", equalTo(0));+ }+}