Exemplo n.º 1
0
        public void request_should_reuse_cookies_with_cookie_container()
        {
            var port = RandomPortFinder.GetRandomPort();

            var configuration = new FileConfiguration
            {
                ReRoutes = new List <FileReRoute>
                {
                    new FileReRoute
                    {
                        DownstreamPathTemplate = "/sso/{everything}",
                        DownstreamScheme       = "http",
                        DownstreamHostAndPorts = new List <FileHostAndPort>
                        {
                            new FileHostAndPort
                            {
                                Host = "localhost",
                                Port = port,
                            }
                        },
                        UpstreamPathTemplate = "/sso/{everything}",
                        UpstreamHttpMethod   = new List <string> {
                            "Get", "Post", "Options"
                        },
                        HttpHandlerOptions = new FileHttpHandlerOptions
                        {
                            UseCookieContainer = true
                        }
                    }
                }
            };

            this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}", "/sso/test", 200))
            .And(x => _steps.GivenThereIsAConfiguration(configuration))
            .And(x => _steps.GivenOcelotIsRunning())
            .And(x => _steps.WhenIGetUrlOnTheApiGateway("/sso/test"))
            .And(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
            .And(x => _steps.ThenTheResponseHeaderIs("Set-Cookie", "test=0; path=/"))
            .And(x => _steps.GivenIAddCookieToMyRequest("test=1; path=/"))
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/sso/test"))
            .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
            .BDDfy();
        }