Exemple #1
0
 public void Setup()
 {
     _authenticators           = new List <IAuthenticator>();
     _basicAuthenticator       = new TestBasicAuthenticator("fark", "farker");
     _bearerTokenAuthenticator = new TestBearerTokenAuthenticator("fark");
     _configuration            = new Configuration();
     _requestMessage           = new HttpRequestMessage();
     _responseMessage          = new HttpResponseMessage(HttpStatusCode.OK);
     _behaviorChain            = Substitute.For <IBehaviorChain>();
     _behaviorChain.InvokeNext().Returns(_responseMessage);
     _actionDescriptor = new ActionDescriptorFactory(_configuration, null, new TypeCache())
                         .CreateDescriptor(null, null);
     _behavior = new AuthenticationBehavior(_behaviorChain, _requestMessage,
                                            _responseMessage, _authenticators, _configuration, _actionDescriptor);
 }
 public void Setup()
 {
     _configuration     = new Configuration();
     _corsEngine        = new CorsEngine();
     _corsConfiguration = new CorsConfiguration();
     _actionDescriptor  = new ActionDescriptor(ActionMethod.From <Handler>(x => x.Get()),
                                               null, null, null, null, null, null, null, new TypeCache());
     _innerResponse = new HttpResponseMessage();
     _behaviorChain = Substitute.For <IBehaviorChain>();
     _behaviorChain.InvokeNext().Returns(_innerResponse);
     _requestMessage = new HttpRequestMessage();
     _requestMessage.Headers.Host = "yourmom.com";
     _requestMessage.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
     _policySources = new List <ICorsPolicySource>();
     _behavior      = new CorsBehavior(_behaviorChain, _corsEngine, _corsConfiguration,
                                       _actionDescriptor, _requestMessage, _policySources, _configuration, null);
 }
            public override async Task <HttpResponseMessage> Invoke()
            {
                await base.Invoke();

                return(await _behaviorChain.InvokeNext());
            }