diff --git a/servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.Tests/Infrastructure/ConsolidatedModeTests.cs b/servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.Tests/Infrastructure/ConsolidatedModeTests.cs index d85ac031b2..f2ea841028 100644 --- a/servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.Tests/Infrastructure/ConsolidatedModeTests.cs +++ b/servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.Tests/Infrastructure/ConsolidatedModeTests.cs @@ -474,7 +474,7 @@ public async Task ConsolidatedMode_Should_Interop_With_Legacy_Initialize_Handsha private static async Task 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); diff --git a/tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs b/tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs index 00bdc9e0a8..740abfc6c7 100644 --- a/tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs +++ b/tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs @@ -122,9 +122,6 @@ private async Task CreateCosmosClientWithAuth( break; } - // Validate the client by performing a lightweight operation - await ValidateCosmosClientAsync(cosmosClient, cancellationToken); - return cosmosClient; } @@ -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 GetCosmosClientAsync( string accountName, string subscription, diff --git a/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/CosmosServiceTests.cs b/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/CosmosServiceTests.cs index 2e1c874fe2..54137cb9ed 100644 --- a/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/CosmosServiceTests.cs +++ b/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/CosmosServiceTests.cs @@ -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)); @@ -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)); @@ -128,7 +128,7 @@ public async Task GetCosmosClientAsync_CredentialAuthRequest_QueriesCacheWithCre _cacheService.GetAsync>(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) .Returns(default(List)); - // 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(() => _service.ListDatabases("myaccount", "sub123", AuthMethod.Credential, cancellationToken: TestContext.Current.CancellationToken)); @@ -156,7 +156,7 @@ public async Task GetCosmosClientAsync_KeyAuthRequest_QueriesCacheWithKeyAuthKey _cacheService.GetAsync>(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) .Returns(default(List)); - // 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(() => _service.ListDatabases("myaccount", "sub123", AuthMethod.Key, cancellationToken: TestContext.Current.CancellationToken)); diff --git a/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/assets.json b/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/assets.json index c081c1c1ca..f79a6ae454 100644 --- a/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/assets.json +++ b/tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.Tests/assets.json @@ -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" }