2023-10-26 23:47:44 +02:00
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationApiKeys;
|
|
|
|
|
using Bit.Core.Entities;
|
2022-11-29 01:39:09 +01:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Bit.Core.Repositories;
|
|
|
|
|
using Bit.Test.Common.AutoFixture;
|
|
|
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
|
using NSubstitute;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2023-10-26 23:47:44 +02:00
|
|
|
|
namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.OrganizationApiKeys;
|
2022-11-29 01:39:09 +01:00
|
|
|
|
|
|
|
|
|
[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));
|
|
|
|
|
}
|
|
|
|
|
}
|