diff --git a/docs/services/rds.md b/docs/services/rds.md index 5453ef6daa..a11964a92b 100644 --- a/docs/services/rds.md +++ b/docs/services/rds.md @@ -187,6 +187,7 @@ including empty strings, return `InvalidParameterValue` before changing resource | `CreateDBProxy` | `RequireTLS`, `DebugLogging` | Defaults to `false` | | `ModifyDBProxy` | `RequireTLS`, `DebugLogging` | Preserves the current value | | `ResetDBParameterGroup`, `ResetDBClusterParameterGroup` | `ResetAllParameters` | Defaults to `false`; named parameter resets keep their existing behavior | +| `CopyDBClusterSnapshot` | `CopyTags` | Defaults to `false`; explicit request tags still apply | Malformed reset flags leave saved parameter overrides unchanged. diff --git a/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java index a572f43fca..f7dfc021f6 100644 --- a/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java @@ -2300,7 +2300,7 @@ public class RdsQueryHandler { if (missing != null) { return missing; } - boolean copyTags = "true".equalsIgnoreCase(params.getFirst("CopyTags")); + boolean copyTags = Boolean.TRUE.equals(parseOptionalBoolean(params, "CopyTags")); DbClusterSnapshot copy = service.copyDbClusterSnapshot(sourceId, targetId, copyTags, parseTags(params), region); return Response.ok(AwsQueryResponse.envelope("CopyDBClusterSnapshot", AwsNamespaces.RDS, dbClusterSnapshotXml(copy))).build(); diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java index e7478e38b1..7bac274b28 100644 --- a/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java @@ -2284,6 +2284,51 @@ class RdsQueryHandlerTest { verify(service, never()).startDbCluster(any(), any()); } + @ParameterizedTest + @ValueSource(strings = {"yes", "", "not-a-boolean"}) + void copyClusterSnapshotRejectsMalformedCopyTagsBeforeServiceCall(String value) { + DbClusterSnapshot snapshot = new DbClusterSnapshot(); + snapshot.setDbClusterSnapshotIdentifier("target"); + when(service.copyDbClusterSnapshot(anyString(), anyString(), anyBoolean(), anyMap(), isNull())) + .thenReturn(snapshot); + MultivaluedMap p = params(); + p.putSingle("SourceDBClusterSnapshotIdentifier", "source"); + p.putSingle("TargetDBClusterSnapshotIdentifier", "target"); + p.putSingle("CopyTags", value); + + Response response = handler.handle("CopyDBClusterSnapshot", p); + + assertEquals(400, response.getStatus()); + assertTrue(((String) response.getEntity()).contains("InvalidParameterValue")); + assertTrue(((String) response.getEntity()).contains("CopyTags must be true or false.")); + verifyNoInteractions(service); + } + + @ParameterizedTest + @NullSource + @ValueSource(strings = {"true", "false", "TrUe", "FaLsE"}) + void copyClusterSnapshotPreservesCopyTagsValuesAndDefault(String value) { + DbClusterSnapshot snapshot = new DbClusterSnapshot(); + snapshot.setDbClusterSnapshotIdentifier("target"); + boolean copyTags = Boolean.parseBoolean(value); + when(service.copyDbClusterSnapshot(eq("source"), eq("target"), eq(copyTags), + eq(Map.of("owner", "team")), isNull())).thenReturn(snapshot); + MultivaluedMap p = params(); + p.putSingle("SourceDBClusterSnapshotIdentifier", "source"); + p.putSingle("TargetDBClusterSnapshotIdentifier", "target"); + p.putSingle("Tags.Tag.1.Key", "owner"); + p.putSingle("Tags.Tag.1.Value", "team"); + if (value != null) { + p.putSingle("CopyTags", value); + } + + Response response = handler.handle("CopyDBClusterSnapshot", p); + + assertEquals(200, response.getStatus()); + assertTrue(((String) response.getEntity()).contains("target")); + verify(service).copyDbClusterSnapshot("source", "target", copyTags, Map.of("owner", "team"), null); + } + @Test void clusterSnapshotActions_dispatchAndRenderTheClusterSnapshot() { DbClusterSnapshot snapshot = new DbClusterSnapshot();