Skip to content

Commit 7bb18e4

Browse files
committed
fixed test that set invalid configuration for access token
1 parent c4660aa commit 7bb18e4

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -911,21 +911,28 @@ public void testBearerTokenAuth() throws Exception {
911911
mockServer.stop();
912912
}
913913
}
914+
915+
private static final String SAMPLE_JWT_TOKEN_FOR_TESTS = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
916+
914917
@Test(groups = { "integration" })
915918
public void testJWTWithCloud() throws Exception {
916-
if (!isCloud()) {
917-
return; // only for cloud
918-
}
919919

920-
String jwt = System.getenv("CLIENT_JWT");
920+
String jwt = isCloud() ? System.getenv("CLIENT_JWT") : SAMPLE_JWT_TOKEN_FOR_TESTS;
921921
Properties properties = new Properties();
922-
properties.put("access_token", jwt);
923-
try (Connection conn = getJdbcConnection(properties);
924-
Statement stmt = conn.createStatement();
925-
ResultSet rs = stmt.executeQuery("SELECT 1")) {
926-
Assert.assertTrue(rs.next());
922+
properties.put(ClientConfigProperties.ACCESS_TOKEN.getKey(), jwt);
923+
properties.put(ClientConfigProperties.USER.getKey(), "default");
924+
properties.put(ClientConfigProperties.DATABASE.getKey(), getDatabase());
925+
926+
try (Connection conn = new ConnectionImpl(getEndpointString(), properties)) {
927+
if (isCloud()) { // else check configuration only
928+
try (Statement stmt = conn.createStatement();
929+
ResultSet rs = stmt.executeQuery("SELECT 1")) {
930+
Assert.assertTrue(rs.next());
931+
}
932+
}
927933
}
928934
}
935+
929936
@Test(groups = { "integration" })
930937
public void testDisableExtraCallToServer() throws Exception {
931938
Properties properties = new Properties();

0 commit comments

Comments
 (0)