private void GivenTheDependenciesAreSetUpCorrectly()
        {
            _rro       = new ReRouteOptions(false, false, false, false, false);
            _requestId = "testy";
            _rrk       = "besty";
            _upt       = new UpstreamPathTemplateBuilder().Build();
            _ao        = new AuthenticationOptionsBuilder().Build();
            _ctt       = new List <ClaimToThing>();
            _qoso      = new QoSOptionsBuilder().Build();
            _rlo       = new RateLimitOptionsBuilder().Build();
            _region    = "vesty";
            _hho       = new HttpHandlerOptionsBuilder().Build();
            _ht        = new HeaderTransformations(new List <HeaderFindAndReplace>(), new List <HeaderFindAndReplace>(), new List <AddHeader>(), new List <AddHeader>());
            _dhp       = new List <DownstreamHostAndPort>();
            _lbo       = new LoadBalancerOptionsBuilder().Build();

            _rroCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_rro);
            _ridkCreator.Setup(x => x.Create(It.IsAny <FileReRoute>(), It.IsAny <FileGlobalConfiguration>())).Returns(_requestId);
            _rrkCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_rrk);
            _utpCreator.Setup(x => x.Create(It.IsAny <IReRoute>())).Returns(_upt);
            _aoCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_ao);
            _cthCreator.Setup(x => x.Create(It.IsAny <Dictionary <string, string> >())).Returns(_ctt);
            _qosoCreator.Setup(x => x.Create(It.IsAny <FileQoSOptions>(), It.IsAny <string>(), It.IsAny <List <string> >())).Returns(_qoso);
            _rloCreator.Setup(x => x.Create(It.IsAny <FileRateLimitRule>(), It.IsAny <FileGlobalConfiguration>())).Returns(_rlo);
            _rCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_region);
            _hhoCreator.Setup(x => x.Create(It.IsAny <FileHttpHandlerOptions>())).Returns(_hho);
            _hfarCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_ht);
            _daCreator.Setup(x => x.Create(It.IsAny <FileReRoute>())).Returns(_dhp);
            _lboCreator.Setup(x => x.Create(It.IsAny <FileLoadBalancerOptions>())).Returns(_lbo);
        }
Esempio n. 2
0
 public ReRoute(PathTemplate downstreamPathTemplate,
                PathTemplate upstreamPathTemplate,
                List <HttpMethod> upstreamHttpMethod,
                UpstreamPathTemplate upstreamTemplatePattern,
                bool isAuthenticated,
                AuthenticationOptions authenticationOptions,
                List <ClaimToThing> claimsToHeaders,
                List <ClaimToThing> claimsToClaims,
                Dictionary <string, string> routeClaimsRequirement,
                bool isAuthorised,
                List <ClaimToThing> claimsToQueries,
                string requestIdKey,
                bool isCached,
                CacheOptions cacheOptions,
                string downstreamScheme,
                string loadBalancer,
                string reRouteKey,
                bool isQos,
                QoSOptions qosOptions,
                bool enableEndpointRateLimiting,
                RateLimitOptions ratelimitOptions,
                HttpHandlerOptions httpHandlerOptions,
                bool useServiceDiscovery,
                string serviceName,
                List <HeaderFindAndReplace> upstreamHeadersFindAndReplace,
                List <HeaderFindAndReplace> downstreamHeadersFindAndReplace,
                List <DownstreamHostAndPort> downstreamAddresses,
                string upstreamHost)
 {
     UpstreamHost = upstreamHost;
     DownstreamHeadersFindAndReplace = downstreamHeadersFindAndReplace ?? new List <HeaderFindAndReplace>();
     UpstreamHeadersFindAndReplace   = upstreamHeadersFindAndReplace ?? new List <HeaderFindAndReplace>();
     ServiceName             = serviceName;
     UseServiceDiscovery     = useServiceDiscovery;
     ReRouteKey              = reRouteKey;
     LoadBalancer            = loadBalancer;
     DownstreamAddresses     = downstreamAddresses ?? new List <DownstreamHostAndPort>();
     DownstreamPathTemplate  = downstreamPathTemplate;
     UpstreamPathTemplate    = upstreamPathTemplate;
     UpstreamHttpMethod      = upstreamHttpMethod;
     UpstreamTemplatePattern = upstreamTemplatePattern;
     IsAuthenticated         = isAuthenticated;
     AuthenticationOptions   = authenticationOptions;
     RouteClaimsRequirement  = routeClaimsRequirement;
     IsAuthorised            = isAuthorised;
     RequestIdKey            = requestIdKey;
     IsCached          = isCached;
     CacheOptions      = cacheOptions;
     ClaimsToQueries   = claimsToQueries ?? new List <ClaimToThing>();
     ClaimsToClaims    = claimsToClaims ?? new List <ClaimToThing>();
     ClaimsToHeaders   = claimsToHeaders ?? new List <ClaimToThing>();
     DownstreamScheme  = downstreamScheme;
     IsQos             = isQos;
     QosOptionsOptions = qosOptions;
     EnableEndpointEndpointRateLimiting = enableEndpointRateLimiting;
     RateLimitOptions   = ratelimitOptions;
     HttpHandlerOptions = httpHandlerOptions;
 }
Esempio n. 3
0
        private void GivenTheUtpCreatorReturns()
        {
            _aggregate1Utp = new UpstreamPathTemplateBuilder().Build();
            _aggregate2Utp = new UpstreamPathTemplateBuilder().Build();

            _utpCreator.SetupSequence(x => x.Create(It.IsAny <IReRoute>()))
            .Returns(_aggregate1Utp)
            .Returns(_aggregate2Utp);
        }
Esempio n. 4
0
 public ReRoute(List <DownstreamReRoute> downstreamReRoute,
                PathTemplate upstreamPathTemplate,
                List <HttpMethod> upstreamHttpMethod,
                UpstreamPathTemplate upstreamTemplatePattern,
                string upstreamHost)
 {
     UpstreamHost            = upstreamHost;
     DownstreamReRoute       = downstreamReRoute;
     UpstreamPathTemplate    = upstreamPathTemplate;
     UpstreamHttpMethod      = upstreamHttpMethod;
     UpstreamTemplatePattern = upstreamTemplatePattern;
 }
Esempio n. 5
0
 public ReRoute(List <DownstreamReRoute> downstreamReRoute,
                List <HttpMethod> upstreamHttpMethod,
                UpstreamPathTemplate upstreamTemplatePattern,
                string upstreamHost,
                string aggregator)
 {
     UpstreamHost            = upstreamHost;
     DownstreamReRoute       = downstreamReRoute;
     UpstreamHttpMethod      = upstreamHttpMethod;
     UpstreamTemplatePattern = upstreamTemplatePattern;
     Aggregator = aggregator;
 }
Esempio n. 6
0
 private void WhenICreateTheTemplatePattern()
 {
     _result = _creator.Create(_fileRoute);
 }
Esempio n. 7
0
 public DownstreamReRouteBuilder WithUpstreamPathTemplate(UpstreamPathTemplate input)
 {
     _upstreamTemplatePattern = input;
     return(this);
 }
        public Response <UrlMatch> Match(string upstreamUrlPath, string upstreamQueryString, UpstreamPathTemplate pathTemplate)
        {
            if (!pathTemplate.ContainsQueryString)
            {
                return(pathTemplate.Pattern.IsMatch(upstreamUrlPath)
                    ? new OkResponse <UrlMatch>(new UrlMatch(true))
                    : new OkResponse <UrlMatch>(new UrlMatch(false)));
            }

            return(pathTemplate.Pattern.IsMatch($"{upstreamUrlPath}{upstreamQueryString}")
                ? new OkResponse <UrlMatch>(new UrlMatch(true))
                : new OkResponse <UrlMatch>(new UrlMatch(false)));
        }
Esempio n. 9
0
 public DownstreamReRoute(
     string key,
     UpstreamPathTemplate upstreamPathTemplate,
     List <HeaderFindAndReplace> upstreamHeadersFindAndReplace,
     List <HeaderFindAndReplace> downstreamHeadersFindAndReplace,
     List <DownstreamHostAndPort> downstreamAddresses,
     string serviceName,
     HttpHandlerOptions httpHandlerOptions,
     bool useServiceDiscovery,
     bool enableEndpointEndpointRateLimiting,
     QoSOptions qosOptions,
     string downstreamScheme,
     string requestIdKey,
     bool isCached,
     CacheOptions cacheOptions,
     LoadBalancerOptions loadBalancerOptions,
     RateLimitOptions rateLimitOptions,
     Dictionary <string, string> routeClaimsRequirement,
     List <ClaimToThing> claimsToQueries,
     List <ClaimToThing> claimsToHeaders,
     List <ClaimToThing> claimsToClaims,
     bool isAuthenticated,
     bool isAuthorised,
     AuthenticationOptions authenticationOptions,
     DownstreamPathTemplate downstreamPathTemplate,
     string loadBalancerKey,
     List <string> delegatingHandlers,
     List <AddHeader> addHeadersToDownstream,
     List <AddHeader> addHeadersToUpstream,
     bool dangerousAcceptAnyServerCertificateValidator,
     SecurityOptions securityOptions)
 {
     DangerousAcceptAnyServerCertificateValidator = dangerousAcceptAnyServerCertificateValidator;
     AddHeadersToDownstream = addHeadersToDownstream;
     DelegatingHandlers     = delegatingHandlers;
     Key = key;
     UpstreamPathTemplate            = upstreamPathTemplate;
     UpstreamHeadersFindAndReplace   = upstreamHeadersFindAndReplace ?? new List <HeaderFindAndReplace>();
     DownstreamHeadersFindAndReplace = downstreamHeadersFindAndReplace ?? new List <HeaderFindAndReplace>();
     DownstreamAddresses             = downstreamAddresses ?? new List <DownstreamHostAndPort>();
     ServiceName         = serviceName;
     HttpHandlerOptions  = httpHandlerOptions;
     UseServiceDiscovery = useServiceDiscovery;
     EnableEndpointEndpointRateLimiting = enableEndpointEndpointRateLimiting;
     QosOptions             = qosOptions;
     DownstreamScheme       = downstreamScheme;
     RequestIdKey           = requestIdKey;
     IsCached               = isCached;
     CacheOptions           = cacheOptions;
     LoadBalancerOptions    = loadBalancerOptions;
     RateLimitOptions       = rateLimitOptions;
     RouteClaimsRequirement = routeClaimsRequirement;
     ClaimsToQueries        = claimsToQueries ?? new List <ClaimToThing>();
     ClaimsToHeaders        = claimsToHeaders ?? new List <ClaimToThing>();
     ClaimsToClaims         = claimsToClaims ?? new List <ClaimToThing>();
     IsAuthenticated        = isAuthenticated;
     IsAuthorised           = isAuthorised;
     AuthenticationOptions  = authenticationOptions;
     DownstreamPathTemplate = downstreamPathTemplate;
     LoadBalancerKey        = loadBalancerKey;
     AddHeadersToUpstream   = addHeadersToUpstream;
     SecurityOptions        = securityOptions;
 }
 public void SetUp()
 {
     _urlPathMatcher    = new RegExUrlMatcher();
     _pathTemplate      = new UpstreamPathTemplate("api/product/products/{productId}/variants/", 0, false, null);
     _downstreamUrlPath = "api/product/products/1/variants/?soldout=false";
 }