public HttpHeaderSecurityModule() { _cspReportHelper = new CspReportHelper(); _configHeaderSetter = new ConfigurationHeaderSetter(); _handlerTypeHelper = new HandlerTypeHelper(); _redirectValidationHelper = new RedirectValidationHelper(); }
public ConfigurationHeaderSetterTests() { _mockRequest = new Mock <HttpRequestBase>(); _mockRequest.Setup(r => r.UserAgent).Returns("Ninja CSP browser"); var mockResponse = new Mock <HttpResponseBase>(); mockResponse.Setup(r => r.Headers).Returns(new NameValueCollection()); 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 <IHttpContextWrapper>(), _expectedHeaderResult)); _mockHandlerHelper = new Mock <IHandlerTypeHelper>(); _mockCspReportHelper = new Mock <ICspReportHelper>(MockBehavior.Strict); var mockContextBase = mockedContext.Object; _httpContext = new Mock <IHttpContextWrapper>().Object; Mock.Get(_httpContext).Setup(ctx => ctx.GetOriginalHttpContext <HttpContextBase>()).Returns(mockContextBase); _config = new HttpHeaderSecurityConfigurationSection(); _configHeaderSetter = new ConfigurationHeaderSetter(_config, _mockHeaderGenerator.Object, _mockHeaderResultHandler.Object, _mockHandlerHelper.Object, _mockCspReportHelper.Object); _nwebsecContext = new NWebsecContext(); }