public void When_adding_a_token_twice_it_should_only_be_once_in_the_headerValue()
 {
     var list = new CspSandboxTokenList();
     list.AddToken("allow-scripts");
     list.AddToken("allow-scripts");
     list.ToDirectiveValue().Trim().Should().Be("allow-scripts");
 }
Пример #2
0
        public void When_set_to_empty_it_should_return_an_empty_headerValue()
        {
            var list = new CspSandboxTokenList();

            list.SetToEmptyValue();
            list.ToDirectiveValue().Should().BeEmpty();
        }
Пример #3
0
        public void When_adding_a_valid_sandboxToken_it_should_create_a_headerValue()
        {
            var list = new CspSandboxTokenList();

            list.AddToken("allow-scripts");
            list.ToDirectiveValue().Should().Be("allow-scripts");
        }
Пример #4
0
        public void When_adding_a_token_twice_it_should_only_be_once_in_the_headerValue()
        {
            var list = new CspSandboxTokenList();

            list.AddToken("allow-scripts");
            list.AddToken("allow-scripts");
            list.ToDirectiveValue().Trim().Should().Be("allow-scripts");
        }
 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);
 }
Пример #6
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_set_to_empty_it_should_return_an_empty_headerValue()
 {
     var list = new CspSandboxTokenList();
     list.SetToEmptyValue();
     list.ToDirectiveValue().Should().BeEmpty();
 }
 public void When_adding_a_valid_sandboxToken_it_should_create_a_headerValue()
 {
     var list = new CspSandboxTokenList();
     list.AddToken("allow-scripts");
     list.ToDirectiveValue().Should().Be("allow-scripts");
 }