Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public JdbcConfiguration(String url, Properties info) throws SQLException {
initProperties(urlProperties, info);

// after initializing all properties - set final connection URL
boolean useSSL = Boolean.parseBoolean(info.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
boolean useSSLInfo = Boolean.parseBoolean(info.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
boolean useSSLUrlProperties = Boolean.parseBoolean(urlProperties.getOrDefault(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
boolean useSSL = useSSLInfo || useSSLUrlProperties;
String bearerToken = info.getProperty(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), null);
if (bearerToken != null) {
clientProperties.put(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), bearerToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

public class JdbcConfigurationTest {


@Test(dataProvider = "testConnectionUrlDataProvider")
public void testConnectionUrl(String jdbcUrl, String connectionUrl, Properties properties, Map<String, String> expectedClientProps) throws Exception {
JdbcConfiguration configuration = new JdbcConfiguration(jdbcUrl, properties);
Expand All @@ -38,7 +39,7 @@ public static Object[][] testConnectionUrlDataProvider() {
Map<String, String> useSSLParams = Map.of("ssl", "true");
Map<String, String> withListParams = Map.of("database", "default", "param1", "value1", "custom_header1", "val1,val2,val3", "user", "default", "password", "");
Map<String, String> withListParamsQuotes = Map.of("database", "default", "param1", "value1", "custom_header1", "\"role 1,3,4\",'val2',val3", "user", "default", "password", "");

Map<String, String> useDatabaseSSLParams = Map.of("database", "clickhouse", "ssl", "true", "user", "default", "password", "");

return new Object[][] {
{"jdbc:clickhouse://localhost:8123/", "http://localhost:8123", defaultProps, defaultParams},
Expand All @@ -47,7 +48,7 @@ public static Object[][] testConnectionUrlDataProvider() {
{"jdbc:clickhouse://localhost:8443/", "https://localhost:8443", useSSL, useSSLParams},
{"jdbc:clickhouse://localhost:8443/default?param1=value1&custom_header1=val1,val2,val3", "http://localhost:8443", defaultProps, withListParams},
{"jdbc:clickhouse://localhost:8443/default?custom_header1=\"role 1,3,4\",'val2',val3&param1=value1", "http://localhost:8443", defaultProps, withListParamsQuotes},

{"jdbc:clickhouse://localhost:8443/clickhouse?ssl=true", "https://localhost:8443", defaultProps, useDatabaseSSLParams},
};
}

Expand Down
Loading