Example #1
0
                public void DefaultValue_ReturnsSelf()
                {
                    var builder = new ContentSecurityPolicyBuilder();

                    Assert.Single(builder.Default);
                    Assert.Equal("'self'", builder.Default.First());
                }
Example #2
0
                public void DefaultValue_Empty()
                {
                    var builder = new ContentSecurityPolicyBuilder();

                    Assert.Single(builder.Object);
                    Assert.Equal("'none'", builder.Object.First());
                }
Example #3
0
        private static ContentSecurityPolicyBuilder Builder(bool clear = true)
        {
            var builder = new ContentSecurityPolicyBuilder();

            if (clear)
            {
                builder.Default.Clear();
                builder.Object.Clear();
            }

            return(builder);
        }
                public void WhenCalled_SetsContentSecurityPolicy()
                {
                    var options = Options();
                    var csp     = new ContentSecurityPolicyBuilder();

                    csp.Default.Clear();
                    csp.Object.Clear();
                    csp.Default.Add("https://example.com");

                    options.Configure(csp);

                    Assert.Equal(csp.ToString(), options.ContentSecurityPolicy);
                }
Example #5
0
                public void DefaultValue_Empty()
                {
                    var builder = new ContentSecurityPolicyBuilder();

                    Assert.Empty(builder.Manifest);
                }
Example #6
0
                public void DefaultValue_ReturnsValue()
                {
                    var value = new ContentSecurityPolicyBuilder().ToString();

                    Assert.Equal("default-src 'self'; object-src 'none'", value);
                }
Example #7
0
                public void DefaultValue_Empty()
                {
                    var builder = new ContentSecurityPolicyBuilder();

                    Assert.Empty(builder.StyleAttr);
                }
Example #8
0
                public void DefaultValue_Empty()
                {
                    var builder = new ContentSecurityPolicyBuilder();

                    Assert.Empty(builder.ScriptElem);
                }