Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="CorsService"/>.
        /// </summary>
        /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param>
        public CorsService(IOptions<CorsOptions> options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _options = options.Value;
        }
        public void BuildControllerModel_EnableCorsAttributeAddsCorsAuthorizationFilterFactory()
        {
            // Arrange
            var corsOptions = new CorsOptions();
            corsOptions.AddPolicy("policy", new CorsPolicy());
            var mockOptions = new Mock<IOptions<CorsOptions>>();
            mockOptions.SetupGet(o => o.Options)
                       .Returns(corsOptions);
            var builder = new DefaultControllerModelBuilder(new DefaultActionModelBuilder(null),
                authorizationOptions: null);
            var typeInfo = typeof(CorsController).GetTypeInfo();

            // Act
            var model = builder.BuildControllerModel(typeInfo);

            // Assert
            Assert.Single(model.Filters, f => f is CorsAuthorizationFilterFactory);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new instance of the <see cref="CorsService"/>.
 /// </summary>
 /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param>
 public CorsService([NotNull] IOptions<CorsOptions> options)
 {
     _options = options.Options;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of <see cref="DefaultCorsPolicyProvider"/>.
 /// </summary>
 /// <param name="options">The options configured for the application.</param>
 public DefaultCorsPolicyProvider(IOptions<CorsOptions> options)
 {
     _options = options.Value;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="CorsService"/>.
 /// </summary>
 /// <param name="options">The option model representing <see cref="CorsOptions"/>.</param>
 public CorsService([NotNull] IOptions <CorsOptions> options)
 {
     _options = options.Options;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of <see cref="DefaultCorsPolicyProvider"/>.
 /// </summary>
 /// <param name="options">The options configured for the application.</param>
 public DefaultCorsPolicyProvider(IOptions <CorsOptions> options)
 {
     _options = options.Options;
 }