From 28d5315cae802920058a98e7eb42128c91af4eca Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 16 Aug 2021 18:34:42 +0200 Subject: [PATCH] Disable SSL certificate validation in Cosmos tests (#25528) --- .../CosmosDbContextOptionsBuilderExtensions.cs | 14 ++++++++++++-- .../TestUtilities/CosmosTestStore.cs | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbContextOptionsBuilderExtensions.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbContextOptionsBuilderExtensions.cs index 6eb831b81f2..cf235a47f0d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbContextOptionsBuilderExtensions.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbContextOptionsBuilderExtensions.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Net.Http; +using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Infrastructure; namespace Microsoft.EntityFrameworkCore.TestUtilities @@ -10,8 +12,16 @@ public static class CosmosDbContextOptionsBuilderExtensions { public static CosmosDbContextOptionsBuilder ApplyConfiguration(this CosmosDbContextOptionsBuilder optionsBuilder) { - optionsBuilder.ExecutionStrategy(d => new TestCosmosExecutionStrategy(d)); - optionsBuilder.RequestTimeout(TimeSpan.FromMinutes(1)); + optionsBuilder + .ExecutionStrategy(d => new TestCosmosExecutionStrategy(d)) + .RequestTimeout(TimeSpan.FromMinutes(20)) + .HttpClientFactory( + () => new HttpClient( + new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + })) + .ConnectionMode(ConnectionMode.Gateway); return optionsBuilder; } diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs index 0714176da40..1bdbb0b6f4f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs @@ -55,12 +55,12 @@ private CosmosTestStore( AuthToken = TestEnvironment.AuthToken; ConnectionString = TestEnvironment.ConnectionString; _configureCosmos = extensionConfiguration == null - ? (Action)(b => b.ApplyConfiguration()) - : (b => + ? b => b.ApplyConfiguration() + : b => { b.ApplyConfiguration(); extensionConfiguration(b); - }); + }; _storeContext = new TestStoreContext(this);