From 48e59e5ffcd18165b45d3a50ac193fd511933aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Mon, 23 Dec 2019 10:21:52 +0100 Subject: [PATCH] Add acceptance test for failed SSL handshake --- .../Core/SecurityTests.cs | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/Testing/GenHTTP.Testing.Acceptance/Core/SecurityTests.cs b/Testing/GenHTTP.Testing.Acceptance/Core/SecurityTests.cs index f1282f9e..cb7c5149 100644 --- a/Testing/GenHTTP.Testing.Acceptance/Core/SecurityTests.cs +++ b/Testing/GenHTTP.Testing.Acceptance/Core/SecurityTests.cs @@ -8,7 +8,8 @@ using GenHTTP.Testing.Acceptance.Domain; using GenHTTP.Modules.Core; using GenHTTP.Api.Infrastructure; - +using System.Security.Authentication; + namespace GenHTTP.Testing.Acceptance.Core { @@ -168,6 +169,25 @@ public void TestSecurityError() }); } + /// + /// As a web developer, I can decide not to return a certificate which will + /// abort the server SSL handshake. + /// + [Fact] + public void TestNoCertificate() + { + RunSecure((insec, sec) => + { + Assert.Throws(() => + { + var failedRequest = WebRequest.CreateHttp($"https://localhost:{sec}"); + failedRequest.IgnoreSecurityErrors(); + + failedRequest.GetSafeResponse(); + }); + }, host: "myserver"); + } + private static void RunSecure(Action logic, Action? adjustments = null, SecureUpgrade? mode = null, string host = "localhost") { var content = Layout.Create().Add("index", Content.From("Hello Alice!"), true); @@ -176,13 +196,13 @@ private static void RunSecure(Action logic, Action