diff --git a/Ocelot.nuspec b/Ocelot.nuspec
index 17c4071f..f9875da0 100644
--- a/Ocelot.nuspec
+++ b/Ocelot.nuspec
@@ -25,8 +25,6 @@
-
-
diff --git a/README.md b/README.md
index ca6670a6..7091d719 100644
--- a/README.md
+++ b/README.md
@@ -31,11 +31,76 @@ All versions can be found [here](https://www.nuget.org/packages/Ocelot/)
## Configuration
-An example configuration can be found [here](https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/configuration.yaml). More detailed instructions to come on how to configure this.
+An example configuration can be found [here](https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/configuration.json). More detailed instructions to come on how to configure this.
+
+"ReRoutes": [
+ {
+ # The url we are forwarding the request to
+ "UpstreamTemplate": "/identityserverexample",
+ # The path we are listening on for this re route
+ "UpstreamTemplate": "/identityserverexample",
+ # The method we are listening for on this re route
+ "UpstreamHttpMethod": "Get",
+ # Only support identity server at the moment
+ "AuthenticationOptions": {
+ "Provider": "IdentityServer",
+ "ProviderRootUrl": "http://localhost:52888",
+ "ScopeName": "api",
+ "AdditionalScopes": [
+ "openid",
+ "offline_access"
+ ],
+ # Required if using reference tokens
+ "ScopeSecret": "secret"
+ },
+ # WARNING - will overwrite any headers already in the request with these values.
+ # Ocelot will look in the user claims for the key in [] then return the value and save
+ # it as a header with the given key before the colon (:). The index selection on value
+ # means that Ocelot will use the delimiter specified after the next > to split the
+ # claim value and return the index specified.
+ "AddHeadersToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ # WARNING - will overwrite any claims already in the request with these values.
+ # Ocelot will look in the user claims for the key in [] then return the value and save
+ # it as a claim with the given key before the colon (:). The index selection on value
+ # means that Ocelot will use the delimiter specified after the next > to split the
+ # claim value and return the index specified.
+ "AddClaimsToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ # WARNING - will overwrite any query string entries already in the request with these values.
+ # Ocelot will look in the user claims for the key in [] then return the value and save
+ # it as a query string with the given key before the colon (:). The index selection on value
+ # means that Ocelot will use the delimiter specified after the next > to split the
+ # claim value and return the index specified.
+ "AddQueriesToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ # This specifies any claims that are required for the user to access this re route.
+ # In this example the user must have the claim type UserType and
+ # the value must be registered
+ "RouteClaimsRequirement": {
+ "UserType": "registered"
+ },
+ # This tells Ocelot to look for a header and use its value as a request/correlation id.
+ # If it is set here then the id will be forwarded to the downstream service. If it
+ # does not then it will not be forwarded
+ "RequestIdKey": "OcRequestId"
+ }
## Startup
-An example startup using a yaml file for configuration can be seen below. Currently this is the only way to get configuration into Ocelot.
+An example startup using a json file for configuration can be seen below. Currently this is the only way to get configuration into Ocelot.
public class Startup
{
@@ -45,9 +110,9 @@ An example startup using a yaml file for configuration can be seen below. Curren
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile("configuration.json", optional: true, reloadOnChange: true)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
- .AddYamlFile("configuration.yaml")
.AddEnvironmentVariables();
Configuration = builder.Build();
@@ -56,7 +121,7 @@ An example startup using a yaml file for configuration can be seen below. Curren
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
- services.AddOcelotYamlConfiguration(Configuration);
+ services.AddOcelotFileConfiguration(Configuration);
services.AddOcelot();
}
diff --git a/src/Ocelot/Configuration/Creator/YamlOcelotConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs
similarity index 88%
rename from src/Ocelot/Configuration/Creator/YamlOcelotConfigurationCreator.cs
rename to src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs
index d35a7321..510eb25a 100644
--- a/src/Ocelot/Configuration/Creator/YamlOcelotConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs
@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using Ocelot.Configuration.File;
using Ocelot.Configuration.Parser;
using Ocelot.Configuration.Validator;
-using Ocelot.Configuration.Yaml;
using Ocelot.Responses;
namespace Ocelot.Configuration.Creator
@@ -13,20 +13,20 @@ namespace Ocelot.Configuration.Creator
///
/// Register as singleton
///
- public class YamlOcelotConfigurationCreator : IOcelotConfigurationCreator
+ public class FileOcelotConfigurationCreator : IOcelotConfigurationCreator
{
- private readonly IOptions _options;
+ private readonly IOptions _options;
private readonly IConfigurationValidator _configurationValidator;
private const string RegExMatchEverything = ".*";
private const string RegExMatchEndString = "$";
private readonly IClaimToThingConfigurationParser _claimToThingConfigurationParser;
- private readonly ILogger _logger;
+ private readonly ILogger _logger;
- public YamlOcelotConfigurationCreator(
- IOptions options,
+ public FileOcelotConfigurationCreator(
+ IOptions options,
IConfigurationValidator configurationValidator,
IClaimToThingConfigurationParser claimToThingConfigurationParser,
- ILogger logger)
+ ILogger logger)
{
_options = options;
_configurationValidator = configurationValidator;
@@ -42,7 +42,7 @@ namespace Ocelot.Configuration.Creator
}
///
- /// This method is meant to be tempoary to convert a yaml config to an ocelot config...probably wont keep this but we will see
+ /// This method is meant to be tempoary to convert a config to an ocelot config...probably wont keep this but we will see
/// will need a refactor at some point as its crap
///
private IOcelotConfiguration SetUpConfiguration()
@@ -63,16 +63,16 @@ namespace Ocelot.Configuration.Creator
var reRoutes = new List();
- foreach (var yamlReRoute in _options.Value.ReRoutes)
+ foreach (var reRoute in _options.Value.ReRoutes)
{
- var ocelotReRoute = SetUpReRoute(yamlReRoute);
+ var ocelotReRoute = SetUpReRoute(reRoute);
reRoutes.Add(ocelotReRoute);
}
return new OcelotConfiguration(reRoutes);
}
- private ReRoute SetUpReRoute(YamlReRoute reRoute)
+ private ReRoute SetUpReRoute(FileReRoute reRoute)
{
var upstreamTemplate = reRoute.UpstreamTemplate;
diff --git a/src/Ocelot/Configuration/Yaml/YamlAuthenticationOptions.cs b/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
similarity index 64%
rename from src/Ocelot/Configuration/Yaml/YamlAuthenticationOptions.cs
rename to src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
index 16faa03e..0904d87e 100644
--- a/src/Ocelot/Configuration/Yaml/YamlAuthenticationOptions.cs
+++ b/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
@@ -1,9 +1,14 @@
using System.Collections.Generic;
-namespace Ocelot.Configuration.Yaml
+namespace Ocelot.Configuration.File
{
- public class YamlAuthenticationOptions
+ public class FileAuthenticationOptions
{
+ public FileAuthenticationOptions()
+ {
+ AdditionalScopes = new List();
+ }
+
public string Provider { get; set; }
public string ProviderRootUrl { get; set; }
public string ScopeName { get; set; }
diff --git a/src/Ocelot/Configuration/File/FileConfiguration.cs b/src/Ocelot/Configuration/File/FileConfiguration.cs
new file mode 100644
index 00000000..d82fb94e
--- /dev/null
+++ b/src/Ocelot/Configuration/File/FileConfiguration.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+
+namespace Ocelot.Configuration.File
+{
+ public class FileConfiguration
+ {
+ public FileConfiguration()
+ {
+ ReRoutes = new List();
+ }
+
+ public List ReRoutes { get; set; }
+ }
+}
diff --git a/src/Ocelot/Configuration/Yaml/YamlReRoute.cs b/src/Ocelot/Configuration/File/FileReRoute.cs
similarity index 79%
rename from src/Ocelot/Configuration/Yaml/YamlReRoute.cs
rename to src/Ocelot/Configuration/File/FileReRoute.cs
index 03dbe593..78a4d137 100644
--- a/src/Ocelot/Configuration/Yaml/YamlReRoute.cs
+++ b/src/Ocelot/Configuration/File/FileReRoute.cs
@@ -1,21 +1,22 @@
using System.Collections.Generic;
-namespace Ocelot.Configuration.Yaml
+namespace Ocelot.Configuration.File
{
- public class YamlReRoute
+ public class FileReRoute
{
- public YamlReRoute()
+ public FileReRoute()
{
AddHeadersToRequest = new Dictionary();
AddClaimsToRequest = new Dictionary();
RouteClaimsRequirement = new Dictionary();
AddQueriesToRequest = new Dictionary();
+ AuthenticationOptions = new FileAuthenticationOptions();
}
public string DownstreamTemplate { get; set; }
public string UpstreamTemplate { get; set; }
public string UpstreamHttpMethod { get; set; }
- public YamlAuthenticationOptions AuthenticationOptions { get; set; }
+ public FileAuthenticationOptions AuthenticationOptions { get; set; }
public Dictionary AddHeadersToRequest { get; set; }
public Dictionary AddClaimsToRequest { get; set; }
public Dictionary RouteClaimsRequirement { get; set; }
diff --git a/src/Ocelot/Configuration/Validator/YamlConfigurationValidator.cs b/src/Ocelot/Configuration/Validator/FileConfigurationValidator.cs
similarity index 75%
rename from src/Ocelot/Configuration/Validator/YamlConfigurationValidator.cs
rename to src/Ocelot/Configuration/Validator/FileConfigurationValidator.cs
index b69e9621..fb55a10b 100644
--- a/src/Ocelot/Configuration/Validator/YamlConfigurationValidator.cs
+++ b/src/Ocelot/Configuration/Validator/FileConfigurationValidator.cs
@@ -2,15 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using Ocelot.Authentication.Handler;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using Ocelot.Errors;
using Ocelot.Responses;
namespace Ocelot.Configuration.Validator
{
- public class YamlConfigurationValidator : IConfigurationValidator
+ public class FileConfigurationValidator : IConfigurationValidator
{
- public Response IsValid(YamlConfiguration configuration)
+ public Response IsValid(FileConfiguration configuration)
{
var result = CheckForDupliateReRoutes(configuration);
@@ -29,25 +29,25 @@ namespace Ocelot.Configuration.Validator
return new OkResponse(result);
}
- private ConfigurationValidationResult CheckForUnsupportedAuthenticationProviders(YamlConfiguration configuration)
+ private ConfigurationValidationResult CheckForUnsupportedAuthenticationProviders(FileConfiguration configuration)
{
var errors = new List();
- foreach (var yamlReRoute in configuration.ReRoutes)
+ foreach (var reRoute in configuration.ReRoutes)
{
- var isAuthenticated = !string.IsNullOrEmpty(yamlReRoute.AuthenticationOptions?.Provider);
+ var isAuthenticated = !string.IsNullOrEmpty(reRoute.AuthenticationOptions?.Provider);
if (!isAuthenticated)
{
continue;
}
- if (IsSupportedAuthenticationProvider(yamlReRoute.AuthenticationOptions?.Provider))
+ if (IsSupportedAuthenticationProvider(reRoute.AuthenticationOptions?.Provider))
{
continue;
}
- var error = new UnsupportedAuthenticationProviderError($"{yamlReRoute.AuthenticationOptions?.Provider} is unsupported authentication provider, upstream template is {yamlReRoute.UpstreamTemplate}, upstream method is {yamlReRoute.UpstreamHttpMethod}");
+ var error = new UnsupportedAuthenticationProviderError($"{reRoute.AuthenticationOptions?.Provider} is unsupported authentication provider, upstream template is {reRoute.UpstreamTemplate}, upstream method is {reRoute.UpstreamHttpMethod}");
errors.Add(error);
}
@@ -63,7 +63,7 @@ namespace Ocelot.Configuration.Validator
return Enum.TryParse(provider, true, out supportedProvider);
}
- private ConfigurationValidationResult CheckForDupliateReRoutes(YamlConfiguration configuration)
+ private ConfigurationValidationResult CheckForDupliateReRoutes(FileConfiguration configuration)
{
var hasDupes = configuration.ReRoutes
.GroupBy(x => new { x.UpstreamTemplate, x.UpstreamHttpMethod }).Any(x => x.Skip(1).Any());
diff --git a/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs b/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
index 10955836..09bf7dae 100644
--- a/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
+++ b/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
@@ -1,10 +1,10 @@
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using Ocelot.Responses;
namespace Ocelot.Configuration.Validator
{
public interface IConfigurationValidator
{
- Response IsValid(YamlConfiguration configuration);
+ Response IsValid(FileConfiguration configuration);
}
}
diff --git a/src/Ocelot/Configuration/Yaml/YamlConfiguration.cs b/src/Ocelot/Configuration/Yaml/YamlConfiguration.cs
deleted file mode 100644
index 2224f7d5..00000000
--- a/src/Ocelot/Configuration/Yaml/YamlConfiguration.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Collections.Generic;
-
-namespace Ocelot.Configuration.Yaml
-{
- public class YamlConfiguration
- {
- public YamlConfiguration()
- {
- ReRoutes = new List();
- }
-
- public List ReRoutes { get; set; }
- }
-}
diff --git a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
index 51299365..4984fc91 100644
--- a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
+++ b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
@@ -6,11 +6,11 @@ using Ocelot.Authentication.Handler.Factory;
using Ocelot.Authorisation;
using Ocelot.Claims;
using Ocelot.Configuration.Creator;
+using Ocelot.Configuration.File;
using Ocelot.Configuration.Parser;
using Ocelot.Configuration.Provider;
using Ocelot.Configuration.Repository;
using Ocelot.Configuration.Validator;
-using Ocelot.Configuration.Yaml;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
@@ -26,15 +26,14 @@ namespace Ocelot.DependencyInjection
{
public static class ServiceCollectionExtensions
{
- public static IServiceCollection AddOcelotYamlConfiguration(this IServiceCollection services, IConfigurationRoot configurationRoot)
+ public static IServiceCollection AddOcelotFileConfiguration(this IServiceCollection services, IConfigurationRoot configurationRoot)
{
- // initial configuration from yaml
- services.Configure(configurationRoot);
+ services.Configure(configurationRoot);
// ocelot services.
- services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
return services;
}
diff --git a/src/Ocelot/project.json b/src/Ocelot/project.json
index 05b6adaa..8f194c8a 100644
--- a/src/Ocelot/project.json
+++ b/src/Ocelot/project.json
@@ -27,16 +27,12 @@
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
- },
- "NetEscapades.Configuration.Yaml": "1.2.0",
- "YamlDotNet": "4.0.0"
+ }
},
"frameworks": {
"netcoreapp1.4": {
"imports": [
- "dotnet5.6",
- "portable-net45+win8"
]
}
}
diff --git a/test/Ocelot.AcceptanceTests/AuthenticationTests.cs b/test/Ocelot.AcceptanceTests/AuthenticationTests.cs
index 4c68d85b..da63d134 100644
--- a/test/Ocelot.AcceptanceTests/AuthenticationTests.cs
+++ b/test/Ocelot.AcceptanceTests/AuthenticationTests.cs
@@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -31,16 +31,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_401_using_identity_server_access_token()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -55,7 +55,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceRootUrl, 201, string.Empty))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenThePostHasContent("postContent"))
.When(x => _steps.WhenIPostUrlOnTheApiGateway("/"))
@@ -66,16 +66,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_401_using_identity_server_reference_token()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -90,7 +90,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", AccessTokenType.Reference))
.And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceRootUrl, 201, string.Empty))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenThePostHasContent("postContent"))
.When(x => _steps.WhenIPostUrlOnTheApiGateway("/"))
@@ -101,16 +101,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_using_identity_server()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -126,7 +126,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceRootUrl, 200, "Hello from Laura"))
.And(x => _steps.GivenIHaveAToken(_identityServerRootUrl))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
@@ -138,16 +138,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_201_using_identity_server_access_token()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -163,7 +163,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceRootUrl, 201, string.Empty))
.And(x => _steps.GivenIHaveAToken(_identityServerRootUrl))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.And(x => _steps.GivenThePostHasContent("postContent"))
@@ -175,16 +175,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_201_using_identity_server_reference_token()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -200,7 +200,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", AccessTokenType.Reference))
.And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceRootUrl, 201, string.Empty))
.And(x => _steps.GivenIHaveAToken(_identityServerRootUrl))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.And(x => _steps.GivenThePostHasContent("postContent"))
diff --git a/test/Ocelot.AcceptanceTests/AuthorisationTests.cs b/test/Ocelot.AcceptanceTests/AuthorisationTests.cs
index bd2a9cab..8dfb1314 100644
--- a/test/Ocelot.AcceptanceTests/AuthorisationTests.cs
+++ b/test/Ocelot.AcceptanceTests/AuthorisationTests.cs
@@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -29,16 +29,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_authorising_route()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -71,7 +71,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:51888", "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51876", 200, "Hello from Laura"))
.And(x => _steps.GivenIHaveAToken("http://localhost:51888"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
@@ -83,16 +83,16 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_403_authorising_route()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -124,7 +124,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:51888", "api", AccessTokenType.Jwt))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51876", 200, "Hello from Laura"))
.And(x => _steps.GivenIHaveAToken("http://localhost:51888"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
diff --git a/test/Ocelot.AcceptanceTests/ClaimsToHeadersForwardingTests.cs b/test/Ocelot.AcceptanceTests/ClaimsToHeadersForwardingTests.cs
index 0569c90a..c181a445 100644
--- a/test/Ocelot.AcceptanceTests/ClaimsToHeadersForwardingTests.cs
+++ b/test/Ocelot.AcceptanceTests/ClaimsToHeadersForwardingTests.cs
@@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -44,16 +44,16 @@ namespace Ocelot.AcceptanceTests
}
};
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:52876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List
{
@@ -79,7 +79,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:52888", "api", AccessTokenType.Jwt, user))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:52876", 200))
.And(x => _steps.GivenIHaveAToken("http://localhost:52888"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
diff --git a/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs b/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs
index a98031ec..51e76942 100644
--- a/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs
+++ b/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs
@@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -44,16 +44,16 @@ namespace Ocelot.AcceptanceTests
}
};
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:57876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List
{
@@ -79,7 +79,7 @@ namespace Ocelot.AcceptanceTests
this.Given(x => x.GivenThereIsAnIdentityServerOn("http://localhost:57888", "api", AccessTokenType.Jwt, user))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:57876", 200))
.And(x => _steps.GivenIHaveAToken("http://localhost:57888"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenIHaveAddedATokenToMyRequest())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
diff --git a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs
index abc7f9b8..ec00a6af 100644
--- a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs
+++ b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs
@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
using TestStack.BDDfy;
@@ -25,7 +25,7 @@ namespace Ocelot.AcceptanceTests
public CustomMiddlewareTests()
{
_steps = new Steps();;
- _configurationPath = "configuration.yaml";
+ _configurationPath = "configuration.json";
}
[Fact]
@@ -39,11 +39,11 @@ namespace Ocelot.AcceptanceTests
}
};
- var yamlConfiguration = new YamlConfiguration
+ var fileConfiguration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:41879/",
UpstreamTemplate = "/",
@@ -53,7 +53,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:41879", 200))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration, _configurationPath))
+ .And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
@@ -72,11 +72,11 @@ namespace Ocelot.AcceptanceTests
}
};
- var yamlConfiguration = new YamlConfiguration
+ var fileConfiguration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:41879/",
UpstreamTemplate = "/",
@@ -86,7 +86,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:41879", 200))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration, _configurationPath))
+ .And(x => _steps.GivenThereIsAConfiguration(fileConfiguration, _configurationPath))
.And(x => _steps.GivenOcelotIsRunning(configuration))
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
diff --git a/test/Ocelot.AcceptanceTests/RequestIdTests.cs b/test/Ocelot.AcceptanceTests/RequestIdTests.cs
index 0c3407b5..7a733f24 100644
--- a/test/Ocelot.AcceptanceTests/RequestIdTests.cs
+++ b/test/Ocelot.AcceptanceTests/RequestIdTests.cs
@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -27,11 +27,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_use_default_request_id_and_forward()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
UpstreamTemplate = "/",
@@ -42,7 +42,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheRequestIdIsReturned())
@@ -52,11 +52,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_use_request_id_and_forward()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
UpstreamTemplate = "/",
@@ -69,7 +69,7 @@ namespace Ocelot.AcceptanceTests
var requestId = Guid.NewGuid().ToString();
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/", requestId))
.Then(x => _steps.ThenTheRequestIdIsReturned(requestId))
diff --git a/test/Ocelot.AcceptanceTests/ReturnsErrorTests.cs b/test/Ocelot.AcceptanceTests/ReturnsErrorTests.cs
index 1feb8f67..902de662 100644
--- a/test/Ocelot.AcceptanceTests/ReturnsErrorTests.cs
+++ b/test/Ocelot.AcceptanceTests/ReturnsErrorTests.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Net;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -23,21 +23,21 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_and_foward_claim_as_header()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:53876/",
UpstreamTemplate = "/",
- UpstreamHttpMethod = "Get",
+ UpstreamHttpMethod = "Get"
}
}
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53876"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.InternalServerError))
diff --git a/test/Ocelot.AcceptanceTests/RoutingTests.cs b/test/Ocelot.AcceptanceTests/RoutingTests.cs
index a7ac4996..57b8fa07 100644
--- a/test/Ocelot.AcceptanceTests/RoutingTests.cs
+++ b/test/Ocelot.AcceptanceTests/RoutingTests.cs
@@ -5,7 +5,7 @@ using System.Net;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using TestStack.BDDfy;
using Xunit;
@@ -24,7 +24,7 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_404_when_no_configuration_at_all()
{
- this.Given(x => _steps.GivenThereIsAConfiguration(new YamlConfiguration()))
+ this.Given(x => _steps.GivenThereIsAConfiguration(new FileConfiguration()))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.NotFound))
@@ -34,11 +34,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_with_simple_url()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
UpstreamTemplate = "/",
@@ -48,7 +48,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
@@ -59,11 +59,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_with_complex_url()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/api/products/{productId}",
UpstreamTemplate = "/products/{productId}",
@@ -73,7 +73,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/api/products/1", 200, "Some Product"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/1"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
@@ -84,11 +84,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_201_with_simple_url()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
UpstreamTemplate = "/",
@@ -98,7 +98,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 201, string.Empty))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.And(x => _steps.GivenThePostHasContent("postContent"))
.When(x => _steps.WhenIPostUrlOnTheApiGateway("/"))
@@ -109,11 +109,11 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_201_with_complex_query_string()
{
- var yamlConfiguration = new YamlConfiguration
+ var configuration = new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/newThing",
UpstreamTemplate = "/newThing",
@@ -123,7 +123,7 @@ namespace Ocelot.AcceptanceTests
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
- .And(x => _steps.GivenThereIsAConfiguration(yamlConfiguration))
+ .And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/newThing?DeviceType=IphoneApp&Browser=moonpigIphone&BrowserString=-&CountryCode=123&DeviceName=iPhone 5 (GSM+CDMA)&OperatingSystem=iPhone OS 7.1.2&BrowserVersion=3708AdHoc&ipAddress=-"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs
index 23a7cdbc..7b9a8f83 100644
--- a/test/Ocelot.AcceptanceTests/Steps.cs
+++ b/test/Ocelot.AcceptanceTests/Steps.cs
@@ -10,12 +10,11 @@ using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
-using Ocelot.Configuration.Yaml;
+using Ocelot.Configuration.File;
using Ocelot.DependencyInjection;
using Ocelot.ManualTest;
using Ocelot.Middleware;
using Shouldly;
-using YamlDotNet.Serialization;
namespace Ocelot.AcceptanceTests
{
@@ -29,40 +28,34 @@ namespace Ocelot.AcceptanceTests
public HttpClient OcelotClient => _ocelotClient;
public string RequestIdKey = "OcRequestId";
- public void GivenThereIsAConfiguration(YamlConfiguration yamlConfiguration)
+ public void GivenThereIsAConfiguration(FileConfiguration fileConfiguration)
{
var configurationPath = TestConfiguration.ConfigurationPath;
- var serializer = new Serializer();
+ var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration);
if (File.Exists(configurationPath))
{
File.Delete(configurationPath);
}
- using (TextWriter writer = File.CreateText(configurationPath))
- {
- serializer.Serialize(writer, yamlConfiguration);
- }
+ File.WriteAllText(configurationPath, jsonConfiguration);
}
- public void GivenThereIsAConfiguration(YamlConfiguration yamlConfiguration, string configurationPath)
+ public void GivenThereIsAConfiguration(FileConfiguration fileConfiguration, string configurationPath)
{
- var serializer = new Serializer();
+ var jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration);
if (File.Exists(configurationPath))
{
File.Delete(configurationPath);
}
- using (TextWriter writer = File.CreateText(configurationPath))
- {
- serializer.Serialize(writer, yamlConfiguration);
- }
+ File.WriteAllText(configurationPath, jsonConfiguration);
}
///
- /// This is annoying cos it should be in the constructor but we need to set up the yaml file before calling startup so its a step.
+ /// This is annoying cos it should be in the constructor but we need to set up the file before calling startup so its a step.
///
public void GivenOcelotIsRunning()
{
@@ -73,14 +66,14 @@ namespace Ocelot.AcceptanceTests
}
///
- /// This is annoying cos it should be in the constructor but we need to set up the yaml file before calling startup so its a step.
+ /// This is annoying cos it should be in the constructor but we need to set up the file before calling startup so its a step.
///
public void GivenOcelotIsRunning(OcelotMiddlewareConfiguration ocelotMiddlewareConfig)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddYamlFile("configuration.yaml")
+ .AddJsonFile("configuration.json")
.AddEnvironmentVariables();
var configuration = builder.Build();
@@ -89,7 +82,7 @@ namespace Ocelot.AcceptanceTests
.UseConfiguration(configuration)
.ConfigureServices(s =>
{
- s.AddOcelotYamlConfiguration(configuration);
+ s.AddOcelotFileConfiguration(configuration);
s.AddOcelot();
})
.ConfigureLogging(l =>
diff --git a/test/Ocelot.AcceptanceTests/TestConfiguration.cs b/test/Ocelot.AcceptanceTests/TestConfiguration.cs
index 59547854..69ccc690 100644
--- a/test/Ocelot.AcceptanceTests/TestConfiguration.cs
+++ b/test/Ocelot.AcceptanceTests/TestConfiguration.cs
@@ -3,6 +3,6 @@
public static class TestConfiguration
{
public static double Version => 1.4;
- public static string ConfigurationPath => $"./bin/Debug/netcoreapp{Version}/configuration.yaml";
+ public static string ConfigurationPath => $"./bin/Debug/netcoreapp{Version}/configuration.json";
}
}
diff --git a/test/Ocelot.AcceptanceTests/configuration.json b/test/Ocelot.AcceptanceTests/configuration.json
new file mode 100644
index 00000000..b4a490dc
--- /dev/null
+++ b/test/Ocelot.AcceptanceTests/configuration.json
@@ -0,0 +1 @@
+{"ReRoutes":[{"DownstreamTemplate":"http://localhost:41879/","UpstreamTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null}]}
\ No newline at end of file
diff --git a/test/Ocelot.AcceptanceTests/configuration.yaml b/test/Ocelot.AcceptanceTests/configuration.yaml
deleted file mode 100644
index 82266808..00000000
--- a/test/Ocelot.AcceptanceTests/configuration.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-ReRoutes:
-- DownstreamTemplate: http://localhost:41879/
- UpstreamTemplate: /
- UpstreamHttpMethod: Get
- AddHeadersToRequest: {}
- AddClaimsToRequest: {}
- RouteClaimsRequirement: {}
- AddQueriesToRequest: {}
diff --git a/test/Ocelot.AcceptanceTests/project.json b/test/Ocelot.AcceptanceTests/project.json
index b58a4f94..dec6fd7b 100644
--- a/test/Ocelot.AcceptanceTests/project.json
+++ b/test/Ocelot.AcceptanceTests/project.json
@@ -4,7 +4,7 @@
"buildOptions": {
"copyToOutput": {
"include": [
- "middlewareConfiguration.yaml"
+ "configuration.json"
]
}
},
@@ -22,7 +22,7 @@
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.AspNetCore.Http": "1.0.0",
"Ocelot": "1.0.0-*",
- "xunit": "2.1.0",
+ "xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Ocelot.ManualTest": "1.0.0-*",
"Microsoft.AspNetCore.TestHost": "1.0.0",
@@ -34,15 +34,12 @@
"type": "platform"
},
"Shouldly": "2.8.2",
- "TestStack.BDDfy": "4.3.2",
- "YamlDotNet": "4.0.0"
+ "TestStack.BDDfy": "4.3.2"
},
"frameworks": {
"netcoreapp1.4": {
"imports": [
- "dotnet5.6",
- "portable-net45+win8"
]
}
}
diff --git a/test/Ocelot.Benchmarks/project.json b/test/Ocelot.Benchmarks/project.json
index 89133711..791fea3d 100644
--- a/test/Ocelot.Benchmarks/project.json
+++ b/test/Ocelot.Benchmarks/project.json
@@ -16,8 +16,6 @@
"frameworks": {
"netcoreapp1.4": {
"imports": [
- "dotnet5.6",
- "portable-net45+win8"
]
}
}
diff --git a/test/Ocelot.ManualTest/Startup.cs b/test/Ocelot.ManualTest/Startup.cs
index 8eb7cf9f..f53e894c 100644
--- a/test/Ocelot.ManualTest/Startup.cs
+++ b/test/Ocelot.ManualTest/Startup.cs
@@ -16,7 +16,7 @@ namespace Ocelot.ManualTest
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
- .AddYamlFile("configuration.yaml")
+ .AddJsonFile("configuration.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
@@ -27,7 +27,7 @@ namespace Ocelot.ManualTest
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
- services.AddOcelotYamlConfiguration(Configuration);
+ services.AddOcelotFileConfiguration(Configuration);
services.AddOcelot();
}
diff --git a/test/Ocelot.ManualTest/configuration.json b/test/Ocelot.ManualTest/configuration.json
new file mode 100644
index 00000000..6207d5cd
--- /dev/null
+++ b/test/Ocelot.ManualTest/configuration.json
@@ -0,0 +1,81 @@
+{
+ "ReRoutes": [
+ {
+ "DownstreamTemplate": "http://localhost:52876/",
+ "UpstreamTemplate": "/identityserverexample",
+ "UpstreamHttpMethod": "Get",
+ "AuthenticationOptions": {
+ "Provider": "IdentityServer",
+ "ProviderRootUrl": "http://localhost:52888",
+ "ScopeName": "api",
+ "AdditionalScopes": [
+ "openid",
+ "offline_access"
+ ],
+ "ScopeSecret": "secret"
+ },
+ "AddHeadersToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ "AddClaimsToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ "AddQueriesToRequest": {
+ "CustomerId": "Claims[CustomerId] > value",
+ "LocationId": "Claims[LocationId] > value",
+ "UserType": "Claims[sub] > value[0] > |",
+ "UserId": "Claims[sub] > value[1] > |"
+ },
+ "RouteClaimsRequirement": {
+ "UserType": "registered"
+ },
+ "RequestIdKey": "OcRequestId"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts",
+ "UpstreamTemplate": "/posts",
+ "UpstreamHttpMethod": "Get"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
+ "UpstreamTemplate": "/posts/{postId}",
+ "UpstreamHttpMethod": "Get"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}/comments",
+ "UpstreamTemplate": "/posts/{postId}/comments",
+ "UpstreamHttpMethod": "Get"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/comments",
+ "UpstreamTemplate": "/comments",
+ "UpstreamHttpMethod": "Get"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts",
+ "UpstreamTemplate": "/posts",
+ "UpstreamHttpMethod": "Post"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
+ "UpstreamTemplate": "/posts/{postId}",
+ "UpstreamHttpMethod": "Put"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
+ "UpstreamTemplate": "/posts/{postId}",
+ "UpstreamHttpMethod": "Patch"
+ },
+ {
+ "DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
+ "UpstreamTemplate": "/posts/{postId}",
+ "UpstreamHttpMethod": "Delete"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/Ocelot.ManualTest/configuration.yaml b/test/Ocelot.ManualTest/configuration.yaml
deleted file mode 100644
index 2d2aab11..00000000
--- a/test/Ocelot.ManualTest/configuration.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-ReRoutes:
-# The url we are forwarding the request to
-- DownstreamTemplate: http://localhost:52876/
-# The path we are listening on for this re route
- UpstreamTemplate: /identityserverexample
-# The method we are listening for on this re route
- UpstreamHttpMethod: Get
-# Only support identity server at the moment
- AuthenticationOptions:
- Provider: IdentityServer
- ProviderRootUrl: http://localhost:52888
- ScopeName: api
- AdditionalScopes:
- - openid
- - offline_access
-# Required if using reference tokens
- ScopeSecret: secret
-# WARNING - will overwrite any headers already in the request with these values.
-# Ocelot will look in the user claims for the key in [] then return the value and save
-# it as a header with the given key before the colon (:). The index selection on value
-# means that Ocelot will use the delimiter specified after the next > to split the
-# claim value and return the index specified.
- AddHeadersToRequest:
- CustomerId: Claims[CustomerId] > value
- LocationId: Claims[LocationId] > value
- UserType: Claims[sub] > value[0] > |
- UserId: Claims[sub] > value[1] > |
-# WARNING - will overwrite any claims already in the request with these values.
-# Ocelot will look in the user claims for the key in [] then return the value and save
-# it as a claim with the given key before the colon (:). The index selection on value
-# means that Ocelot will use the delimiter specified after the next > to split the
-# claim value and return the index specified.
- AddClaimsToRequest:
- CustomerId: Claims[CustomerId] > value
- LocationId: Claims[LocationId] > value
- UserType: Claims[sub] > value[0] > |
- UserId: Claims[sub] > value[1] > |
-# WARNING - will overwrite any query string entries already in the request with these values.
-# Ocelot will look in the user claims for the key in [] then return the value and save
-# it as a query string with the given key before the colon (:). The index selection on value
-# means that Ocelot will use the delimiter specified after the next > to split the
-# claim value and return the index specified.
- AddQueriesToRequest:
- CustomerId: Claims[CustomerId] > value
- LocationId: Claims[LocationId] > value
- UserType: Claims[sub] > value[0] > |
- UserId: Claims[sub] > value[1] > |
-# This specifies any claims that are required for the user to access this re route.
-# In this example the user must have the claim type UserType and
-# the value must be registered
- RouteClaimsRequirement:
- UserType: registered
-# This tells Ocelot to look for a header and use its value as a request/correlation id.
-# If it is set here then the id will be forwarded to the downstream service. If it
-# does not then it will not be forwarded
- RequestIdKey: OcRequestId
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts
- UpstreamTemplate: /posts
- UpstreamHttpMethod: Get
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
- UpstreamTemplate: /posts/{postId}
- UpstreamHttpMethod: Get
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}/comments
- UpstreamTemplate: /posts/{postId}/comments
- UpstreamHttpMethod: Get
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/comments
- UpstreamTemplate: /comments
- UpstreamHttpMethod: Get
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts
- UpstreamTemplate: /posts
- UpstreamHttpMethod: Post
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
- UpstreamTemplate: /posts/{postId}
- UpstreamHttpMethod: Put
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
- UpstreamTemplate: /posts/{postId}
- UpstreamHttpMethod: Patch
-# The next re route...
-- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
- UpstreamTemplate: /posts/{postId}
- UpstreamHttpMethod: Delete
\ No newline at end of file
diff --git a/test/Ocelot.ManualTest/project.json b/test/Ocelot.ManualTest/project.json
index 13f521b6..65220938 100644
--- a/test/Ocelot.ManualTest/project.json
+++ b/test/Ocelot.ManualTest/project.json
@@ -17,8 +17,7 @@
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
- },
- "NetEscapades.Configuration.Yaml": "1.2.0"
+ }
},
"tools": {
@@ -28,8 +27,6 @@
"frameworks": {
"netcoreapp1.4": {
"imports": [
- "dotnet5.6",
- "portable-net45+win8"
]
}
},
@@ -39,8 +36,7 @@
"preserveCompilationContext": true,
"copyToOutput": {
"include": [
- "middlewareConfiguration.yaml",
- "configuration.yaml"
+ "configuration.json"
]
}
},
@@ -58,8 +54,7 @@
"Areas/**/Views",
"appsettings.json",
"web.config",
- "middlewareConfiguration.yaml",
- "configuration.yaml"
+ "configuration.json"
]
},
diff --git a/test/Ocelot.UnitTests/Configuration/ConfigurationValidationTests.cs b/test/Ocelot.UnitTests/Configuration/ConfigurationValidationTests.cs
index a2ca9b3e..7f6f4005 100644
--- a/test/Ocelot.UnitTests/Configuration/ConfigurationValidationTests.cs
+++ b/test/Ocelot.UnitTests/Configuration/ConfigurationValidationTests.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
+using Ocelot.Configuration.File;
using Ocelot.Configuration.Validator;
-using Ocelot.Configuration.Yaml;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
@@ -10,23 +10,23 @@ namespace Ocelot.UnitTests.Configuration
{
public class ConfigurationValidationTests
{
- private YamlConfiguration _yamlConfiguration;
+ private FileConfiguration _fileConfiguration;
private readonly IConfigurationValidator _configurationValidator;
private Response _result;
public ConfigurationValidationTests()
{
- _configurationValidator = new YamlConfigurationValidator();
+ _configurationValidator = new FileConfigurationValidator();
}
[Fact]
public void configuration_is_valid_with_one_reroute()
{
- this.Given(x => x.GivenAConfiguration(new YamlConfiguration()
+ this.Given(x => x.GivenAConfiguration(new FileConfiguration()
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com"
@@ -41,15 +41,15 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_valid_with_valid_authentication_provider()
{
- this.Given(x => x.GivenAConfiguration(new YamlConfiguration()
+ this.Given(x => x.GivenAConfiguration(new FileConfiguration()
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
Provider = "IdentityServer"
}
@@ -64,15 +64,15 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_invalid_with_invalid_authentication_provider()
{
- this.Given(x => x.GivenAConfiguration(new YamlConfiguration()
+ this.Given(x => x.GivenAConfiguration(new FileConfiguration()
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
Provider = "BootyBootyBottyRockinEverywhere"
}
@@ -88,16 +88,16 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_not_valid_with_duplicate_reroutes()
{
- this.Given(x => x.GivenAConfiguration(new YamlConfiguration()
+ this.Given(x => x.GivenAConfiguration(new FileConfiguration()
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com"
},
- new YamlReRoute
+ new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com"
@@ -110,14 +110,14 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
- private void GivenAConfiguration(YamlConfiguration yamlConfiguration)
+ private void GivenAConfiguration(FileConfiguration fileConfiguration)
{
- _yamlConfiguration = yamlConfiguration;
+ _fileConfiguration = fileConfiguration;
}
private void WhenIValidateTheConfiguration()
{
- _result = _configurationValidator.IsValid(_yamlConfiguration);
+ _result = _configurationValidator.IsValid(_fileConfiguration);
}
private void ThenTheResultIsValid()
diff --git a/test/Ocelot.UnitTests/Configuration/YamlConfigurationCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs
similarity index 82%
rename from test/Ocelot.UnitTests/Configuration/YamlConfigurationCreatorTests.cs
rename to test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs
index 36acefc2..8d0c6092 100644
--- a/test/Ocelot.UnitTests/Configuration/YamlConfigurationCreatorTests.cs
+++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs
@@ -5,9 +5,9 @@ using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
+using Ocelot.Configuration.File;
using Ocelot.Configuration.Parser;
using Ocelot.Configuration.Validator;
-using Ocelot.Configuration.Yaml;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
@@ -15,34 +15,34 @@ using Xunit;
namespace Ocelot.UnitTests.Configuration
{
- public class YamlConfigurationCreatorTests
+ public class FileConfigurationCreatorTests
{
- private readonly Mock> _yamlConfig;
+ private readonly Mock> _fileConfig;
private readonly Mock _validator;
private Response _config;
- private YamlConfiguration _yamlConfiguration;
+ private FileConfiguration _fileConfiguration;
private readonly Mock _configParser;
- private readonly Mock> _logger;
- private readonly YamlOcelotConfigurationCreator _ocelotConfigurationCreator;
+ private readonly Mock> _logger;
+ private readonly FileOcelotConfigurationCreator _ocelotConfigurationCreator;
- public YamlConfigurationCreatorTests()
+ public FileConfigurationCreatorTests()
{
- _logger = new Mock>();
+ _logger = new Mock>();
_configParser = new Mock();
_validator = new Mock();
- _yamlConfig = new Mock>();
- _ocelotConfigurationCreator = new YamlOcelotConfigurationCreator(
- _yamlConfig.Object, _validator.Object, _configParser.Object, _logger.Object);
+ _fileConfig = new Mock>();
+ _ocelotConfigurationCreator = new FileOcelotConfigurationCreator(
+ _fileConfig.Object, _validator.Object, _configParser.Object, _logger.Object);
}
[Fact]
public void should_create_template_pattern_that_matches_anything_to_end_of_string()
{
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/api/products/{productId}",
DownstreamTemplate = "/products/{productId}",
@@ -50,7 +50,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(new List
{
@@ -86,16 +86,16 @@ namespace Ocelot.UnitTests.Configuration
.Build()
};
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/api/products/{productId}",
DownstreamTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -111,7 +111,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.And(x => x.GivenTheConfigHeaderExtractorReturns(new ClaimToThing("CustomerId", "CustomerId", "", 0)))
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(expected))
@@ -144,16 +144,16 @@ namespace Ocelot.UnitTests.Configuration
.Build()
};
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/api/products/{productId}",
DownstreamTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get",
- AuthenticationOptions = new YamlAuthenticationOptions
+ AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List(),
Provider = "IdentityServer",
@@ -165,7 +165,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(expected))
.And(x => x.ThenTheAuthenticationOptionsAre(expected))
@@ -175,11 +175,11 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_create_template_pattern_that_matches_more_than_one_placeholder()
{
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/api/products/{productId}/variants/{variantId}",
DownstreamTemplate = "/products/{productId}",
@@ -187,7 +187,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(new List
{
@@ -204,11 +204,11 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_create_template_pattern_that_matches_more_than_one_placeholder_with_trailing_slash()
{
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/api/products/{productId}/variants/{variantId}/",
DownstreamTemplate = "/products/{productId}",
@@ -216,7 +216,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(new List
{
@@ -233,11 +233,11 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_create_template_pattern_that_matches_to_end_of_string()
{
- this.Given(x => x.GivenTheYamlConfigIs(new YamlConfiguration
+ this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
- ReRoutes = new List
+ ReRoutes = new List
{
- new YamlReRoute
+ new FileReRoute
{
UpstreamTemplate = "/",
DownstreamTemplate = "/api/products/",
@@ -245,7 +245,7 @@ namespace Ocelot.UnitTests.Configuration
}
}
}))
- .And(x => x.GivenTheYamlConfigIsValid())
+ .And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(new List
{
@@ -259,19 +259,19 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
- private void GivenTheYamlConfigIsValid()
+ private void GivenTheConfigIsValid()
{
_validator
- .Setup(x => x.IsValid(It.IsAny()))
+ .Setup(x => x.IsValid(It.IsAny()))
.Returns(new OkResponse(new ConfigurationValidationResult(false)));
}
- private void GivenTheYamlConfigIs(YamlConfiguration yamlConfiguration)
+ private void GivenTheConfigIs(FileConfiguration fileConfiguration)
{
- _yamlConfiguration = yamlConfiguration;
- _yamlConfig
+ _fileConfiguration = fileConfiguration;
+ _fileConfig
.Setup(x => x.Value)
- .Returns(_yamlConfiguration);
+ .Returns(_fileConfiguration);
}
private void WhenICreateTheConfig()
diff --git a/test/Ocelot.UnitTests/Configuration/YamlConfigurationProviderTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs
similarity index 97%
rename from test/Ocelot.UnitTests/Configuration/YamlConfigurationProviderTests.cs
rename to test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs
index abc4a464..1bdb3279 100644
--- a/test/Ocelot.UnitTests/Configuration/YamlConfigurationProviderTests.cs
+++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs
@@ -15,14 +15,14 @@ using Xunit;
namespace Ocelot.UnitTests.Configuration
{
- public class YamlConfigurationProviderTests
+ public class FileConfigurationProviderTests
{
private readonly IOcelotConfigurationProvider _ocelotConfigurationProvider;
private readonly Mock _configurationRepository;
private readonly Mock _creator;
private Response _result;
- public YamlConfigurationProviderTests()
+ public FileConfigurationProviderTests()
{
_creator = new Mock();
_configurationRepository = new Mock();
diff --git a/test/Ocelot.UnitTests/project.json b/test/Ocelot.UnitTests/project.json
index 627df2d7..beb19321 100644
--- a/test/Ocelot.UnitTests/project.json
+++ b/test/Ocelot.UnitTests/project.json
@@ -14,7 +14,7 @@
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.AspNetCore.Http": "1.0.0",
"Ocelot": "1.0.0-*",
- "xunit": "2.1.0",
+ "xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Moq": "4.6.38-alpha",
"Microsoft.AspNetCore.TestHost": "1.0.0",
@@ -25,15 +25,12 @@
"type": "platform"
},
"Shouldly": "2.8.2",
- "TestStack.BDDfy": "4.3.2",
- "YamlDotNet": "4.0.0"
+ "TestStack.BDDfy": "4.3.2"
},
"frameworks": {
"netcoreapp1.4": {
"imports": [
- "dotnet5.6",
- "portable-net45+win8"
]
}
}