|
25 | 25 | import java.net.URISyntaxException; |
26 | 26 | import java.util.Map; |
27 | 27 |
|
| 28 | +import io.grpc.HttpConnectProxiedSocketAddress; |
28 | 29 | import io.grpc.ProxyDetector; |
29 | 30 | import io.grpc.internal.GrpcUtil; |
30 | 31 | import org.apache.arrow.flight.CallHeaders; |
@@ -276,15 +277,23 @@ public void useParamsFromQueryConfig() throws Exception { |
276 | 277 |
|
277 | 278 | @Test |
278 | 279 | void createProxyDetector() { |
| 280 | + String hostUrl = "https://localhost:80"; |
279 | 281 | ClientConfig clientConfig = new ClientConfig.Builder() |
280 | | - .host("https://localhost:80") |
| 282 | + .host(hostUrl) |
281 | 283 | .build(); |
282 | 284 | try (FlightSqlClient flightSqlClient = new FlightSqlClient(clientConfig)) { |
283 | | - String hostUrl = "https://youtube.com"; |
284 | 285 | InetSocketAddress proxyAddress = new InetSocketAddress("localhost", 10000); |
285 | 286 | ProxyDetector proxyDetector = flightSqlClient.createProxyDetector(hostUrl, proxyAddress); |
286 | 287 | 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) |
288 | 297 | )).isNull(); |
289 | 298 | } catch (Exception e) { |
290 | 299 | throw new RuntimeException(e); |
|
0 commit comments