1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-23 04:21:05 -05:00

Resolve the failing test

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
Cy Okeke 2025-05-21 09:50:15 +01:00
parent b63055cc6a
commit d23373b776
No known key found for this signature in database
GPG Key ID: 88B341B55C84B45C

View File

@ -255,25 +255,32 @@ public class OrganizationsController : Controller
Seats = organization.Seats Seats = organization.Seats
}; };
if (model.PlanType.HasValue)
{
var freePlan = await _pricingClient.GetPlanOrThrow(model.PlanType.Value); var freePlan = await _pricingClient.GetPlanOrThrow(model.PlanType.Value);
if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free && model.Seats > freePlan.PasswordManager.MaxSeats)
if (organization.PlanType != PlanType.Free &&
model.PlanType.Value == PlanType.Free &&
model.Seats.HasValue &&
model.Seats.Value > freePlan.PasswordManager.MaxSeats)
{ {
TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxSeats} seats cannot be downgraded to the Free plan"; TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxSeats} seats cannot be downgraded to the Free plan";
return RedirectToAction("Edit", new { id }); return RedirectToAction("Edit", new { id });
} }
if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free && model.MaxCollections > freePlan.PasswordManager.MaxCollections) if (organization.PlanType != PlanType.Free && model.PlanType.Value == PlanType.Free && model.MaxCollections > freePlan.PasswordManager.MaxCollections)
{ {
TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxCollections} collections cannot be downgraded to the Free plan. Your organization currently has {organization.MaxCollections} collections."; TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxCollections} collections cannot be downgraded to the Free plan. Your organization currently has {organization.MaxCollections} collections.";
return RedirectToAction("Edit", new { id }); return RedirectToAction("Edit", new { id });
} }
if (organization.PlanType != PlanType.Free && model.PlanType == PlanType.Free) if (organization.PlanType != PlanType.Free && model.PlanType.Value == PlanType.Free)
{ {
model.MaxStorageGb = null; model.MaxStorageGb = null;
model.ExpirationDate = null; model.ExpirationDate = null;
model.Enabled = true; model.Enabled = true;
} }
}
UpdateOrganization(organization, model); UpdateOrganization(organization, model);
var plan = await _pricingClient.GetPlanOrThrow(organization.PlanType); var plan = await _pricingClient.GetPlanOrThrow(organization.PlanType);