private void ThenTheFollowingOptionsReturned(HttpHandlerOptions expected)
 {
     _httpHandlerOptions.ShouldNotBeNull();
     _httpHandlerOptions.AllowAutoRedirect.ShouldBe(expected.AllowAutoRedirect);
     _httpHandlerOptions.UseCookieContainer.ShouldBe(expected.UseCookieContainer);
     _httpHandlerOptions.UseTracing.ShouldBe(expected.UseTracing);
 }
        public void should_call_httpHandler_creator()
        {
            var reRouteOptions = new ReRouteOptionsBuilder()
                                 .Build();
            var httpHandlerOptions = new HttpHandlerOptions(true, true);

            this.Given(x => x.GivenTheConfigIs(new FileConfiguration
            {
                ReRoutes = new List <FileReRoute>
                {
                    new FileReRoute
                    {
                        DownstreamHost         = "127.0.0.1",
                        UpstreamPathTemplate   = "/api/products/{productId}",
                        DownstreamPathTemplate = "/products/{productId}",
                        UpstreamHttpMethod     = new List <string> {
                            "Get"
                        }
                    }
                },
            }))
            .And(x => x.GivenTheFollowingOptionsAreReturned(reRouteOptions))
            .And(x => x.GivenTheConfigIsValid())
            .And(x => x.GivenTheFollowingHttpHandlerOptionsAreReturned(httpHandlerOptions))
            .When(x => x.WhenICreateTheConfig())
            .Then(x => x.ThenTheHttpHandlerOptionsCreatorIsCalledCorrectly())
            .BDDfy();
        }
        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);
        }
        public void should_create_options_with_useCookie_false_and_allowAutoRedirect_true_as_default()
        {
            var fileReRoute     = new FileReRoute();
            var expectedOptions = new HttpHandlerOptions(false, false, false);

            this.Given(x => GivenTheFollowing(fileReRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
Beispiel #5
0
 public DownstreamRouteCreatorTests()
 {
     _qosOptionsCreator   = new Mock <IQoSOptionsCreator>();
     _qoSOptions          = new QoSOptionsBuilder().Build();
     _handlerOptions      = new HttpHandlerOptionsBuilder().Build();
     _loadBalancerOptions = new LoadBalancerOptionsBuilder().WithType(nameof(NoLoadBalancer)).Build();
     _qosOptionsCreator
     .Setup(x => x.Create(It.IsAny <QoSOptions>(), It.IsAny <string>(), It.IsAny <List <string> >()))
     .Returns(_qoSOptions);
     _creator = new DownstreamRouteCreator(_qosOptionsCreator.Object);
 }
        public void should_create_options_with_useproxy_true_as_default()
        {
            var fileReRoute = new FileReRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions()
            };

            var expectedOptions = new HttpHandlerOptions(false, false, false, true);

            this.Given(x => GivenTheFollowing(fileReRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
        private void GivenTheDependenciesAreSetUp()
        {
            _fileConfig = new FileConfiguration
            {
                GlobalConfiguration = new FileGlobalConfiguration()
            };
            _reRoutes = new List <ReRoute>();
            _spc      = new ServiceProviderConfiguration("", "", 1, "", "", 1);
            _lbo      = new LoadBalancerOptionsBuilder().Build();
            _qoso     = new QoSOptions(1, 1, 1, "");
            _hho      = new HttpHandlerOptionsBuilder().Build();

            _spcCreator.Setup(x => x.Create(It.IsAny <FileGlobalConfiguration>())).Returns(_spc);
            _lboCreator.Setup(x => x.Create(It.IsAny <FileLoadBalancerOptions>())).Returns(_lbo);
            _qosCreator.Setup(x => x.Create(It.IsAny <FileQoSOptions>())).Returns(_qoso);
            _hhoCreator.Setup(x => x.Create(It.IsAny <FileHttpHandlerOptions>())).Returns(_hho);
        }
        public void should_not_use_tracing_if_fake_tracer_registered()
        {
            var fileReRoute = new FileReRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions
                {
                    UseTracing = true
                }
            };

            var expectedOptions = new HttpHandlerOptions(false, false, false, true);

            this.Given(x => GivenTheFollowing(fileReRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
        public void should_create_options_with_specified_useproxy()
        {
            var fileReRoute = new FileReRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions
                {
                    UseProxy = false
                }
            };

            var expectedOptions = new HttpHandlerOptions(false, false, false, false);

            this.Given(x => GivenTheFollowing(fileReRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
        public void should_create_options_fixing_specified_MaxConnectionsPerServer_range_when_zero()
        {
            var fileRoute = new FileRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions
                {
                    MaxConnectionsPerServer = 0
                }
            };

            var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);

            this.Given(x => GivenTheFollowing(fileRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
        public void should_create_options_with_specified_MaxConnectionsPerServer()
        {
            var fileRoute = new FileRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions
                {
                    MaxConnectionsPerServer = 10
                }
            };

            var expectedOptions = new HttpHandlerOptions(false, false, false, true, 10);

            this.Given(x => GivenTheFollowing(fileRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
Beispiel #12
0
        public void should_create_options_with_specified_useCookie_and_allowAutoRedirect()
        {
            var fileReRoute = new FileReRoute
            {
                HttpHandlerOptions = new FileHttpHandlerOptions
                {
                    AllowAutoRedirect  = false,
                    UseCookieContainer = false
                }
            };

            var expectedOptions = new HttpHandlerOptions(false, false);

            this.Given(x => GivenTheFollowing(fileReRoute))
            .When(x => WhenICreateHttpHandlerOptions())
            .Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
            .BDDfy();
        }
 private void WhenICreateHttpHandlerOptions()
 {
     _httpHandlerOptions = _httpHandlerOptionsCreator.Create(_fileReRoute);
 }
Beispiel #14
0
 public DownstreamReRouteBuilder WithHttpHandlerOptions(HttpHandlerOptions input)
 {
     _httpHandlerOptions = input;
     return(this);
 }
 private void GivenTheFollowingHttpHandlerOptionsAreReturned(HttpHandlerOptions httpHandlerOptions)
 {
     _httpHandlerOptionsCreator.Setup(x => x.Create(It.IsAny <FileHttpHandlerOptions>()))
     .Returns(httpHandlerOptions);
 }
Beispiel #16
0
 private void ThenTheFollowingOptionsReturned(HttpHandlerOptions options)
 {
     _httpHandlerOptions.ShouldNotBeNull();
     _httpHandlerOptions.AllowAutoRedirect.ShouldBe(options.AllowAutoRedirect);
     _httpHandlerOptions.UseCookieContainer.ShouldBe(options.UseCookieContainer);
 }