public void GetCspSandboxConfigCloned_Configured_ClonesDirective() { var firstDirective = new CspSandboxDirectiveConfiguration { AllowForms = true, AllowPointerLock = true, AllowPopups = true }; var firstConfig = new CspConfiguration(false) { SandboxDirective = firstDirective }; var secondDirective = new CspSandboxDirectiveConfiguration() { AllowSameOrigin = true, AllowScripts = true, AllowTopNavigation = true, Enabled = true }; var secondConfig = new CspConfiguration(false) { SandboxDirective = secondDirective }; var mapper = new CspConfigMapper(); var firstResult = mapper.GetCspSandboxConfigCloned(firstConfig); var secondResult = mapper.GetCspSandboxConfigCloned(secondConfig); Assert.That(firstResult, Is.EqualTo(firstDirective).Using(new CspSandboxDirectiveConfigurationComparer())); Assert.That(secondResult, Is.EqualTo(secondDirective).Using(new CspSandboxDirectiveConfigurationComparer())); }
public void GetCspPluginTypesConfigCloned_Configured_ClonesDirective() { var firstDirective = new CspPluginTypesDirectiveConfiguration() { Enabled = false, MediaTypes = new[] { "application/pdf" } }; var firstConfig = new CspConfiguration(false) { PluginTypesDirective = firstDirective }; var secondDirective = new CspPluginTypesDirectiveConfiguration() { Enabled = true, MediaTypes = new[] { "image/png", "application/pdf" } }; var secondConfig = new CspConfiguration(false) { PluginTypesDirective = secondDirective }; var mapper = new CspConfigMapper(); var firstResult = mapper.GetCspPluginTypesConfigCloned(firstConfig); var secondResult = mapper.GetCspPluginTypesConfigCloned(secondConfig); Assert.That(firstResult, Is.EqualTo(firstDirective).Using(new CspPluginTypesDirectiveConfigurationComparer())); Assert.That(secondResult, Is.EqualTo(secondDirective).Using(new CspPluginTypesDirectiveConfigurationComparer())); }
public void GetCspSandboxConfigCloned_Configured_ClonesDirective() { var firstDirective = new CspSandboxDirectiveConfiguration { AllowForms = true, AllowModals = true, AllowOrientationLock = true, AllowPointerLock = true, AllowPopups = true }; var firstConfig = new CspConfiguration(false) { SandboxDirective = firstDirective }; var secondDirective = new CspSandboxDirectiveConfiguration() { AllowPopupsToEscapeSandbox = true, AllowPresentation = true, AllowSameOrigin = true, AllowScripts = true, AllowTopNavigation = true, Enabled = true }; var secondConfig = new CspConfiguration(false) { SandboxDirective = secondDirective }; var mapper = new CspConfigMapper(); var firstResult = mapper.GetCspSandboxConfigCloned(firstConfig); var secondResult = mapper.GetCspSandboxConfigCloned(secondConfig); Assert.Equal(firstResult, firstDirective, new CspSandboxDirectiveConfigurationEqualityComparer()); Assert.Equal(secondResult, secondDirective, new CspSandboxDirectiveConfigurationEqualityComparer()); }
public void GetCspDirectiveConfigCloned_NoConfig_ReturnsNull() { var mapper = new CspConfigMapper(); var clone = mapper.GetCspDirectiveConfigCloned(null, CspDirectives.ScriptSrc); Assert.Null(clone); }
public void GetCspSandboxConfigCloned_NoConfig_ReturnsNull() { var mapper = new CspConfigMapper(); var clone = mapper.GetCspSandboxConfigCloned(null); Assert.Null(clone); }
public void GetCspPluginTypesConfigCloned_NoConfig_ReturnsNull() { var mapper = new CspConfigMapper(); var clone = mapper.GetCspPluginTypesConfigCloned(null); Assert.IsNull(clone); }
public void GetCspDirectiveConfigCloned_NoDirective_ReturnsNull() { var config = new CspConfiguration(false); var mapper = new CspConfigMapper(); var clone = mapper.GetCspDirectiveConfigCloned(config, CspDirectives.ScriptSrc); Assert.IsNull(clone); }
public void GetCspSandboxConfigCloned_NoDirective_ReturnsNull() { var config = new CspConfiguration(false); var mapper = new CspConfigMapper(); var clone = mapper.GetCspSandboxConfigCloned(config); Assert.IsNull(clone); }
public void GetCspDirectiveConfigCloned_DefaultDirective_ClonesDirective() { var directive = new CspDirectiveConfiguration(); var config = new CspConfiguration(false) { ScriptSrcDirective = directive }; var mapper = new CspConfigMapper(); var clone = mapper.GetCspDirectiveConfigCloned(config, CspDirectives.ScriptSrc); Assert.AreNotSame(directive, clone); Assert.That(clone, Is.EqualTo(directive).Using(new CspDirectiveConfigurationComparer())); }
public void GetCspDirectiveConfigCloned_DefaultDirective_ClonesDirective() { var directive = new CspDirectiveConfiguration(); var config = new CspConfiguration(false) { ScriptSrcDirective = directive }; var mapper = new CspConfigMapper(); var clone = mapper.GetCspDirectiveConfigCloned(config, CspDirectives.ScriptSrc); Assert.NotSame(directive, clone); Assert.Equal(clone, directive, new CspDirectiveConfigurationEqualityComparer()); }
public void GetCspMixedContentConfigCloned_Configured_ClonesDirective(bool enabled) { var directive = new CspMixedContentDirectiveConfiguration { Enabled = enabled }; var cspConfig = new CspConfiguration(false) { MixedContentDirective = directive }; var mapper = new CspConfigMapper(); var result = mapper.GetCspMixedContentConfigCloned(cspConfig); Assert.NotNull(result); Assert.NotSame(directive, result); Assert.Equal(directive.Enabled, result.Enabled); }
public void GetCspDirectiveConfigCloned_Configured_ClonesDirective() { var directive = new CspDirectiveConfiguration { Enabled = false, NoneSrc = true, SelfSrc = true, UnsafeEvalSrc = true, UnsafeInlineSrc = false, CustomSources = new[] { "https://www.nwebsec.com", "www.klings.org" } }; var config = new CspConfiguration(false) { ScriptSrcDirective = directive }; var mapper = new CspConfigMapper(); var clone = mapper.GetCspDirectiveConfigCloned(config, CspDirectives.ScriptSrc); Assert.AreNotSame(directive, clone); Assert.That(clone, Is.EqualTo(directive).Using(new CspDirectiveConfigurationComparer())); }
public void Setup() { _mapper = new CspConfigMapper(); }
public CspConfigMapperTests() { _mapper = new CspConfigMapper(); }