public void CreatesCorrectPolicy(string header1, string header2)
        {
            var basePolicy = new ExposeHeaders(new [] { header1, header2 });
            var xml        = basePolicy.GetXml().ToString();

            xml.Should().Be(
                @$ "<expose-headers>
  <header>{header1}</header>
Exemple #2
0
        internal override IDictionary <string, IOpenApiAny> ToDictionary()
        {
            var children = new OpenApiObject();

            if (AllowOrigins != null && AllowOrigins.Any())
            {
                var allowOrigins = new OpenApiArray();
                allowOrigins.AddRange(AllowOrigins.Select(x => new OpenApiString(x)));

                children[AllowOriginsKey] = allowOrigins;
            }

            if (AllowCredentials.HasValue)
            {
                children[AllowCredentialsKey] = new OpenApiBoolean(AllowCredentials.Value);
            }

            if (ExposeHeaders != null && ExposeHeaders.Any())
            {
                var exposeHeaders = new OpenApiArray();
                exposeHeaders.AddRange(ExposeHeaders.Select(x => new OpenApiString(x)));

                children[ExposeHeadersKey] = exposeHeaders;
            }

            if (MaxAge.HasValue)
            {
                children[MaxAgeKey] = new OpenApiInteger(MaxAge.Value);
            }

            if (AllowMethods != null && AllowMethods.Any())
            {
                var allowMethods = new OpenApiArray();
                allowMethods.AddRange(AllowMethods.Select(x => new OpenApiString(x)));

                children[AllowMethodsKey] = allowMethods;
            }

            if (AllowHeaders != null && AllowHeaders.Any())
            {
                var allowHeaders = new OpenApiArray();
                allowHeaders.AddRange(AllowHeaders.Select(x => new OpenApiString(x)));

                children[AllowHeadersKey] = allowHeaders;
            }

            return(new Dictionary <string, IOpenApiAny>()
            {
                { CORSRootKey, children }
            });
        }
Exemple #3
0
 public ISectionPolicy ExposeHeaders(params string[] exposeHeaders)
 {
     _exposedHeaders = new ExposeHeaders(exposeHeaders);
     return(Create());
 }
Exemple #4
0
 public ISectionPolicy AllExposeHeaders()
 {
     _exposedHeaders = new ExposeHeaders();
     return(Create());
 }