From 3b0acad46b0a625794c98a95241adba9d2351504 Mon Sep 17 00:00:00 2001 From: Adam Kolodziejczyk Date: Thu, 5 Dec 2024 17:34:27 +0100 Subject: [PATCH] code review changes --- .../client/authentication/ExternalBrowserIT.java | 3 +-- .../snowflake/client/authentication/IdTokenIT.java | 14 ++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/test/java/net/snowflake/client/authentication/ExternalBrowserIT.java b/src/test/java/net/snowflake/client/authentication/ExternalBrowserIT.java index 3ad81e3ba..aba5398e0 100644 --- a/src/test/java/net/snowflake/client/authentication/ExternalBrowserIT.java +++ b/src/test/java/net/snowflake/client/authentication/ExternalBrowserIT.java @@ -15,11 +15,10 @@ class ExternalBrowserIT { String login = AuthConnectionParameters.SSO_USER; String password = AuthConnectionParameters.SSO_PASSWORD; - AuthTest authTest; + AuthTest authTest = new AuthTest(); @BeforeEach public void setUp() throws IOException { - authTest = new AuthTest(); AuthTest.deleteIdToken(); } diff --git a/src/test/java/net/snowflake/client/authentication/IdTokenIT.java b/src/test/java/net/snowflake/client/authentication/IdTokenIT.java index f784ab87a..61a739e58 100644 --- a/src/test/java/net/snowflake/client/authentication/IdTokenIT.java +++ b/src/test/java/net/snowflake/client/authentication/IdTokenIT.java @@ -4,12 +4,11 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; -import java.io.IOException; import net.snowflake.client.category.TestTags; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Tag; @@ -22,7 +21,7 @@ class IdTokenIT { String login = AuthConnectionParameters.SSO_USER; String password = AuthConnectionParameters.SSO_PASSWORD; - AuthTest authTest; + AuthTest authTest = new AuthTest(); private static String firstToken; @BeforeAll @@ -30,11 +29,6 @@ public static void globalSetUp() { AuthTest.deleteIdToken(); } - @BeforeEach - public void setUp() throws IOException { - authTest = new AuthTest(); - } - @AfterEach public void tearDown() { authTest.cleanBrowserProcesses(); @@ -51,7 +45,7 @@ void shouldAuthenticateUsingExternalBrowserAndSaveToken() throws InterruptedExce authTest.connectAndProvideCredentials(provideCredentialsThread, connectThread); authTest.verifyExceptionIsNotThrown(); firstToken = authTest.getIdToken(); - verifyFirstTokenWasSaved(); + assertThat("Id token was not saved", firstToken, notNullValue()); } @Test @@ -80,6 +74,6 @@ void shouldOpenBrowserAgainWhenTokenIsDeleted() throws InterruptedException { } private void verifyFirstTokenWasSaved() { - assertThat("Id token was not saved", firstToken, notNullValue()); + assumeTrue(firstToken != null, "token was not saved, skipping test"); } }