public ExceptionHandlerMiddleware(OcelotRequestDelegate next,
                                   IOcelotLoggerFactory loggerFactory,
                                   IInternalConfigurationRepository configRepo,
                                   IRequestScopedDataRepository repo)
     : base(loggerFactory.CreateLogger <ExceptionHandlerMiddleware>())
 {
     _configRepo = configRepo;
     _repo       = repo;
     _next       = next;
 }
Esempio n. 2
0
 public DiffClientRateLimitMiddleware(OcelotRequestDelegate next,
                                      IOcelotLoggerFactory loggerFactory,
                                      IClientRateLimitProcessor clientRateLimitProcessor,
                                      CusOcelotConfiguration options)
     : base(loggerFactory.CreateLogger <DiffClientRateLimitMiddleware>())
 {
     _next = next;
     _clientRateLimitProcessor = clientRateLimitProcessor;
     _options = options;
 }
 public HttpHeadersTransformationMiddleware(OcelotRequestDelegate next,
                                            IOcelotLoggerFactory loggerFactory,
                                            IHttpContextRequestHeaderReplacer preReplacer,
                                            IHttpResponseHeaderReplacer postReplacer)
 {
     _next         = next;
     _postReplacer = postReplacer;
     _preReplacer  = preReplacer;
     _logger       = loggerFactory.CreateLogger <HttpHeadersTransformationMiddleware>();
 }
Esempio n. 4
0
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache,
                              ICacheKeyGenerator cacheGeneratot)
     : base(loggerFactory.CreateLogger <OutputCacheMiddleware>())
 {
     _next           = next;
     _outputCache    = outputCache;
     _cacheGeneratot = cacheGeneratot;
 }
Esempio n. 5
0
 public ClaimsToClaimsMiddlewareTests()
 {
     _addHeaders        = new Mock <IAddClaimsToRequest>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <ClaimsToClaimsMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _middleware = new ClaimsToClaimsMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
 }
 public DotNettyHttpMiddleware(
     OcelotRequestDelegate next,
     IDotNettyRequestBuilder dotNettyRequestBuilder,
     IServiceProxyProvider serviceProxyProvider,
     IOcelotLoggerFactory factory) : base(factory.CreateLogger <DotNettyHttpMiddleware>())
 {
     _next = next;
     _dotNettyRequestBuilder = dotNettyRequestBuilder;
     _serviceProxyProvider   = serviceProxyProvider;
 }
Esempio n. 7
0
 public TokenRefreshMiddleware(OcelotRequestDelegate next,
                               IOcelotLoggerFactory loggerFactory,
                               ICustomTokenRefreshService refreshService,
                               OcelotConfiguration options)
     : base(loggerFactory.CreateLogger <AuthenticaitonMiddleware>())
 {
     _next                = next;
     _options             = options;
     _tokenRefreshService = refreshService;
 }
 public DownstreamUrlCreatorMiddlewareTests()
 {
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <DownstreamUrlCreatorMiddleware>()).Returns(_logger.Object);
     _downstreamUrlTemplateVariableReplacer = new Mock <IDownstreamPathPlaceholderReplacer>();
     _downstreamContext.DownstreamRequest   = new HttpRequestMessage(HttpMethod.Get, "https://my.url/abc/?q=123");
     _next = context => Task.CompletedTask;
 }
Esempio n. 9
0
 public ExceptionHandlerMiddleware(OcelotRequestDelegate next,
                                   IOcelotLoggerFactory loggerFactory,
                                   IOcelotConfigurationProvider provider,
                                   IRequestScopedDataRepository repo)
     : base(loggerFactory.CreateLogger <ExceptionHandlerMiddleware>())
 {
     _provider = provider;
     _repo     = repo;
     _next     = next;
 }
 public DownstreamRequestInitialiserMiddleware(OcelotRequestDelegate next,
                                               IOcelotLoggerFactory loggerFactory,
                                               Mapper.IRequestMapper requestMapper,
                                               IDownstreamRequestCreator creator)
     : base(loggerFactory.CreateLogger <DownstreamRequestInitialiserMiddleware>())
 {
     _next          = next;
     _requestMapper = requestMapper;
     _creator       = creator;
 }
Esempio n. 11
0
 public AuthorisationMiddleware(OcelotRequestDelegate next,
                                IClaimsAuthoriser claimsAuthoriser,
                                IScopesAuthoriser scopesAuthoriser,
                                IOcelotLoggerFactory loggerFactory)
 {
     _next             = next;
     _claimsAuthoriser = claimsAuthoriser;
     _scopesAuthoriser = scopesAuthoriser;
     _logger           = loggerFactory.CreateLogger <AuthorisationMiddleware>();
 }
Esempio n. 12
0
 public DownstreamRouteFinderMiddleware(OcelotRequestDelegate next,
                                        IOcelotLoggerFactory loggerFactory,
                                        IDownstreamRouteProviderFactory downstreamRouteFinder,
                                        IMultiplexer multiplexer)
     : base(loggerFactory.CreateLogger <DownstreamRouteFinderMiddleware>())
 {
     _multiplexer = multiplexer;
     _next        = next;
     _factory     = downstreamRouteFinder;
 }
Esempio n. 13
0
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache,
                              IRegionCreator regionCreator)
 {
     _next          = next;
     _outputCache   = outputCache;
     _logger        = loggerFactory.CreateLogger <OutputCacheMiddleware>();
     _regionCreator = regionCreator;
 }
 public AhphAuthenticationMiddleware(OcelotRequestDelegate next,
                                     IOcelotLoggerFactory loggerFactory,
                                     IAhphAuthenticationProcessor ahphAuthenticationProcessor,
                                     AhphOcelotConfiguration options)
     : base(loggerFactory.CreateLogger <AhphAuthenticationMiddleware>())
 {
     _next = next;
     _ahphAuthenticationProcessor = ahphAuthenticationProcessor;
     _options = options;
 }
Esempio n. 15
0
 public HttpRequesterMiddlewareTests()
 {
     _requester     = new Mock <IHttpRequester>();
     _loggerFactory = new Mock <IOcelotLoggerFactory>();
     _logger        = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <HttpRequesterMiddleware>()).Returns(_logger.Object);
     _next       = async context => {
         //do nothing
     };
     _middleware = new HttpRequesterMiddleware(_next, _loggerFactory.Object, _requester.Object);
 }
Esempio n. 16
0
 public ClaimsToDownstreamPathMiddlewareTests()
 {
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <ClaimsToDownstreamPathMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _changePath = new Mock <IChangeDownstreamPathTemplate>();
     _downstreamContext.DownstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "http://test.com"));
     _middleware = new ClaimsToDownstreamPathMiddleware(_next, _loggerFactory.Object, _changePath.Object);
 }
Esempio n. 17
0
 public ResponderMiddleware(OcelotRequestDelegate next,
                            IHttpResponder responder,
                            IOcelotLoggerFactory loggerFactory,
                            IErrorsToHttpStatusCodeMapper codeMapper
                            )
     : base(loggerFactory.CreateLogger <ResponderMiddleware>())
 {
     _next       = next;
     _responder  = responder;
     _codeMapper = codeMapper;
 }
Esempio n. 18
0
 private void WhenICallTheMiddleware()
 {
     _next = (context) => {
         byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
         var    stream    = new MemoryStream(byteArray);
         context.HttpContext.Response.Body = stream;
         return(Task.CompletedTask);
     };
     _middleware = new AuthenticationMiddleware(_next, _factory.Object);
     _middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
 }
 public GrpcHttpMiddleware(OcelotRequestDelegate next,
                           IGrpcChannelFactory grpcChannelFactory,
                           IGrpcServiceDescriptor grpcServiceDescriptor,
                           IGrpcRequestBuilder grpcRequestBuilder,
                           IOcelotLoggerFactory factory) : base(factory.CreateLogger <GrpcHttpMiddleware>())
 {
     this.next = next;
     this.grpcChannelFactory    = grpcChannelFactory;
     this.grpcServiceDescriptor = grpcServiceDescriptor;
     this.grpcRequestBuilder    = grpcRequestBuilder;
 }
 public OutputCacheMiddlewareTests()
 {
     _cache             = new Mock <IOcelotCache <CachedResponse> >();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _cacheKeyGenerator = new CacheKeyGenerator();
     _loggerFactory.Setup(x => x.CreateLogger <OutputCacheMiddleware>()).Returns(_logger.Object);
     _next = context => Task.CompletedTask;
     _downstreamContext.DownstreamRequest = new Ocelot.Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"));
 }
Esempio n. 21
0
 public ResponderMiddlewareTests()
 {
     _responder         = new Mock <IHttpResponder>();
     _codeMapper        = new Mock <IErrorsToHttpStatusCodeMapper>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <ResponderMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _middleware = new ResponderMiddleware(_next, _responder.Object, _loggerFactory.Object, _codeMapper.Object);
 }
Esempio n. 22
0
 public ClaimsToQueryStringMiddlewareTests()
 {
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <ClaimsToQueryStringMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _addQueries = new Mock <IAddQueriesToRequest>();
     _downstreamContext.DownstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "http://test.com"));
     _middleware = new ClaimsToQueryStringMiddleware(_next, _loggerFactory.Object, _addQueries.Object);
 }
Esempio n. 23
0
 public AuthorisationMiddlewareTests()
 {
     _authService       = new Mock <IClaimsAuthoriser>();
     _authScopesService = new Mock <IScopesAuthoriser>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <AuthorisationMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _middleware = new AuthorisationMiddleware(_next, _authService.Object, _authScopesService.Object, _loggerFactory.Object);
 }
 public QueryStringBuilderMiddlewareTests()
 {
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <QueryStringBuilderMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _addQueries = new Mock <IAddQueriesToRequest>();
     _downstreamContext.DownstreamRequest = new HttpRequestMessage();
     _middleware = new QueryStringBuilderMiddleware(_next, _loggerFactory.Object, _addQueries.Object);
 }
 public HttpHeadersTransformationMiddlewareTests()
 {
     _preReplacer       = new Mock <IHttpContextRequestHeaderReplacer>();
     _postReplacer      = new Mock <IHttpResponseHeaderReplacer>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <AuthorisationMiddleware>()).Returns(_logger.Object);
     _next       = context => Task.CompletedTask;
     _middleware = new HttpHeadersTransformationMiddleware(_next, _loggerFactory.Object, _preReplacer.Object, _postReplacer.Object);
 }
Esempio n. 26
0
 public DownstreamRouteFinderMiddleware(OcelotRequestDelegate next,
                                        IOcelotLoggerFactory loggerFactory,
                                        IDownstreamRouteFinder downstreamRouteFinder,
                                        IOcelotConfigurationProvider configProvider,
                                        IMultiplexer multiplexer)
 {
     _configProvider        = configProvider;
     _multiplexer           = multiplexer;
     _next                  = next;
     _downstreamRouteFinder = downstreamRouteFinder;
     _logger                = loggerFactory.CreateLogger <DownstreamRouteFinderMiddleware>();
 }
 public DownstreamRouteFinderMiddlewareTests()
 {
     _repo              = new Mock <IInternalConfigurationRepository>();
     _finder            = new Mock <IDownstreamRouteFinder>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <DownstreamRouteFinderMiddleware>()).Returns(_logger.Object);
     _next        = context => Task.CompletedTask;
     _multiplexer = new Mock <IMultiplexer>();
     _middleware  = new DownstreamRouteFinderMiddleware(_next, _loggerFactory.Object, _finder.Object, _repo.Object, _multiplexer.Object);
 }
Esempio n. 28
0
 public ClaimsBuilderMiddlewareTests()
 {
     _addHeaders        = new Mock <IAddClaimsToRequest>();
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <ClaimsBuilderMiddleware>()).Returns(_logger.Object);
     _next       = async context => {
         //do nothing
     };
     _middleware = new ClaimsBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
 }
Esempio n. 29
0
 public DownstreamRouteFinderMiddleware(OcelotRequestDelegate next,
                                        IOcelotLoggerFactory loggerFactory,
                                        IDownstreamRouteFinder downstreamRouteFinder,
                                        IInternalConfigurationRepository repo,
                                        IMultiplexer multiplexer)
     : base(loggerFactory.CreateLogger <DownstreamRouteFinderMiddleware>())
 {
     _repo                  = repo;
     _multiplexer           = multiplexer;
     _next                  = next;
     _downstreamRouteFinder = downstreamRouteFinder;
 }
Esempio n. 30
0
 public LoadBalancerMiddlewareTests()
 {
     _loadBalancerHouse = new Mock <ILoadBalancerHouse>();
     _loadBalancer      = new Mock <ILoadBalancer>();
     _loadBalancerHouse = new Mock <ILoadBalancerHouse>();
     _downstreamRequest = new HttpRequestMessage(HttpMethod.Get, "http://test.com/");
     _downstreamContext = new DownstreamContext(new DefaultHttpContext());
     _loggerFactory     = new Mock <IOcelotLoggerFactory>();
     _logger            = new Mock <IOcelotLogger>();
     _loggerFactory.Setup(x => x.CreateLogger <LoadBalancingMiddleware>()).Returns(_logger.Object);
     _next = context => Task.CompletedTask;
     _downstreamContext.DownstreamRequest = new DownstreamRequest(_downstreamRequest);
 }