public void Keywords_should_create_the_correct_header_values()
 {
     var list = new CspSandboxTokenList();
     list.AddKeyword(SandboxKeyword.AllowForms);
     list.AddKeyword(SandboxKeyword.AllowPointerLock);
     list.AddKeyword(SandboxKeyword.AllowPopups);
     list.AddKeyword(SandboxKeyword.AllowSameOrigin);
     list.AddKeyword(SandboxKeyword.AllowScripts);
     list.AddKeyword(SandboxKeyword.AllowTopNavigation);
     var split = list.ToDirectiveValue().Split(new[] {" "}, StringSplitOptions.None).Select(item => item.Trim());
     var expectedValues = new[] {
         "allow-forms", "allow-pointer-lock", "allow-popups", "allow-same-origin", "allow-scripts", "allow-top-navigation"
     };
     split.Should().Contain(expectedValues);
 }
Пример #2
0
        public void Keywords_should_create_the_correct_header_values()
        {
            var list = new CspSandboxTokenList();

            list.AddKeyword(SandboxKeyword.AllowForms);
            list.AddKeyword(SandboxKeyword.AllowPointerLock);
            list.AddKeyword(SandboxKeyword.AllowPopups);
            list.AddKeyword(SandboxKeyword.AllowSameOrigin);
            list.AddKeyword(SandboxKeyword.AllowScripts);
            list.AddKeyword(SandboxKeyword.AllowTopNavigation);
            var split          = list.ToDirectiveValue().Split(new[] { " " }, StringSplitOptions.None).Select(item => item.Trim());
            var expectedValues = new[] {
                "allow-forms", "allow-pointer-lock", "allow-popups", "allow-same-origin", "allow-scripts", "allow-top-navigation"
            };

            split.Should().Contain(expectedValues);
        }
 public void When_add_an_invalid_keyword_it_should_throw_an_argumentOutOfRangeException()
 {
     var list = new CspSandboxTokenList();
     Assert.Throws<ArgumentOutOfRangeException>(() => list.AddKeyword((SandboxKeyword) (-1)));
 }
Пример #4
0
        public void When_add_an_invalid_keyword_it_should_throw_an_argumentOutOfRangeException()
        {
            var list = new CspSandboxTokenList();

            Assert.Throws <ArgumentOutOfRangeException>(() => list.AddKeyword((SandboxKeyword)(-1)));
        }