mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
[AC 1451] Refactor staticstore plans and consuming logic (#3164)
* refactor the plan and create new objects * initial commit * Add new plan types * continue the refactoring by adding new plantypes * changes for plans * Refactoring continues * making changes for plan * Fixing the failing test * Fixing whitespace * Fix some in correct values * Resolve the plan data * rearranging the plan * Make the plan more immutable * Resolve the lint errors * Fix the failing test * Add custom plan * Fix the failing test * Fix the failing test * resolve the failing addons after refactoring * Refactoring * Merge branch 'master' into ac-1451/refactor-staticstore-plans-and-consuming-logic * merge from master * Merge branch 'master' into ac-1451/refactor-staticstore-plans-and-consuming-logic * format whitespace * resolve the conflict * Fix some pr comments * Fixing some of the pr comments * fixing some of the pr comments * Resolve some pr comments * Resolve pr comments * Resolves some pr comments * Resolving some or comments * Resolve a failing test * fix the failing test * Resolving some pr comments * Fix the failing test * resolve pr comment * add a using statement fir a failing test --------- Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.StaticStore;
|
||||
using Bit.Core.Utilities;
|
||||
using Xunit;
|
||||
|
||||
@ -14,57 +13,18 @@ public class StaticStoreTests
|
||||
var plans = StaticStore.Plans;
|
||||
Assert.NotNull(plans);
|
||||
Assert.NotEmpty(plans);
|
||||
Assert.Equal(17, plans.Count());
|
||||
Assert.Equal(12, plans.Count());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PlanType.EnterpriseAnnually)]
|
||||
public void StaticStore_GetPasswordManagerPlanByPlanType_Success(PlanType planType)
|
||||
[InlineData(PlanType.EnterpriseMonthly)]
|
||||
[InlineData(PlanType.TeamsMonthly)]
|
||||
[InlineData(PlanType.TeamsAnnually)]
|
||||
public void StaticStore_GetPlan_Success(PlanType planType)
|
||||
{
|
||||
var plan = StaticStore.GetPasswordManagerPlan(planType);
|
||||
|
||||
var plan = StaticStore.GetPlan(planType);
|
||||
Assert.NotNull(plan);
|
||||
Assert.Equal(planType, plan.Type);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PlanType.EnterpriseAnnually)]
|
||||
public void StaticStore_GetSecretsManagerPlanByPlanType_Success(PlanType planType)
|
||||
{
|
||||
var plan = StaticStore.GetSecretsManagerPlan(planType);
|
||||
|
||||
Assert.NotNull(plan);
|
||||
Assert.Equal(planType, plan.Type);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PlanType.EnterpriseAnnually)]
|
||||
public void StaticStore_GetPasswordManagerPlan_ReturnsPasswordManagerPlans(PlanType planType)
|
||||
{
|
||||
var plan = StaticStore.GetPasswordManagerPlan(planType);
|
||||
Assert.NotNull(plan);
|
||||
Assert.Equal(BitwardenProductType.PasswordManager, plan.BitwardenProduct);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PlanType.EnterpriseAnnually)]
|
||||
public void StaticStore_GetSecretsManagerPlan_ReturnsSecretManagerPlans(PlanType planType)
|
||||
{
|
||||
var plan = StaticStore.GetSecretsManagerPlan(planType);
|
||||
Assert.NotNull(plan);
|
||||
Assert.Equal(BitwardenProductType.SecretsManager, plan.BitwardenProduct);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PlanType.EnterpriseAnnually, BitwardenProductType.PasswordManager)]
|
||||
public void StaticStore_AddDuplicatePlans_SingleOrDefaultThrowsException(PlanType planType, BitwardenProductType bitwardenProductType)
|
||||
{
|
||||
var plansStore = new List<Plan>
|
||||
{
|
||||
new Plan { Type = PlanType.EnterpriseAnnually, BitwardenProduct = BitwardenProductType.PasswordManager },
|
||||
new Plan { Type = PlanType.EnterpriseAnnually, BitwardenProduct = BitwardenProductType.PasswordManager }
|
||||
};
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => plansStore.SingleOrDefault(p => p.Type == planType && p.BitwardenProduct == bitwardenProductType));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user