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 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_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()));
        }