Skip to content

Commit 0eab464

Browse files
authored
Disable cert validation in Https tests (#6133)
1 parent b87ac1d commit 0eab464

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/Servers/IIS/test/Common.FunctionalTests/HttpsTests.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ public async Task HttpsHelloWorld(TestVariant variant)
4444

4545
var deploymentResult = await DeployAsync(deploymentParameters);
4646

47-
var handler = new HttpClientHandler
48-
{
49-
ServerCertificateCustomValidationCallback = (a, b, c, d) => true
50-
};
51-
var client = deploymentResult.CreateClient(handler);
47+
var client = CreateNonValidatingClient(deploymentResult);
5248
var response = await client.GetAsync("HttpsHelloWorld");
5349
var responseText = await response.Content.ReadAsStringAsync();
5450
if (variant.HostingModel == HostingModel.OutOfProcess)
@@ -94,7 +90,9 @@ public async Task ServerAddressesIncludesBaseAddress()
9490
});
9591

9692
var deploymentResult = await DeployAsync(deploymentParameters);
97-
Assert.Equal(deploymentParameters.ApplicationBaseUriHint + appName, await deploymentResult.HttpClient.GetStringAsync($"/{appName}/ServerAddresses"));
93+
var client = CreateNonValidatingClient(deploymentResult);
94+
95+
Assert.Equal(deploymentParameters.ApplicationBaseUriHint + appName, await client.GetStringAsync($"/{appName}/ServerAddresses"));
9896
}
9997

10098
[ConditionalFact]
@@ -115,7 +113,9 @@ public async Task HttpsPortCanBeOverriden()
115113
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_HTTPS_PORT"] = "123";
116114

117115
var deploymentResult = await DeployAsync(deploymentParameters);
118-
Assert.Equal("123", await deploymentResult.HttpClient.GetStringAsync("/HTTPS_PORT"));
116+
var client = CreateNonValidatingClient(deploymentResult);
117+
118+
Assert.Equal("123", await client.GetStringAsync("/HTTPS_PORT"));
119119
}
120120

121121
[ConditionalFact]
@@ -142,7 +142,18 @@ public async Task MultipleHttpsPortsProduceNoEnvVar()
142142
});
143143

144144
var deploymentResult = await DeployAsync(deploymentParameters);
145-
Assert.Equal("NOVALUE", await deploymentResult.HttpClient.GetStringAsync("/HTTPS_PORT"));
145+
var client = CreateNonValidatingClient(deploymentResult);
146+
147+
Assert.Equal("NOVALUE", await client.GetStringAsync("/HTTPS_PORT"));
148+
}
149+
150+
private static HttpClient CreateNonValidatingClient(IISDeploymentResult deploymentResult)
151+
{
152+
var handler = new HttpClientHandler
153+
{
154+
ServerCertificateCustomValidationCallback = (a, b, c, d) => true
155+
};
156+
return deploymentResult.CreateClient(handler);
146157
}
147158

148159
public static int GetNextSSLPort(int avoid = 0)

0 commit comments

Comments
 (0)