Skip to content

Commit 9a0e918

Browse files
authored
[PECO-1898] Update SDK version to resolve CVEs (#591)
* Update SDK version * fix tests as apiClient is being used in sdk now
1 parent 153cba6 commit 9a0e918

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<immutables.value.version>2.9.2</immutables.value.version>
5454
<httpclient.version>4.5.14</httpclient.version>
5555
<commons-io.version>2.14.0</commons-io.version>
56-
<databricks-sdk.version>0.31.1</databricks-sdk.version>
56+
<databricks-sdk.version>0.37.0</databricks-sdk.version>
5757
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
5858
<sql-logic-test.version>0.3</sql-logic-test.version>
5959
<lz4-compression.version>1.8.0</lz4-compression.version>

src/test/java/com/databricks/jdbc/TestConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class TestConstants {
9999
ByteBuffer.allocate(Long.BYTES).putLong(123456789L).array();
100100
public static final String TEST_CLIENT_ID = "test-client-id";
101101
public static final String TEST_TOKEN_URL = "https://test.token.url";
102+
public static final String TEST_AUTH_URL = "https://test.auth.url";
102103
public static final String TEST_DISCOVERY_URL = "https://test.discovery.url";
103104
public static final String TEST_JWT_KID = "test-kid";
104105
public static final String TEST_SCOPE = "test-scope";

src/test/java/com/databricks/jdbc/auth/OAuthRefreshCredentialsProviderTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.databricks.jdbc.auth;
22

3+
import static com.databricks.jdbc.TestConstants.TEST_AUTH_URL;
4+
import static com.databricks.jdbc.TestConstants.TEST_TOKEN_URL;
35
import static org.junit.jupiter.api.Assertions.*;
46
import static org.mockito.ArgumentMatchers.any;
57
import static org.mockito.Mockito.*;
@@ -11,11 +13,11 @@
1113
import com.databricks.sdk.core.HeaderFactory;
1214
import com.databricks.sdk.core.commons.CommonsHttpClient;
1315
import com.databricks.sdk.core.http.Response;
16+
import com.databricks.sdk.core.oauth.OAuthResponse;
1417
import com.databricks.sdk.core.oauth.OpenIDConnectEndpoints;
1518
import com.databricks.sdk.core.oauth.Token;
16-
import java.io.ByteArrayInputStream;
1719
import java.io.IOException;
18-
import java.io.InputStream;
20+
import java.net.URL;
1921
import java.util.Map;
2022
import java.util.Properties;
2123
import org.apache.http.HttpHeaders;
@@ -34,6 +36,9 @@ public class OAuthRefreshCredentialsProviderTest {
3436
@Mock DatabricksConfig databricksConfig;
3537
@Mock CommonsHttpClient httpClient;
3638
@Mock Response httpResponse;
39+
@Mock OAuthResponse oAuthResponse;
40+
41+
@Mock Response response;
3742
private OAuthRefreshCredentialsProvider credentialsProvider;
3843
private static final String REFRESH_TOKEN_URL_DEFAULT =
3944
"jdbc:databricks://host:4423/default;transportMode=http;ssl=1;AuthMech=11;AuthFlow=0;httpPath=/sql/1.0/warehouses/erg6767gg;OAuthRefreshToken=refresh-token";
@@ -89,27 +94,21 @@ void testRefreshSuccess(String refreshTokenUrl) throws Exception {
8994
boolean isDefaultEndpointPath = connectionContext.getTokenEndpoint() == null;
9095
if (isDefaultEndpointPath) {
9196
when(databricksConfig.getOidcEndpoints())
92-
.thenReturn(
93-
new OpenIDConnectEndpoints(
94-
"https://oauth.example.com/oidc/v1/token",
95-
"https://oauth.example.com/oidc/v1/authorize"));
97+
.thenReturn(new OpenIDConnectEndpoints(TEST_TOKEN_URL, TEST_AUTH_URL));
9698
}
9799
credentialsProvider = new OAuthRefreshCredentialsProvider(connectionContext, databricksConfig);
98100

99101
// Reinitialize the OAUTH_RESPONSE InputStream for each test run
100-
InputStream oauthResponse =
101-
new ByteArrayInputStream(
102-
new JSONObject()
103-
.put("access_token", "access-token")
104-
.put("token_type", "token-type")
105-
.put("expires_in", 360)
106-
.put("refresh_token", "refresh-token")
107-
.toString()
108-
.getBytes());
102+
String jsonResponse =
103+
new JSONObject()
104+
.put("access_token", "access-token")
105+
.put("token_type", "token-type")
106+
.put("expires_in", 360)
107+
.put("refresh_token", "refresh-token")
108+
.toString();
109109

110110
when(databricksConfig.getHttpClient()).thenReturn(httpClient);
111-
when(httpClient.execute(any())).thenReturn(httpResponse);
112-
when(httpResponse.getBody()).thenReturn(oauthResponse);
111+
when(httpClient.execute(any())).thenReturn(new Response(jsonResponse, new URL(TEST_TOKEN_URL)));
113112
HeaderFactory headerFactory = credentialsProvider.configure(databricksConfig);
114113
Map<String, String> headers = headerFactory.headers();
115114
assertNotNull(headers.get(HttpHeaders.AUTHORIZATION));

0 commit comments

Comments
 (0)