Skip to content

Commit 1d3edf8

Browse files
committed
fix revert
1 parent 01cb38e commit 1d3edf8

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

csharp/src/Drivers/Databricks/Auth/OAuthClientCredentialsProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public OAuthClientCredentialsProvider(
7575
private string DetermineTokenEndpoint()
7676
{
7777
// For workspace URLs, the token endpoint is always /oidc/v1/token
78-
// TODO: Might be different for Azure AAD SPs
7978
return $"https://{_host}/oidc/v1/token";
8079
}
8180

@@ -97,7 +96,7 @@ private async Task<string> RefreshTokenInternalAsync(CancellationToken cancellat
9796
response = await _httpClient.SendAsync(request, cancellationToken);
9897
response.EnsureSuccessStatusCode();
9998
}
100-
catch (HttpRequestException ex)
99+
catch (Exception ex)
101100
{
102101
throw new DatabricksException($"Failed to acquire OAuth access token: {ex.Message}", ex);
103102
}

csharp/test/Drivers/Databricks/Auth/OAuthClientCredentialsProviderTests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,56 +27,56 @@ namespace Apache.Arrow.Adbc.Tests.Drivers.Databricks.Auth
2727
{
2828
public class OAuthClientCredentialsProviderTests : TestBase<DatabricksTestConfiguration, DatabricksTestEnvironment>, IDisposable
2929
{
30-
private readonly OAuthClientCredentialsProvider _service;
31-
3230
public OAuthClientCredentialsProviderTests(ITestOutputHelper? outputHelper)
3331
: base(outputHelper, new DatabricksTestEnvironment.Factory())
3432
{
35-
_service = new OAuthClientCredentialsProvider(
33+
}
34+
35+
private OAuthClientCredentialsProvider CreateService()
36+
{
37+
return new OAuthClientCredentialsProvider(
3638
TestConfiguration.OAuthClientId,
3739
TestConfiguration.OAuthClientSecret,
3840
TestConfiguration.HostName,
3941
timeoutMinutes: 1);
4042
}
4143

42-
[Fact]
44+
[SkippableFact]
4345
public void GetAccessToken_WithValidCredentials_ReturnsToken()
4446
{
4547
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
4648

47-
var token = _service.GetAccessToken();
49+
var service = CreateService();
50+
var token = service.GetAccessToken();
4851

4952
Assert.NotNull(token);
5053
Assert.NotEmpty(token);
5154
}
5255

53-
[Fact]
56+
[SkippableFact]
5457
public void GetAccessToken_WithCancellation_ThrowsOperationCanceledException()
5558
{
5659
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
5760

61+
var service = CreateService();
5862
using var cts = new CancellationTokenSource();
5963
cts.Cancel();
6064

61-
Assert.Throws<OperationCanceledException>(() =>
62-
_service.GetAccessToken(cts.Token));
65+
var ex = Assert.ThrowsAny<OperationCanceledException>(() =>
66+
service.GetAccessToken(cts.Token));
67+
Assert.IsType<TaskCanceledException>(ex);
6368
}
6469

65-
[Fact]
70+
[SkippableFact]
6671
public void GetAccessToken_MultipleCalls_ReusesCachedToken()
6772
{
6873
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
6974

70-
var token1 = _service.GetAccessToken();
71-
var token2 = _service.GetAccessToken();
75+
var service = CreateService();
76+
var token1 = service.GetAccessToken();
77+
var token2 = service.GetAccessToken();
7278

7379
Assert.Equal(token1, token2);
7480
}
75-
76-
void IDisposable.Dispose()
77-
{
78-
_service.Dispose();
79-
base.Dispose();
80-
}
8181
}
8282
}

0 commit comments

Comments
 (0)