Skip to content

Commit ae6bb29

Browse files
committed
fix revert
1 parent 01cb38e commit ae6bb29

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ private class TokenInfo
4444
public string? AccessToken { get; set; }
4545
public DateTime ExpiresAt { get; set; }
4646

47-
public bool IsExpired => DateTime.UtcNow >= ExpiresAt;
48-
4947
// Add buffer time to refresh token before actual expiration
5048
public bool NeedsRefresh => DateTime.UtcNow >= ExpiresAt.AddMinutes(-5);
5149
}
@@ -75,7 +73,6 @@ public OAuthClientCredentialsProvider(
7573
private string DetermineTokenEndpoint()
7674
{
7775
// For workspace URLs, the token endpoint is always /oidc/v1/token
78-
// TODO: Might be different for Azure AAD SPs
7976
return $"https://{_host}/oidc/v1/token";
8077
}
8178

@@ -97,7 +94,7 @@ private async Task<string> RefreshTokenInternalAsync(CancellationToken cancellat
9794
response = await _httpClient.SendAsync(request, cancellationToken);
9895
response.EnsureSuccessStatusCode();
9996
}
100-
catch (HttpRequestException ex)
97+
catch (Exception ex)
10198
{
10299
throw new DatabricksException($"Failed to acquire OAuth access token: {ex.Message}", ex);
103100
}

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)