/// <summary> /// Initializes a new instance of the <see cref="XRobotsTagAttribute"/> class /// </summary> public XRobotsTagAttribute() { _config = new XRobotsTagConfiguration { Enabled = true }; _headerConfigurationOverrideHelper = new HeaderConfigurationOverrideHelper(); _headerOverrideHelper = new HeaderOverrideHelper(new CspReportHelper()); }
public void Validate_HeaderDisabled_NoException() { var xRobotsConfig = new XRobotsTagConfiguration { Enabled = false }; _validator.Validate(xRobotsConfig); }
public void CreateXRobotsTagResult_Disabled_ReturnsNull() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = false, NoIndex = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag); Assert.IsNull(result); }
public void Validate_HeaderDisabled_NoException() { var xRobotsConfig = new XRobotsTagConfiguration { Enabled = false }; Assert.DoesNotThrow(() => _validator.Validate(xRobotsConfig)); }
public void Validate_HeaderEnabledWithNoDirectives_ThrowsException() { var xRobotsConfig = new XRobotsTagConfiguration { Enabled = true }; Assert.Throws <Exception>(() => _validator.Validate(xRobotsConfig)); }
public void Validate_HeaderEnabledWithDirectives_NoException() { var xRobotsConfig = new XRobotsTagConfiguration { Enabled = true, NoIndex = true }; Assert.DoesNotThrow(() => _validator.Validate(xRobotsConfig)); }
public void GetXRobotsTagConfiguration_NoOwinContext_ReturnsSystemWebConfig() { var config = new XRobotsTagConfiguration(); _systemWebContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.AreSame(config, result); }
public void GetXRobotsTagWithOverride_ConfigOverriden_ReturnsOverrideElement() { var configOverride = new XRobotsTagConfiguration { Enabled = true, NoIndex = true }; _headerConfigurationOverrideHelper.SetXRobotsTagHeaderOverride(_mockContext, configOverride); Assert.AreSame(configOverride, _headerConfigurationOverrideHelper.GetXRobotsTagWithOverride(_mockContext)); }
public void GetXRobotsTagConfiguration_ReturnsContextConfig() { var config = new XRobotsTagConfiguration(); _nwContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.Same(config, result); }
public void GetXRobotsTagConfiguration_NoOwinContext_ReturnsSystemWebConfig() { var config = new XRobotsTagConfiguration(); _systemWebContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.Same(config, result); }
public void GetXRobotsTagConfiguration_HasOwinConfig_ReturnsOwinConfig() { SetupOwinContext(); var config = new XRobotsTagConfiguration(); _owinContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.AreSame(config, result); }
public void CreateXRobotsTagResult_EnabledWithNoOdp_ReturnsSetXRobotsTagNoOdpResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoOdp = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag); Assert.IsNotNull(result); Assert.AreEqual(HeaderResult.ResponseAction.Set, result.Action); Assert.AreEqual("X-Robots-Tag", result.Name); Assert.AreEqual("noodp", result.Value); }
public void GetXRobotsTagConfiguration_HasOwinConfig_ReturnsOwinConfig() { SetupOwinContext(); var config = new XRobotsTagConfiguration(); _owinContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.Same(config, result); }
public void SetXRobotsTagHeader_NoOverride_DoesNothing() { var contextConfig = new XRobotsTagConfiguration(); _contextHelper.Setup(h => h.GetXRobotsTagConfiguration(It.IsAny<HttpContextBase>())).Returns(contextConfig); _configurationOverrideHelper.Setup(h => h.GetXRobotsTagWithOverride(It.IsAny<HttpContextBase>())).Returns((XRobotsTagConfiguration)null); _overrideHelper.SetXRobotsTagHeader(_mockContext); _headerGenerator.Verify(g => g.CreateXRobotsTagResult(It.IsAny<XRobotsTagConfiguration>(), It.IsAny<XRobotsTagConfiguration>()), Times.Never); _headerResultHandler.Verify(h => h.HandleHeaderResult(It.IsAny<HttpResponseBase>(), It.IsAny<HeaderResult>()), Times.Never); }
public void GetXRobotsTagConfiguration_OwinContextWithoutConfig_ReturnsSystemWebConfig() { SetupOwinContext(); var config = new XRobotsTagConfiguration(); _systemWebContext.XRobotsTag = config; var result = _contextHelper.GetXRobotsTagConfiguration(_mockContext); Assert.AreSame(config, result); }
public void SetXRobotsTagHeader_Override_CreatesAndHandlesHeaderResult() { var contextConfig = new XRobotsTagConfiguration(); var overrideConfig = new XRobotsTagConfiguration(); _contextHelper.Setup(h => h.GetXRobotsTagConfiguration(It.IsAny<HttpContextBase>())).Returns(contextConfig); _configurationOverrideHelper.Setup(h => h.GetXRobotsTagWithOverride(It.IsAny<HttpContextBase>())).Returns(overrideConfig); _headerGenerator.Setup(g => g.CreateXRobotsTagResult(overrideConfig, contextConfig)).Returns(_expectedHeaderResult); _overrideHelper.SetXRobotsTagHeader(_mockContext); _headerResultHandler.Verify(h => h.HandleHeaderResult(It.IsAny<HttpResponseBase>(), _expectedHeaderResult), Times.Once); }
public void SetXRobotsTagHeader_NoOverride_DoesNothing() { var contextConfig = new XRobotsTagConfiguration(); _contextHelper.Setup(h => h.GetXRobotsTagConfiguration(It.IsAny <HttpContextBase>())).Returns(contextConfig); _configurationOverrideHelper.Setup(h => h.GetXRobotsTagWithOverride(It.IsAny <HttpContextBase>())).Returns((XRobotsTagConfiguration)null); _overrideHelper.SetXRobotsTagHeader(_mockContext); _headerGenerator.Verify(g => g.CreateXRobotsTagResult(It.IsAny <XRobotsTagConfiguration>(), It.IsAny <XRobotsTagConfiguration>()), Times.Never); _headerResultHandler.Verify(h => h.HandleHeaderResult(It.IsAny <HttpResponseBase>(), It.IsAny <HeaderResult>()), Times.Never); }
public void SetXRobotsTagHeader_Override_CreatesAndHandlesHeaderResult() { var contextConfig = new XRobotsTagConfiguration(); var overrideConfig = new XRobotsTagConfiguration(); _contextHelper.Setup(h => h.GetXRobotsTagConfiguration(It.IsAny <HttpContextBase>())).Returns(contextConfig); _configurationOverrideHelper.Setup(h => h.GetXRobotsTagWithOverride(It.IsAny <HttpContextBase>())).Returns(overrideConfig); _headerGenerator.Setup(g => g.CreateXRobotsTagResult(overrideConfig, contextConfig)).Returns(_expectedHeaderResult); _overrideHelper.SetXRobotsTagHeader(_mockContext); _headerResultHandler.Verify(h => h.HandleHeaderResult(It.IsAny <HttpResponseBase>(), _expectedHeaderResult), Times.Once); }
public void CreateXRobotsTagResult_EnabledWithMultipleDirectives_ReturnsSetXRobotsTagWithDirectivesResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoIndex = true, NoFollow = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag); Assert.IsNotNull(result); Assert.AreEqual(HeaderResult.ResponseAction.Set, result.Action); Assert.AreEqual("X-Robots-Tag", result.Name); Assert.AreEqual("noindex, nofollow", result.Value); }
public void CreateXRobotsTagResult_EnabledWithNoIndexNoOdp_ReturnsSetXRobotsTagNoIndexOnlyResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoIndex = true, NoOdp = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag); Assert.NotNull(result); Assert.Equal(HeaderResult.ResponseAction.Set, result.Action); Assert.Equal("X-Robots-Tag", result.Name); Assert.Equal("noindex", result.Value); }
public void CreateXRobotsTagResult_EnabledWithNoTranslate_ReturnsSetXRobotsTagNoTranslateResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoTranslate = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag); Assert.IsNotNull(result); Assert.AreEqual(HeaderResult.ResponseAction.Set, result.Action); Assert.AreEqual("X-Robots-Tag", result.Name); Assert.AreEqual("notranslate", result.Value); }
public void CreateXRobotsTagResult_DisabledWithNoIndexInOldConfig_ReturnsRemoveXRobotsTagResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = false, NoIndex = true }; var oldXRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoIndex = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag, oldXRobotsTag); Assert.IsNotNull(result); Assert.AreEqual(HeaderResult.ResponseAction.Remove, result.Action); Assert.AreEqual("X-Robots-Tag", result.Name); }
public void CreateXRobotsTagResult_EnabledWithNoArchiveAndEnabledWithNoIndexInOldConfig_ReturnsSetXRobotsTagNoArchiveResult() { var xRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoArchive = true }; var oldXRobotsTag = new XRobotsTagConfiguration { Enabled = true, NoIndex = true }; var result = _generator.CreateXRobotsTagResult(xRobotsTag, oldXRobotsTag); Assert.IsNotNull(result); Assert.AreEqual(HeaderResult.ResponseAction.Set, result.Action); Assert.AreEqual("X-Robots-Tag", result.Name); Assert.AreEqual("noarchive", result.Value); }
public XRobotsTagOptions() { Config = new XRobotsTagConfiguration(); }
public void Validate_HeaderEnabledWithNoDirectives_ThrowsException() { var xRobotsConfig = new XRobotsTagConfiguration { Enabled = true }; Assert.Throws<Exception>(() => _validator.Validate(xRobotsConfig)); }
internal XRobotsTagOptions() { Config = new XRobotsTagConfiguration(); }
/// <summary> /// Initializes a new instance of the <see cref="XRobotsTagAttribute"/> class /// </summary> public XRobotsTagAttribute() { _config = new XRobotsTagConfiguration { Enabled = true }; _headerConfigurationOverrideHelper = new HeaderConfigurationOverrideHelper(); _headerOverrideHelper = new HeaderOverrideHelper(); }