public async Task GetsNamedPolicy(string policyName)
        {
            // Arrange
            var options = new CorsOptions();
            var policy = new CorsPolicy();
            options.AddPolicy(policyName, policy);

            var corsOptions = Options.Create(options);
            var policyProvider = new DefaultCorsPolicyProvider(corsOptions);

            // Act
            var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName);

            // Assert
            Assert.Same(policy, actualPolicy);
        }
Пример #2
0
        public async Task UsesTheDefaultPolicyName()
        {
            // Arrange
            var options = new CorsOptions();
            var policy  = new CorsPolicy();

            options.AddPolicy(options.DefaultPolicyName, policy);

            var corsOptions = new TestCorsOptions
            {
                Value = options
            };
            var policyProvider = new DefaultCorsPolicyProvider(corsOptions);

            // Act
            var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName : null);

            // Assert
            Assert.Same(policy, actualPolicy);
        }