diff --git a/test/Duende.Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs b/test/Duende.Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs index 5d8ab57d..3a2e7839 100644 --- a/test/Duende.Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs +++ b/test/Duende.Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs @@ -212,5 +212,14 @@ public async Task response_status_403_from_remote_endpoint_should_return_403_fro response.StatusCode.Should().Be(HttpStatusCode.Forbidden); } + + [Fact] + public async Task invalid_configuration_of_routes_should_return_500() + { + var req = new HttpRequestMessage(HttpMethod.Get, BffHost.Url("/api_invalid/test")); + var response = await BffHost.BrowserClient.SendAsync(req); + + response.StatusCode.Should().Be(HttpStatusCode.InternalServerError); + } } } diff --git a/test/Duende.Bff.Tests/TestHosts/YarpBffHost.cs b/test/Duende.Bff.Tests/TestHosts/YarpBffHost.cs index e0ebfce0..77309206 100644 --- a/test/Duende.Bff.Tests/TestHosts/YarpBffHost.cs +++ b/test/Duende.Bff.Tests/TestHosts/YarpBffHost.cs @@ -135,7 +135,23 @@ private void ConfigureServices(IServiceCollection services) Path = "/api_user_or_client/{**catch-all}" } }.WithAntiforgeryCheck() - .WithAccessToken(TokenType.UserOrClient) + .WithAccessToken(TokenType.UserOrClient), + + // This route configuration is invalid. WithAccessToken says + // that the access token is required, while + // WithOptionalUserAccessToken says that it is optional. + // Calling this endpoint results in a run time error. + new RouteConfig() + { + RouteId = "api_invalid", + ClusterId = "cluster1", + + Match = new() + { + Path = "/api_invalid/{**catch-all}" + } + }.WithOptionalUserAccessToken() + .WithAccessToken(TokenType.User), }, new[]