mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -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:
@ -43,7 +43,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedPasswordManagerSeats = 20
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsStarterPlan, updatedSubscriptionData);
|
||||
|
||||
var upgradeItemOptions = subscriptionUpdate.UpgradeItemsOptions(subscription);
|
||||
|
||||
@ -114,7 +114,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedAdditionalStorage = 10
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsMonthlyPlan, updatedSubscriptionData);
|
||||
|
||||
var upgradeItemOptions = subscriptionUpdate.UpgradeItemsOptions(subscription);
|
||||
|
||||
@ -221,7 +221,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedAdditionalStorage = 10
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsMonthlyPlan, updatedSubscriptionData);
|
||||
|
||||
var upgradeItemOptions = subscriptionUpdate.UpgradeItemsOptions(subscription);
|
||||
|
||||
@ -302,7 +302,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedPasswordManagerSeats = 20
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsStarterPlan, updatedSubscriptionData);
|
||||
|
||||
var revertItemOptions = subscriptionUpdate.RevertItemsOptions(subscription);
|
||||
|
||||
@ -372,7 +372,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedAdditionalStorage = 10
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsMonthlyPlan, updatedSubscriptionData);
|
||||
|
||||
var revertItemOptions = subscriptionUpdate.RevertItemsOptions(subscription);
|
||||
|
||||
@ -478,7 +478,7 @@ public class CompleteSubscriptionUpdateTests
|
||||
PurchasedAdditionalStorage = 10
|
||||
};
|
||||
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, updatedSubscriptionData);
|
||||
var subscriptionUpdate = new CompleteSubscriptionUpdate(organization, teamsMonthlyPlan, updatedSubscriptionData);
|
||||
|
||||
var revertItemOptions = subscriptionUpdate.RevertItemsOptions(subscription);
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
using Bit.Core.Billing.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Business;
|
||||
using Bit.Core.Models.StaticStore;
|
||||
using Bit.Core.Test.AutoFixture.OrganizationFixtures;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Xunit;
|
||||
|
||||
@ -11,19 +13,40 @@ namespace Bit.Core.Test.Models.Business;
|
||||
[SecretsManagerOrganizationCustomize]
|
||||
public class SecretsManagerSubscriptionUpdateTests
|
||||
{
|
||||
private static TheoryData<Plan> ToPlanTheory(List<PlanType> types)
|
||||
{
|
||||
var theoryData = new TheoryData<Plan>();
|
||||
var plans = types.Select(StaticStore.GetPlan).ToArray();
|
||||
theoryData.AddRange(plans);
|
||||
return theoryData;
|
||||
}
|
||||
|
||||
public static TheoryData<Plan> NonSmPlans =>
|
||||
ToPlanTheory([PlanType.Custom, PlanType.FamiliesAnnually, PlanType.FamiliesAnnually2019]);
|
||||
|
||||
public static TheoryData<Plan> SmPlans => ToPlanTheory([
|
||||
PlanType.EnterpriseAnnually2019,
|
||||
PlanType.EnterpriseAnnually,
|
||||
PlanType.TeamsMonthly2019,
|
||||
PlanType.TeamsAnnually2020,
|
||||
PlanType.TeamsMonthly,
|
||||
PlanType.TeamsAnnually2019,
|
||||
PlanType.TeamsAnnually2020,
|
||||
PlanType.TeamsAnnually,
|
||||
PlanType.TeamsStarter
|
||||
]);
|
||||
|
||||
[Theory]
|
||||
[BitAutoData(PlanType.Custom)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually)]
|
||||
[BitAutoData(PlanType.FamiliesAnnually2019)]
|
||||
[BitMemberAutoData(nameof(NonSmPlans))]
|
||||
public Task UpdateSubscriptionAsync_WithNonSecretsManagerPlanType_ThrowsBadRequestException(
|
||||
PlanType planType,
|
||||
Plan plan,
|
||||
Organization organization)
|
||||
{
|
||||
// Arrange
|
||||
organization.PlanType = planType;
|
||||
organization.PlanType = plan.Type;
|
||||
|
||||
// Act
|
||||
var exception = Assert.Throws<NotFoundException>(() => new SecretsManagerSubscriptionUpdate(organization, false));
|
||||
var exception = Assert.Throws<NotFoundException>(() => new SecretsManagerSubscriptionUpdate(organization, plan, false));
|
||||
|
||||
// Assert
|
||||
Assert.Contains("Invalid Secrets Manager plan", exception.Message, StringComparison.InvariantCultureIgnoreCase);
|
||||
@ -31,28 +54,16 @@ public class SecretsManagerSubscriptionUpdateTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly2019)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly2020)]
|
||||
[BitAutoData(PlanType.EnterpriseMonthly)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually2019)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually2020)]
|
||||
[BitAutoData(PlanType.EnterpriseAnnually)]
|
||||
[BitAutoData(PlanType.TeamsMonthly2019)]
|
||||
[BitAutoData(PlanType.TeamsMonthly2020)]
|
||||
[BitAutoData(PlanType.TeamsMonthly)]
|
||||
[BitAutoData(PlanType.TeamsAnnually2019)]
|
||||
[BitAutoData(PlanType.TeamsAnnually2020)]
|
||||
[BitAutoData(PlanType.TeamsAnnually)]
|
||||
[BitAutoData(PlanType.TeamsStarter)]
|
||||
[BitMemberAutoData(nameof(SmPlans))]
|
||||
public void UpdateSubscription_WithNonSecretsManagerPlanType_DoesNotThrowException(
|
||||
PlanType planType,
|
||||
Plan plan,
|
||||
Organization organization)
|
||||
{
|
||||
// Arrange
|
||||
organization.PlanType = planType;
|
||||
organization.PlanType = plan.Type;
|
||||
|
||||
// Act
|
||||
var ex = Record.Exception(() => new SecretsManagerSubscriptionUpdate(organization, false));
|
||||
var ex = Record.Exception(() => new SecretsManagerSubscriptionUpdate(organization, plan, false));
|
||||
|
||||
// Assert
|
||||
Assert.Null(ex);
|
||||
|
Reference in New Issue
Block a user