Skip to content

Commit

Permalink
Add failing test for invalid configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdecock committed Jul 6, 2023
1 parent 6735231 commit 486a01f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/Duende.Bff.Tests/Endpoints/YarpRemoteEndpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
18 changes: 17 additions & 1 deletion test/Duende.Bff.Tests/TestHosts/YarpBffHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down

0 comments on commit 486a01f

Please sign in to comment.