Skip to content

Commit 3d2c2b7

Browse files
committed
Test fixes
1 parent 405bc54 commit 3d2c2b7

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22
using System.Threading;
33
using System.Threading.Tasks;
44
using Apache.Arrow.Adbc.Drivers.Databricks.Auth;
5-
using Apache.Arrow.Adbc.Tests;
6-
using Apache.Arrow.Adbc.Tests.Drivers.Apache.Spark;
5+
using Apache.Arrow.Adbc.Tests.Drivers.Databricks;
76
using Xunit;
87
using Xunit.Abstractions;
98

109
namespace Apache.Arrow.Adbc.Tests.Drivers.Databricks.Auth
1110
{
12-
public class OAuthClientCredentialsServiceTests : TestBase<SparkTestConfiguration, SparkTestEnvironment>, IDisposable
11+
public class OAuthClientCredentialsServiceTests : TestBase<DatabricksTestConfiguration, DatabricksTestEnvironment>, IDisposable
1312
{
1413
private readonly OAuthClientCredentialsService _service;
1514

1615
public OAuthClientCredentialsServiceTests(ITestOutputHelper? outputHelper)
17-
: base(outputHelper, new SparkTestEnvironment.Factory())
16+
: base(outputHelper, new DatabricksTestEnvironment.Factory())
1817
{
1918
_service = new OAuthClientCredentialsService(
20-
TestConfiguration.Username,
21-
TestConfiguration.Password,
19+
TestConfiguration.OAuthClientId,
20+
TestConfiguration.OAuthClientSecret,
2221
new Uri(TestConfiguration.Uri),
2322
timeoutMinutes: 1);
2423
}
2524

2625
[Fact]
2726
public async Task GetAccessToken_WithValidCredentials_ReturnsToken()
2827
{
28+
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
29+
2930
var token = await _service.GetAccessTokenAsync(CancellationToken.None);
3031

3132
Assert.NotNull(token);
@@ -35,16 +36,20 @@ public async Task GetAccessToken_WithValidCredentials_ReturnsToken()
3536
[Fact]
3637
public async Task GetAccessToken_WithCancellation_ThrowsOperationCanceledException()
3738
{
39+
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
40+
3841
using var cts = new CancellationTokenSource();
3942
cts.Cancel();
4043

41-
await Assert.ThrowsAsync<OperationCanceledException>(() =>
44+
await Assert.ThrowsAsync<TaskCanceledException>(() =>
4245
_service.GetAccessTokenAsync(cts.Token));
4346
}
4447

4548
[Fact]
4649
public async Task GetAccessToken_MultipleCalls_ReusesCachedToken()
4750
{
51+
Skip.IfNot(!string.IsNullOrEmpty(TestConfiguration.OAuthClientId), "OAuth credentials not configured");
52+
4853
var token1 = await _service.GetAccessTokenAsync(CancellationToken.None);
4954
var token2 = await _service.GetAccessTokenAsync(CancellationToken.None);
5055

csharp/test/Drivers/Databricks/DatabricksTestConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18+
using System.Text.Json.Serialization;
1819
using Apache.Arrow.Adbc.Tests.Drivers.Apache.Spark;
1920

2021
namespace Apache.Arrow.Adbc.Tests.Drivers.Databricks
2122
{
2223
public class DatabricksTestConfiguration : SparkTestConfiguration
2324
{
25+
[JsonPropertyName("oauth_client_id"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
26+
public string OAuthClientId { get; set; } = string.Empty;
2427

28+
[JsonPropertyName("oauth_client_secret"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
29+
public string OAuthClientSecret { get; set; } = string.Empty;
2530
}
2631
}

0 commit comments

Comments
 (0)