1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

[PM-16684] Integrate Pricing Service behind FF (#5276)

* Remove gRPC and convert PricingClient to HttpClient wrapper

* Add PlanType.GetProductTier extension

Many instances of StaticStore use are just to get the ProductTierType of a PlanType, but this can be derived from the PlanType itself without having to fetch the entire plan.

* Remove invocations of the StaticStore in non-Test code

* Deprecate StaticStore entry points

* Run dotnet format

* Matt's feedback

* Run dotnet format

* Rui's feedback

* Run dotnet format

* Replacements since approval

* Run dotnet format
This commit is contained in:
Alex Morask
2025-02-27 07:55:46 -05:00
committed by GitHub
parent bd66f06bd9
commit a2e665cb96
78 changed files with 1178 additions and 712 deletions

View File

@ -1,8 +1,10 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Billing.Constants;
using Bit.Core.Billing.Pricing;
using Bit.Core.Billing.Services;
using Bit.Core.Billing.Services.Implementations;
using Bit.Core.Repositories;
using Bit.Core.Utilities;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using NSubstitute;
@ -15,43 +17,6 @@ namespace Bit.Core.Test.Billing.Services;
public class OrganizationBillingServiceTests
{
#region GetMetadata
[Theory, BitAutoData]
public async Task GetMetadata_OrganizationNull_ReturnsNull(
Guid organizationId,
SutProvider<OrganizationBillingService> sutProvider)
{
var metadata = await sutProvider.Sut.GetMetadata(organizationId);
Assert.Null(metadata);
}
[Theory, BitAutoData]
public async Task GetMetadata_CustomerNull_ReturnsNull(
Guid organizationId,
Organization organization,
SutProvider<OrganizationBillingService> sutProvider)
{
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organizationId).Returns(organization);
var metadata = await sutProvider.Sut.GetMetadata(organizationId);
Assert.False(metadata.IsOnSecretsManagerStandalone);
}
[Theory, BitAutoData]
public async Task GetMetadata_SubscriptionNull_ReturnsNull(
Guid organizationId,
Organization organization,
SutProvider<OrganizationBillingService> sutProvider)
{
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organizationId).Returns(organization);
sutProvider.GetDependency<ISubscriberService>().GetCustomer(organization).Returns(new Customer());
var metadata = await sutProvider.Sut.GetMetadata(organizationId);
Assert.False(metadata.IsOnSecretsManagerStandalone);
}
[Theory, BitAutoData]
public async Task GetMetadata_Succeeds(
@ -61,6 +26,11 @@ public class OrganizationBillingServiceTests
{
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organizationId).Returns(organization);
sutProvider.GetDependency<IPricingClient>().ListPlans().Returns(StaticStore.Plans.ToList());
sutProvider.GetDependency<IPricingClient>().GetPlanOrThrow(organization.PlanType)
.Returns(StaticStore.GetPlan(organization.PlanType));
var subscriberService = sutProvider.GetDependency<ISubscriberService>();
subscriberService
@ -99,7 +69,8 @@ public class OrganizationBillingServiceTests
var metadata = await sutProvider.Sut.GetMetadata(organizationId);
Assert.True(metadata.IsOnSecretsManagerStandalone);
Assert.True(metadata!.IsOnSecretsManagerStandalone);
}
#endregion
}