Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public async Task ConsolidatedMode_Should_Interop_With_Legacy_Initialize_Handsha

private static async Task<string?> ReadJsonRpcResponseAsync(StreamReader reader)
{
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
try
{
return await reader.ReadLineAsync(cts.Token);
Expand Down
9 changes: 0 additions & 9 deletions tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ private async Task<CosmosClient> CreateCosmosClientWithAuth(
break;
}

// Validate the client by performing a lightweight operation
await ValidateCosmosClientAsync(cosmosClient, cancellationToken);

return cosmosClient;
}
Comment thread
chidozieononiwu marked this conversation as resolved.

Expand All @@ -139,12 +136,6 @@ private string GetCosmosBaseUri(string accountName)
};
}

private async Task ValidateCosmosClientAsync(CosmosClient client, CancellationToken cancellationToken = default)
{
// Perform a lightweight operation to validate the client
await client.ReadAccountAsync().WaitAsync(cancellationToken);
}

private async Task<CosmosClient> GetCosmosClientAsync(
string accountName,
string subscription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task GenerateEmbedding_RejectsUntrustedEndpoint(string endpoint)
[Fact]
public async Task ListDatabases_CredentialAuthFails_DoesNotFallBackToKeyAuth()
{
// Arrange: HTTP handler returns 401 so credential-based CosmosClient validation fails
// Arrange: HTTP handler returns 401 so the credential-based database operation fails
var handler = new MockHttpHandler(HttpStatusCode.Unauthorized);
_azureService.GetClient().Returns(new HttpClient(handler));

Expand All @@ -98,7 +98,7 @@ await _azureService.DidNotReceive()
[Fact]
public async Task ListDatabases_CredentialAuthFailsWith403_DoesNotFallBackToKeyAuth()
{
// Arrange: HTTP handler returns 403 so credential-based CosmosClient validation fails
// Arrange: HTTP handler returns 403 so the credential-based database operation fails
var handler = new MockHttpHandler(HttpStatusCode.Forbidden);
_azureService.GetClient().Returns(new HttpClient(handler));

Expand Down Expand Up @@ -128,7 +128,7 @@ public async Task GetCosmosClientAsync_CredentialAuthRequest_QueriesCacheWithCre
_cacheService.GetAsync<List<string>>(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<TimeSpan?>(), Arg.Any<CancellationToken>())
.Returns(default(List<string>));

// Act: client creation fails, but cache lookup has already happened
// Act: the database operation fails, but the client cache lookup has already happened
await Assert.ThrowsAnyAsync<Exception>(() =>
_service.ListDatabases("myaccount", "sub123", AuthMethod.Credential, cancellationToken: TestContext.Current.CancellationToken));

Expand Down Expand Up @@ -156,7 +156,7 @@ public async Task GetCosmosClientAsync_KeyAuthRequest_QueriesCacheWithKeyAuthKey
_cacheService.GetAsync<List<string>>(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<TimeSpan?>(), Arg.Any<CancellationToken>())
.Returns(default(List<string>));

// Act: client creation fails after the cache miss, but cache lookup has already happened
// Act: key authentication setup fails after the cache miss, but cache lookup has already happened
await Assert.ThrowsAnyAsync<Exception>(() =>
_service.ListDatabases("myaccount", "sub123", AuthMethod.Key, cancellationToken: TestContext.Current.CancellationToken));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "",
"TagPrefix": "Azure.Mcp.Tools.Cosmos.Tests",
"Tag": "Azure.Mcp.Tools.Cosmos.Tests_04ac7b75fd"
"Tag": "Azure.Mcp.Tools.Cosmos.Tests_241ef3d966"
}
Loading