From ae91e3c8a4989c0bf4a9a13de4e50577f2eef4bc Mon Sep 17 00:00:00 2001 From: Piotr Bulawa Date: Wed, 14 Aug 2024 17:49:59 +0200 Subject: [PATCH] Fix keypair tests --- .../net/snowflake/client/jdbc/ConnectionIT.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java index 2e0a9f13e..a6159b0d2 100644 --- a/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java +++ b/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java @@ -459,8 +459,12 @@ 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)); + } + + try (Connection connection = DriverManager.getConnection(uri, properties)) { + assertFalse(connection.isClosed()); } finally { - try (Connection connection = DriverManager.getConnection(uri, properties); + 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)); @@ -543,7 +547,12 @@ public void testDifferentKeyLength() throws Exception { properties.put("privateKey", privateKey); try (Connection connection = DriverManager.getConnection(uri, properties); Statement statement = connection.createStatement()) { - statement.execute(String.format("alter user %s unset rsa_public_key", testUser)); + assertFalse(connection.isClosed()); + } finally { + try (Connection connection = getConnection(); + Statement statement = connection.createStatement()) { + statement.execute(String.format("alter user %s unset rsa_public_key", testUser)); + } } } }