diff --git a/docs/services/rds.md b/docs/services/rds.md index 07199d4706..2d2814edc3 100644 --- a/docs/services/rds.md +++ b/docs/services/rds.md @@ -177,6 +177,13 @@ checked against the instance's other window. Modifications apply immediately — `arn:aws:rds:::cluster-snapshot:`. RDS reserved instances aren't modeled (there's no reserved-instance API), so tagging doesn't apply to them. +## DB proxy boolean parameters + +`CreateDBProxy` accepts `true` or `false` (case-insensitive) for `RequireTLS` and +`DebugLogging`, defaulting each omitted flag to `false`. Other values, including empty +strings, return `InvalidParameterValue` before a proxy is created. `ModifyDBProxy` +uses the same boolean parsing and preserves an omitted flag's current value. + ## Event notification subscriptions The four subscription actions manage the resource itself. **Nothing is published to the topic.** 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 cb22cc6194..89de38974b 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 @@ -1786,8 +1786,8 @@ public class RdsQueryHandler { validateDbProxyNetworkType(targetConnectionNetworkType, "TargetConnectionNetworkType", false, "IPV4 or IPV6"); String name = params.getFirst("DBProxyName"); String engineFamily = params.getFirst("EngineFamily"); - boolean requireTls = "true".equalsIgnoreCase(params.getFirst("RequireTLS")); - boolean debugLogging = "true".equalsIgnoreCase(params.getFirst("DebugLogging")); + boolean requireTls = Boolean.TRUE.equals(parseOptionalBoolean(params, "RequireTLS")); + boolean debugLogging = Boolean.TRUE.equals(parseOptionalBoolean(params, "DebugLogging")); int idleClientTimeout = 1800; String idleClientTimeoutValue = params.getFirst("IdleClientTimeout"); if (idleClientTimeoutValue != null) { 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 7a1fce2350..e09e54c801 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 @@ -1592,6 +1592,58 @@ class RdsQueryHandlerTest { eq(1800), eq(false), eq(Map.of()), eq("us-west-2"), isNull(), isNull()); } + @ParameterizedTest + @ValueSource(strings = {"RequireTLS", "DebugLogging"}) + void createDbProxyRejectsMalformedBooleanFlagsBeforeCallingService(String parameter) { + when(service.createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(), + anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any())) + .thenReturn(new DbProxy()); + for (String invalid : List.of("yes", "", "1", "0", " true", "false ", "not-a-boolean")) { + MultivaluedMap p = params(); + p.putSingle("DBProxyName", "app-proxy"); + p.putSingle("EngineFamily", "POSTGRESQL"); + p.putSingle(parameter, invalid); + + Response response = handler.handle("CreateDBProxy", p, "us-west-2"); + + assertEquals(400, response.getStatus(), parameter + "=" + invalid); + String body = (String) response.getEntity(); + assertTrue(body.contains("InvalidParameterValue")); + assertTrue(body.contains(parameter + " must be true or false.")); + verifyNoInteractions(service); + } + } + + @ParameterizedTest + @NullSource + @ValueSource(strings = {"true", "false", "TrUe", "FaLsE"}) + void createDbProxyBooleanFlagsPreserveValuesAndDefaults(String value) { + boolean enabled = Boolean.parseBoolean(value); + DbProxy proxy = new DbProxy(); + proxy.setRequireTls(enabled); + proxy.setDebugLogging(enabled); + when(service.createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(enabled), eq(false), + isNull(), isNull(), eq(List.of()), eq(List.of()), eq(List.of()), eq(1800), + eq(enabled), eq(Map.of()), eq("us-west-2"), isNull(), isNull())).thenReturn(proxy); + MultivaluedMap p = params(); + p.putSingle("DBProxyName", "app-proxy"); + p.putSingle("EngineFamily", "POSTGRESQL"); + if (value != null) { + p.putSingle("RequireTLS", value); + p.putSingle("DebugLogging", value); + } + + Response response = handler.handle("CreateDBProxy", p, "us-west-2"); + + assertEquals(200, response.getStatus()); + String body = (String) response.getEntity(); + assertTrue(body.contains("" + enabled + "")); + assertTrue(body.contains("" + enabled + "")); + verify(service).createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(enabled), eq(false), + isNull(), isNull(), eq(List.of()), eq(List.of()), eq(List.of()), eq(1800), + eq(enabled), eq(Map.of()), eq("us-west-2"), isNull(), isNull()); + } + @Test void createDbProxyRejectsInvalidNetworkTypeValuesBeforeCallingService() { // TargetConnectionNetworkType has no DUAL value on real AWS (only EndpointNetworkType does).