Example #1
0
        public CspOptions()
        {
            Script  = new CspScriptSrcOptions();
            Style   = new CspStyleSrcOptions();
            Default = new CspDefaultSrcOptions();
#pragma warning disable CS0618 // Type or member is obsolete
            Child = new CspChildSrcOptions();
#pragma warning restore CS0618 // Type or member is obsolete
            Connect         = new CspConnectSrcOptions();
            Manifest        = new CspManifestSrcOptions();
            Font            = new CspFontSrcOptions();
            FormAction      = new CspFormActionOptions();
            Img             = new CspImgSrcOptions();
            Media           = new CspMediaSrcOptions();
            Object          = new CspObjectSrcOptions();
            FrameAncestors  = new CspFrameAncestorsOptions();
            PluginTypes     = new CspPluginTypesOptions();
            Sandbox         = new CspSandboxOptions();
            RequireSri      = new CspRequireSriOptions();
            Frame           = new CspFrameSrcOptions();
            Worker          = new CspWorkerSrcOptions();
            Prefetch        = new CspPrefetchSrcOptions();
            BaseUri         = new CspBaseUriOptions();
            OnSendingHeader = context => Task.CompletedTask;
        }
Example #2
0
        public void WithoutWithStrictDynamic_LeavesStrictDynamicToFalse()
        {
            var builder = new CspScriptsBuilder();

            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.False(options.StrictDynamic);
        }
Example #3
0
        public void AllowUnsafeInline_SetsUnsafeInlineToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.AllowUnsafeInline();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.AllowUnsafeInline);
        }
Example #4
0
        public void From_AddsUrlToAllowedSources()
        {
            var builder = new CspScriptsBuilder();

            builder.From("www.google.com");
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.Equal("www.google.com", options.AllowedSources.Single());
        }
Example #5
0
        public void FromSelf_SetsAllowSelfToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.FromSelf();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.AllowSelf);
        }
Example #6
0
        public void WithStrictDynamic_SetsStrictDynamicToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.WithStrictDynamic();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.StrictDynamic);
        }
Example #7
0
        public void FromNowhere_SetsAllowNoneToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.FromNowhere();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.AllowNone);
        }
Example #8
0
        public void OnlyOverHttps_SetsAllowOnlyHttpsToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.OnlyOverHttps();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.AllowOnlyHttps);
        }
Example #9
0
        public void AddNonce_SetsAddNonceToTrue()
        {
            var builder = new CspScriptsBuilder();

            builder.AddNonce();
            CspScriptSrcOptions options = builder.BuildOptions();

            Assert.True(options.AddNonce);
        }
Example #10
0
 public CspOptions()
 {
     Script         = new CspScriptSrcOptions();
     Style          = new CspStyleSrcOptions();
     Default        = new CspDefaultSrcOptions();
     Child          = new CspChildSrcOptions();
     Connect        = new CspConnectSrcOptions();
     Font           = new CspFontSrcOptions();
     FormAction     = new CspFormActionOptions();
     Img            = new CspImgSrcOptions();
     Media          = new CspMediaSrcOptions();
     Object         = new CspObjectSrcOptions();
     FrameAncestors = new CspFrameAncestorsOptions();
     PluginTypes    = new CspPluginTypesOptions();
     Sandbox        = new CspSandboxOptions();
 }