예제 #1
0
        public void should_return_response_401_using_identity_server_with_token_requested_for_other_api()
        {
            var configuration = new FileConfiguration
            {
                ReRoutes = new List <FileReRoute>
                {
                    new FileReRoute
                    {
                        DownstreamPathTemplate = _downstreamServicePath,
                        DownstreamPort         = _downstreamServicePort,
                        DownstreamHost         = _downstreamServiceHost,
                        DownstreamScheme       = _downstreamServiceScheme,
                        UpstreamPathTemplate   = "/",
                        UpstreamHttpMethod     = new List <string> {
                            "Get"
                        },
                        AuthenticationOptions = new FileAuthenticationOptions
                        {
                            AuthenticationProviderKey = "Test"
                        }
                    }
                }
            };

            this.Given(x => x.GivenThereIsAnIdentityServerOn(_identityServerRootUrl, "api", "api2", AccessTokenType.Jwt))
            .And(x => x.GivenThereIsAServiceRunningOn(_downstreamServiceUrl, 200, "Hello from Laura"))
            .And(x => _steps.GivenIHaveATokenForApi2(_identityServerRootUrl))
            .And(x => _steps.GivenThereIsAConfiguration(configuration))
            .And(x => _steps.GivenOcelotIsRunning(_options, "Test"))
            .And(x => _steps.GivenIHaveAddedATokenToMyRequest())
            .When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
            .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.Unauthorized))
            .BDDfy();
        }