fixing tests

This commit is contained in:
Nick Sharp 2017-06-26 21:32:44 +01:00
parent 20f6ebac2f
commit a7eeadb4c6
5 changed files with 14 additions and 18 deletions

View File

@ -19,7 +19,7 @@ namespace Ocelot.Authentication.Handler.Creator
{ {
var builder = app.New(); var builder = app.New();
var authenticationConfig = authOptions.Config as IdentityServerConfig; var authenticationConfig = authOptions.Config;
builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{ {

View File

@ -2,9 +2,11 @@
namespace Ocelot.Configuration namespace Ocelot.Configuration
{ {
using Newtonsoft.Json;
public class AuthenticationOptions public class AuthenticationOptions
{ {
public AuthenticationOptions(string provider, List<string> allowedScopes, IAuthenticationConfig config) public AuthenticationOptions(string provider, List<string> allowedScopes, IdentityServerConfig config)
{ {
Provider = provider; Provider = provider;
AllowedScopes = allowedScopes; AllowedScopes = allowedScopes;
@ -15,15 +17,10 @@ namespace Ocelot.Configuration
public List<string> AllowedScopes { get; private set; } public List<string> AllowedScopes { get; private set; }
public IAuthenticationConfig Config { get; } public IdentityServerConfig Config { get; private set; }
} }
public class IdentityServerConfig
public interface IAuthenticationConfig
{
}
public class IdentityServerConfig : IAuthenticationConfig
{ {
public IdentityServerConfig(string providerRootUrl, string apiName, bool requireHttps, string apiSecret) public IdentityServerConfig(string providerRootUrl, string apiName, bool requireHttps, string apiSecret)
{ {

View File

@ -9,7 +9,7 @@ namespace Ocelot.Configuration.Builder
private List<string> _allowedScopes; private List<string> _allowedScopes;
private IAuthenticationConfig _config; private IdentityServerConfig _identityServerConfig;
public AuthenticationOptionsBuilder WithProvider(string provider) public AuthenticationOptionsBuilder WithProvider(string provider)
{ {
@ -23,15 +23,15 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public AuthenticationOptionsBuilder WithConfiguration(IAuthenticationConfig config) public AuthenticationOptionsBuilder WithIdntityServerConfigConfiguration(IdentityServerConfig config)
{ {
_config = config; _identityServerConfig = config;
return this; return this;
} }
public AuthenticationOptions Build() public AuthenticationOptions Build()
{ {
return new AuthenticationOptions(_provider, _allowedScopes, _config); return new AuthenticationOptions(_provider, _allowedScopes, _identityServerConfig);
} }
} }

View File

@ -7,19 +7,19 @@ namespace Ocelot.Configuration.Creator
{ {
public AuthenticationOptions Create(FileReRoute fileReRoute) public AuthenticationOptions Create(FileReRoute fileReRoute)
{ {
var authenticationConfig = new AuthenticationConfigCreator().Create(fileReRoute.AuthenticationOptions); var authenticationConfig = new IdentityServerConfigCreator().Create(fileReRoute.AuthenticationOptions);
return new AuthenticationOptionsBuilder() return new AuthenticationOptionsBuilder()
.WithProvider(fileReRoute.AuthenticationOptions?.Provider) .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
.WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes) .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
.WithConfiguration(authenticationConfig) .WithIdntityServerConfigConfiguration(authenticationConfig)
.Build(); .Build();
} }
} }
public class AuthenticationConfigCreator public class IdentityServerConfigCreator
{ {
public IAuthenticationConfig Create(FileAuthenticationOptions authenticationOptions) public IdentityServerConfig Create(FileAuthenticationOptions authenticationOptions)
{ {
return new IdentityServerConfigBuilder() return new IdentityServerConfigBuilder()
.WithApiName(authenticationOptions.IdentityServerConfig?.ApiName) .WithApiName(authenticationOptions.IdentityServerConfig?.ApiName)

View File

@ -29,7 +29,6 @@ namespace Ocelot.AcceptanceTests
_steps = new Steps(); _steps = new Steps();
} }
[Fact] [Fact]
public void should_return_response_200_with_simple_url() public void should_return_response_200_with_simple_url()
{ {