mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Fix: Do not returns HTML content if authentication to API fails
This commit is contained in:
parent
5443ac4688
commit
b28fc85974
3 changed files with 10 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"parallelizeTestCollections": false,
|
||||
"longRunningTestSeconds": 60,
|
||||
"diagnosticMessages": true
|
||||
"diagnosticMessages": true,
|
||||
"methodDisplay": "method"
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Add table
Reference in a new issue