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"); }
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")); }
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"); }
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'"); }
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"); }
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/")); }
public void When_adding_a_valid_host_source_it_should_succeed() { var list = new CspSourceList(); list.AddHost("http://*.example.com:80/path/"); }
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"); }
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!")); }
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")); }
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'"); }
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/")); }
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!")); }
public void When_adding_a_valid_host_source_it_should_succeed() { var list = new CspSourceList(); list.AddHost("http://*.example.com:80/path/"); }