Added a get authentication test, removed the infrastructure name space as it seemed pointless, started thinking about how to pass claims on with the request

This commit is contained in:
tom.pallister 2016-10-17 18:00:36 +01:00
parent ce84ad4fc2
commit 3d60602c7e
97 changed files with 614 additions and 508 deletions

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http; namespace Ocelot.Library.Authentication
namespace Ocelot.Library.Infrastructure.Authentication
{ {
using Microsoft.AspNetCore.Http;
public class AuthenticationHandler public class AuthenticationHandler
{ {
public AuthenticationHandler(string provider, RequestDelegate handler) public AuthenticationHandler(string provider, RequestDelegate handler)

View File

@ -1,11 +1,11 @@
namespace Ocelot.Library.Authentication
{
using IdentityServer4.AccessTokenValidation; using IdentityServer4.AccessTokenValidation;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Responses; using Responses;
using AuthenticationOptions = Ocelot.Library.Infrastructure.Configuration.AuthenticationOptions; using AuthenticationOptions = Configuration.AuthenticationOptions;
namespace Ocelot.Library.Infrastructure.Authentication
{
/// <summary> /// <summary>
/// Cannot unit test things in this class due to use of extension methods /// Cannot unit test things in this class due to use of extension methods
/// </summary> /// </summary>

View File

@ -1,11 +1,11 @@
using System.Collections.Generic; namespace Ocelot.Library.Authentication
using Microsoft.AspNetCore.Builder;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
using AuthenticationOptions = Ocelot.Library.Infrastructure.Configuration.AuthenticationOptions;
namespace Ocelot.Library.Infrastructure.Authentication
{ {
using System.Collections.Generic;
using Errors;
using Microsoft.AspNetCore.Builder;
using Responses;
using AuthenticationOptions = Configuration.AuthenticationOptions;
public class AuthenticationHandlerFactory : IAuthenticationHandlerFactory public class AuthenticationHandlerFactory : IAuthenticationHandlerFactory
{ {
private readonly IAuthenticationHandlerCreator _creator; private readonly IAuthenticationHandlerCreator _creator;

View File

@ -0,0 +1,12 @@
namespace Ocelot.Library.Authentication
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Responses;
using AuthenticationOptions = Configuration.AuthenticationOptions;
public interface IAuthenticationHandlerCreator
{
Response<RequestDelegate> CreateIdentityServerAuthenticationHandler(IApplicationBuilder app, AuthenticationOptions authOptions);
}
}

View File

@ -0,0 +1,11 @@
namespace Ocelot.Library.Authentication
{
using Microsoft.AspNetCore.Builder;
using Responses;
using AuthenticationOptions = Configuration.AuthenticationOptions;
public interface IAuthenticationHandlerFactory
{
Response<AuthenticationHandler> Get(IApplicationBuilder app, AuthenticationOptions authOptions);
}
}

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Authentication namespace Ocelot.Library.Authentication
{ {
public enum SupportAuthenticationProviders public enum SupportAuthenticationProviders
{ {

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Authentication
namespace Ocelot.Library.Infrastructure.Authentication
{ {
using Errors;
public class UnableToCreateAuthenticationHandlerError : Error public class UnableToCreateAuthenticationHandlerError : Error
{ {
public UnableToCreateAuthenticationHandlerError(string message) public UnableToCreateAuthenticationHandlerError(string message)

View File

@ -1,7 +1,6 @@
using System.Collections.Generic; namespace Ocelot.Library.Builder
namespace Ocelot.Library.Infrastructure.Builder
{ {
using System.Collections.Generic;
using Configuration; using Configuration;
public class ReRouteBuilder public class ReRouteBuilder

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; namespace Ocelot.Library.Configuration
namespace Ocelot.Library.Infrastructure.Configuration
{ {
using System.Collections.Generic;
public class AuthenticationOptions public class AuthenticationOptions
{ {
public AuthenticationOptions(string provider, string providerRootUrl, string scopeName, bool requireHttps, List<string> additionalScopes, string scopeSecret) public AuthenticationOptions(string provider, string providerRootUrl, string scopeName, bool requireHttps, List<string> additionalScopes, string scopeSecret)

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Configuration
{
using System.Collections.Generic; using System.Collections.Generic;
namespace Ocelot.Library.Infrastructure.Configuration
{
public interface IOcelotConfiguration public interface IOcelotConfiguration
{ {
List<ReRoute> ReRoutes { get; } List<ReRoute> ReRoutes { get; }

View File

@ -1,9 +1,9 @@
namespace Ocelot.Library.Configuration
{
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Ocelot.Library.Infrastructure.Configuration.Yaml; using Yaml;
namespace Ocelot.Library.Infrastructure.Configuration
{
public class OcelotConfiguration : IOcelotConfiguration public class OcelotConfiguration : IOcelotConfiguration
{ {
private readonly IOptions<YamlConfiguration> _options; private readonly IOptions<YamlConfiguration> _options;

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Configuration namespace Ocelot.Library.Configuration
{ {
public class ReRoute public class ReRoute
{ {

View File

@ -1,9 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.Configuration.Yaml
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using System.Collections.Generic;
using Errors;
public class ConfigurationValidationResult public class ConfigurationValidationResult
{ {
public ConfigurationValidationResult(bool isError) public ConfigurationValidationResult(bool isError)

View File

@ -1,12 +1,12 @@
using System; namespace Ocelot.Library.Configuration.Yaml
{
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ocelot.Library.Infrastructure.Authentication; using Authentication;
using Ocelot.Library.Infrastructure.Errors; using Errors;
using Ocelot.Library.Infrastructure.Responses; using Responses;
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{
public class ConfigurationValidator : IConfigurationValidator public class ConfigurationValidator : IConfigurationValidator
{ {
public Response<ConfigurationValidationResult> IsValid(YamlConfiguration configuration) public Response<ConfigurationValidationResult> IsValid(YamlConfiguration configuration)

View File

@ -1,8 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Configuration.Yaml
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using Errors;
public class DownstreamTemplateAlreadyUsedError : Error public class DownstreamTemplateAlreadyUsedError : Error
{ {
public DownstreamTemplateAlreadyUsedError(string message) : base(message, OcelotErrorCode.DownstreamTemplateAlreadyUsedError) public DownstreamTemplateAlreadyUsedError(string message) : base(message, OcelotErrorCode.DownstreamTemplateAlreadyUsedError)

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Responses; namespace Ocelot.Library.Configuration.Yaml
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using Responses;
public interface IConfigurationValidator public interface IConfigurationValidator
{ {
Response<ConfigurationValidationResult> IsValid(YamlConfiguration configuration); Response<ConfigurationValidationResult> IsValid(YamlConfiguration configuration);

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Configuration.Yaml
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using Errors;
public class UnsupportedAuthenticationProviderError : Error public class UnsupportedAuthenticationProviderError : Error
{ {
public UnsupportedAuthenticationProviderError(string message) public UnsupportedAuthenticationProviderError(string message)

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; namespace Ocelot.Library.Configuration.Yaml
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using System.Collections.Generic;
public class YamlAuthenticationOptions public class YamlAuthenticationOptions
{ {
public string Provider { get; set; } public string Provider { get; set; }

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; namespace Ocelot.Library.Configuration.Yaml
namespace Ocelot.Library.Infrastructure.Configuration.Yaml
{ {
using System.Collections.Generic;
public class YamlConfiguration public class YamlConfiguration
{ {
public YamlConfiguration() public YamlConfiguration()

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Configuration.Yaml namespace Ocelot.Library.Configuration.Yaml
{ {
public class YamlReRoute public class YamlReRoute
{ {

View File

@ -0,0 +1,44 @@
namespace Ocelot.Library.DependencyInjection
{
using Authentication;
using Configuration;
using Configuration.Yaml;
using DownstreamRouteFinder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Repository;
using RequestBuilder;
using Requester;
using Responder;
using UrlMatcher;
using UrlTemplateReplacer;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddOcelot(this IServiceCollection services, IConfigurationRoot configurationRoot)
{
services.Configure<YamlConfiguration>(configurationRoot);
// Add framework services.
services.AddSingleton<IConfigurationValidator, ConfigurationValidator>();
services.AddSingleton<IOcelotConfiguration, OcelotConfiguration>();
services.AddSingleton<IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>();
services.AddSingleton<ITemplateVariableNameAndValueFinder, TemplateVariableNameAndValueFinder>();
services.AddSingleton<IDownstreamUrlTemplateVariableReplacer, DownstreamUrlTemplateVariableReplacer>();
services.AddSingleton<IDownstreamRouteFinder, DownstreamRouteFinder>();
services.AddSingleton<IHttpRequester, HttpClientHttpRequester>();
services.AddSingleton<IHttpResponder, HttpContextResponder>();
services.AddSingleton<IRequestBuilder, HttpRequestBuilder>();
services.AddSingleton<IErrorsToHttpStatusCodeMapper, ErrorsToHttpStatusCodeMapper>();
services.AddSingleton<IAuthenticationHandlerFactory, AuthenticationHandlerFactory>();
services.AddSingleton<IAuthenticationHandlerCreator, AuthenticationHandlerCreator>();
// see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IScopedRequestDataRepository, ScopedRequestDataRepository>();
return services;
}
}
}

View File

@ -1,9 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.DownstreamRouteFinder
using Ocelot.Library.Infrastructure.UrlMatcher;
namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
{ {
using System.Collections.Generic;
using Configuration; using Configuration;
using UrlMatcher;
public class DownstreamRoute public class DownstreamRoute
{ {

View File

@ -1,14 +1,13 @@
using System; namespace Ocelot.Library.DownstreamRouteFinder
{
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.Extensions.Options; using Configuration;
using Ocelot.Library.Infrastructure.Configuration; using Errors;
using Ocelot.Library.Infrastructure.Errors; using Responses;
using Ocelot.Library.Infrastructure.Responses; using UrlMatcher;
using Ocelot.Library.Infrastructure.UrlMatcher;
namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
{
public class DownstreamRouteFinder : IDownstreamRouteFinder public class DownstreamRouteFinder : IDownstreamRouteFinder
{ {
private readonly IOcelotConfiguration _configuration; private readonly IOcelotConfiguration _configuration;

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Responses; namespace Ocelot.Library.DownstreamRouteFinder
namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
{ {
using Responses;
public interface IDownstreamRouteFinder public interface IDownstreamRouteFinder
{ {
Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath, string upstreamHttpMethod); Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath, string upstreamHttpMethod);

View File

@ -0,0 +1,11 @@
namespace Ocelot.Library.DownstreamRouteFinder
{
using Errors;
public class UnableToFindDownstreamRouteError : Error
{
public UnableToFindDownstreamRouteError() : base("UnableToFindDownstreamRouteError", OcelotErrorCode.UnableToFindDownstreamRouteError)
{
}
}
}

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Errors namespace Ocelot.Library.Errors
{ {
public abstract class Error public abstract class Error
{ {

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Errors namespace Ocelot.Library.Errors
{ {
public enum OcelotErrorCode public enum OcelotErrorCode
{ {

View File

@ -1,12 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Responses;
using AuthenticationOptions = Ocelot.Library.Infrastructure.Configuration.AuthenticationOptions;
namespace Ocelot.Library.Infrastructure.Authentication
{
public interface IAuthenticationHandlerCreator
{
Response<RequestDelegate> CreateIdentityServerAuthenticationHandler(IApplicationBuilder app, AuthenticationOptions authOptions);
}
}

View File

@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Ocelot.Library.Infrastructure.Responses;
using AuthenticationOptions = Ocelot.Library.Infrastructure.Configuration.AuthenticationOptions;
namespace Ocelot.Library.Infrastructure.Authentication
{
public interface IAuthenticationHandlerFactory
{
Response<AuthenticationHandler> Get(IApplicationBuilder app, AuthenticationOptions authOptions);
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
{
public class UnableToFindDownstreamRouteError : Error
{
public UnableToFindDownstreamRouteError() : base("UnableToFindDownstreamRouteError", OcelotErrorCode.UnableToFindDownstreamRouteError)
{
}
}
}

View File

@ -1,12 +0,0 @@
using System.Net.Http;
using System.Threading.Tasks;
using Ocelot.Library.Infrastructure.RequestBuilder;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Requester
{
public interface IHttpRequester
{
Task<Response<HttpResponseMessage>> GetResponse(Request request);
}
}

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Responder
{
public interface IErrorsToHttpStatusCodeMapper
{
Response<int> Map(List<Error> errors);
}
}

View File

@ -1,9 +0,0 @@
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlMatcher
{
public interface IUrlPathToUrlTemplateMatcher
{
Response<UrlMatch> Match(string upstreamUrlPath, string upstreamUrlPathTemplate);
}
}

View File

@ -1,10 +0,0 @@
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlTemplateReplacer
{
public interface IDownstreamUrlTemplateVariableReplacer
{
Response<string> ReplaceTemplateVariables(DownstreamRoute downstreamRoute);
}
}

View File

@ -1,15 +1,15 @@
using System.Collections.Generic; namespace Ocelot.Library.Middleware
{
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Authentication;
using Configuration;
using DownstreamRouteFinder;
using Errors;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Authentication; using Repository;
using Ocelot.Library.Infrastructure.Configuration;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Repository;
namespace Ocelot.Library.Infrastructure.Middleware
{
public class AuthenticationMiddleware : OcelotMiddleware public class AuthenticationMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class AuthenticationMiddlewareMiddlewareExtensions public static class AuthenticationMiddlewareMiddlewareExtensions
{ {
public static IApplicationBuilder UseAuthenticationMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseAuthenticationMiddleware(this IApplicationBuilder builder)

View File

@ -0,0 +1,23 @@
namespace Ocelot.Library.Middleware
{
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Repository;
public class ClaimsParserMiddleware : OcelotMiddleware
{
private readonly RequestDelegate _next;
public ClaimsParserMiddleware(RequestDelegate next, IScopedRequestDataRepository scopedRequestDataRepository)
: base(scopedRequestDataRepository)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
await _next.Invoke(context);
}
}
}

View File

@ -1,10 +1,10 @@
using System.Threading.Tasks; namespace Ocelot.Library.Middleware
using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Repository;
namespace Ocelot.Library.Infrastructure.Middleware
{ {
using System.Threading.Tasks;
using DownstreamRouteFinder;
using Microsoft.AspNetCore.Http;
using Repository;
public class DownstreamRouteFinderMiddleware : OcelotMiddleware public class DownstreamRouteFinderMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class DownstreamRouteFinderMiddlewareExtensions public static class DownstreamRouteFinderMiddlewareExtensions
{ {
public static IApplicationBuilder UseDownstreamRouteFinderMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseDownstreamRouteFinderMiddleware(this IApplicationBuilder builder)

View File

@ -1,11 +1,11 @@
using System.Threading.Tasks; namespace Ocelot.Library.Middleware
using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.UrlTemplateReplacer;
namespace Ocelot.Library.Infrastructure.Middleware
{ {
using System.Threading.Tasks;
using DownstreamRouteFinder;
using Microsoft.AspNetCore.Http;
using Repository;
using UrlTemplateReplacer;
public class DownstreamUrlCreatorMiddleware : OcelotMiddleware public class DownstreamUrlCreatorMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class DownstreamUrlCreatorMiddlewareExtensions public static class DownstreamUrlCreatorMiddlewareExtensions
{ {
public static IApplicationBuilder UseDownstreamUrlCreatorMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseDownstreamUrlCreatorMiddleware(this IApplicationBuilder builder)

View File

@ -1,10 +1,10 @@
namespace Ocelot.Library.Middleware
{
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Repository; using Repository;
using Ocelot.Library.Infrastructure.RequestBuilder; using RequestBuilder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public class HttpRequestBuilderMiddleware : OcelotMiddleware public class HttpRequestBuilderMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class HttpRequestBuilderMiddlewareExtensions public static class HttpRequestBuilderMiddlewareExtensions
{ {
public static IApplicationBuilder UseHttpRequestBuilderMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseHttpRequestBuilderMiddleware(this IApplicationBuilder builder)

View File

@ -1,11 +1,11 @@
namespace Ocelot.Library.Middleware
{
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Repository; using Repository;
using Ocelot.Library.Infrastructure.RequestBuilder; using RequestBuilder;
using Ocelot.Library.Infrastructure.Requester; using Requester;
namespace Ocelot.Library.Infrastructure.Middleware
{
public class HttpRequesterMiddleware : OcelotMiddleware public class HttpRequesterMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class HttpRequesterMiddlewareExtensions public static class HttpRequesterMiddlewareExtensions
{ {
public static IApplicationBuilder UseHttpRequesterMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseHttpRequesterMiddleware(this IApplicationBuilder builder)

View File

@ -1,11 +1,11 @@
namespace Ocelot.Library.Middleware
{
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Repository; using Repository;
using Ocelot.Library.Infrastructure.Responder; using Responder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public class HttpResponderMiddleware : OcelotMiddleware public class HttpResponderMiddleware : OcelotMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;

View File

@ -1,7 +1,7 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
namespace Ocelot.Library.Infrastructure.Middleware
{
public static class HttpResponderMiddlewareExtensions public static class HttpResponderMiddlewareExtensions
{ {
public static IApplicationBuilder UseHttpResponderMiddleware(this IApplicationBuilder builder) public static IApplicationBuilder UseHttpResponderMiddleware(this IApplicationBuilder builder)

View File

@ -1,10 +1,9 @@
using System.Collections.Generic; namespace Ocelot.Library.Middleware
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Middleware
{ {
using System.Collections.Generic;
using Errors;
using Repository;
public abstract class OcelotMiddleware public abstract class OcelotMiddleware
{ {
private readonly IScopedRequestDataRepository _scopedRequestDataRepository; private readonly IScopedRequestDataRepository _scopedRequestDataRepository;

View File

@ -0,0 +1,24 @@
namespace Ocelot.Library.Middleware
{
using Microsoft.AspNetCore.Builder;
public static class OcelotMiddlewareExtensions
{
public static IApplicationBuilder UseOcelot(this IApplicationBuilder builder)
{
builder.UseHttpResponderMiddleware();
builder.UseDownstreamRouteFinderMiddleware();
builder.UseAuthenticationMiddleware();
builder.UseDownstreamUrlCreatorMiddleware();
builder.UseHttpRequestBuilderMiddleware();
builder.UseHttpRequesterMiddleware();
return builder;
}
}
}

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Middleware
namespace Ocelot.Library.Infrastructure.Middleware
{ {
using Errors;
public class UnauthenticatedError : Error public class UnauthenticatedError : Error
{ {
public UnauthenticatedError(string message) : base(message, OcelotErrorCode.UnauthenticatedError) public UnauthenticatedError(string message) : base(message, OcelotErrorCode.UnauthenticatedError)

View File

@ -1,8 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Repository
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Repository
{ {
using Errors;
public class CannotAddDataError : Error public class CannotAddDataError : Error
{ {
public CannotAddDataError(string message) : base(message, OcelotErrorCode.CannotAddDataError) public CannotAddDataError(string message) : base(message, OcelotErrorCode.CannotAddDataError)

View File

@ -1,8 +1,7 @@
using Ocelot.Library.Infrastructure.Errors; namespace Ocelot.Library.Repository
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Repository
{ {
using Errors;
public class CannotFindDataError : Error public class CannotFindDataError : Error
{ {
public CannotFindDataError(string message) : base(message, OcelotErrorCode.CannotFindDataError) public CannotFindDataError(string message) : base(message, OcelotErrorCode.CannotFindDataError)

View File

@ -1,7 +1,7 @@
using Ocelot.Library.Infrastructure.Responses; namespace Ocelot.Library.Repository
namespace Ocelot.Library.Infrastructure.Repository
{ {
using Responses;
public interface IScopedRequestDataRepository public interface IScopedRequestDataRepository
{ {
Response Add<T>(string key, T value); Response Add<T>(string key, T value);

View File

@ -1,11 +1,11 @@
using System; namespace Ocelot.Library.Repository
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Repository
{ {
using System;
using System.Collections.Generic;
using Errors;
using Microsoft.AspNetCore.Http;
using Responses;
public class ScopedRequestDataRepository : IScopedRequestDataRepository public class ScopedRequestDataRepository : IScopedRequestDataRepository
{ {
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;

View File

@ -1,14 +1,14 @@
using System; namespace Ocelot.Library.RequestBuilder
{
using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Responses; using Responses;
namespace Ocelot.Library.Infrastructure.RequestBuilder
{
public class HttpRequestBuilder : IRequestBuilder public class HttpRequestBuilder : IRequestBuilder
{ {
public async Task<Response<Request>> Build(string httpMethod, string downstreamUrl, Stream content, IHeaderDictionary headers, public async Task<Response<Request>> Build(string httpMethod, string downstreamUrl, Stream content, IHeaderDictionary headers,

View File

@ -1,10 +1,10 @@
using System.IO; namespace Ocelot.Library.RequestBuilder
{
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Responses; using Responses;
namespace Ocelot.Library.Infrastructure.RequestBuilder
{
public interface IRequestBuilder public interface IRequestBuilder
{ {
Task<Response<Request>> Build(string httpMethod, Task<Response<Request>> Build(string httpMethod,

View File

@ -1,8 +1,8 @@
using System.Net; namespace Ocelot.Library.RequestBuilder
{
using System.Net;
using System.Net.Http; using System.Net.Http;
namespace Ocelot.Library.Infrastructure.RequestBuilder
{
public class Request public class Request
{ {
public Request(HttpRequestMessage httpRequestMessage, CookieContainer cookieContainer) public Request(HttpRequestMessage httpRequestMessage, CookieContainer cookieContainer)

View File

@ -1,13 +1,13 @@
using System; namespace Ocelot.Library.Requester
{
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ocelot.Library.Infrastructure.Errors; using Errors;
using Ocelot.Library.Infrastructure.RequestBuilder; using RequestBuilder;
using Ocelot.Library.Infrastructure.Responses; using Responses;
namespace Ocelot.Library.Infrastructure.Requester
{
public class HttpClientHttpRequester : IHttpRequester public class HttpClientHttpRequester : IHttpRequester
{ {
public async Task<Response<HttpResponseMessage>> GetResponse(Request request) public async Task<Response<HttpResponseMessage>> GetResponse(Request request)

View File

@ -0,0 +1,12 @@
namespace Ocelot.Library.Requester
{
using System.Net.Http;
using System.Threading.Tasks;
using RequestBuilder;
using Responses;
public interface IHttpRequester
{
Task<Response<HttpResponseMessage>> GetResponse(Request request);
}
}

View File

@ -1,9 +1,8 @@
using System; namespace Ocelot.Library.Requester
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Requester
{ {
using System;
using Errors;
public class UnableToCompleteRequestError : Error public class UnableToCompleteRequestError : Error
{ {
public UnableToCompleteRequestError(Exception exception) public UnableToCompleteRequestError(Exception exception)

View File

@ -1,10 +1,10 @@
namespace Ocelot.Library.Responder
{
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ocelot.Library.Infrastructure.Errors; using Errors;
using Ocelot.Library.Infrastructure.Responses; using Responses;
namespace Ocelot.Library.Infrastructure.Responder
{
public class ErrorsToHttpStatusCodeMapper : IErrorsToHttpStatusCodeMapper public class ErrorsToHttpStatusCodeMapper : IErrorsToHttpStatusCodeMapper
{ {
public Response<int> Map(List<Error> errors) public Response<int> Map(List<Error> errors)

View File

@ -1,9 +1,9 @@
using System.Net.Http; namespace Ocelot.Library.Responder
{
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
namespace Ocelot.Library.Infrastructure.Responder
{
/// <summary> /// <summary>
/// Cannot unit test things in this class due to methods not being implemented /// Cannot unit test things in this class due to methods not being implemented
/// on .net concretes used for testing /// on .net concretes used for testing

View File

@ -0,0 +1,11 @@
namespace Ocelot.Library.Responder
{
using System.Collections.Generic;
using Errors;
using Responses;
public interface IErrorsToHttpStatusCodeMapper
{
Response<int> Map(List<Error> errors);
}
}

View File

@ -1,9 +1,9 @@
using System.Net.Http; namespace Ocelot.Library.Responder
{
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
namespace Ocelot.Library.Infrastructure.Responder
{
public interface IHttpResponder public interface IHttpResponder
{ {
Task<HttpContext> CreateResponse(HttpContext context, HttpResponseMessage response); Task<HttpContext> CreateResponse(HttpContext context, HttpResponseMessage response);

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.Responses
using Ocelot.Library.Infrastructure.Errors;
namespace Ocelot.Library.Infrastructure.Responses
{ {
using System.Collections.Generic;
using Errors;
public class ErrorResponse : Response public class ErrorResponse : Response
{ {
public ErrorResponse(List<Error> errors) : base(errors) public ErrorResponse(List<Error> errors) : base(errors)

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.Responses
using Ocelot.Library.Infrastructure.Errors;
namespace Ocelot.Library.Infrastructure.Responses
{ {
using System.Collections.Generic;
using Errors;
public class ErrorResponse<T> : Response<T> public class ErrorResponse<T> : Response<T>
{ {
public ErrorResponse(List<Error> errors) : base(errors) public ErrorResponse(List<Error> errors) : base(errors)

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Responses namespace Ocelot.Library.Responses
{ {
public class OkResponse : Response public class OkResponse : Response
{ {

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.Responses namespace Ocelot.Library.Responses
{ {
public class OkResponse<T> : Response<T> public class OkResponse<T> : Response<T>
{ {

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.Responses
using Ocelot.Library.Infrastructure.Errors;
namespace Ocelot.Library.Infrastructure.Responses
{ {
using System.Collections.Generic;
using Errors;
public abstract class Response public abstract class Response
{ {
protected Response() protected Response()

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.Responses
using Ocelot.Library.Infrastructure.Errors;
namespace Ocelot.Library.Infrastructure.Responses
{ {
using System.Collections.Generic;
using Errors;
public abstract class Response<T> : Response public abstract class Response<T> : Response
{ {
protected Response(T data) protected Response(T data)

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.UrlMatcher
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlMatcher
{ {
using System.Collections.Generic;
using Responses;
public interface ITemplateVariableNameAndValueFinder public interface ITemplateVariableNameAndValueFinder
{ {
Response<List<TemplateVariableNameAndValue>> Find(string upstreamUrlPath, string upstreamUrlPathTemplate); Response<List<TemplateVariableNameAndValue>> Find(string upstreamUrlPath, string upstreamUrlPathTemplate);

View File

@ -0,0 +1,9 @@
namespace Ocelot.Library.UrlMatcher
{
using Responses;
public interface IUrlPathToUrlTemplateMatcher
{
Response<UrlMatch> Match(string upstreamUrlPath, string upstreamUrlPathTemplate);
}
}

View File

@ -1,8 +1,8 @@
using System.Text.RegularExpressions; namespace Ocelot.Library.UrlMatcher
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlMatcher
{ {
using System.Text.RegularExpressions;
using Responses;
public class RegExUrlMatcher : IUrlPathToUrlTemplateMatcher public class RegExUrlMatcher : IUrlPathToUrlTemplateMatcher
{ {
public Response<UrlMatch> Match(string upstreamUrlPath, string upstreamUrlPathTemplate) public Response<UrlMatch> Match(string upstreamUrlPath, string upstreamUrlPathTemplate)

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.UrlMatcher namespace Ocelot.Library.UrlMatcher
{ {
public class TemplateVariableNameAndValue public class TemplateVariableNameAndValue
{ {

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; namespace Ocelot.Library.UrlMatcher
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlMatcher
{ {
using System.Collections.Generic;
using Responses;
public class TemplateVariableNameAndValueFinder : ITemplateVariableNameAndValueFinder public class TemplateVariableNameAndValueFinder : ITemplateVariableNameAndValueFinder
{ {
public Response<List<TemplateVariableNameAndValue>> Find(string upstreamUrlPath, string upstreamUrlPathTemplate) public Response<List<TemplateVariableNameAndValue>> Find(string upstreamUrlPath, string upstreamUrlPathTemplate)

View File

@ -1,4 +1,4 @@
namespace Ocelot.Library.Infrastructure.UrlMatcher namespace Ocelot.Library.UrlMatcher
{ {
public class UrlMatch public class UrlMatch
{ {

View File

@ -1,9 +1,9 @@
using System.Text; namespace Ocelot.Library.UrlTemplateReplacer
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.UrlTemplateReplacer
{ {
using System.Text;
using DownstreamRouteFinder;
using Responses;
public class DownstreamUrlTemplateVariableReplacer : IDownstreamUrlTemplateVariableReplacer public class DownstreamUrlTemplateVariableReplacer : IDownstreamUrlTemplateVariableReplacer
{ {
public Response<string> ReplaceTemplateVariables(DownstreamRoute downstreamRoute) public Response<string> ReplaceTemplateVariables(DownstreamRoute downstreamRoute)

View File

@ -0,0 +1,10 @@
namespace Ocelot.Library.UrlTemplateReplacer
{
using DownstreamRouteFinder;
using Responses;
public interface IDownstreamUrlTemplateVariableReplacer
{
Response<string> ReplaceTemplateVariables(DownstreamRoute downstreamRoute);
}
}

View File

@ -1,26 +1,14 @@
using System.Collections.Generic; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ocelot.Library.Infrastructure.Authentication;
using Ocelot.Library.Infrastructure.Configuration;
using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.RequestBuilder;
using Ocelot.Library.Infrastructure.Requester;
using Ocelot.Library.Infrastructure.Responder;
using Ocelot.Library.Infrastructure.UrlMatcher;
using Ocelot.Library.Infrastructure.UrlTemplateReplacer;
namespace Ocelot namespace Ocelot
{ {
using Library.DependencyInjection;
using Library.Middleware;
public class Startup public class Startup
{ {
public Startup(IHostingEnvironment env) public Startup(IHostingEnvironment env)
@ -45,26 +33,7 @@ namespace Ocelot
services.AddMvcCore().AddAuthorization().AddJsonFormatters(); services.AddMvcCore().AddAuthorization().AddJsonFormatters();
services.AddAuthentication(); services.AddAuthentication();
services.AddLogging(); services.AddLogging();
services.AddOcelot(Configuration);
services.Configure<YamlConfiguration>(Configuration);
// Add framework services.
services.AddSingleton<IConfigurationValidator, ConfigurationValidator>();
services.AddSingleton<IOcelotConfiguration, OcelotConfiguration>();
services.AddSingleton<IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>();
services.AddSingleton<ITemplateVariableNameAndValueFinder, TemplateVariableNameAndValueFinder>();
services.AddSingleton<IDownstreamUrlTemplateVariableReplacer, DownstreamUrlTemplateVariableReplacer>();
services.AddSingleton<IDownstreamRouteFinder, DownstreamRouteFinder>();
services.AddSingleton<IHttpRequester, HttpClientHttpRequester>();
services.AddSingleton<IHttpResponder, HttpContextResponder>();
services.AddSingleton<IRequestBuilder, HttpRequestBuilder>();
services.AddSingleton<IErrorsToHttpStatusCodeMapper, ErrorsToHttpStatusCodeMapper>();
services.AddSingleton<IAuthenticationHandlerFactory, AuthenticationHandlerFactory>();
services.AddSingleton<IAuthenticationHandlerCreator, AuthenticationHandlerCreator>();
// see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IScopedRequestDataRepository, ScopedRequestDataRepository>();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -74,17 +43,7 @@ namespace Ocelot
loggerFactory.AddDebug(); loggerFactory.AddDebug();
app.UseHttpResponderMiddleware(); app.UseOcelot();
app.UseDownstreamRouteFinderMiddleware();
app.UseAuthenticationMiddleware();
app.UseDownstreamUrlCreatorMiddleware();
app.UseHttpRequestBuilderMiddleware();
app.UseHttpRequesterMiddleware();
} }
} }
} }

View File

@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
@ -21,6 +20,9 @@ using YamlDotNet.Serialization;
namespace Ocelot.AcceptanceTests namespace Ocelot.AcceptanceTests
{ {
using System.Security.Claims;
using Library.Configuration.Yaml;
public class AuthenticationTests : IDisposable public class AuthenticationTests : IDisposable
{ {
private TestServer _ocelotServer; private TestServer _ocelotServer;
@ -28,7 +30,7 @@ namespace Ocelot.AcceptanceTests
private HttpResponseMessage _response; private HttpResponseMessage _response;
private readonly string _configurationPath; private readonly string _configurationPath;
private StringContent _postContent; private StringContent _postContent;
private IWebHost _ocelotBbuilder; private IWebHost _servicebuilder;
// Sadly we need to change this when we update the netcoreapp version to make the test update the config correctly // Sadly we need to change this when we update the netcoreapp version to make the test update the config correctly
private double _netCoreAppVersion = 1.4; private double _netCoreAppVersion = 1.4;
@ -106,6 +108,42 @@ namespace Ocelot.AcceptanceTests
.BDDfy(); .BDDfy();
} }
[Fact]
public void should_return_response_200_using_identity_server()
{
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:51888", "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51876", 200, "Hello from Laura"))
.And(x => x.GivenIHaveAToken("http://localhost:51888"))
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration
{
ReRoutes = new List<YamlReRoute>
{
new YamlReRoute
{
DownstreamTemplate = "http://localhost:51876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
{
AdditionalScopes = new List<string>(),
Provider = "IdentityServer",
ProviderRootUrl = "http://localhost:51888",
RequireHttps = false,
ScopeName = "api",
ScopeSecret = "secret"
}
}
}
}))
.And(x => x.GivenTheApiGatewayIsRunning())
.And(x => x.GivenIHaveAddedATokenToMyRequest())
.When(x => x.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
.And(x => x.ThenTheResponseBodyShouldBe("Hello from Laura"))
.BDDfy();
}
[Fact] [Fact]
public void should_return_201_using_identity_server_access_token() public void should_return_201_using_identity_server_access_token()
{ {
@ -176,6 +214,21 @@ namespace Ocelot.AcceptanceTests
.BDDfy(); .BDDfy();
} }
private void WhenIGetUrlOnTheApiGateway(string url)
{
_response = _ocelotClient.GetAsync(url).Result;
}
private void WhenIPostUrlOnTheApiGateway(string url)
{
_response = _ocelotClient.PostAsync(url, _postContent).Result;
}
private void ThenTheResponseBodyShouldBe(string expectedBody)
{
_response.Content.ReadAsStringAsync().Result.ShouldBe(expectedBody);
}
private void GivenThePostHasContent(string postcontent) private void GivenThePostHasContent(string postcontent)
{ {
_postContent = new StringContent(postcontent); _postContent = new StringContent(postcontent);
@ -209,7 +262,7 @@ namespace Ocelot.AcceptanceTests
private void GivenThereIsAServiceRunningOn(string url, int statusCode, string responseBody) private void GivenThereIsAServiceRunningOn(string url, int statusCode, string responseBody)
{ {
_ocelotBbuilder = new WebHostBuilder() _servicebuilder = new WebHostBuilder()
.UseUrls(url) .UseUrls(url)
.UseKestrel() .UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
@ -225,7 +278,7 @@ namespace Ocelot.AcceptanceTests
}) })
.Build(); .Build();
_ocelotBbuilder.Start(); _servicebuilder.Start();
} }
private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType) private void GivenThereIsAnIdentityServerOn(string url, string scopeName, AccessTokenType tokenType)
@ -240,7 +293,9 @@ namespace Ocelot.AcceptanceTests
{ {
services.AddLogging(); services.AddLogging();
services.AddDeveloperIdentityServer() services.AddDeveloperIdentityServer()
.AddInMemoryScopes(new List<Scope> { new Scope .AddInMemoryScopes(new List<Scope>
{
new Scope
{ {
Name = scopeName, Name = scopeName,
Description = "My API", Description = "My API",
@ -253,25 +308,34 @@ namespace Ocelot.AcceptanceTests
Value = "secret".Sha256() Value = "secret".Sha256()
} }
} }
}}) },
.AddInMemoryClients(new List<Client> {
StandardScopes.OpenId,
StandardScopes.OfflineAccess
})
.AddInMemoryClients(new List<Client>
{
new Client new Client
{ {
ClientId = "client", ClientId = "client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets = new List<Secret> {new Secret("secret".Sha256())}, ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
AllowedScopes = new List<string> { scopeName }, AllowedScopes = new List<string> { scopeName, "openid", "offline_access" },
AccessTokenType = tokenType, AccessTokenType = tokenType,
Enabled = true, Enabled = true,
RequireClientSecret = false RequireClientSecret = false
} }) }
.AddInMemoryUsers(new List<InMemoryUser> { new InMemoryUser })
.AddInMemoryUsers(new List<InMemoryUser>
{
new InMemoryUser
{ {
Username = "test", Username = "test",
Password = "test", Password = "test",
Enabled = true, Enabled = true,
Subject = "asdads" Subject = "asdads"
}}); }
});
}) })
.Configure(app => .Configure(app =>
{ {
@ -322,11 +386,6 @@ namespace Ocelot.AcceptanceTests
_ocelotClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken); _ocelotClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken);
} }
private void WhenIPostUrlOnTheApiGateway(string url)
{
_response = _ocelotClient.PostAsync(url, _postContent).Result;
}
private void ThenTheStatusCodeShouldBe(HttpStatusCode expectedHttpStatusCode) private void ThenTheStatusCodeShouldBe(HttpStatusCode expectedHttpStatusCode)
{ {
_response.StatusCode.ShouldBe(expectedHttpStatusCode); _response.StatusCode.ShouldBe(expectedHttpStatusCode);
@ -334,7 +393,7 @@ namespace Ocelot.AcceptanceTests
public void Dispose() public void Dispose()
{ {
_ocelotBbuilder?.Dispose(); _servicebuilder?.Dispose();
_ocelotClient?.Dispose(); _ocelotClient?.Dispose();
_ocelotServer?.Dispose(); _ocelotServer?.Dispose();
_identityServerBuilder?.Dispose(); _identityServerBuilder?.Dispose();

View File

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
@ -15,6 +14,8 @@ using YamlDotNet.Serialization;
namespace Ocelot.AcceptanceTests namespace Ocelot.AcceptanceTests
{ {
using Library.Configuration.Yaml;
public class OcelotTests : IDisposable public class OcelotTests : IDisposable
{ {
private TestServer _server; private TestServer _server;

View File

@ -3,21 +3,23 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Authentication;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Authentication namespace Ocelot.UnitTests.Authentication
{ {
using Library.Authentication;
using Library.Configuration;
using Library.Errors;
using Library.Responses;
public class AuthenticationHandlerFactoryTests public class AuthenticationHandlerFactoryTests
{ {
private readonly IAuthenticationHandlerFactory _authenticationHandlerFactory; private readonly IAuthenticationHandlerFactory _authenticationHandlerFactory;
private readonly Mock<IApplicationBuilder> _app; private readonly Mock<IApplicationBuilder> _app;
private readonly Mock<IAuthenticationHandlerCreator> _creator; private readonly Mock<IAuthenticationHandlerCreator> _creator;
private Library.Infrastructure.Configuration.AuthenticationOptions _authenticationOptions; private AuthenticationOptions _authenticationOptions;
private Response<AuthenticationHandler> _result; private Response<AuthenticationHandler> _result;
public AuthenticationHandlerFactoryTests() public AuthenticationHandlerFactoryTests()
@ -30,7 +32,7 @@ namespace Ocelot.UnitTests.Authentication
[Fact] [Fact]
public void should_return_identity_server_access_token_handler() public void should_return_identity_server_access_token_handler()
{ {
this.Given(x => x.GivenTheAuthenticationOptionsAre(new Library.Infrastructure.Configuration.AuthenticationOptions("IdentityServer", "","",false, new List<string>(), ""))) this.Given(x => x.GivenTheAuthenticationOptionsAre(new AuthenticationOptions("IdentityServer", "","",false, new List<string>(), "")))
.And(x => x.GivenTheCreatorReturns()) .And(x => x.GivenTheCreatorReturns())
.When(x => x.WhenIGetFromTheFactory()) .When(x => x.WhenIGetFromTheFactory())
.Then(x => x.ThenTheHandlerIsReturned("IdentityServer")) .Then(x => x.ThenTheHandlerIsReturned("IdentityServer"))
@ -40,14 +42,14 @@ namespace Ocelot.UnitTests.Authentication
[Fact] [Fact]
public void should_return_error_if_cannot_create_handler() public void should_return_error_if_cannot_create_handler()
{ {
this.Given(x => x.GivenTheAuthenticationOptionsAre(new Library.Infrastructure.Configuration.AuthenticationOptions("IdentityServer", "", "", false, new List<string>(), ""))) this.Given(x => x.GivenTheAuthenticationOptionsAre(new AuthenticationOptions("IdentityServer", "", "", false, new List<string>(), "")))
.And(x => x.GivenTheCreatorReturnsAnError()) .And(x => x.GivenTheCreatorReturnsAnError())
.When(x => x.WhenIGetFromTheFactory()) .When(x => x.WhenIGetFromTheFactory())
.Then(x => x.ThenAnErrorResponseIsReturned()) .Then(x => x.ThenAnErrorResponseIsReturned())
.BDDfy(); .BDDfy();
} }
private void GivenTheAuthenticationOptionsAre(Library.Infrastructure.Configuration.AuthenticationOptions authenticationOptions) private void GivenTheAuthenticationOptionsAre(AuthenticationOptions authenticationOptions)
{ {
_authenticationOptions = authenticationOptions; _authenticationOptions = authenticationOptions;
} }
@ -55,7 +57,7 @@ namespace Ocelot.UnitTests.Authentication
private void GivenTheCreatorReturnsAnError() private void GivenTheCreatorReturnsAnError()
{ {
_creator _creator
.Setup(x => x.CreateIdentityServerAuthenticationHandler(It.IsAny<IApplicationBuilder>(), It.IsAny<Library.Infrastructure.Configuration.AuthenticationOptions>())) .Setup(x => x.CreateIdentityServerAuthenticationHandler(It.IsAny<IApplicationBuilder>(), It.IsAny<AuthenticationOptions>()))
.Returns(new ErrorResponse<RequestDelegate>(new List<Error> .Returns(new ErrorResponse<RequestDelegate>(new List<Error>
{ {
new UnableToCreateAuthenticationHandlerError($"Unable to create authentication handler for xxx") new UnableToCreateAuthenticationHandlerError($"Unable to create authentication handler for xxx")
@ -65,7 +67,7 @@ namespace Ocelot.UnitTests.Authentication
private void GivenTheCreatorReturns() private void GivenTheCreatorReturns()
{ {
_creator _creator
.Setup(x => x.CreateIdentityServerAuthenticationHandler(It.IsAny<IApplicationBuilder>(), It.IsAny<Library.Infrastructure.Configuration.AuthenticationOptions>())) .Setup(x => x.CreateIdentityServerAuthenticationHandler(It.IsAny<IApplicationBuilder>(), It.IsAny<AuthenticationOptions>()))
.Returns(new OkResponse<RequestDelegate>(x => Task.CompletedTask)); .Returns(new OkResponse<RequestDelegate>(x => Task.CompletedTask));
} }

View File

@ -1,12 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Configuration namespace Ocelot.UnitTests.Configuration
{ {
using Library.Configuration.Yaml;
using Library.Responses;
public class ConfigurationValidationTests public class ConfigurationValidationTests
{ {
private YamlConfiguration _yamlConfiguration; private YamlConfiguration _yamlConfiguration;

View File

@ -1,16 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Builder;
using Ocelot.Library.Infrastructure.Configuration;
using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Configuration namespace Ocelot.UnitTests.Configuration
{ {
using Library.Builder;
using Library.Configuration;
using Library.Configuration.Yaml;
using Library.Responses;
public class OcelotConfigurationTests public class OcelotConfigurationTests
{ {
private readonly Mock<IOptions<YamlConfiguration>> _yamlConfig; private readonly Mock<IOptions<YamlConfiguration>> _yamlConfig;

View File

@ -1,16 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Builder;
using Ocelot.Library.Infrastructure.Configuration;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.DownstreamRouteFinder namespace Ocelot.UnitTests.DownstreamRouteFinder
{ {
using Library.Builder;
using Library.Configuration;
using Library.DownstreamRouteFinder;
using Library.Responses;
using Library.UrlMatcher;
public class DownstreamRouteFinderTests public class DownstreamRouteFinderTests
{ {
private readonly IDownstreamRouteFinder _downstreamRouteFinder; private readonly IDownstreamRouteFinder _downstreamRouteFinder;
@ -28,7 +29,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
_mockConfig = new Mock<IOcelotConfiguration>(); _mockConfig = new Mock<IOcelotConfiguration>();
_mockMatcher = new Mock<IUrlPathToUrlTemplateMatcher>(); _mockMatcher = new Mock<IUrlPathToUrlTemplateMatcher>();
_finder = new Mock<ITemplateVariableNameAndValueFinder>(); _finder = new Mock<ITemplateVariableNameAndValueFinder>();
_downstreamRouteFinder = new Library.Infrastructure.DownstreamRouteFinder.DownstreamRouteFinder(_mockConfig.Object, _mockMatcher.Object, _finder.Object); _downstreamRouteFinder = new DownstreamRouteFinder(_mockConfig.Object, _mockMatcher.Object, _finder.Object);
} }
[Fact] [Fact]

View File

@ -6,19 +6,18 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Authentication;
using Ocelot.Library.Infrastructure.Builder;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Middleware namespace Ocelot.UnitTests.Middleware
{ {
using Library.Infrastructure.Configuration; using Library.Authentication;
using Library.Builder;
using Library.DownstreamRouteFinder;
using Library.Middleware;
using Library.Repository;
using Library.Responses;
using Library.UrlMatcher;
public class AuthenticationMiddlewareTests : IDisposable public class AuthenticationMiddlewareTests : IDisposable
{ {

View File

@ -6,17 +6,18 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Builder;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Middleware namespace Ocelot.UnitTests.Middleware
{ {
using Library.Builder;
using Library.DownstreamRouteFinder;
using Library.Middleware;
using Library.Repository;
using Library.Responses;
using Library.UrlMatcher;
public class DownstreamRouteFinderMiddlewareTests : IDisposable public class DownstreamRouteFinderMiddlewareTests : IDisposable
{ {
private readonly Mock<IDownstreamRouteFinder> _downstreamRouteFinder; private readonly Mock<IDownstreamRouteFinder> _downstreamRouteFinder;

View File

@ -1,18 +1,16 @@
using Ocelot.Library.Infrastructure.Builder; namespace Ocelot.UnitTests.Middleware
using Ocelot.Library.Infrastructure.Middleware;
namespace Ocelot.UnitTests.Middleware
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using Library.Infrastructure.Configuration; using Library.Builder;
using Library.Infrastructure.DownstreamRouteFinder; using Library.DownstreamRouteFinder;
using Library.Infrastructure.Repository; using Library.Middleware;
using Library.Infrastructure.Responses; using Library.Repository;
using Library.Infrastructure.UrlMatcher; using Library.Responses;
using Library.Infrastructure.UrlTemplateReplacer; using Library.UrlMatcher;
using Library.UrlTemplateReplacer;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;

View File

@ -7,15 +7,16 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.RequestBuilder;
using Ocelot.Library.Infrastructure.Responses;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Middleware namespace Ocelot.UnitTests.Middleware
{ {
using Library.Middleware;
using Library.Repository;
using Library.RequestBuilder;
using Library.Responses;
public class HttpRequestBuilderMiddlewareTests : IDisposable public class HttpRequestBuilderMiddlewareTests : IDisposable
{ {
private readonly Mock<IRequestBuilder> _requestBuilder; private readonly Mock<IRequestBuilder> _requestBuilder;

View File

@ -6,16 +6,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.RequestBuilder;
using Ocelot.Library.Infrastructure.Requester;
using Ocelot.Library.Infrastructure.Responses;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Middleware namespace Ocelot.UnitTests.Middleware
{ {
using Library.Middleware;
using Library.Repository;
using Library.RequestBuilder;
using Library.Requester;
using Library.Responses;
public class HttpRequesterMiddlewareTests : IDisposable public class HttpRequesterMiddlewareTests : IDisposable
{ {
private readonly Mock<IHttpRequester> _requester; private readonly Mock<IHttpRequester> _requester;

View File

@ -6,15 +6,16 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Moq; using Moq;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.Responder;
using Ocelot.Library.Infrastructure.Responses;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Middleware namespace Ocelot.UnitTests.Middleware
{ {
using Library.Middleware;
using Library.Repository;
using Library.Responder;
using Library.Responses;
public class HttpResponderMiddlewareTests : IDisposable public class HttpResponderMiddlewareTests : IDisposable
{ {
private readonly Mock<IHttpResponder> _responder; private readonly Mock<IHttpResponder> _responder;

View File

@ -1,12 +1,13 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Repository;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Repository namespace Ocelot.UnitTests.Repository
{ {
using Library.Repository;
using Library.Responses;
public class ScopedRequestDataRepositoryTests public class ScopedRequestDataRepositoryTests
{ {
private IScopedRequestDataRepository _scopedRequestDataRepository; private IScopedRequestDataRepository _scopedRequestDataRepository;

View File

@ -5,14 +5,15 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
using Ocelot.Library.Infrastructure.RequestBuilder;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.RequestBuilder namespace Ocelot.UnitTests.RequestBuilder
{ {
using Library.RequestBuilder;
using Library.Responses;
public class RequestBuilderTests public class RequestBuilderTests
{ {
private string _httpMethod; private string _httpMethod;
@ -28,7 +29,7 @@ namespace Ocelot.UnitTests.RequestBuilder
public RequestBuilderTests() public RequestBuilderTests()
{ {
_content = new StringContent(string.Empty); _content = new StringContent(string.Empty);
_requestBuilder = new Library.Infrastructure.RequestBuilder.HttpRequestBuilder(); _requestBuilder = new HttpRequestBuilder();
} }
[Fact] [Fact]

View File

@ -2,16 +2,17 @@
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Ocelot.Library.Infrastructure.Errors;
using Ocelot.Library.Infrastructure.Middleware;
using Ocelot.Library.Infrastructure.Responder;
using Ocelot.Library.Infrastructure.Responses;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.Responder namespace Ocelot.UnitTests.Responder
{ {
using Library.Errors;
using Library.Middleware;
using Library.Responder;
using Library.Responses;
public class ErrorsToHttpStatusCodeMapperTests public class ErrorsToHttpStatusCodeMapperTests
{ {
private readonly IErrorsToHttpStatusCodeMapper _codeMapper; private readonly IErrorsToHttpStatusCodeMapper _codeMapper;

View File

@ -1,11 +1,12 @@
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.UrlMatcher namespace Ocelot.UnitTests.UrlMatcher
{ {
using Library.Responses;
using Library.UrlMatcher;
public class RegExUrlMatcherTests public class RegExUrlMatcherTests
{ {
private readonly IUrlPathToUrlTemplateMatcher _urlMatcher; private readonly IUrlPathToUrlTemplateMatcher _urlMatcher;

View File

@ -1,13 +1,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.UrlMatcher namespace Ocelot.UnitTests.UrlMatcher
{ {
using Library.Responses;
using Library.UrlMatcher;
public class UrlPathToUrlTemplateMatcherTests public class UrlPathToUrlTemplateMatcherTests
{ {
private readonly ITemplateVariableNameAndValueFinder _finder; private readonly ITemplateVariableNameAndValueFinder _finder;

View File

@ -1,16 +1,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using Ocelot.Library.Infrastructure.Builder;
using Ocelot.Library.Infrastructure.DownstreamRouteFinder;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
using Ocelot.Library.Infrastructure.UrlTemplateReplacer;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
namespace Ocelot.UnitTests.UrlTemplateReplacer namespace Ocelot.UnitTests.UrlTemplateReplacer
{ {
using Library.Infrastructure.Configuration; using Library.Builder;
using Library.DownstreamRouteFinder;
using Library.Responses;
using Library.UrlMatcher;
using Library.UrlTemplateReplacer;
public class UpstreamUrlPathTemplateVariableReplacerTests public class UpstreamUrlPathTemplateVariableReplacerTests
{ {