Skip to content
Closed
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 @@ -7,11 +7,8 @@

import java.sql.DriverPropertyInfo;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.testng.Assert.assertEquals;
Expand All @@ -27,27 +24,31 @@ public void testConnectionUrl(String jdbcUrl, String connectionUrl, Properties p

@DataProvider(name = "testConnectionUrlDataProvider")
public static Object[][] testConnectionUrlDataProvider() {
Properties emptyProps = new Properties();
Properties defaultProps = new Properties();
defaultProps.setProperty(ClientConfigProperties.USER.getKey(), "default");
defaultProps.setProperty(ClientConfigProperties.PASSWORD.getKey(), "");
Properties useSSL = new Properties();
useSSL.put(JdbcConfiguration.USE_SSL_PROP, "true");
Properties bearerToken = new Properties();
bearerToken.put(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), "jwtToken");

Map<String, String> defaultParams = Map.of( "user", "default", "password", "");
Map<String, String> simpleParams = Map.of( "database", "clickhouse", "param1", "value1", "param2", "value2", "user", "default", "password", "");
Map<String, String> useSSLParams = Map.of("ssl", "true");
Map<String, String> useSSLParams = Map.of("database", "clickhouse", "ssl", "true");
Map<String, String> bearerTokenParams = Map.of("database", "clickhouse", "bearer_token", "jwtToken");
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", "");


return new Object[][] {
{"jdbc:clickhouse://localhost:8123/", "http://localhost:8123", defaultProps, defaultParams},
{"jdbc:clickhouse://localhost:8443/clickhouse?param1=value1&param2=value2", "http://localhost:8443", defaultProps, simpleParams},
{"jdbc:clickhouse:https://localhost:8123/clickhouse?param1=value1&param2=value2", "https://localhost:8123", defaultProps, simpleParams},
{"jdbc:clickhouse://localhost:8443/", "https://localhost:8443", useSSL, useSSLParams},
{"jdbc:clickhouse://localhost:8443/clickhouse", "https://localhost:8443", useSSL, useSSLParams},
{"jdbc:clickhouse://localhost:8443/clickhouse?ssl=true", "https://localhost:8443", emptyProps, useSSLParams},
{"jdbc:clickhouse://localhost:8443/clickhouse", "http://localhost:8443", bearerToken, bearerTokenParams},
{"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},

};
}

Expand Down
Loading