public void Build_WhenNoValues_ReturnsNullValue()
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            var result = builder.Build();

            result.ConstantValue.Should().BeNullOrEmpty();
        }
        public void Build_AddRequireCorp_AddsValue()
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            builder.RequireCorp();

            var result = builder.Build();

            result.ConstantValue.Should().Be("require-corp");
        }
        public void Build_AddUnsafeNone_AddsValue()
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            builder.UnsafeNone();

            var result = builder.Build();

            result.ConstantValue.Should().Be("unsafe-none");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Configure a Cross Origin Embedder Policy
        /// </summary>
        /// <param name="configure">Configure the Cross Origin Embedder Policy</param>
        /// <param name="asReportOnly">If true, the header is added as report only</param>
        /// <returns>The configured <see cref="CrossOriginEmbedderPolicyHeader "/></returns>
        public static CrossOriginEmbedderPolicyHeader Build(Action <CrossOriginEmbedderPolicyBuilder> configure, bool asReportOnly)
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            configure(builder);

            var coopResult = builder.Build();

            return(new StaticCrossOriginEmbedderPolicyHeader(coopResult.ConstantValue, asReportOnly));
        }
        public void Build_AddRequireCorp_WithReportEndpoint_AddsValue()
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            builder.RequireCorp();
            builder.AddReport().To("default");

            var result = builder.Build();

            result.ConstantValue.Should().Be("require-corp; report-to=\"default\"");
        }
        public void Build_AddUnsafeNone_WithReportEndpoint_AddsValue()
        {
            var builder = new CrossOriginEmbedderPolicyBuilder();

            builder.UnsafeNone();
            builder.AddReport().To("default");

            var result = builder.Build();

            result.ConstantValue.Should().Be("unsafe-none; report-to=\"default\"");
        }