public HttpHeaderSecurityModule() { _cspReportHelper = new CspReportHelper(); _configHeaderSetter = new ConfigurationHeaderSetter(); _handlerTypeHelper = new HandlerTypeHelper(); _redirectValidationHelper = new RedirectValidationHelper(); }
public void HeaderModuleTestInitialize() { _mockRequest = new Mock<HttpRequestBase>(); _mockRequest.Setup(r => r.UserAgent).Returns("Ninja CSP browser"); _responseHeaders = new NameValueCollection(); _mockResponse = new Mock<HttpResponseBase>(); _mockResponse.Setup(r => r.Headers).Returns(_responseHeaders); var mockedContext = new Mock<HttpContextBase>(); mockedContext.SetupAllProperties(); mockedContext.Setup(c => c.Request).Returns(_mockRequest.Object); mockedContext.Setup(c => c.Response).Returns(_mockResponse.Object); _expectedHeaderResult = new HeaderResult(HeaderResult.ResponseAction.Set, "SomeHeader", "SomeValue"); _mockHeaderGenerator = new Mock<IHeaderGenerator>(MockBehavior.Strict); _mockHeaderResultHandler = new Mock<IHeaderResultHandler>(MockBehavior.Strict); _mockHeaderResultHandler.Setup(h => h.HandleHeaderResult(It.IsAny<HttpResponseBase>(), _expectedHeaderResult)); _mockHandlerHelper = new Mock<IHandlerTypeHelper>(); _mockCspReportHelper = new Mock<ICspReportHelper>(MockBehavior.Strict); _mockContext = mockedContext.Object; _config = new HttpHeaderSecurityConfigurationSection(); _configHeaderSetter = new ConfigurationHeaderSetter(_config, _mockHeaderGenerator.Object, _mockHeaderResultHandler.Object, _mockHandlerHelper.Object, _mockCspReportHelper.Object); _nwebsecContext = new NWebsecContext(); }