renamed provider to handler

This commit is contained in:
TomPallister 2016-10-16 16:47:08 +01:00
parent 320b442526
commit 7289cd803b
6 changed files with 16 additions and 16 deletions

View File

@ -5,11 +5,11 @@ using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Authentication namespace Ocelot.Library.Infrastructure.Authentication
{ {
public class AuthenticationProviderFactory : IAuthenticationProviderFactory public class AuthenticationHandlerFactory : IAuthenticationHandlerFactory
{ {
private readonly IAuthenticationHandlerCreator _creator; private readonly IAuthenticationHandlerCreator _creator;
public AuthenticationProviderFactory(IAuthenticationHandlerCreator creator) public AuthenticationHandlerFactory(IAuthenticationHandlerCreator creator)
{ {
_creator = creator; _creator = creator;
} }

View File

@ -3,7 +3,7 @@ using Ocelot.Library.Infrastructure.Responses;
namespace Ocelot.Library.Infrastructure.Authentication namespace Ocelot.Library.Infrastructure.Authentication
{ {
public interface IAuthenticationProviderFactory public interface IAuthenticationHandlerFactory
{ {
Response<AuthenticationHandler> Get(string provider, IApplicationBuilder app); Response<AuthenticationHandler> Get(string provider, IApplicationBuilder app);
} }

View File

@ -22,15 +22,15 @@ namespace Ocelot.Library.Infrastructure.Middleware
private RequestDelegate _authenticationNext; private RequestDelegate _authenticationNext;
private readonly IScopedRequestDataRepository _scopedRequestDataRepository; private readonly IScopedRequestDataRepository _scopedRequestDataRepository;
private readonly IApplicationBuilder _app; private readonly IApplicationBuilder _app;
private readonly IAuthenticationProviderFactory _authProviderFactory; private readonly IAuthenticationHandlerFactory _authHandlerFactory;
public AuthenticationMiddleware(RequestDelegate next, IApplicationBuilder app, public AuthenticationMiddleware(RequestDelegate next, IApplicationBuilder app,
IScopedRequestDataRepository scopedRequestDataRepository, IAuthenticationProviderFactory authProviderFactory) IScopedRequestDataRepository scopedRequestDataRepository, IAuthenticationHandlerFactory authHandlerFactory)
: base(scopedRequestDataRepository) : base(scopedRequestDataRepository)
{ {
_next = next; _next = next;
_scopedRequestDataRepository = scopedRequestDataRepository; _scopedRequestDataRepository = scopedRequestDataRepository;
_authProviderFactory = authProviderFactory; _authHandlerFactory = authHandlerFactory;
_app = app; _app = app;
} }
@ -46,7 +46,7 @@ namespace Ocelot.Library.Infrastructure.Middleware
if (IsAuthenticatedRoute(downstreamRoute.Data.ReRoute)) if (IsAuthenticatedRoute(downstreamRoute.Data.ReRoute))
{ {
var authenticationNext = _authProviderFactory.Get(downstreamRoute.Data.ReRoute.AuthenticationProvider, _app); var authenticationNext = _authHandlerFactory.Get(downstreamRoute.Data.ReRoute.AuthenticationProvider, _app);
if (!authenticationNext.IsError) if (!authenticationNext.IsError)
{ {

View File

@ -57,7 +57,7 @@ namespace Ocelot
services.AddSingleton<IHttpResponder, HttpContextResponder>(); services.AddSingleton<IHttpResponder, HttpContextResponder>();
services.AddSingleton<IRequestBuilder, HttpRequestBuilder>(); services.AddSingleton<IRequestBuilder, HttpRequestBuilder>();
services.AddSingleton<IErrorsToHttpStatusCodeMapper, ErrorsToHttpStatusCodeMapper>(); services.AddSingleton<IErrorsToHttpStatusCodeMapper, ErrorsToHttpStatusCodeMapper>();
services.AddSingleton<IAuthenticationProviderFactory, AuthenticationProviderFactory>(); services.AddSingleton<IAuthenticationHandlerFactory, AuthenticationHandlerFactory>();
services.AddSingleton<IAuthenticationHandlerCreator, AuthenticationHandlerCreator>(); 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 // see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc

View File

@ -12,24 +12,24 @@ using Xunit;
namespace Ocelot.UnitTests.Authentication namespace Ocelot.UnitTests.Authentication
{ {
public class AuthenticationProviderFactoryTests public class AuthenticationHandlerFactoryTests
{ {
private readonly IAuthenticationProviderFactory _authenticationProviderFactory; 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 string _provider; private string _provider;
private Response<AuthenticationHandler> _result; private Response<AuthenticationHandler> _result;
public AuthenticationProviderFactoryTests() public AuthenticationHandlerFactoryTests()
{ {
_app = new Mock<IApplicationBuilder>(); _app = new Mock<IApplicationBuilder>();
_creator = new Mock<IAuthenticationHandlerCreator>(); _creator = new Mock<IAuthenticationHandlerCreator>();
_authenticationProviderFactory = new AuthenticationProviderFactory(_creator.Object); _authenticationHandlerFactory = new AuthenticationHandlerFactory(_creator.Object);
} }
[Fact] [Fact]
public void should_return_identity_server_access_token_provider() public void should_return_identity_server_access_token_handler()
{ {
this.Given(x => x.GivenTheProviderIs("IdentityServer.AccessToken")) this.Given(x => x.GivenTheProviderIs("IdentityServer.AccessToken"))
.And(x => x.GivenTheCreatorReturns()) .And(x => x.GivenTheCreatorReturns())
@ -72,7 +72,7 @@ namespace Ocelot.UnitTests.Authentication
private void WhenIGetFromTheFactory() private void WhenIGetFromTheFactory()
{ {
_result = _authenticationProviderFactory.Get(_provider, _app.Object); _result = _authenticationHandlerFactory.Get(_provider, _app.Object);
} }
private void ThenTheHandlerIsReturned(string expected) private void ThenTheHandlerIsReturned(string expected)

View File

@ -22,7 +22,7 @@ namespace Ocelot.UnitTests.Middleware
public class AuthenticationMiddlewareTests : IDisposable public class AuthenticationMiddlewareTests : IDisposable
{ {
private readonly Mock<IScopedRequestDataRepository> _scopedRepository; private readonly Mock<IScopedRequestDataRepository> _scopedRepository;
private readonly Mock<IAuthenticationProviderFactory> _authFactory; private readonly Mock<IAuthenticationHandlerFactory> _authFactory;
private readonly string _url; private readonly string _url;
private readonly TestServer _server; private readonly TestServer _server;
private readonly HttpClient _client; private readonly HttpClient _client;
@ -33,7 +33,7 @@ namespace Ocelot.UnitTests.Middleware
{ {
_url = "http://localhost:51879"; _url = "http://localhost:51879";
_scopedRepository = new Mock<IScopedRequestDataRepository>(); _scopedRepository = new Mock<IScopedRequestDataRepository>();
_authFactory = new Mock<IAuthenticationProviderFactory>(); _authFactory = new Mock<IAuthenticationHandlerFactory>();
var builder = new WebHostBuilder() var builder = new WebHostBuilder()
.ConfigureServices(x => .ConfigureServices(x =>
{ {