Skip to content

Commit 630edf7

Browse files
feat: add more test cases
1 parent 24c16d5 commit 630edf7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/test/java/com/influxdb/v3/client/internal/FlightSqlClientTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.net.URISyntaxException;
2626
import java.util.Map;
2727

28+
import io.grpc.HttpConnectProxiedSocketAddress;
2829
import io.grpc.ProxyDetector;
2930
import io.grpc.internal.GrpcUtil;
3031
import org.apache.arrow.flight.CallHeaders;
@@ -276,15 +277,23 @@ public void useParamsFromQueryConfig() throws Exception {
276277

277278
@Test
278279
void createProxyDetector() {
280+
String hostUrl = "https://localhost:80";
279281
ClientConfig clientConfig = new ClientConfig.Builder()
280-
.host("https://localhost:80")
282+
.host(hostUrl)
281283
.build();
282284
try (FlightSqlClient flightSqlClient = new FlightSqlClient(clientConfig)) {
283-
String hostUrl = "https://youtube.com";
284285
InetSocketAddress proxyAddress = new InetSocketAddress("localhost", 10000);
285286
ProxyDetector proxyDetector = flightSqlClient.createProxyDetector(hostUrl, proxyAddress);
286287
Assertions.assertThat(proxyDetector.proxyFor(
287-
new InetSocketAddress("142.250.198.142", 80)
288+
new InetSocketAddress("localhost", 80)
289+
)).isEqualTo(HttpConnectProxiedSocketAddress.newBuilder()
290+
.setProxyAddress(proxyAddress)
291+
.setTargetAddress(new InetSocketAddress("localhost", 80))
292+
.build());
293+
294+
// Return null case
295+
Assertions.assertThat(proxyDetector.proxyFor(
296+
new InetSocketAddress("123.2.3.1", 80)
288297
)).isNull();
289298
} catch (Exception e) {
290299
throw new RuntimeException(e);

0 commit comments

Comments
 (0)