|
12 | 12 | import com.clickhouse.client.api.enums.ProxyType; |
13 | 13 | import com.clickhouse.client.api.insert.InsertResponse; |
14 | 14 | import com.clickhouse.client.api.insert.InsertSettings; |
| 15 | +import com.clickhouse.client.api.internal.ServerSettings; |
15 | 16 | import com.clickhouse.client.api.query.GenericRecord; |
16 | 17 | import com.clickhouse.client.api.query.QueryResponse; |
17 | 18 | import com.clickhouse.client.api.query.QuerySettings; |
@@ -909,4 +910,31 @@ public void testBearerTokenAuth() throws Exception { |
909 | 910 | mockServer.stop(); |
910 | 911 | } |
911 | 912 | } |
| 913 | + |
| 914 | + @Test |
| 915 | + public void testJWTWithCloud() throws Exception { |
| 916 | + String jwt = System.getenv("CLIENT_JWT"); |
| 917 | + try (Client client = newClient().useBearerTokenAuth(jwt).build()) { |
| 918 | + try { |
| 919 | + List<GenericRecord> response = client.queryAll("SELECT user(), now()"); |
| 920 | + System.out.println("response: " + response.get(0).getString(1) + " time: " + response.get(0).getString(2)); |
| 921 | + } catch (Exception e) { |
| 922 | + e.printStackTrace(); |
| 923 | + throw e; |
| 924 | + } |
| 925 | + } |
| 926 | + } |
| 927 | + |
| 928 | + protected Client.Builder newClient() { |
| 929 | + ClickHouseNode node = getServer(ClickHouseProtocol.HTTP); |
| 930 | + boolean isSecure = isCloud(); |
| 931 | + return new Client.Builder() |
| 932 | + .addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isSecure) |
| 933 | +// .setUsername("default") |
| 934 | +// .setPassword(ClickHouseServerForTest.getPassword()) |
| 935 | + .compressClientRequest(false) |
| 936 | + .setDefaultDatabase(ClickHouseServerForTest.getDatabase()) |
| 937 | + .serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1") |
| 938 | + .useNewImplementation(System.getProperty("client.tests.useNewImplementation", "true").equals("true")); |
| 939 | + } |
912 | 940 | } |
0 commit comments