public void IsSecureConnectionReturnsTrueIfHeaderMatchesAnOffloadHeader() { // Arrange. var mockRequest = new Mock<HttpRequestBase>(); mockRequest.SetupGet(req => req.Headers).Returns(new NameValueCollection { { "SOME_HEADER", "some-value" }, { "SSL_REQUEST", "on" } }); var settings = new Settings(); var evaluator = new HeadersSecurityEvaluator(); // Act. settings.OffloadedSecurityHeaders = "SSL_REQUEST=on"; var resultWithHeaderValueMatch = evaluator.IsSecureConnection(mockRequest.Object, settings); settings.OffloadedSecurityHeaders = "SSL_REQUEST="; var resultWithJustHeaderPresent = evaluator.IsSecureConnection(mockRequest.Object, settings); // Assert. Assert.True(resultWithHeaderValueMatch); Assert.True(resultWithJustHeaderPresent); }
public void IsSecureConnectionReturnsFalseIfNoHeaderMatchesAnOffloadHeader() { // Arrange. var mockRequest = new Mock<HttpRequestBase>(); mockRequest.SetupGet(req => req.Headers).Returns(new NameValueCollection { { "SOME_HEADER", "some-value" } }); var settings = new Settings { OffloadedSecurityHeaders = "SSL_REQUEST=on" }; var evaluator = new HeadersSecurityEvaluator(); // Act. var result = evaluator.IsSecureConnection(mockRequest.Object, settings); // Assert. Assert.False(result); }