Skip to content

Commit

Permalink
Fix keypair tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pbulawa committed Aug 20, 2024
1 parent e2a092d commit b26cec6
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,17 @@ public void testConnectUsingKeyPair() throws Exception {
String encodePublicKey2 = Base64.encodeBase64String(publicKey2.getEncoded());
statement.execute(
String.format("alter user %s set rsa_public_key_2='%s'", testUser, encodePublicKey2));
} finally {
try (Connection connection = DriverManager.getConnection(uri, properties);
Statement statement = connection.createStatement()) {
statement.execute("use role accountadmin");
statement.execute(String.format("alter user %s unset rsa_public_key", testUser));
statement.execute(String.format("alter user %s unset rsa_public_key_2", testUser));
}
}

try (Connection connection = DriverManager.getConnection(uri, properties)) {
assertFalse(connection.isClosed());
}

try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
statement.execute("use role accountadmin");
statement.execute(String.format("alter user %s unset rsa_public_key", testUser));
statement.execute(String.format("alter user %s unset rsa_public_key_2", testUser));
}
}

Expand Down Expand Up @@ -541,8 +545,13 @@ public void testDifferentKeyLength() throws Exception {

// test correct private key one
properties.put("privateKey", privateKey);
try (Connection connection = DriverManager.getConnection(uri, properties);
try (Connection connection = DriverManager.getConnection(uri, properties)) {
assertFalse(connection.isClosed());
}

try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
statement.execute("use role accountadmin");
statement.execute(String.format("alter user %s unset rsa_public_key", testUser));
}
}
Expand Down

0 comments on commit b26cec6

Please sign in to comment.