mirror of
https://github.com/bitwarden/server.git
synced 2026-06-01 01:55:55 -05:00
* chore: add CLAUDE.local.md and .worktrees to gitignore * feat(billing): add Stripe interval and payment behavior constants and feature flag * feat(billing): add OrganizationSubscriptionChangeSet model and unit tests * refactor(billing): rename UpdateOrganizationSubscriptionCommand to BulkUpdateOrganizationSubscriptionsCommand * feat(billing): add UpdateOrganizationSubscriptionCommand with tests * feat(billing): use UpdateOrganizationSubscriptionCommand in BulkUpdateOrganizationSubscriptions behind feature flag * feat(billing): use UpdateOrganizationSubscriptionCommand in SetUpSponsorshipCommand behind feature flag * feat(billing): add UpgradeOrganizationPlanVNextCommand with tests and feature flag gate * feat(billing): use UpdateOrganizationSubscriptionCommand in OrganizationService.AdjustSeatsAsync behind feature flag * feat(billing): use UpdateOrganizationSubscriptionCommand in UpdateSecretsManagerSubscriptionCommand behind feature flag * feat(billing): use UpdateOrganizationSubscriptionCommand in BillingHelpers.AdjustStorageAsync behind feature flag * chore: run dotnet format * fix(billing): missed optional owner in OrganizationBillingService.Finalize after merge * refactor(billing): address PR feedback on UpdateOrganizationSubscription
61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using Bit.Api.AdminConsole.Jobs;
|
|
using Bit.Core;
|
|
using Bit.Core.AdminConsole.Models.Data.Organizations;
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations.Interfaces;
|
|
using Bit.Core.Services;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using NSubstitute;
|
|
using Quartz;
|
|
using Xunit;
|
|
|
|
namespace Bit.Api.Test.AdminConsole.Jobs;
|
|
|
|
[SutProviderCustomize]
|
|
public class OrganizationSubscriptionUpdateJobTests
|
|
{
|
|
[Theory]
|
|
[BitAutoData]
|
|
public async Task ExecuteJobAsync_WhenScimInviteUserIsDisabled_ThenQueryAndCommandAreNotExecuted(
|
|
SutProvider<OrganizationSubscriptionUpdateJob> sutProvider)
|
|
{
|
|
sutProvider.GetDependency<IFeatureService>()
|
|
.IsEnabled(FeatureFlagKeys.ScimInviteUserOptimization)
|
|
.Returns(false);
|
|
|
|
var contextMock = Substitute.For<IJobExecutionContext>();
|
|
|
|
await sutProvider.Sut.Execute(contextMock);
|
|
|
|
await sutProvider.GetDependency<IGetOrganizationSubscriptionsToUpdateQuery>()
|
|
.DidNotReceive()
|
|
.GetOrganizationSubscriptionsToUpdateAsync();
|
|
|
|
await sutProvider.GetDependency<IBulkUpdateOrganizationSubscriptionsCommand>()
|
|
.DidNotReceive()
|
|
.BulkUpdateOrganizationSubscriptionsAsync(Arg.Any<IEnumerable<OrganizationSubscriptionUpdate>>());
|
|
}
|
|
|
|
[Theory]
|
|
[BitAutoData]
|
|
public async Task ExecuteJobAsync_WhenScimInviteUserIsEnabled_ThenQueryAndCommandAreExecuted(
|
|
SutProvider<OrganizationSubscriptionUpdateJob> sutProvider)
|
|
{
|
|
sutProvider.GetDependency<IFeatureService>()
|
|
.IsEnabled(FeatureFlagKeys.ScimInviteUserOptimization)
|
|
.Returns(true);
|
|
|
|
var contextMock = Substitute.For<IJobExecutionContext>();
|
|
|
|
await sutProvider.Sut.Execute(contextMock);
|
|
|
|
await sutProvider.GetDependency<IGetOrganizationSubscriptionsToUpdateQuery>()
|
|
.Received(1)
|
|
.GetOrganizationSubscriptionsToUpdateAsync();
|
|
|
|
await sutProvider.GetDependency<IBulkUpdateOrganizationSubscriptionsCommand>()
|
|
.Received(1)
|
|
.BulkUpdateOrganizationSubscriptionsAsync(Arg.Any<IEnumerable<OrganizationSubscriptionUpdate>>());
|
|
}
|
|
}
|