mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 19:50:49 +08:00 
			
		
		
		
	Added test coverage around responder middleware, and refactored these to not use test server.
This commit is contained in:
		@@ -36,7 +36,7 @@ namespace Ocelot.Authentication.Middleware
 | 
			
		||||
        {
 | 
			
		||||
            if (IsAuthenticatedRoute(DownstreamRoute.ReRoute))
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogDebug($"{context.Request.Path} is an authenticated route. {MiddlwareName} checking if client is authenticated");
 | 
			
		||||
                _logger.LogDebug($"{context.Request.Path} is an authenticated route. {MiddlewareName} checking if client is authenticated");
 | 
			
		||||
 | 
			
		||||
                var authenticationHandler = _authHandlerFactory.Get(_app, DownstreamRoute.ReRoute.AuthenticationOptions);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
 | 
			
		||||
 | 
			
		||||
            if (downstreamRoute.IsError)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"{MiddlwareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}");
 | 
			
		||||
                _logger.LogError($"{MiddlewareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}");
 | 
			
		||||
 | 
			
		||||
                SetPipelineError(downstreamRoute.Errors);
 | 
			
		||||
                return;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,10 +13,10 @@ namespace Ocelot.Middleware
 | 
			
		||||
        protected OcelotMiddleware(IRequestScopedDataRepository requestScopedDataRepository)
 | 
			
		||||
        {
 | 
			
		||||
            _requestScopedDataRepository = requestScopedDataRepository;
 | 
			
		||||
            MiddlwareName = this.GetType().Name;
 | 
			
		||||
            MiddlewareName = this.GetType().Name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string MiddlwareName { get; }
 | 
			
		||||
        public string MiddlewareName { get; }
 | 
			
		||||
 | 
			
		||||
        public bool PipelineError => _requestScopedDataRepository.Get<bool>("OcelotMiddlewareError").Data;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ namespace Ocelot.Responder.Middleware
 | 
			
		||||
            if (PipelineError)
 | 
			
		||||
            {
 | 
			
		||||
                var errors = PipelineErrors;
 | 
			
		||||
                _logger.LogError($"{errors.Count} pipeline errors found in {MiddlwareName}. Setting error response status code");
 | 
			
		||||
                _logger.LogError($"{PipelineErrors.Count} pipeline errors found in {MiddlewareName}. Setting error response status code");
 | 
			
		||||
 | 
			
		||||
                SetErrorResponse(context, errors);
 | 
			
		||||
            }
 | 
			
		||||
@@ -53,7 +53,6 @@ namespace Ocelot.Responder.Middleware
 | 
			
		||||
        private void SetErrorResponse(HttpContext context, List<Error> errors)
 | 
			
		||||
        {
 | 
			
		||||
            var statusCode = _codeMapper.Map(errors);
 | 
			
		||||
 | 
			
		||||
            _responder.SetErrorResponseOnContext(context, statusCode);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user