コード例 #1
0
        public void When_using_a_comma_in_a_value_it_should_be_escaped()
        {
            var list = new CspSourceList();

            list.AddHost("http://example.com/abcd,/asdas");
            list.ToDirectiveValue().Should().Be("http://example.com/abcd%2C/asdas");
        }
コード例 #2
0
        public void When_set_list_to_none_adding_a_host_should_throw_an_invalidOperationException()
        {
            var list = new CspSourceList();

            list.SetToNone();
            Assert.Throws <InvalidOperationException>(() => list.AddHost("http://www.example.com"));
        }
コード例 #3
0
        public void When_adding_one_host_it_should_create_the_correct_header_value()
        {
            var list = new CspSourceList();

            list.AddHost("http://*.example.com:*/path/file.js");
            list.ToDirectiveValue().Trim().ShouldEqual("http://*.example.com:*/path/file.js");
        }
コード例 #4
0
        public void When_adding_scheme_host_and_keyword_it_should_create_correct_header_value()
        {
            var list = new CspSourceList();

            list.AddScheme("https");
            list.AddKeyword(SourceListKeyword.Self);
            list.AddHost("https://www.example.com/");
            list.ToDirectiveValue().Trim().ShouldEqual("https:  https://www.example.com/  'self'");
        }
コード例 #5
0
 public void When_adding_one_host_it_should_create_the_correct_header_value()
 {
     var list = new CspSourceList();
     list.AddHost("http://*.example.com:*/path/file.js");
     list.ToDirectiveValue().Trim().ShouldEqual("http://*.example.com:*/path/file.js");
 }
コード例 #6
0
 public void When_adding_a_valid_uri_as_host_it_should_not_throw_a_exception()
 {
     var list = new CspSourceList();
     list.AddHost(new Uri("https://www.example.com/abcd/"));
 }
コード例 #7
0
 public void When_adding_a_valid_host_source_it_should_succeed()
 {
     var list = new CspSourceList();
     list.AddHost("http://*.example.com:80/path/");
 }
コード例 #8
0
 public void When_using_a_semicolon_in_a_value_it_should_be_escaped()
 {
     var list = new CspSourceList();
     list.AddHost("http://example.com/abcd;/asdas");
     list.ToDirectiveValue().Should().Be("http://example.com/abcd%3B/asdas");
 }
コード例 #9
0
 public void When_adding_an_invalid_host_source_it_should_fail()
 {
     var list = new CspSourceList();
     Assert.Throws<FormatException>(() => list.AddHost("holy crap this will fail!"));
 }
コード例 #10
0
 public void When_set_list_to_none_adding_a_host_should_throw_an_invalidOperationException()
 {
     var list = new CspSourceList();
     list.SetToNone();
     Assert.Throws<InvalidOperationException>(() => list.AddHost("http://www.example.com"));
 }
コード例 #11
0
 public void When_adding_scheme_host_and_keyword_it_should_create_correct_header_value()
 {
     var list = new CspSourceList();
     list.AddScheme("https");
     list.AddKeyword(SourceListKeyword.Self);
     list.AddHost("https://www.example.com/");
     list.ToDirectiveValue().Trim().ShouldEqual("https:  https://www.example.com/  'self'");
 }
コード例 #12
0
        public void When_adding_a_valid_uri_as_host_it_should_not_throw_a_exception()
        {
            var list = new CspSourceList();

            list.AddHost(new Uri("https://www.example.com/abcd/"));
        }
コード例 #13
0
        public void When_adding_an_invalid_host_source_it_should_fail()
        {
            var list = new CspSourceList();

            Assert.Throws <FormatException>(() => list.AddHost("holy crap this will fail!"));
        }
コード例 #14
0
        public void When_adding_a_valid_host_source_it_should_succeed()
        {
            var list = new CspSourceList();

            list.AddHost("http://*.example.com:80/path/");
        }