From 17a4978c326987c54a3271288d56d9003020c195 Mon Sep 17 00:00:00 2001 From: wfurt Date: Tue, 6 Oct 2020 18:57:25 -0700 Subject: [PATCH 1/2] adjust renegotiation tests to match product change --- .../tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs | 4 +--- .../tests/FunctionalTests/SslStreamNetworkStreamTest.cs | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs index b2becd6ac6a6c..19cc26bba879a 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs @@ -54,15 +54,13 @@ public async Task SslStream_AllowRenegotiation_True_Succeeds() Assert.True(ssl.IsAuthenticated); Assert.True(ssl.IsEncrypted); - // Issue request that triggers regotiation from server. + // Issue request that triggers renegotiation from server. byte[] message = Encoding.UTF8.GetBytes("GET /EchoClientCertificate.ashx HTTP/1.1\r\nHost: corefx-net-tls.azurewebsites.net\r\n\r\n"); await ssl.WriteAsync(message, 0, message.Length); // Initiate Read operation, that results in starting renegotiation as per server response to the above request. int bytesRead = await ssl.ReadAsync(message, 0, message.Length); - // Renegotiation will trigger another validation callback/ - Assert.InRange(validationCount, 2, int.MaxValue); Assert.InRange(bytesRead, 1, message.Length); Assert.Contains("HTTP/1.1 200 OK", Encoding.UTF8.GetString(message)); } diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs index 7882d2ac4e6b6..f3d79cf9fe40f 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs @@ -201,8 +201,6 @@ public async Task SslStream_NetworkStream_Renegotiation_Succeeds(bool useSync) // Initiate Read operation, that results in starting renegotiation as per server response to the above request. int bytesRead = useSync ? ssl.Read(message, 0, message.Length) : await ssl.ReadAsync(message, 0, message.Length); - // renegotiation will trigger validation callback again. - Assert.InRange(validationCount, 2, int.MaxValue); Assert.InRange(bytesRead, 1, message.Length); Assert.Contains("HTTP/1.1 200 OK", Encoding.UTF8.GetString(message)); } From 025b7e0785ceb8d7086ac68158ff956a8c60107f Mon Sep 17 00:00:00 2001 From: wfurt Date: Wed, 7 Oct 2020 12:53:05 -0700 Subject: [PATCH 2/2] add assert for validationCount --- .../tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs | 1 + .../tests/FunctionalTests/SslStreamNetworkStreamTest.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs index 19cc26bba879a..7520221e6e9a3 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAllowRenegotiationTests.cs @@ -61,6 +61,7 @@ public async Task SslStream_AllowRenegotiation_True_Succeeds() // Initiate Read operation, that results in starting renegotiation as per server response to the above request. int bytesRead = await ssl.ReadAsync(message, 0, message.Length); + Assert.Equal(1, validationCount); Assert.InRange(bytesRead, 1, message.Length); Assert.Contains("HTTP/1.1 200 OK", Encoding.UTF8.GetString(message)); } diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs index f3d79cf9fe40f..b7c2fb9a41b05 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs @@ -201,6 +201,7 @@ public async Task SslStream_NetworkStream_Renegotiation_Succeeds(bool useSync) // Initiate Read operation, that results in starting renegotiation as per server response to the above request. int bytesRead = useSync ? ssl.Read(message, 0, message.Length) : await ssl.ReadAsync(message, 0, message.Length); + Assert.Equal(1, validationCount); Assert.InRange(bytesRead, 1, message.Length); Assert.Contains("HTTP/1.1 200 OK", Encoding.UTF8.GetString(message)); }