Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1625156: Fix keypair tests #1871

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading