mirror of
https://github.com/bitwarden/server.git
synced 2025-12-11 03:37:11 -06:00
* Add CQRS and caching support for OrganizationIntegrations * Use primary constructor for Delete command, per Claude suggestion * Fix namespace * Add XMLDoc for new commands / queries * Remove unnecessary extra call to AddExtendedCache in Startup (call in EventIntegrationsServiceCollectionExtensions handles this instead) * Alter strategy to use one cache / database call to retrieve all configurations for an event (including wildcards) * Updated README documentation to reflect updated Caching doc and updated CQRS approach
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Bit.Core.AdminConsole.Entities;
|
|
using Bit.Core.AdminConsole.EventIntegrations.OrganizationIntegrations;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Core.Test.AdminConsole.EventIntegrations.OrganizationIntegrations;
|
|
|
|
[SutProviderCustomize]
|
|
public class GetOrganizationIntegrationsQueryTests
|
|
{
|
|
[Theory, BitAutoData]
|
|
public async Task GetManyByOrganizationAsync_CallsRepository(
|
|
SutProvider<GetOrganizationIntegrationsQuery> sutProvider,
|
|
Guid organizationId,
|
|
List<OrganizationIntegration> integrations)
|
|
{
|
|
sutProvider.GetDependency<IOrganizationIntegrationRepository>()
|
|
.GetManyByOrganizationAsync(organizationId)
|
|
.Returns(integrations);
|
|
|
|
var result = await sutProvider.Sut.GetManyByOrganizationAsync(organizationId);
|
|
|
|
await sutProvider.GetDependency<IOrganizationIntegrationRepository>().Received(1)
|
|
.GetManyByOrganizationAsync(organizationId);
|
|
Assert.Equal(integrations.Count, result.Count);
|
|
}
|
|
|
|
[Theory, BitAutoData]
|
|
public async Task GetManyByOrganizationAsync_NoIntegrations_ReturnsEmptyList(
|
|
SutProvider<GetOrganizationIntegrationsQuery> sutProvider,
|
|
Guid organizationId)
|
|
{
|
|
sutProvider.GetDependency<IOrganizationIntegrationRepository>()
|
|
.GetManyByOrganizationAsync(organizationId)
|
|
.Returns([]);
|
|
|
|
var result = await sutProvider.Sut.GetManyByOrganizationAsync(organizationId);
|
|
|
|
Assert.Empty(result);
|
|
}
|
|
}
|