mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
fix test
This commit is contained in:
parent
56ba834ca2
commit
7899c2d5c5
@ -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…
Reference in New Issue
Block a user