mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[SG-841] Refactor GetOrganizationApiKeyCommand (#2436)
* Renamed and split up class to only query for an organization key * Added a command class to create an organization api key * Updated service registration and controller to include new changes * Updated test cases to reflect refactor * fixed lint issues * Fixed PR comment
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.OrganizationFeatures.OrganizationApiKeys;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ReceivedExtensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.OrganizationFeatures.OrganizationApiKeys;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class CreateOrganizationApiKeyCommandTest
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task CreateAsync_CreatesOrganizationApiKey(SutProvider<CreateOrganizationApiKeyCommand> sutProvider,
|
||||
Guid organizationId, OrganizationApiKeyType keyType)
|
||||
{
|
||||
await sutProvider.Sut.CreateAsync(organizationId, keyType);
|
||||
|
||||
await sutProvider.GetDependency<IOrganizationApiKeyRepository>().Received(1)
|
||||
.CreateAsync(Arg.Is<OrganizationApiKey>(o => o.OrganizationId == organizationId
|
||||
&& o.Type == keyType));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user