private void GivenTheDownstreamRequestHasSessionId(string value)
        {
            var context = new DefaultHttpContext();
            var cookies = new FakeCookies();

            cookies.AddCookie("sessionid", value);
            context.Request.Cookies = cookies;
            _downstreamContext      = new DownstreamContext(context);
        }
        private async Task WhenIMakeTwoRequetsWithDifferentSessionValues()
        {
            var contextOne = new DefaultHttpContext();
            var cookiesOne = new FakeCookies();

            cookiesOne.AddCookie("sessionid", "321");
            contextOne.Request.Cookies = cookiesOne;
            var contextTwo = new DefaultHttpContext();
            var cookiesTwo = new FakeCookies();

            cookiesTwo.AddCookie("sessionid", "123");
            contextTwo.Request.Cookies = cookiesTwo;
            _firstHostAndPort          = await _stickySessions.Lease(new DownstreamContext(contextOne));

            _secondHostAndPort = await _stickySessions.Lease(new DownstreamContext(contextTwo));
        }
Пример #3
0
        private async Task WhenTheStickySessionExpires()
        {
            var context = new DefaultHttpContext();
            var cookies = new FakeCookies();

            cookies.AddCookie("sessionid", "321");
            context.Request.Cookies = cookies;
            _downstreamContext      = new DownstreamContext(context);

            var firstHostAndPort = await _stickySessions.Lease(_downstreamContext);

            var secondHostAndPort = await _stickySessions.Lease(_downstreamContext);

            firstHostAndPort.Data.DownstreamHost.ShouldBe("one");
            firstHostAndPort.Data.DownstreamPort.ShouldBe(80);

            secondHostAndPort.Data.DownstreamHost.ShouldBe("one");
            secondHostAndPort.Data.DownstreamPort.ShouldBe(80);

            Thread.Sleep(150);
        }