Fix: Do not returns HTML content if authentication to API fails

This commit is contained in:
nicolas.dorier 2020-05-01 21:33:27 +09:00
parent 5443ac4688
commit b28fc85974
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
3 changed files with 10 additions and 1 deletions

View file

@ -607,6 +607,12 @@ namespace BTCPayServer.Tests
{
Assert.Equal("Object not found", ex.Errors.First());
}
var req = new HttpRequestMessage(HttpMethod.Get, "/invoices/Cy9jfK82eeEED1T3qhwF3Y");
req.Headers.TryAddWithoutValidation("Authorization", "Basic dGVzdA==");
req.Content = new StringContent("{}", Encoding.UTF8, "application/json");
var result = await tester.PayTester.HttpClient.SendAsync(req);
Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
Assert.Equal(0, result.Content.Headers.ContentLength.Value);
}
}

View file

@ -1,5 +1,6 @@
{
"parallelizeTestCollections": false,
"longRunningTestSeconds": 60,
"diagnosticMessages": true
"diagnosticMessages": true,
"methodDisplay": "method"
}

View file

@ -12,6 +12,8 @@ namespace BTCPayServer.Controllers
{
public IActionResult Handle(int? statusCode = null)
{
if (Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
return this.StatusCode(statusCode.Value);
if (statusCode.HasValue)
{
var specialPages = new[] { 404, 429, 500 };