1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 20:50:21 -05:00

revert new key management endpoints

This commit is contained in:
Maciej Zieniuk 2025-03-29 16:12:32 +00:00
parent aba05f7970
commit 210d06acb4
No known key found for this signature in database
GPG Key ID: 9CACE59F1272ACD9
2 changed files with 16 additions and 25 deletions

View File

@ -57,7 +57,8 @@ public class AccountsKeyManagementController : Controller
emergencyAccessValidator,
IRotationValidator<IEnumerable<ResetPasswordWithOrgIdRequestModel>, IReadOnlyList<OrganizationUser>>
organizationUserValidator,
IRotationValidator<IEnumerable<WebAuthnLoginRotateKeyRequestModel>, IEnumerable<WebAuthnLoginRotateKeyData>> webAuthnKeyValidator)
IRotationValidator<IEnumerable<WebAuthnLoginRotateKeyRequestModel>, IEnumerable<WebAuthnLoginRotateKeyData>>
webAuthnKeyValidator)
{
_userService = userService;
_featureService = featureService;
@ -129,8 +130,6 @@ public class AccountsKeyManagementController : Controller
throw new BadRequestException(ModelState);
}
[HttpPost("key-management/set-key-connector-key")]
// Backwards compatibility, to be deleted in the future
[HttpPost("set-key-connector-key")]
public async Task PostSetKeyConnectorKeyAsync([FromBody] SetKeyConnectorKeyRequestModel model)
{
@ -154,8 +153,6 @@ public class AccountsKeyManagementController : Controller
throw new BadRequestException(ModelState);
}
[HttpPost("key-management/convert-to-key-connector")]
// Backwards compatibility, to be deleted in the future
[HttpPost("convert-to-key-connector")]
public async Task PostConvertToKeyConnectorAsync()
{

View File

@ -175,7 +175,8 @@ public class AccountsKeyManagementControllerTests : IClassFixture<ApiApplication
[Theory]
[BitAutoData]
public async Task RotateUserAccountKeysAsync_NotLoggedIn_Unauthorized(RotateUserAccountKeysAndDataRequestModel request)
public async Task RotateUserAccountKeysAsync_NotLoggedIn_Unauthorized(
RotateUserAccountKeysAndDataRequestModel request)
{
var response = await _client.PostAsJsonAsync("/accounts/key-management/rotate-user-account-keys", request);
@ -257,20 +258,17 @@ public class AccountsKeyManagementControllerTests : IClassFixture<ApiApplication
}
[Theory]
[BitAutoData("/accounts/key-management/set-key-connector-key")]
[BitAutoData("/accounts/set-key-connector-key")]
public async Task PostSetKeyConnectorKeyAsync_NotLoggedIn_Unauthorized(string uri,
SetKeyConnectorKeyRequestModel request)
[BitAutoData]
public async Task PostSetKeyConnectorKeyAsync_NotLoggedIn_Unauthorized(SetKeyConnectorKeyRequestModel request)
{
var response = await _client.PostAsJsonAsync(uri, request);
var response = await _client.PostAsJsonAsync("/accounts/set-key-connector-key", request);
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
}
[Theory]
[BitAutoData("/accounts/key-management/set-key-connector-key")]
[BitAutoData("/accounts/set-key-connector-key")]
public async Task PostSetKeyConnectorKeyAsync_Success(string uri, string organizationSsoIdentifier,
[BitAutoData]
public async Task PostSetKeyConnectorKeyAsync_Success(string organizationSsoIdentifier,
SetKeyConnectorKeyRequestModel request)
{
var (organization, _) = await OrganizationTestHelpers.SignUpAsync(_factory,
@ -291,7 +289,7 @@ public class AccountsKeyManagementControllerTests : IClassFixture<ApiApplication
request.Key = _mockEncryptedString;
request.OrgIdentifier = organizationSsoIdentifier;
var response = await _client.PostAsJsonAsync(uri, request);
var response = await _client.PostAsJsonAsync("/accounts/set-key-connector-key", request);
response.EnsureSuccessStatusCode();
var user = await _userRepository.GetByEmailAsync(ssoUserEmail);
@ -308,20 +306,16 @@ public class AccountsKeyManagementControllerTests : IClassFixture<ApiApplication
Assert.Null(ssoOrganizationUser.Email);
}
[Theory]
[BitAutoData("/accounts/key-management/convert-to-key-connector")]
[BitAutoData("/accounts/convert-to-key-connector")]
public async Task PostConvertToKeyConnectorAsync_NotLoggedIn_Unauthorized(string uri)
[Fact]
public async Task PostConvertToKeyConnectorAsync_NotLoggedIn_Unauthorized()
{
var response = await _client.PostAsJsonAsync(uri, new { });
var response = await _client.PostAsJsonAsync("/accounts/convert-to-key-connector", new { });
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
}
[Theory]
[BitAutoData("/accounts/key-management/convert-to-key-connector")]
[BitAutoData("/accounts/convert-to-key-connector")]
public async Task PostConvertToKeyConnectorAsync_Success(string uri)
[Fact]
public async Task PostConvertToKeyConnectorAsync_Success()
{
var (organization, _) = await OrganizationTestHelpers.SignUpAsync(_factory,
PlanType.EnterpriseAnnually, _ownerEmail, passwordManagerSeats: 10,
@ -337,7 +331,7 @@ public class AccountsKeyManagementControllerTests : IClassFixture<ApiApplication
await OrganizationTestHelpers.CreateUserAsync(_factory, organization.Id, ssoUserEmail,
OrganizationUserType.User, userStatusType: OrganizationUserStatusType.Accepted);
var response = await _client.PostAsJsonAsync(uri, new { });
var response = await _client.PostAsJsonAsync("/accounts/convert-to-key-connector", new { });
response.EnsureSuccessStatusCode();
var user = await _userRepository.GetByEmailAsync(ssoUserEmail);