mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 12:18:16 +08:00
Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Values;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using TestStack.BDDfy;
|
||||
using Values;
|
||||
using Xunit;
|
||||
|
||||
public class AggregatesCreatorTests
|
||||
@ -112,13 +112,13 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result[1].UpstreamTemplatePattern.ShouldBe(_aggregate2Utp);
|
||||
_result[1].Aggregator.ShouldBe(_fileConfiguration.Aggregates[1].Aggregator);
|
||||
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[2].DownstreamReRoute[0]);
|
||||
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[3].DownstreamReRoute[0]);
|
||||
_result[1].DownstreamReRoute.ShouldContain(x => x == _reRoutes[3].DownstreamReRoute[0]);
|
||||
}
|
||||
|
||||
private void ThenTheUtpCreatorIsCalledCorrectly()
|
||||
{
|
||||
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[0]), Times.Once);
|
||||
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[1]), Times.Once);
|
||||
_utpCreator.Verify(x => x.Create(_fileConfiguration.Aggregates[1]), Times.Once);
|
||||
}
|
||||
|
||||
private void GivenTheUtpCreatorReturns()
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -54,9 +54,9 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
|
||||
private void ThenTheFollowingConfigIsReturned(AuthenticationOptions expected)
|
||||
{
|
||||
_result.AllowedScopes.ShouldBe(expected.AllowedScopes);
|
||||
{
|
||||
_result.AllowedScopes.ShouldBe(expected.AllowedScopes);
|
||||
_result.AuthenticationProviderKey.ShouldBe(expected.AuthenticationProviderKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Parser;
|
||||
using Ocelot.Errors;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -114,4 +114,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_dictionary = dictionary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Creator;
|
||||
@ -8,6 +6,8 @@ using Ocelot.Errors;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
public class ClaimsToThingCreatorTests
|
||||
{
|
||||
private readonly Mock<IClaimToThingConfigurationParser> _configParser;
|
||||
private Dictionary<string,string> _claimsToThings;
|
||||
private Dictionary<string, string> _claimsToThings;
|
||||
private ClaimsToThingCreator _claimsToThingsCreator;
|
||||
private Mock<IOcelotLoggerFactory> _loggerFactory;
|
||||
private List<ClaimToThing> _result;
|
||||
@ -36,13 +36,13 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_return_claims_to_things()
|
||||
{
|
||||
var userInput = new Dictionary<string,string>()
|
||||
var userInput = new Dictionary<string, string>()
|
||||
{
|
||||
{"CustomerId", "Claims[CustomerId] > value"}
|
||||
};
|
||||
|
||||
var claimsToThing = new OkResponse<ClaimToThing>(new ClaimToThing("CustomerId", "CustomerId", "", 0));
|
||||
|
||||
var claimsToThing = new OkResponse<ClaimToThing>(new ClaimToThing("CustomerId", "CustomerId", "", 0));
|
||||
|
||||
this.Given(x => x.GivenTheFollowingDictionary(userInput))
|
||||
.And(x => x.GivenTheConfigHeaderExtractorReturns(claimsToThing))
|
||||
.When(x => x.WhenIGetTheThings())
|
||||
@ -53,14 +53,14 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
[Fact]
|
||||
public void should_log_error_if_cannot_parse_claim_to_thing()
|
||||
{
|
||||
var userInput = new Dictionary<string,string>()
|
||||
{
|
||||
var userInput = new Dictionary<string, string>()
|
||||
{
|
||||
{"CustomerId", "Claims[CustomerId] > value"}
|
||||
};
|
||||
|
||||
var claimsToThing = new ErrorResponse<ClaimToThing>(It.IsAny<Error>());
|
||||
|
||||
var claimsToThing = new ErrorResponse<ClaimToThing>(It.IsAny<Error>());
|
||||
|
||||
this.Given(x => x.GivenTheFollowingDictionary(userInput))
|
||||
.And(x => x.GivenTheConfigHeaderExtractorReturns(claimsToThing))
|
||||
.When(x => x.WhenIGetTheThings())
|
||||
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.Count.ShouldBeGreaterThan(0);
|
||||
}
|
||||
|
||||
private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
|
||||
private void GivenTheFollowingDictionary(Dictionary<string, string> claimsToThings)
|
||||
{
|
||||
_claimsToThings = claimsToThings;
|
||||
}
|
||||
@ -108,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
@ -8,6 +7,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Repository;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Ocelot.Configuration.Repository;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
public class DiskFileConfigurationRepositoryTests : IDisposable
|
||||
{
|
||||
@ -26,6 +26,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
// cant pick it up if they run in parralel..and the semaphore stops them running at the same time...sigh
|
||||
// these are not really unit tests but whatever...
|
||||
private string _environmentName = "DEV.DEV";
|
||||
|
||||
private static SemaphoreSlim _semaphore;
|
||||
|
||||
public DiskFileConfigurationRepositoryTests()
|
||||
@ -102,7 +103,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
private void GivenTheUserAddedOcelotJson()
|
||||
{
|
||||
_ocelotJsonPath = $"{AppContext.BaseDirectory}/ocelot.json";
|
||||
_ocelotJsonPath = $"{AppContext.BaseDirectory}/ocelot.json";
|
||||
|
||||
if (File.Exists(_ocelotJsonPath))
|
||||
{
|
||||
@ -136,7 +137,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.GlobalConfiguration.ServiceDiscoveryProvider.Host.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Host);
|
||||
_result.GlobalConfiguration.ServiceDiscoveryProvider.Port.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Port);
|
||||
|
||||
for(var i = 0; i < _result.ReRoutes.Count; i++)
|
||||
for (var i = 0; i < _result.ReRoutes.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < _result.ReRoutes[i].DownstreamHostAndPorts.Count; j++)
|
||||
{
|
||||
@ -176,7 +177,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
private void ThenTheConfigurationJsonIsIndented(FileConfiguration expecteds)
|
||||
{
|
||||
var path = !string.IsNullOrEmpty(_environmentSpecificPath) ? _environmentSpecificPath : _environmentSpecificPath = $"{AppContext.BaseDirectory}/ocelot{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";
|
||||
|
||||
|
||||
var resultText = File.ReadAllText(path);
|
||||
var expectedText = JsonConvert.SerializeObject(expecteds, Formatting.Indented);
|
||||
resultText.ShouldBe(expectedText);
|
||||
@ -193,7 +194,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.GlobalConfiguration.ServiceDiscoveryProvider.Host.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Host);
|
||||
_result.GlobalConfiguration.ServiceDiscoveryProvider.Port.ShouldBe(expecteds.GlobalConfiguration.ServiceDiscoveryProvider.Port);
|
||||
|
||||
for(var i = 0; i < _result.ReRoutes.Count; i++)
|
||||
for (var i = 0; i < _result.ReRoutes.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < _result.ReRoutes[i].DownstreamHostAndPorts.Count; j++)
|
||||
{
|
||||
|
@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -47,7 +46,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
new FileHostAndPort
|
||||
{
|
||||
Host = "test",
|
||||
Port = 80
|
||||
Port = 80
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -87,8 +86,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
new DownstreamHostAndPort("test", 80),
|
||||
new DownstreamHostAndPort("west", 443)
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
this.Given(x => GivenTheFollowingReRoute(reRoute))
|
||||
.When(x => WhenICreate())
|
||||
.Then(x => TheThenFollowingIsReturned(expected))
|
||||
@ -119,4 +118,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Repository;
|
||||
using Ocelot.Configuration.Setter;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using Shouldly;
|
||||
using static Ocelot.Infrastructure.Wait;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
@ -44,20 +43,21 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_poller = new FileConfigurationPoller(_factory.Object, _repo.Object, _config.Object, _internalConfigRepo.Object, _internalConfigCreator.Object);
|
||||
_poller.StartAsync(new CancellationToken());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void should_start()
|
||||
{
|
||||
this.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
|
||||
.BDDfy();
|
||||
this.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_call_setter_when_gets_new_config()
|
||||
{
|
||||
var newConfig = new FileConfiguration {
|
||||
var newConfig = new FileConfiguration
|
||||
{
|
||||
ReRoutes = new List<FileReRoute>
|
||||
{
|
||||
{
|
||||
new FileReRoute
|
||||
{
|
||||
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||
@ -126,8 +126,6 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void WhenProviderErrors()
|
||||
{
|
||||
_repo
|
||||
@ -145,14 +143,15 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
private void ThenTheSetterIsCalled(FileConfiguration fileConfig, int times)
|
||||
{
|
||||
var result = WaitFor(4000).Until(() => {
|
||||
var result = WaitFor(4000).Until(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_internalConfigRepo.Verify(x => x.AddOrReplace(_internalConfig), Times.Exactly(times));
|
||||
_internalConfigCreator.Verify(x => x.Create(fileConfig), Times.Exactly(times));
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -162,14 +161,15 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
private void ThenTheSetterIsCalledAtLeast(FileConfiguration fileConfig, int times)
|
||||
{
|
||||
var result = WaitFor(4000).Until(() => {
|
||||
var result = WaitFor(4000).Until(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_internalConfigRepo.Verify(x => x.AddOrReplace(_internalConfig), Times.AtLeast(times));
|
||||
_internalConfigCreator.Verify(x => x.Create(fileConfig), Times.AtLeast(times));
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
@ -10,6 +8,7 @@ using Ocelot.Configuration.Setter;
|
||||
using Ocelot.Errors;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -22,7 +21,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
private Mock<IInternalConfigurationRepository> _configRepo;
|
||||
private Mock<IInternalConfigurationCreator> _configCreator;
|
||||
private Response<IInternalConfiguration> _configuration;
|
||||
private object _result;
|
||||
private object _result;
|
||||
private Mock<IFileConfigurationRepository> _repo;
|
||||
|
||||
public FileConfigurationSetterTests()
|
||||
@ -109,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.Verify(x => x.AddOrReplace(_configuration.Data), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Validator;
|
||||
using Ocelot.Errors;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using Ocelot.Errors;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using System.Linq;
|
||||
|
||||
public class FileInternalConfigurationCreatorTests
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
@ -20,8 +19,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
rng.GetBytes(salt);
|
||||
}
|
||||
|
||||
var storedSalt = Convert.ToBase64String(salt);
|
||||
|
||||
var storedSalt = Convert.ToBase64String(salt);
|
||||
|
||||
var storedHash = Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
||||
password: password,
|
||||
salt: salt,
|
||||
@ -30,4 +29,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
numBytesRequested: 256 / 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -43,8 +40,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
{"Test", "Test, Chicken"},
|
||||
{"Moop", "o, a"}
|
||||
},
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
},
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Pop", "West, East"},
|
||||
{"Bop", "e, r"}
|
||||
@ -96,8 +93,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
public void should_use_base_url_placeholder()
|
||||
{
|
||||
var reRoute = new FileReRoute
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Location", "http://www.bbc.co.uk/, {BaseUrl}"},
|
||||
}
|
||||
@ -153,8 +150,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
public void should_use_base_url_partial_placeholder()
|
||||
{
|
||||
var reRoute = new FileReRoute
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Location", "http://www.bbc.co.uk/pay, {BaseUrl}pay"},
|
||||
}
|
||||
@ -176,8 +173,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
public void should_add_trace_id_header()
|
||||
{
|
||||
var reRoute = new FileReRoute
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Trace-Id", "{TraceId}"},
|
||||
}
|
||||
@ -244,8 +241,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
_result.AddHeadersToDownstream[0].Key.ShouldBe(addHeader.Key);
|
||||
_result.AddHeadersToDownstream[0].Value.ShouldBe(addHeader.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ThenTheFollowingAddHeaderToUpstreamIsReturned(AddHeader addHeader)
|
||||
{
|
||||
_result.AddHeadersToUpstream[0].Key.ShouldBe(addHeader.Key);
|
||||
@ -254,8 +251,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
private void ThenTheFollowingDownstreamIsReturned(List<HeaderFindAndReplace> downstream)
|
||||
{
|
||||
_result.Downstream.Count.ShouldBe(downstream.Count);
|
||||
|
||||
_result.Downstream.Count.ShouldBe(downstream.Count);
|
||||
|
||||
for (int i = 0; i < _result.Downstream.Count; i++)
|
||||
{
|
||||
var result = _result.Downstream[i];
|
||||
@ -264,7 +261,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
result.Index.ShouldBe(expected.Index);
|
||||
result.Key.ShouldBe(expected.Key);
|
||||
result.Replace.ShouldBe(expected.Replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GivenTheReRoute(FileReRoute reRoute)
|
||||
@ -279,8 +276,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
|
||||
private void ThenTheFollowingUpstreamIsReturned(List<HeaderFindAndReplace> expecteds)
|
||||
{
|
||||
_result.Upstream.Count.ShouldBe(expecteds.Count);
|
||||
|
||||
_result.Upstream.Count.ShouldBe(expecteds.Count);
|
||||
|
||||
for (int i = 0; i < _result.Upstream.Count; i++)
|
||||
{
|
||||
var result = _result.Upstream[i];
|
||||
@ -292,4 +289,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Requester;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Logging;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Logging;
|
||||
|
||||
public class HttpHandlerOptionsCreatorTests
|
||||
{
|
||||
@ -34,7 +33,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_not_use_tracing_if_fake_tracer_registered()
|
||||
{
|
||||
var fileReRoute = new FileReRoute
|
||||
var fileReRoute = new FileReRoute
|
||||
{
|
||||
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||
{
|
||||
@ -53,7 +52,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_use_tracing_if_real_tracer_registered()
|
||||
{
|
||||
var fileReRoute = new FileReRoute
|
||||
var fileReRoute = new FileReRoute
|
||||
{
|
||||
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||
{
|
||||
@ -165,7 +164,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_httpHandlerOptionsCreator = new HttpHandlerOptionsCreator(_serviceProvider);
|
||||
}
|
||||
|
||||
class FakeTracer : ITracer
|
||||
private class FakeTracer : ITracer
|
||||
{
|
||||
public void Event(HttpContext httpContext, string @event)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Repository;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -71,7 +71,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.IsError.ShouldBeFalse();
|
||||
}
|
||||
|
||||
class FakeConfig : IInternalConfiguration
|
||||
private class FakeConfig : IInternalConfiguration
|
||||
{
|
||||
private readonly string _downstreamTemplatePath;
|
||||
|
||||
@ -100,15 +100,15 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
public string AdministrationPath {get;}
|
||||
public string AdministrationPath { get; }
|
||||
|
||||
public ServiceProviderConfiguration ServiceProviderConfiguration => throw new NotImplementedException();
|
||||
|
||||
public string RequestId {get;}
|
||||
public string RequestId { get; }
|
||||
public LoadBalancerOptions LoadBalancerOptions { get; }
|
||||
public string DownstreamScheme { get; }
|
||||
public QoSOptions QoSOptions { get; }
|
||||
public HttpHandlerOptions HttpHandlerOptions { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
public QoSOptionsCreatorTests()
|
||||
{
|
||||
_creator = new QoSOptionsCreator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_create_qos_options()
|
||||
{
|
||||
@ -26,7 +26,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
QoSOptions = new FileQoSOptions
|
||||
{
|
||||
ExceptionsAllowedBeforeBreaking = 1,
|
||||
ExceptionsAllowedBeforeBreaking = 1,
|
||||
DurationOfBreak = 1,
|
||||
TimeoutValue = 1
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.LoadBalancer.LoadBalancers;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
var reRoute = new FileReRoute
|
||||
{
|
||||
UpstreamPathTemplate = "/api/product",
|
||||
UpstreamHttpMethod = new List<string> {"GET", "POST", "PUT"},
|
||||
UpstreamHttpMethod = new List<string> { "GET", "POST", "PUT" },
|
||||
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||
{
|
||||
new FileHostAndPort
|
||||
@ -80,6 +80,5 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
_result.ShouldBe(expected);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -19,7 +19,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
_creator = new ReRouteOptionsCreator();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void should_create_re_route_options()
|
||||
{
|
||||
|
@ -1,8 +1,5 @@
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using Ocelot.Cache;
|
||||
using Ocelot.Configuration;
|
||||
@ -11,6 +8,8 @@
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Values;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -31,7 +30,7 @@
|
||||
private Mock<ILoadBalancerOptionsCreator> _lboCreator;
|
||||
private Mock<IReRouteKeyCreator> _rrkCreator;
|
||||
private Mock<ISecurityOptionsCreator> _soCreator;
|
||||
private FileConfiguration _fileConfig;
|
||||
private FileConfiguration _fileConfig;
|
||||
private ReRouteOptions _rro;
|
||||
private string _requestId;
|
||||
private string _rrk;
|
||||
|
@ -56,7 +56,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
var reRoute = new FileReRoute
|
||||
{
|
||||
RequestIdKey = "cheese"
|
||||
};
|
||||
};
|
||||
var globalConfig = new FileGlobalConfiguration
|
||||
{
|
||||
RequestIdKey = "test"
|
||||
@ -89,4 +89,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Configuration.File;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -49,7 +47,6 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_fileReRoute = reRoute;
|
||||
}
|
||||
|
||||
|
||||
private void WhenICreate()
|
||||
{
|
||||
_result = _creator.Create(_fileReRoute.SecurityOptions);
|
||||
@ -67,6 +64,5 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.IPBlockedList[i].ShouldBe(expected.IPBlockedList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
Type = "ServiceFabric",
|
||||
Token = "testtoken",
|
||||
ConfigurationKey = "woo",
|
||||
Namespace ="default"
|
||||
Namespace = "default"
|
||||
}
|
||||
};
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.When(x => x.WhenICreate())
|
||||
.Then(x => x.ThenTheConfigIs(expected))
|
||||
.BDDfy();
|
||||
}
|
||||
}
|
||||
|
||||
private void GivenTheFollowingGlobalConfig(FileGlobalConfiguration fileGlobalConfig)
|
||||
{
|
||||
|
@ -101,11 +101,11 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_set_upstream_template_pattern_to_respect_case_sensitivity()
|
||||
{
|
||||
var fileReRoute = new FileReRoute
|
||||
{
|
||||
UpstreamPathTemplate = "/PRODUCTS/{productId}",
|
||||
ReRouteIsCaseSensitive = true
|
||||
};
|
||||
var fileReRoute = new FileReRoute
|
||||
{
|
||||
UpstreamPathTemplate = "/PRODUCTS/{productId}",
|
||||
ReRouteIsCaseSensitive = true
|
||||
};
|
||||
this.Given(x => x.GivenTheFollowingFileReRoute(fileReRoute))
|
||||
.When(x => x.WhenICreateTheTemplatePattern())
|
||||
.Then(x => x.ThenTheFollowingIsReturned("^/PRODUCTS/.+$"))
|
||||
|
@ -1,25 +1,25 @@
|
||||
namespace Ocelot.UnitTests.Configuration.Validation
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Validator;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Ocelot.Requester;
|
||||
using Requester;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.ServiceDiscovery;
|
||||
using Ocelot.ServiceDiscovery.Providers;
|
||||
using Ocelot.Values;
|
||||
using Ocelot.ServiceDiscovery;
|
||||
using Requester;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
public class FileConfigurationFluentValidatorTests
|
||||
{
|
||||
@ -126,7 +126,7 @@
|
||||
.Then(x => x.ThenTheResultIsValid())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void configuration_is_invalid_if_service_discovery_options_specified_but_no_service_discovery_handler()
|
||||
{
|
||||
@ -300,7 +300,7 @@
|
||||
.Then(x => x.ThenTheResultIsValid())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void configuration_is_invalid_if_qos_options_specified_but_no_qos_handler()
|
||||
{
|
||||
@ -1382,7 +1382,7 @@
|
||||
private void GivenAQoSHandler()
|
||||
{
|
||||
var collection = new ServiceCollection();
|
||||
QosDelegatingHandlerDelegate del = (a,b) => new FakeDelegatingHandler();
|
||||
QosDelegatingHandlerDelegate del = (a, b) => new FakeDelegatingHandler();
|
||||
collection.AddSingleton<QosDelegatingHandlerDelegate>(del);
|
||||
var provider = collection.BuildServiceProvider();
|
||||
_configurationValidator = new FileConfigurationFluentValidator(provider, new ReRouteFluentValidator(_authProvider.Object, new HostAndPortValidator(), new FileQoSOptionsFluentValidator(provider)), new FileGlobalConfigurationFluentValidator(new FileQoSOptionsFluentValidator(provider)));
|
||||
@ -1391,7 +1391,7 @@
|
||||
private void GivenAServiceDiscoveryHandler()
|
||||
{
|
||||
var collection = new ServiceCollection();
|
||||
ServiceDiscoveryFinderDelegate del = (a,b,c) => new FakeServiceDiscoveryProvider();
|
||||
ServiceDiscoveryFinderDelegate del = (a, b, c) => new FakeServiceDiscoveryProvider();
|
||||
collection.AddSingleton<ServiceDiscoveryFinderDelegate>(del);
|
||||
var provider = collection.BuildServiceProvider();
|
||||
_configurationValidator = new FileConfigurationFluentValidator(provider, new ReRouteFluentValidator(_authProvider.Object, new HostAndPortValidator(), new FileQoSOptionsFluentValidator(provider)), new FileGlobalConfigurationFluentValidator(new FileQoSOptionsFluentValidator(provider)));
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using FluentValidation.Results;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Validator;
|
||||
using Ocelot.Requester;
|
||||
@ -64,7 +62,6 @@ namespace Ocelot.UnitTests.Configuration.Validation
|
||||
.Then(_ => ThenTheResultIsInValid())
|
||||
.And(_ => ThenTheErrorIs())
|
||||
.BDDfy();
|
||||
|
||||
}
|
||||
|
||||
private void ThenTheErrorIs()
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using FluentValidation.Results;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.Configuration.Validator;
|
||||
|
@ -1,8 +1,5 @@
|
||||
namespace Ocelot.UnitTests.Configuration.Validation
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FluentValidation.Results;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -11,6 +8,9 @@
|
||||
using Ocelot.Configuration.Validator;
|
||||
using Ocelot.Requester;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -342,7 +342,7 @@
|
||||
_result.Errors.ShouldContain(x => x.ErrorMessage == expected);
|
||||
}
|
||||
|
||||
class FakeAutheHandler : IAuthenticationHandler
|
||||
private class FakeAutheHandler : IAuthenticationHandler
|
||||
{
|
||||
public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context)
|
||||
{
|
||||
|
Reference in New Issue
Block a user