Skip to content

Commit 70186c4

Browse files
author
Oleksii Sokol
committed
test
1 parent 6be38ef commit 70186c4

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,7 @@ public CosmosTestContainer()
3232
.WithImage("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator")
3333
.WithName(containerName)
3434
.WithExposedPort(8081)
35-
.WithExposedPort(10250)
36-
.WithExposedPort(10251)
37-
.WithExposedPort(10252)
38-
.WithExposedPort(10253)
39-
.WithExposedPort(10254)
40-
.WithExposedPort(10255)
4135
.WithPortBinding(8081, 8081)
42-
.WithPortBinding(10250, 10250)
43-
.WithPortBinding(10251, 10251)
44-
.WithPortBinding(10252, 10252)
45-
.WithPortBinding(10253, 10253)
46-
.WithPortBinding(10254, 10254)
47-
.WithPortBinding(10255, 10255)
4836
.WithEnvironment("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", "1")
4937
.WithEnvironment("AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE", "127.0.0.1")
5038
.WithEnvironment("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "false")
@@ -98,27 +86,24 @@ public async Task InitializeAsync()
9886
}
9987
}
10088

101-
var database = $"db{Guid.NewGuid().ToString("N")}";
89+
var httpMessageHandler = new HttpClientHandler()
90+
{
91+
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
92+
};
93+
10294

10395
_database = new CosmosDatabase(new CosmosOptions
10496
{
10597
ConnectionString =
10698
$"AccountEndpoint=https://localhost:{publicPort}/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
107-
DatabaseName = database,
99+
DatabaseName = "database",
108100
CollectionName = $"testContainer",
109101
AllowTableCreation = true,
110102
CosmosClientOptions = new CosmosClientOptions()
111103
{
112-
HttpClientFactory = () =>
113-
{
114-
HttpMessageHandler httpMessageHandler = new HttpClientHandler()
115-
{
116-
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
117-
};
118-
119-
return new HttpClient(httpMessageHandler);
120-
},
121-
ConnectionMode = ConnectionMode.Gateway
104+
HttpClientFactory = () => new HttpClient(httpMessageHandler),
105+
ConnectionMode = ConnectionMode.Gateway,
106+
RequestTimeout = TimeSpan.FromMinutes(3)
122107
},
123108
});
124109

0 commit comments

Comments
 (0)