1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-23 12:25:16 +01:00
bitwarden-server/test/Api.Test/Billing/Utilities.cs
Alex Morask fa62b36d44
[AC-2774] Consolidated issues for Consolidated Billing (#4201)
* Add BaseProviderController, update some endpoints to ServiceUser permissions

* Prevent service user from scaling provider seats above seat minimum

* Expand invoice response to include DueDate
2024-06-24 11:15:47 -04:00

48 lines
1.5 KiB
C#

using Bit.Api.Billing.Controllers;
using Bit.Core;
using Bit.Core.AdminConsole.Entities.Provider;
using Bit.Core.AdminConsole.Enums.Provider;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Context;
using Bit.Core.Services;
using Bit.Test.Common.AutoFixture;
using NSubstitute;
namespace Bit.Api.Test.Billing;
public static class Utilities
{
public static void ConfigureStableAdminInputs<T>(
Provider provider,
SutProvider<T> sutProvider) where T : BaseProviderController
{
ConfigureBaseInputs(provider, sutProvider);
sutProvider.GetDependency<ICurrentContext>().ProviderProviderAdmin(provider.Id)
.Returns(true);
}
public static void ConfigureStableServiceUserInputs<T>(
Provider provider,
SutProvider<T> sutProvider) where T : BaseProviderController
{
ConfigureBaseInputs(provider, sutProvider);
sutProvider.GetDependency<ICurrentContext>().ProviderUser(provider.Id)
.Returns(true);
}
private static void ConfigureBaseInputs<T>(
Provider provider,
SutProvider<T> sutProvider) where T : BaseProviderController
{
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.EnableConsolidatedBilling)
.Returns(true);
provider.Type = ProviderType.Msp;
provider.Status = ProviderStatusType.Billable;
sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider);
}
}