|
39 | 39 | import org.junit.jupiter.params.ParameterizedTest; |
40 | 40 | import org.junit.jupiter.params.provider.Arguments; |
41 | 41 | import org.junit.jupiter.params.provider.MethodSource; |
| 42 | +import org.junit.jupiter.params.provider.ValueSource; |
42 | 43 |
|
43 | 44 | public final class ArrowFlightConnectionConfigImplTest { |
44 | 45 |
|
@@ -71,6 +72,22 @@ public void testGetProperty( |
71 | 72 | arrowFlightConnectionConfigFunction.apply(arrowFlightConnectionConfig), is(expected)); |
72 | 73 | } |
73 | 74 |
|
| 75 | + @ParameterizedTest |
| 76 | + @ValueSource(strings = {"true", "TRUE", "True", "tRuE", "1"}) |
| 77 | + public void testUseEncryptionAcceptsTruthyValuesCaseInsensitively(String value) { |
| 78 | + // A connection string value like "TRUE" must enable TLS. Parsing it as false would |
| 79 | + // silently downgrade the connection to plaintext and leak credentials. |
| 80 | + properties.put(USE_ENCRYPTION.camelName(), value); |
| 81 | + assertThat(arrowFlightConnectionConfig.useEncryption(), is(true)); |
| 82 | + } |
| 83 | + |
| 84 | + @ParameterizedTest |
| 85 | + @ValueSource(strings = {"false", "FALSE", "0", ""}) |
| 86 | + public void testUseEncryptionRejectsFalsyValues(String value) { |
| 87 | + properties.put(USE_ENCRYPTION.camelName(), value); |
| 88 | + assertThat(arrowFlightConnectionConfig.useEncryption(), is(false)); |
| 89 | + } |
| 90 | + |
74 | 91 | public static Stream<Arguments> provideParameters() { |
75 | 92 | int port = RANDOM.nextInt(Short.toUnsignedInt(Short.MAX_VALUE)); |
76 | 93 | boolean useEncryption = RANDOM.nextBoolean(); |
|
0 commit comments