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_adding_a_keyword_it_should_create_the_correct_value_for_the_header() { var list = new CspSourceList(); list.AddKeyword(SourceListKeyword.Self); list.ToDirectiveValue().Trim().ShouldEqual("'self'"); }
public void When_adding_keyword_unsafeinline_it_should_create_the_correct_header_value() { var list = new CspSourceList(); list.AddKeyword(SourceListKeyword.UnsafeInline); list.ToDirectiveValue().Trim().ShouldEqual("'unsafe-inline'"); }
public void When_adding_an_scheme_it_should_create_the_correct_value_for_the_header() { var list = new CspSourceList(); list.AddScheme("http"); list.ToDirectiveValue().Trim().ShouldEqual("http:"); }
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_set_list_to_none_it_should_create_header_value_with_none() { var list = new CspSourceList(); list.SetToNone(); list.ToDirectiveValue().ShouldEqual("'none'"); }
public void When_adding_multiple_schemes_it_should_create_the_schemes_whiteSpace_separated() { var list = new CspSourceList(); list.AddScheme("http"); list.AddScheme("ftp"); list.AddScheme("https"); list.ToDirectiveValue().ShouldEqual("http: ftp: https:"); }
public void When_adding_one_scheme_multiple_times_it_should_only_be_once_in_the_header_value() { var list = new CspSourceList(); list.AddScheme("http:"); list.AddScheme("http"); list.ToDirectiveValue().Trim().ShouldEqual("http:"); }
public void When_adding_a_keyword_multiple_times_it_should_return_it_only_once_in_header_value() { var list = new CspSourceList(); list.AddKeyword(SourceListKeyword.Self); list.AddKeyword(SourceListKeyword.Self); list.AddKeyword(SourceListKeyword.Self); list.AddKeyword(SourceListKeyword.Self); list.ToDirectiveValue().Trim().ShouldEqual("'self'"); }
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_addin_mutliple_keywords_it_should_create_the_keywords_whiteSpace_separated() { var list = new CspSourceList(); list.AddKeyword(SourceListKeyword.Self); list.AddKeyword(SourceListKeyword.UnsafeEval); list.AddKeyword(SourceListKeyword.Self); list.AddKeyword(SourceListKeyword.UnsafeInline); list.AddKeyword(SourceListKeyword.UnsafeRedirect); list.ToDirectiveValue().Trim().ShouldEqual("'self' 'unsafe-eval' 'unsafe-inline' 'unsafe-redirect'"); }
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"); }