mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
fix test
This commit is contained in:
parent
56ba834ca2
commit
7899c2d5c5
2 changed files with 10 additions and 4 deletions
|
@ -46,13 +46,13 @@ namespace BTCPayServer.Tests
|
|||
Assert.Single(apiKeyData.Permissions);
|
||||
|
||||
//a client using Basic Auth has no business here
|
||||
await AssertHttpError(401, async () => await clientBasic.GetCurrentAPIKeyInfo());
|
||||
await AssertHttpError(404, async () => await clientBasic.GetCurrentAPIKeyInfo());
|
||||
|
||||
//revoke current api key
|
||||
await client.RevokeCurrentAPIKeyInfo();
|
||||
await AssertHttpError(401, async () => await client.GetCurrentAPIKeyInfo());
|
||||
//a client using Basic Auth has no business here
|
||||
await AssertHttpError(401, async () => await clientBasic.RevokeCurrentAPIKeyInfo());
|
||||
await AssertHttpError(404, async () => await clientBasic.RevokeCurrentAPIKeyInfo());
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ namespace BTCPayServer.Controllers.RestApi
|
|||
[HttpGet("~/api/v1/api-keys/current")]
|
||||
public async Task<ActionResult<ApiKeyData>> GetKey()
|
||||
{
|
||||
ControllerContext.HttpContext.GetAPIKey(out var apiKey);
|
||||
if (!ControllerContext.HttpContext.GetAPIKey(out var apiKey))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
var data = await _apiKeyRepository.GetKey(apiKey);
|
||||
return Ok(FromModel(data));
|
||||
}
|
||||
|
@ -36,7 +39,10 @@ namespace BTCPayServer.Controllers.RestApi
|
|||
[Authorize(Policy = Policies.Unrestricted, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
public async Task<ActionResult<ApiKeyData>> RevokeKey()
|
||||
{
|
||||
ControllerContext.HttpContext.GetAPIKey(out var apiKey);
|
||||
if (!ControllerContext.HttpContext.GetAPIKey(out var apiKey))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
await _apiKeyRepository.Remove(apiKey, _userManager.GetUserId(User));
|
||||
return Ok();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue