Added test coverage around responder middleware, and refactored these to not use test server.

This commit is contained in:
Philip Wood
2017-07-11 18:45:53 +01:00
parent c173f3bb45
commit b0c12431d6
7 changed files with 281 additions and 43 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}