mirror of
https://github.com/bitwarden/server
synced 2026-01-04 01:23:25 +00:00
Feature/bit auto data (#2219)
* Update ProviderService tests * Use BitAutoData in CipherService tests * Simplify UserCipher fixture Because we use a single customizer for all ciphers, they all have the same userId. * Clean up more cipher fixtures * Swap Cipher Fixtures to BitCustomizeAttribute * Clean up collection fixtures * Clean up GroupFixtures * Move SendService Tests to BitAutoData * Clean up Organization Fixtures TODO: The customize attributes should not be customizing more than one class * Name files after the class they contain * Clear up usage of CustomAutoDataAttribute in tests * Clean up usages of InlineCustomAutoData * format * Manually merge with file-scoped-namespace changes
This commit is contained in:
@@ -64,7 +64,7 @@ internal class PaidOrganization : ICustomization
|
||||
public PlanType CheckedPlanType { get; set; }
|
||||
public void Customize(IFixture fixture)
|
||||
{
|
||||
var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != PlanType.Free && !p.Disabled).Select(p => p.Type).ToList();
|
||||
var validUpgradePlans = StaticStore.Plans.Where(p => p.Type != PlanType.Free && p.LegacyYear == null).OrderBy(p => p.UpgradeSortOrder).Select(p => p.Type).ToList();
|
||||
var lowestActivePaidPlan = validUpgradePlans.First();
|
||||
CheckedPlanType = CheckedPlanType.Equals(PlanType.Free) ? lowestActivePaidPlan : CheckedPlanType;
|
||||
validUpgradePlans.Remove(lowestActivePaidPlan);
|
||||
@@ -109,7 +109,7 @@ internal class OrganizationInvite : ICustomization
|
||||
public string PermissionsBlob { get; set; }
|
||||
public void Customize(IFixture fixture)
|
||||
{
|
||||
var organizationId = new Guid();
|
||||
var organizationId = Guid.NewGuid();
|
||||
PermissionsBlob = PermissionsBlob ?? JsonSerializer.Serialize(new Permissions(), new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
@@ -126,60 +126,38 @@ internal class OrganizationInvite : ICustomization
|
||||
}
|
||||
}
|
||||
|
||||
internal class PaidOrganizationAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class OrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public PaidOrganizationAutoDataAttribute(PlanType planType) : base(new SutProviderCustomization(),
|
||||
new PaidOrganization { CheckedPlanType = planType })
|
||||
{ }
|
||||
public PaidOrganizationAutoDataAttribute(int planType = 0) : this((PlanType)planType) { }
|
||||
public bool UseGroups { get; set; }
|
||||
public override ICustomization GetCustomization() => new OrganizationCustomization() { UseGroups = UseGroups };
|
||||
}
|
||||
|
||||
internal class InlinePaidOrganizationAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class PaidOrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlinePaidOrganizationAutoDataAttribute(PlanType planType, object[] values) : base(
|
||||
new ICustomization[] { new SutProviderCustomization(), new PaidOrganization { CheckedPlanType = planType } }, values)
|
||||
{ }
|
||||
|
||||
public InlinePaidOrganizationAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(PaidOrganization) }, values)
|
||||
{ }
|
||||
public PlanType CheckedPlanType { get; set; } = PlanType.FamiliesAnnually;
|
||||
public override ICustomization GetCustomization() => new PaidOrganization() { CheckedPlanType = CheckedPlanType };
|
||||
}
|
||||
|
||||
internal class InlineFreeOrganizationAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class FreeOrganizationCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlineFreeOrganizationAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(FreeOrganization) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new FreeOrganization();
|
||||
}
|
||||
|
||||
internal class FreeOrganizationUpgradeAutoDataAttribute : CustomAutoDataAttribute
|
||||
internal class FreeOrganizationUpgradeCustomize : BitCustomizeAttribute
|
||||
{
|
||||
public FreeOrganizationUpgradeAutoDataAttribute() : base(new SutProviderCustomization(), new FreeOrganizationUpgrade())
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new FreeOrganizationUpgrade();
|
||||
}
|
||||
|
||||
internal class InlineFreeOrganizationUpgradeAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
internal class OrganizationInviteCustomizeAttribute : BitCustomizeAttribute
|
||||
{
|
||||
public InlineFreeOrganizationUpgradeAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(FreeOrganizationUpgrade) }, values)
|
||||
{ }
|
||||
}
|
||||
public OrganizationUserType InviteeUserType { get; set; } = OrganizationUserType.Owner;
|
||||
public OrganizationUserType InvitorUserType { get; set; } = OrganizationUserType.Owner;
|
||||
public string PermissionsBlob { get; set; }
|
||||
|
||||
internal class OrganizationInviteAutoDataAttribute : CustomAutoDataAttribute
|
||||
{
|
||||
public OrganizationInviteAutoDataAttribute(int inviteeUserType = 0, int invitorUserType = 0, string permissionsBlob = null) : base(new SutProviderCustomization(),
|
||||
new OrganizationInvite
|
||||
{
|
||||
InviteeUserType = (OrganizationUserType)inviteeUserType,
|
||||
InvitorUserType = (OrganizationUserType)invitorUserType,
|
||||
PermissionsBlob = permissionsBlob,
|
||||
})
|
||||
{ }
|
||||
}
|
||||
|
||||
internal class InlineOrganizationInviteAutoDataAttribute : InlineCustomAutoDataAttribute
|
||||
{
|
||||
public InlineOrganizationInviteAutoDataAttribute(params object[] values) : base(new[] { typeof(SutProviderCustomization),
|
||||
typeof(OrganizationInvite) }, values)
|
||||
{ }
|
||||
public override ICustomization GetCustomization() => new OrganizationInvite
|
||||
{
|
||||
InviteeUserType = InviteeUserType,
|
||||
InvitorUserType = InvitorUserType,
|
||||
PermissionsBlob = PermissionsBlob,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user