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-1016470: Increase code coverage to at least 90% in JDBC Part2 #1821

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,45 @@ public void testSessionUtilExternalBrowser() throws Throwable {
}
}

// @Test
// public void testSessionUtilExternalBrowserWithConsoleLogin() throws Throwable {
// SFLoginInput loginInput = mock(SFLoginInput.class);
// when(loginInput.getServerUrl()).thenReturn("https://testaccount.snowflakecomputing.com/");
// when(loginInput.getAuthenticator())
// .thenReturn(ClientAuthnDTO.AuthenticatorType.EXTERNALBROWSER.name());
// when(loginInput.getAccountName()).thenReturn("testaccount");
// when(loginInput.getUserName()).thenReturn("testuser");
// when(loginInput.getDisableConsoleLogin()).thenReturn(false);
//
// try (MockedStatic<HttpUtil> mockedHttpUtil = mockStatic(HttpUtil.class)) {
// mockedHttpUtil
// .when(
// () ->
// HttpUtil.executeGeneralRequest(
// Mockito.any(HttpRequestBase.class),
// Mockito.anyInt(),
// Mockito.anyInt(),
// Mockito.anyInt(),
// Mockito.anyInt(),
// Mockito.nullable(HttpClientSettingsKey.class)))
// .thenReturn(
// "{\"success\":\"true\",\"data\":{\"proofKey\":\""
// + MOCK_PROOF_KEY
// + "\","
// + " \"ssoUrl\":\""
// + MOCK_SSO_URL
// + "\"}}");
//
// SessionUtilExternalBrowser sub = FakeSessionUtilExternalBrowser.createInstance(loginInput);
// sub.authenticate();
// assertThat("", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
//
// sub = FakeSessionUtilExternalBrowser.createInstance(loginInput, true);
// sub.authenticate();
// assertThat("", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
// }
// }

/**
* Unit test for SessionUtilExternalBrowser (fail)
*
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/net/snowflake/client/jdbc/BaseJDBCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ protected void expectStatementAlreadyClosedException(MethodRaisesSQLException f)
}
}

protected void expectMapSFExceptionToSQLException(MethodRaisesSQLException f) {
try {
f.run();
fail("must raise exception");
} catch (SQLException ex) {
assertEquals((int) ErrorCode.STATEMENT_CLOSED.getMessageCode(), ex.getErrorCode());
}
}

protected void expectResultSetAlreadyClosedException(MethodRaisesSQLException f) {
try {
f.run();
Expand Down
Loading
Loading