mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
found missing tests
This commit is contained in:
parent
88e51971c5
commit
24c2ba10de
@ -1,133 +1,62 @@
|
|||||||
// using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
// using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
// using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
// using Ocelot.Configuration.Creator;
|
using Ocelot.Configuration.Creator;
|
||||||
// using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
// using Shouldly;
|
using Shouldly;
|
||||||
// using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
// using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
// namespace Ocelot.UnitTests.Configuration
|
namespace Ocelot.UnitTests.Configuration
|
||||||
// {
|
{
|
||||||
// public class AuthenticationOptionsCreatorTests
|
public class AuthenticationOptionsCreatorTests
|
||||||
// {
|
{
|
||||||
// private readonly AuthenticationOptionsCreator _authOptionsCreator;
|
private readonly AuthenticationOptionsCreator _authOptionsCreator;
|
||||||
// private FileReRoute _fileReRoute;
|
private FileReRoute _fileReRoute;
|
||||||
// private AuthenticationOptions _result;
|
private AuthenticationOptions _result;
|
||||||
|
|
||||||
// public AuthenticationOptionsCreatorTests()
|
public AuthenticationOptionsCreatorTests()
|
||||||
// {
|
{
|
||||||
// _authOptionsCreator = new AuthenticationOptionsCreator(new AuthenticationProviderConfigCreator());
|
_authOptionsCreator = new AuthenticationOptionsCreator();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [Fact]
|
[Fact]
|
||||||
// public void should_return_auth_options()
|
public void should_return_auth_options()
|
||||||
// {
|
{
|
||||||
// var fileReRoute = new FileReRoute()
|
var fileReRoute = new FileReRoute()
|
||||||
// {
|
{
|
||||||
// AuthenticationOptions = new FileAuthenticationOptions
|
AuthenticationOptions = new FileAuthenticationOptions
|
||||||
// {
|
{
|
||||||
// Provider = "Geoff",
|
AuthenticationProviderKey = "Test",
|
||||||
// IdentityServerConfig = new FileIdentityServerConfig()
|
AllowedScopes = new List<string> { "cheese" },
|
||||||
// {
|
}
|
||||||
// ProviderRootUrl = "http://www.bbc.co.uk/",
|
};
|
||||||
// ApiName = "Laura",
|
|
||||||
// RequireHttps = true,
|
|
||||||
// ApiSecret = "secret"
|
|
||||||
// },
|
|
||||||
// AllowedScopes = new List<string> { "cheese" },
|
|
||||||
|
|
||||||
// }
|
var expected = new AuthenticationOptionsBuilder()
|
||||||
// };
|
.WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
|
||||||
|
.WithAuthenticationProviderKey("Test")
|
||||||
|
.Build();
|
||||||
|
|
||||||
// var authenticationConfig = new IdentityServerConfigBuilder()
|
this.Given(x => x.GivenTheFollowing(fileReRoute))
|
||||||
// .WithProviderRootUrl(fileReRoute.AuthenticationOptions?.IdentityServerConfig?.ProviderRootUrl)
|
.When(x => x.WhenICreateTheAuthenticationOptions())
|
||||||
// .WithApiName(fileReRoute.AuthenticationOptions?.IdentityServerConfig?.ApiName)
|
.Then(x => x.ThenTheFollowingConfigIsReturned(expected))
|
||||||
// .WithRequireHttps(fileReRoute.AuthenticationOptions.IdentityServerConfig.RequireHttps)
|
.BDDfy();
|
||||||
// .WithApiSecret(fileReRoute.AuthenticationOptions?.IdentityServerConfig?.ApiSecret)
|
}
|
||||||
// .Build();
|
|
||||||
|
|
||||||
// var expected = new AuthenticationOptionsBuilder()
|
private void GivenTheFollowing(FileReRoute fileReRoute)
|
||||||
// .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
|
{
|
||||||
// .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
|
_fileReRoute = fileReRoute;
|
||||||
// .WithConfig(authenticationConfig)
|
}
|
||||||
// .Build();
|
|
||||||
|
|
||||||
// this.Given(x => x.GivenTheFollowing(fileReRoute))
|
private void WhenICreateTheAuthenticationOptions()
|
||||||
// .When(x => x.WhenICreateTheAuthenticationOptions())
|
{
|
||||||
// .Then(x => x.ThenTheFollowingIdentityServerConfigIsReturned(expected))
|
_result = _authOptionsCreator.Create(_fileReRoute);
|
||||||
// .BDDfy();
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
private void ThenTheFollowingConfigIsReturned(AuthenticationOptions expected)
|
||||||
// public void should_return_Jwt_auth_options()
|
{
|
||||||
// {
|
_result.AllowedScopes.ShouldBe(expected.AllowedScopes);
|
||||||
// var fileReRoute = new FileReRoute()
|
_result.AuthenticationProviderKey.ShouldBe(expected.AuthenticationProviderKey);
|
||||||
// {
|
}
|
||||||
// AuthenticationOptions = new FileAuthenticationOptions
|
}
|
||||||
// {
|
}
|
||||||
// Provider = "Jwt",
|
|
||||||
// JwtConfig = new FileJwtConfig()
|
|
||||||
// {
|
|
||||||
// Audience = "Audience",
|
|
||||||
// Authority = "Authority"
|
|
||||||
// },
|
|
||||||
// AllowedScopes = new List<string> { "cheese" }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var authenticationConfig = new JwtConfigBuilder()
|
|
||||||
// .WithAudience(fileReRoute.AuthenticationOptions?.JwtConfig?.Audience)
|
|
||||||
// .WithAuthority(fileReRoute.AuthenticationOptions?.JwtConfig?.Authority)
|
|
||||||
// .Build();
|
|
||||||
|
|
||||||
// var expected = new AuthenticationOptionsBuilder()
|
|
||||||
// .WithProvider(fileReRoute.AuthenticationOptions?.Provider)
|
|
||||||
// .WithAllowedScopes(fileReRoute.AuthenticationOptions?.AllowedScopes)
|
|
||||||
// .WithConfig(authenticationConfig)
|
|
||||||
// .Build();
|
|
||||||
|
|
||||||
// this.Given(x => x.GivenTheFollowing(fileReRoute))
|
|
||||||
// .When(x => x.WhenICreateTheAuthenticationOptions())
|
|
||||||
// .Then(x => x.ThenTheFollowingJwtConfigIsReturned(expected))
|
|
||||||
// .BDDfy();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void GivenTheFollowing(FileReRoute fileReRoute)
|
|
||||||
// {
|
|
||||||
// _fileReRoute = fileReRoute;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void WhenICreateTheAuthenticationOptions()
|
|
||||||
// {
|
|
||||||
// _result = _authOptionsCreator.Create(_fileReRoute);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void ThenTheFollowingJwtConfigIsReturned(AuthenticationOptions expected)
|
|
||||||
// {
|
|
||||||
// _result.AllowedScopes.ShouldBe(expected.AllowedScopes);
|
|
||||||
// _result.Provider.ShouldBe(expected.Provider);
|
|
||||||
|
|
||||||
// var _resultSettings = _result.Config as JwtConfig;
|
|
||||||
// var expectedSettngs = expected.Config as JwtConfig;
|
|
||||||
|
|
||||||
// _resultSettings.Audience.ShouldBe(expectedSettngs.Audience);
|
|
||||||
// _resultSettings.Authority.ShouldBe(expectedSettngs.Authority);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void ThenTheFollowingIdentityServerConfigIsReturned(AuthenticationOptions expected)
|
|
||||||
// {
|
|
||||||
// _result.AllowedScopes.ShouldBe(expected.AllowedScopes);
|
|
||||||
// _result.Provider.ShouldBe(expected.Provider);
|
|
||||||
|
|
||||||
// var _resultSettings = _result.Config as IdentityServerConfig;
|
|
||||||
// var expectedSettngs = expected.Config as IdentityServerConfig;
|
|
||||||
|
|
||||||
// _resultSettings.ProviderRootUrl.ShouldBe(expectedSettngs.ProviderRootUrl);
|
|
||||||
// _resultSettings.RequireHttps.ShouldBe(expectedSettngs.RequireHttps);
|
|
||||||
// _resultSettings.ApiName.ShouldBe(expectedSettngs.ApiName);
|
|
||||||
// _resultSettings.ApiSecret.ShouldBe(expectedSettngs.ApiSecret);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
Loading…
x
Reference in New Issue
Block a user