auth options builders

This commit is contained in:
Tom Gardham-Pallister 2017-02-07 20:30:26 +00:00
parent 33ce162693
commit 7fffc9827a
27 changed files with 222 additions and 167 deletions

View File

@ -122,7 +122,7 @@ Ocelot's primary functionality is to take incomeing http requests and forward th
to a downstream service. At the moment in the form of another http request (in the future to a downstream service. At the moment in the form of another http request (in the future
this could be any transport mechanism.). this could be any transport mechanism.).
Ocelot always adds a trailing slash to an UpstreamTemplate. Ocelot always adds a trailing slash to an UpstreamPathTemplate.
Ocelot's describes the routing of one request to another as a ReRoute. In order to get Ocelot's describes the routing of one request to another as a ReRoute. In order to get
anything working in Ocelot you need to set up a ReRoute in the configuration. anything working in Ocelot you need to set up a ReRoute in the configuration.
@ -140,16 +140,16 @@ the following.
"DownstreamScheme": "https", "DownstreamScheme": "https",
"DownstreamPort": 80, "DownstreamPort": 80,
"DownstreamHost" "localhost" "DownstreamHost" "localhost"
"UpstreamTemplate": "/posts/{postId}", "UpstreamPathTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Put" "UpstreamHttpMethod": "Put"
} }
The DownstreamPathTemplate,Scheme, Port and Host make the URL that this request will be forwarded to. The DownstreamPathTemplate,Scheme, Port and Host make the URL that this request will be forwarded to.
The UpstreamTemplate is the URL that Ocelot will use to identity which The UpstreamPathTemplate is the URL that Ocelot will use to identity which
DownstreamPathTemplate to use for a given request. Finally the UpstreamHttpMethod is used so DownstreamPathTemplate to use for a given request. Finally the UpstreamHttpMethod is used so
Ocelot can distinguish between requests to the same URL and is obviously needed to work :) Ocelot can distinguish between requests to the same URL and is obviously needed to work :)
In Ocelot you can add placeholders for variables to your Templates in the form of {something}. In Ocelot you can add placeholders for variables to your Templates in the form of {something}.
The placeholder needs to be in both the DownstreamPathTemplate and UpstreamTemplate. If it is The placeholder needs to be in both the DownstreamPathTemplate and UpstreamPathTemplate. If it is
Ocelot will attempt to replace the placeholder with the correct variable value from the Ocelot will attempt to replace the placeholder with the correct variable value from the
Upstream URL when the request comes in. Upstream URL when the request comes in.
@ -190,7 +190,7 @@ and LeastConnection algorithm you can use. If no load balancer is specified Ocel
{ {
"DownstreamPathTemplate": "/api/posts/{postId}", "DownstreamPathTemplate": "/api/posts/{postId}",
"DownstreamScheme": "https", "DownstreamScheme": "https",
"UpstreamTemplate": "/posts/{postId}", "UpstreamPathTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Put", "UpstreamHttpMethod": "Put",
"ServiceName": "product" "ServiceName": "product"
"LoadBalancer": "LeastConnection" "LoadBalancer": "LeastConnection"

View File

@ -15,7 +15,7 @@
# The path template we are listening on for this re route, Ocelot will add a trailing # The path template we are listening on for this re route, Ocelot will add a trailing
# slash to this property. Then when a request is made Ocelot makes sure a trailing # slash to this property. Then when a request is made Ocelot makes sure a trailing
# slash is added, so everything matches # slash is added, so everything matches
"UpstreamTemplate": "/identityserverexample", "UpstreamPathTemplate": "/identityserverexample",
# The method we are listening for on this re route # The method we are listening for on this re route
"UpstreamHttpMethod": "Get", "UpstreamHttpMethod": "Get",
# Only support identity server at the moment # Only support identity server at the moment

View File

@ -61,7 +61,7 @@ namespace Ocelot.Authorisation.Middleware
SetPipelineError(new List<Error> SetPipelineError(new List<Error>
{ {
new UnauthorisedError( new UnauthorisedError(
$"{context.User.Identity.Name} unable to access {DownstreamRoute.ReRoute.UpstreamTemplate}") $"{context.User.Identity.Name} unable to access {DownstreamRoute.ReRoute.UpstreamPathTemplate.Value}")
}); });
} }
} }

View File

@ -0,0 +1,56 @@
using System.Collections.Generic;
namespace Ocelot.Configuration.Builder
{
public class AuthenticationOptionsBuilder
{
private string _provider;
private string _providerRootUrl;
private string _scopeName;
private string _scopeSecret;
private bool _requireHttps;
private List<string> _additionalScopes;
public AuthenticationOptionsBuilder WithProvider(string provider)
{
_provider = provider;
return this;
}
public AuthenticationOptionsBuilder WithProviderRootUrl(string providerRootUrl)
{
_providerRootUrl = providerRootUrl;
return this;
}
public AuthenticationOptionsBuilder WithScopeName(string scopeName)
{
_scopeName = scopeName;
return this;
}
public AuthenticationOptionsBuilder WithScopeSecret(string scopeSecret)
{
_scopeSecret = scopeSecret;
return this;
}
public AuthenticationOptionsBuilder WithRequireHttps(bool requireHttps)
{
_requireHttps = requireHttps;
return this;
}
public AuthenticationOptionsBuilder WithAdditionalScopes(List<string> additionalScopes)
{
_additionalScopes = additionalScopes;
return this;
}
public AuthenticationOptions Build()
{
return new AuthenticationOptions(_provider, _providerRootUrl, _scopeName, _requireHttps, _additionalScopes, _scopeSecret);
}
}
}

View File

@ -1,23 +1,19 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http;
using Ocelot.Values; using Ocelot.Values;
namespace Ocelot.Configuration.Builder namespace Ocelot.Configuration.Builder
{ {
public class ReRouteBuilder public class ReRouteBuilder
{ {
private AuthenticationOptions _authenticationOptions;
private string _loadBalancerKey; private string _loadBalancerKey;
private string _downstreamPathTemplate; private string _downstreamPathTemplate;
private string _upstreamTemplate; private string _upstreamTemplate;
private string _upstreamTemplatePattern; private string _upstreamTemplatePattern;
private string _upstreamHttpMethod; private string _upstreamHttpMethod;
private bool _isAuthenticated; private bool _isAuthenticated;
private string _authenticationProvider;
private string _authenticationProviderUrl;
private string _scopeName;
private List<string> _additionalScopes;
private bool _requireHttps;
private string _scopeSecret;
private List<ClaimToThing> _configHeaderExtractorProperties; private List<ClaimToThing> _configHeaderExtractorProperties;
private List<ClaimToThing> _claimToClaims; private List<ClaimToThing> _claimToClaims;
private Dictionary<string, string> _routeClaimRequirement; private Dictionary<string, string> _routeClaimRequirement;
@ -33,11 +29,6 @@ namespace Ocelot.Configuration.Builder
private string _loadBalancer; private string _loadBalancer;
private ServiceProviderConfiguraion _serviceProviderConfiguraion; private ServiceProviderConfiguraion _serviceProviderConfiguraion;
public ReRouteBuilder()
{
_additionalScopes = new List<string>();
}
public ReRouteBuilder WithLoadBalancer(string loadBalancer) public ReRouteBuilder WithLoadBalancer(string loadBalancer)
{ {
_loadBalancer = loadBalancer; _loadBalancer = loadBalancer;
@ -68,7 +59,7 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public ReRouteBuilder WithUpstreamTemplate(string input) public ReRouteBuilder WithUpstreamPathTemplate(string input)
{ {
_upstreamTemplate = input; _upstreamTemplate = input;
return this; return this;
@ -96,42 +87,6 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public ReRouteBuilder WithAuthenticationProvider(string input)
{
_authenticationProvider = input;
return this;
}
public ReRouteBuilder WithAuthenticationProviderUrl(string input)
{
_authenticationProviderUrl = input;
return this;
}
public ReRouteBuilder WithAuthenticationProviderScopeName(string input)
{
_scopeName = input;
return this;
}
public ReRouteBuilder WithAuthenticationProviderAdditionalScopes(List<string> input)
{
_additionalScopes = input;
return this;
}
public ReRouteBuilder WithRequireHttps(bool input)
{
_requireHttps = input;
return this;
}
public ReRouteBuilder WithScopeSecret(string input)
{
_scopeSecret = input;
return this;
}
public ReRouteBuilder WithRequestIdKey(string input) public ReRouteBuilder WithRequestIdKey(string input)
{ {
_requestIdHeaderKey = input; _requestIdHeaderKey = input;
@ -192,13 +147,35 @@ namespace Ocelot.Configuration.Builder
return this; return this;
} }
public ReRouteBuilder WithAuthenticationOptions(AuthenticationOptions authenticationOptions)
{
_authenticationOptions = authenticationOptions;
return this;
}
public ReRoute Build() public ReRoute Build()
{ {
return new ReRoute(new PathTemplate(_downstreamPathTemplate), new PathTemplate(_upstreamTemplate), _upstreamHttpMethod, _upstreamTemplatePattern, return new ReRoute(
_isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName, new PathTemplate(_downstreamPathTemplate),
_requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement, new PathTemplate(_upstreamTemplate),
_isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer, new HttpMethod(_upstreamHttpMethod),
_downstreamHost, _downstreamPort, _loadBalancerKey, _serviceProviderConfiguraion); _upstreamTemplatePattern,
_isAuthenticated,
_authenticationOptions,
_configHeaderExtractorProperties,
_claimToClaims,
_routeClaimRequirement,
_isAuthorised,
_claimToQueries,
_requestIdHeaderKey,
_isCached,
_fileCacheOptions,
_downstreamScheme,
_loadBalancer,
_downstreamHost,
_downstreamPort,
_loadBalancerKey,
_serviceProviderConfiguraion);
} }
} }
} }

View File

@ -1,4 +1,4 @@
namespace Ocelot.Configuration namespace Ocelot.Configuration.Builder
{ {
public class ServiceProviderConfiguraionBuilder public class ServiceProviderConfiguraionBuilder
{ {

View File

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.File; using Ocelot.Configuration.File;
using Ocelot.Configuration.Parser; using Ocelot.Configuration.Parser;
using Ocelot.Configuration.Validator; using Ocelot.Configuration.Validator;
@ -88,7 +90,7 @@ namespace Ocelot.Configuration.Creator
{ {
var globalRequestIdConfiguration = !string.IsNullOrEmpty(globalConfiguration?.RequestIdKey); var globalRequestIdConfiguration = !string.IsNullOrEmpty(globalConfiguration?.RequestIdKey);
var upstreamTemplate = BuildUpstreamTemplate(fileReRoute); var upstreamTemplatePattern = BuildUpstreamTemplate(fileReRoute);
var isAuthenticated = !string.IsNullOrEmpty(fileReRoute.AuthenticationOptions?.Provider); var isAuthenticated = !string.IsNullOrEmpty(fileReRoute.AuthenticationOptions?.Provider);
@ -104,7 +106,7 @@ namespace Ocelot.Configuration.Creator
&& !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Provider); && !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Provider);
//note - not sure if this is the correct key, but this is probably the only unique key i can think of given my poor brain //note - not sure if this is the correct key, but this is probably the only unique key i can think of given my poor brain
var loadBalancerKey = $"{fileReRoute.UpstreamTemplate}{fileReRoute.UpstreamHttpMethod}"; var loadBalancerKey = $"{fileReRoute.UpstreamPathTemplate}{fileReRoute.UpstreamHttpMethod}";
ReRoute reRoute; ReRoute reRoute;
@ -132,20 +134,29 @@ namespace Ocelot.Configuration.Creator
var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest); var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate), reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate),
new PathTemplate(fileReRoute.UpstreamTemplate), new PathTemplate(fileReRoute.UpstreamPathTemplate),
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated, new HttpMethod(fileReRoute.UpstreamHttpMethod), upstreamTemplatePattern, isAuthenticated,
authOptionsForRoute, claimsToHeaders, claimsToClaims, authOptionsForRoute, claimsToHeaders, claimsToClaims,
fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries, fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds) requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
, fileReRoute.DownstreamScheme, , fileReRoute.DownstreamScheme,
fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey, fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
serviceProviderConfiguration); serviceProviderConfiguration);
//reRoute = new ReRouteBuilder()
// .WithDownstreamPathTemplate(fileReRoute.DownstreamPathTemplate)
// .WithUpstreamPathTemplate(fileReRoute.UpstreamPathTemplate)
// .WithUpstreamHttpMethod(fileReRoute.UpstreamHttpMethod)
// .WithUpstreamTemplatePattern(upstreamTemplatePattern)
// .WithIsAuthenticated(isAuthenticated)
//.Build();
} }
else else
{ {
reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate), reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate),
new PathTemplate(fileReRoute.UpstreamTemplate), new PathTemplate(fileReRoute.UpstreamPathTemplate),
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated, new HttpMethod(fileReRoute.UpstreamHttpMethod), upstreamTemplatePattern, isAuthenticated,
null, new List<ClaimToThing>(), new List<ClaimToThing>(), null, new List<ClaimToThing>(), new List<ClaimToThing>(),
fileReRoute.RouteClaimsRequirement, isAuthorised, new List<ClaimToThing>(), fileReRoute.RouteClaimsRequirement, isAuthorised, new List<ClaimToThing>(),
requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds), requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds),
@ -161,7 +172,7 @@ namespace Ocelot.Configuration.Creator
private string BuildUpstreamTemplate(FileReRoute reRoute) private string BuildUpstreamTemplate(FileReRoute reRoute)
{ {
var upstreamTemplate = reRoute.UpstreamTemplate; var upstreamTemplate = reRoute.UpstreamPathTemplate;
upstreamTemplate = upstreamTemplate.SetLastCharacterAs('/'); upstreamTemplate = upstreamTemplate.SetLastCharacterAs('/');

View File

@ -15,7 +15,7 @@ namespace Ocelot.Configuration.File
} }
public string DownstreamPathTemplate { get; set; } public string DownstreamPathTemplate { get; set; }
public string UpstreamTemplate { get; set; } public string UpstreamPathTemplate { get; set; }
public string UpstreamHttpMethod { get; set; } public string UpstreamHttpMethod { get; set; }
public FileAuthenticationOptions AuthenticationOptions { get; set; } public FileAuthenticationOptions AuthenticationOptions { get; set; }
public Dictionary<string, string> AddHeadersToRequest { get; set; } public Dictionary<string, string> AddHeadersToRequest { get; set; }

View File

@ -8,7 +8,7 @@ namespace Ocelot.Configuration
public class ReRoute public class ReRoute
{ {
public ReRoute(PathTemplate downstreamPathTemplate, public ReRoute(PathTemplate downstreamPathTemplate,
PathTemplate upstreamTemplate, string upstreamHttpMethod, PathTemplate upstreamTemplate, HttpMethod upstreamHttpMethod,
string upstreamTemplatePattern, string upstreamTemplatePattern,
bool isAuthenticated, AuthenticationOptions authenticationOptions, bool isAuthenticated, AuthenticationOptions authenticationOptions,
List<ClaimToThing> configurationHeaderExtractorProperties, List<ClaimToThing> configurationHeaderExtractorProperties,
@ -25,8 +25,8 @@ namespace Ocelot.Configuration
DownstreamHost = downstreamHost; DownstreamHost = downstreamHost;
DownstreamPort = downstreamPort; DownstreamPort = downstreamPort;
DownstreamPathTemplate = downstreamPathTemplate; DownstreamPathTemplate = downstreamPathTemplate;
UpstreamTemplate = upstreamTemplate; UpstreamPathTemplate = upstreamTemplate;
UpstreamHttpMethod = new HttpMethod(upstreamHttpMethod); UpstreamHttpMethod = upstreamHttpMethod;
UpstreamTemplatePattern = upstreamTemplatePattern; UpstreamTemplatePattern = upstreamTemplatePattern;
IsAuthenticated = isAuthenticated; IsAuthenticated = isAuthenticated;
AuthenticationOptions = authenticationOptions; AuthenticationOptions = authenticationOptions;
@ -46,7 +46,7 @@ namespace Ocelot.Configuration
public string LoadBalancerKey {get;private set;} public string LoadBalancerKey {get;private set;}
public PathTemplate DownstreamPathTemplate { get; private set; } public PathTemplate DownstreamPathTemplate { get; private set; }
public PathTemplate UpstreamTemplate { get; private set; } public PathTemplate UpstreamPathTemplate { get; private set; }
public string UpstreamTemplatePattern { get; private set; } public string UpstreamTemplatePattern { get; private set; }
public HttpMethod UpstreamHttpMethod { get; private set; } public HttpMethod UpstreamHttpMethod { get; private set; }
public bool IsAuthenticated { get; private set; } public bool IsAuthenticated { get; private set; }

View File

@ -54,7 +54,7 @@ namespace Ocelot.Configuration.Validator
continue; continue;
} }
var error = new UnsupportedAuthenticationProviderError($"{reRoute.AuthenticationOptions?.Provider} is unsupported authentication provider, upstream template is {reRoute.UpstreamTemplate}, upstream method is {reRoute.UpstreamHttpMethod}"); var error = new UnsupportedAuthenticationProviderError($"{reRoute.AuthenticationOptions?.Provider} is unsupported authentication provider, upstream template is {reRoute.UpstreamPathTemplate}, upstream method is {reRoute.UpstreamHttpMethod}");
errors.Add(error); errors.Add(error);
} }
@ -94,18 +94,18 @@ namespace Ocelot.Configuration.Validator
private ConfigurationValidationResult CheckForDupliateReRoutes(FileConfiguration configuration) private ConfigurationValidationResult CheckForDupliateReRoutes(FileConfiguration configuration)
{ {
var hasDupes = configuration.ReRoutes var hasDupes = configuration.ReRoutes
.GroupBy(x => new { x.UpstreamTemplate, x.UpstreamHttpMethod }).Any(x => x.Skip(1).Any()); .GroupBy(x => new { x.UpstreamPathTemplate, x.UpstreamHttpMethod }).Any(x => x.Skip(1).Any());
if (!hasDupes) if (!hasDupes)
{ {
return new ConfigurationValidationResult(false); return new ConfigurationValidationResult(false);
} }
var dupes = configuration.ReRoutes.GroupBy(x => new { x.UpstreamTemplate, x.UpstreamHttpMethod }) var dupes = configuration.ReRoutes.GroupBy(x => new { x.UpstreamPathTemplate, x.UpstreamHttpMethod })
.Where(x => x.Skip(1).Any()); .Where(x => x.Skip(1).Any());
var errors = dupes var errors = dupes
.Select(d => new DownstreamPathTemplateAlreadyUsedError(string.Format("Duplicate DownstreamPath: {0}", d.Key.UpstreamTemplate))) .Select(d => new DownstreamPathTemplateAlreadyUsedError(string.Format("Duplicate DownstreamPath: {0}", d.Key.UpstreamPathTemplate)))
.Cast<Error>() .Cast<Error>()
.ToList(); .ToList();

View File

@ -34,7 +34,7 @@ namespace Ocelot.DownstreamRouteFinder.Finder
if (urlMatch.Data.Match) if (urlMatch.Data.Match)
{ {
var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamTemplate.Value); var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamPathTemplate.Value);
return new OkResponse<DownstreamRoute>(new DownstreamRoute(templateVariableNameAndValues.Data, reRoute)); return new OkResponse<DownstreamRoute>(new DownstreamRoute(templateVariableNameAndValues.Data, reRoute));
} }

View File

@ -47,7 +47,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = _downstreamServicePort, DownstreamPort = _downstreamServicePort,
DownstreamHost = _downstreamServiceHost, DownstreamHost = _downstreamServiceHost,
DownstreamScheme = _downstreamServiceScheme, DownstreamScheme = _downstreamServiceScheme,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
@ -85,7 +85,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = _downstreamServicePort, DownstreamPort = _downstreamServicePort,
DownstreamHost = _downstreamServiceHost, DownstreamHost = _downstreamServiceHost,
DownstreamScheme = _downstreamServiceScheme, DownstreamScheme = _downstreamServiceScheme,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
@ -123,7 +123,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = _downstreamServicePort, DownstreamPort = _downstreamServicePort,
DownstreamHost = _downstreamServiceHost, DownstreamHost = _downstreamServiceHost,
DownstreamScheme = _downstreamServiceScheme, DownstreamScheme = _downstreamServiceScheme,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
@ -163,7 +163,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = _downstreamServicePort, DownstreamPort = _downstreamServicePort,
DownstreamHost = _downstreamServiceHost, DownstreamHost = _downstreamServiceHost,
DownstreamScheme = _downstreamServiceScheme, DownstreamScheme = _downstreamServiceScheme,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
@ -203,7 +203,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = _downstreamServicePort, DownstreamPort = _downstreamServicePort,
DownstreamHost = _downstreamServiceHost, DownstreamHost = _downstreamServiceHost,
DownstreamScheme = _downstreamServiceScheme, DownstreamScheme = _downstreamServiceScheme,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Post", UpstreamHttpMethod = "Post",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {

View File

@ -41,7 +41,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51876, DownstreamPort = 51876,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
@ -98,7 +98,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51876, DownstreamPort = 51876,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {

View File

@ -35,7 +35,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
FileCacheOptions = new FileCacheOptions FileCacheOptions = new FileCacheOptions
{ {
@ -71,7 +71,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
FileCacheOptions = new FileCacheOptions FileCacheOptions = new FileCacheOptions
{ {

View File

@ -34,7 +34,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get" UpstreamHttpMethod = "Get"
} }
} }
@ -61,7 +61,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = false ReRouteIsCaseSensitive = false
} }
@ -89,7 +89,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
} }
@ -117,7 +117,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/PRODUCTS/{productId}", UpstreamPathTemplate = "/PRODUCTS/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
} }
@ -145,7 +145,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
} }
@ -173,7 +173,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/PRODUCTS/{productId}", UpstreamPathTemplate = "/PRODUCTS/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
} }

View File

@ -55,7 +55,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 52876, DownstreamPort = 52876,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {

View File

@ -55,7 +55,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 57876, DownstreamPort = 57876,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {

View File

@ -49,7 +49,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -86,7 +86,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -123,7 +123,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -160,7 +160,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -197,7 +197,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -234,7 +234,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 41879, DownstreamPort = 41879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }

View File

@ -37,7 +37,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
RequestIdKey = _steps.RequestIdKey RequestIdKey = _steps.RequestIdKey
} }
@ -65,7 +65,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
RequestIdKey = _steps.RequestIdKey RequestIdKey = _steps.RequestIdKey
} }
@ -95,7 +95,7 @@ namespace Ocelot.AcceptanceTests
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
}, },

View File

@ -30,7 +30,7 @@ namespace Ocelot.AcceptanceTests
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "http://localhost:53876/", DownstreamPathTemplate = "http://localhost:53876/",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get" UpstreamHttpMethod = "Get"
} }
} }

View File

@ -44,7 +44,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -72,7 +72,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -100,7 +100,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost/", DownstreamHost = "localhost/",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -128,7 +128,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/products/", UpstreamPathTemplate = "/products/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/products", UpstreamPathTemplate = "/products",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -184,7 +184,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
} }
@ -211,7 +211,7 @@ namespace Ocelot.AcceptanceTests
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
UpstreamTemplate = "/products/{productId}", UpstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get" UpstreamHttpMethod = "Get"
} }
} }
@ -239,7 +239,7 @@ namespace Ocelot.AcceptanceTests
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,
DownstreamScheme = "http", DownstreamScheme = "http",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Post" UpstreamHttpMethod = "Post"
} }
} }
@ -264,7 +264,7 @@ namespace Ocelot.AcceptanceTests
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "/newThing", DownstreamPathTemplate = "/newThing",
UpstreamTemplate = "/newThing", UpstreamPathTemplate = "/newThing",
DownstreamScheme = "http", DownstreamScheme = "http",
DownstreamHost = "localhost", DownstreamHost = "localhost",
DownstreamPort = 51879, DownstreamPort = 51879,

View File

@ -68,7 +68,7 @@ namespace Ocelot.AcceptanceTests
{ {
DownstreamPathTemplate = "/", DownstreamPathTemplate = "/",
DownstreamScheme = "http", DownstreamScheme = "http",
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ServiceName = serviceName, ServiceName = serviceName,
LoadBalancer = "LeastConnection", LoadBalancer = "LeastConnection",

View File

@ -1 +1 @@
{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"LoadBalancer":null}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0}}} {"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"LoadBalancer":null}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0}}}

View File

@ -29,7 +29,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "http://www.bbc.co.uk/api/products/{productId}", DownstreamPathTemplate = "http://www.bbc.co.uk/api/products/{productId}",
UpstreamTemplate = "http://asdf.com" UpstreamPathTemplate = "http://asdf.com"
} }
} }
})) }))
@ -48,7 +48,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "/api/products/", DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com" UpstreamPathTemplate = "http://asdf.com"
} }
} }
})) }))
@ -67,7 +67,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "/api/products/", DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com", UpstreamPathTemplate = "http://asdf.com",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
Provider = "IdentityServer" Provider = "IdentityServer"
@ -90,7 +90,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "/api/products/", DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com", UpstreamPathTemplate = "http://asdf.com",
AuthenticationOptions = new FileAuthenticationOptions AuthenticationOptions = new FileAuthenticationOptions
{ {
Provider = "BootyBootyBottyRockinEverywhere" Provider = "BootyBootyBottyRockinEverywhere"
@ -114,12 +114,12 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "/api/products/", DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com" UpstreamPathTemplate = "http://asdf.com"
}, },
new FileReRoute new FileReRoute
{ {
DownstreamPathTemplate = "http://www.bbc.co.uk", DownstreamPathTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com" UpstreamPathTemplate = "http://asdf.com"
} }
} }
})) }))

View File

@ -53,7 +53,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamHost = "127.0.0.1", DownstreamHost = "127.0.0.1",
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
@ -78,7 +78,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamHost = "127.0.0.1", DownstreamHost = "127.0.0.1",
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
@ -91,7 +91,7 @@ namespace Ocelot.UnitTests.Configuration
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamHost("127.0.0.1") .WithDownstreamHost("127.0.0.1")
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.Build() .Build()
@ -109,7 +109,7 @@ namespace Ocelot.UnitTests.Configuration
new FileReRoute new FileReRoute
{ {
DownstreamScheme = "https", DownstreamScheme = "https",
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
} }
@ -122,7 +122,7 @@ namespace Ocelot.UnitTests.Configuration
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamScheme("https") .WithDownstreamScheme("https")
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.Build() .Build()
@ -139,7 +139,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = false, ReRouteIsCaseSensitive = false,
@ -161,7 +161,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.WithServiceName("ProductService") .WithServiceName("ProductService")
@ -184,7 +184,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = false, ReRouteIsCaseSensitive = false,
@ -197,7 +197,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.WithServiceProviderConfiguraion(new ServiceProviderConfiguraionBuilder() .WithServiceProviderConfiguraion(new ServiceProviderConfiguraionBuilder()
@ -217,7 +217,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = false ReRouteIsCaseSensitive = false
@ -230,7 +230,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.Build() .Build()
@ -247,7 +247,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get" UpstreamHttpMethod = "Get"
} }
@ -259,7 +259,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("(?i)/api/products/.*/$") .WithUpstreamTemplatePattern("(?i)/api/products/.*/$")
.Build() .Build()
@ -276,7 +276,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -289,7 +289,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/$")
.Build() .Build()
@ -306,7 +306,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -323,7 +323,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/$")
.WithRequestIdKey("blahhhh") .WithRequestIdKey("blahhhh")
@ -341,7 +341,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -354,7 +354,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/$")
.Build() .Build()
@ -365,18 +365,23 @@ namespace Ocelot.UnitTests.Configuration
[Fact] [Fact]
public void should_create_with_headers_to_extract() public void should_create_with_headers_to_extract()
{ {
var authenticationOptions = new AuthenticationOptionsBuilder()
.WithProvider("IdentityServer")
.WithProviderRootUrl("http://localhost:51888")
.WithRequireHttps(false)
.WithScopeSecret("secret")
.WithScopeName("api")
.WithAdditionalScopes(new List<string>())
.Build();
var expected = new List<ReRoute> var expected = new List<ReRoute>
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/$")
.WithAuthenticationProvider("IdentityServer") .WithAuthenticationOptions(authenticationOptions)
.WithAuthenticationProviderUrl("http://localhost:51888")
.WithRequireHttps(false)
.WithScopeSecret("secret")
.WithAuthenticationProviderScopeName("api")
.WithClaimsToHeaders(new List<ClaimToThing> .WithClaimsToHeaders(new List<ClaimToThing>
{ {
new ClaimToThing("CustomerId", "CustomerId", "", 0), new ClaimToThing("CustomerId", "CustomerId", "", 0),
@ -390,7 +395,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true, ReRouteIsCaseSensitive = true,
@ -429,18 +434,23 @@ namespace Ocelot.UnitTests.Configuration
[Fact] [Fact]
public void should_create_with_authentication_properties() public void should_create_with_authentication_properties()
{ {
var authenticationOptions = new AuthenticationOptionsBuilder()
.WithProvider("IdentityServer")
.WithProviderRootUrl("http://localhost:51888")
.WithRequireHttps(false)
.WithScopeSecret("secret")
.WithScopeName("api")
.WithAdditionalScopes(new List<string>())
.Build();
var expected = new List<ReRoute> var expected = new List<ReRoute>
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}") .WithUpstreamPathTemplate("/api/products/{productId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/$")
.WithAuthenticationProvider("IdentityServer") .WithAuthenticationOptions(authenticationOptions)
.WithAuthenticationProviderUrl("http://localhost:51888")
.WithRequireHttps(false)
.WithScopeSecret("secret")
.WithAuthenticationProviderScopeName("api")
.Build() .Build()
}; };
@ -450,7 +460,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}", UpstreamPathTemplate = "/api/products/{productId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true, ReRouteIsCaseSensitive = true,
@ -483,7 +493,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}/variants/{variantId}", UpstreamPathTemplate = "/api/products/{productId}/variants/{variantId}",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -496,7 +506,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}/variants/{variantId}") .WithUpstreamPathTemplate("/api/products/{productId}/variants/{variantId}")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/variants/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/variants/.*/$")
.Build() .Build()
@ -513,7 +523,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/api/products/{productId}/variants/{variantId}/", UpstreamPathTemplate = "/api/products/{productId}/variants/{variantId}/",
DownstreamPathTemplate = "/products/{productId}", DownstreamPathTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -526,7 +536,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/products/{productId}") .WithDownstreamPathTemplate("/products/{productId}")
.WithUpstreamTemplate("/api/products/{productId}/variants/{variantId}/") .WithUpstreamPathTemplate("/api/products/{productId}/variants/{variantId}/")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/api/products/.*/variants/.*/$") .WithUpstreamTemplatePattern("/api/products/.*/variants/.*/$")
.Build() .Build()
@ -543,7 +553,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new FileReRoute new FileReRoute
{ {
UpstreamTemplate = "/", UpstreamPathTemplate = "/",
DownstreamPathTemplate = "/api/products/", DownstreamPathTemplate = "/api/products/",
UpstreamHttpMethod = "Get", UpstreamHttpMethod = "Get",
ReRouteIsCaseSensitive = true ReRouteIsCaseSensitive = true
@ -556,7 +566,7 @@ namespace Ocelot.UnitTests.Configuration
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("/api/products/") .WithDownstreamPathTemplate("/api/products/")
.WithUpstreamTemplate("/") .WithUpstreamPathTemplate("/")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("/$") .WithUpstreamTemplatePattern("/$")
.Build() .Build()
@ -593,7 +603,7 @@ namespace Ocelot.UnitTests.Configuration
result.DownstreamPathTemplate.Value.ShouldBe(expected.DownstreamPathTemplate.Value); result.DownstreamPathTemplate.Value.ShouldBe(expected.DownstreamPathTemplate.Value);
result.UpstreamHttpMethod.ShouldBe(expected.UpstreamHttpMethod); result.UpstreamHttpMethod.ShouldBe(expected.UpstreamHttpMethod);
result.UpstreamTemplate.Value.ShouldBe(expected.UpstreamTemplate.Value); result.UpstreamPathTemplate.Value.ShouldBe(expected.UpstreamPathTemplate.Value);
result.UpstreamTemplatePattern.ShouldBe(expected.UpstreamTemplatePattern); result.UpstreamTemplatePattern.ShouldBe(expected.UpstreamTemplatePattern);
} }
} }

View File

@ -45,7 +45,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("someDownstreamPath") .WithDownstreamPathTemplate("someDownstreamPath")
.WithUpstreamTemplate("someUpstreamPath") .WithUpstreamPathTemplate("someUpstreamPath")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("someUpstreamPath") .WithUpstreamTemplatePattern("someUpstreamPath")
.Build() .Build()
@ -77,13 +77,13 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("someDownstreamPath") .WithDownstreamPathTemplate("someDownstreamPath")
.WithUpstreamTemplate("someUpstreamPath") .WithUpstreamPathTemplate("someUpstreamPath")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("") .WithUpstreamTemplatePattern("")
.Build(), .Build(),
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("someDownstreamPathForAPost") .WithDownstreamPathTemplate("someDownstreamPathForAPost")
.WithUpstreamTemplate("someUpstreamPath") .WithUpstreamPathTemplate("someUpstreamPath")
.WithUpstreamHttpMethod("Post") .WithUpstreamHttpMethod("Post")
.WithUpstreamTemplatePattern("") .WithUpstreamTemplatePattern("")
.Build() .Build()
@ -110,7 +110,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
{ {
new ReRouteBuilder() new ReRouteBuilder()
.WithDownstreamPathTemplate("somPath") .WithDownstreamPathTemplate("somPath")
.WithUpstreamTemplate("somePath") .WithUpstreamPathTemplate("somePath")
.WithUpstreamHttpMethod("Get") .WithUpstreamHttpMethod("Get")
.WithUpstreamTemplatePattern("somePath") .WithUpstreamTemplatePattern("somePath")
.Build(), .Build(),
@ -145,7 +145,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
private void ThenTheUrlMatcherIsCalledCorrectly() private void ThenTheUrlMatcherIsCalledCorrectly()
{ {
_mockMatcher _mockMatcher
.Verify(x => x.Match(_upstreamUrlPath, _reRoutesConfig[0].UpstreamTemplate.Value), Times.Once); .Verify(x => x.Match(_upstreamUrlPath, _reRoutesConfig[0].UpstreamPathTemplate.Value), Times.Once);
} }
private void GivenTheUrlMatcherReturns(Response<UrlMatch> match) private void GivenTheUrlMatcherReturns(Response<UrlMatch> match)

View File

@ -1,4 +1,5 @@
using Ocelot.Configuration; using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.ServiceDiscovery; using Ocelot.ServiceDiscovery;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;