changed to json configuration to get rid of yaml imports

This commit is contained in:
TomPallister
2016-11-02 21:50:53 +00:00
parent 190e394011
commit f4acb4f041
33 changed files with 386 additions and 356 deletions

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = _downstreamServiceRootUrl,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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"))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = "http://localhost:51876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = "http://localhost:51876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>(),
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("/"))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = "http://localhost:52876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>
{
@ -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("/"))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
new YamlReRoute
new FileReRoute
{
DownstreamTemplate = "http://localhost:57876/",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
AuthenticationOptions = new YamlAuthenticationOptions
AuthenticationOptions = new FileAuthenticationOptions
{
AdditionalScopes = new List<string>
{
@ -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("/"))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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))

View File

@ -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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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<YamlReRoute>
ReRoutes = new List<FileReRoute>
{
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))

View File

@ -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);
}
/// <summary>
/// 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.
/// </summary>
public void GivenOcelotIsRunning()
{
@ -73,14 +66,14 @@ namespace Ocelot.AcceptanceTests
}
/// <summary>
/// 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.
/// </summary>
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 =>

View File

@ -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";
}
}

View File

@ -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}]}

View File

@ -1,8 +0,0 @@
ReRoutes:
- DownstreamTemplate: http://localhost:41879/
UpstreamTemplate: /
UpstreamHttpMethod: Get
AddHeadersToRequest: {}
AddClaimsToRequest: {}
RouteClaimsRequirement: {}
AddQueriesToRequest: {}

View File

@ -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"
]
}
}