From 7cbe888b82d7fbaba7e68f7ac2c6836eceeed738 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Mon, 5 Feb 2024 15:51:31 -0500 Subject: [PATCH] SM-1012: Removing SM Beta (Phase 2) (#3663) * SM-1012: Phase 2, removing SM Beta from the server (but not db) * SM-1012: Add migration for RemoveSMBetaFromOrganization * SM-1012: Dotnet format * SM-1012: Undo RemoveSMBetaFromOrganization EF migration * SM-1012: Redo RemoveSMBetaFromOrganization EF migration * SM-1012: Ran dotnet format --- ...ountNewServiceAccountSlotsRequiredQuery.cs | 2 +- ...ewServiceAccountSlotsRequiredQueryTests.cs | 23 - .../Controllers/OrganizationsController.cs | 2 - src/Admin/Models/OrganizationEditModel.cs | 4 - .../Views/Shared/_OrganizationForm.cshtml | 6 +- .../Shared/_OrganizationFormScripts.cshtml | 16 - .../OrganizationResponseModel.cs | 7 - .../AdminConsole/Entities/Organization.cs | 1 - .../CountNewSmSeatsRequiredQuery.cs | 2 +- .../AddSecretsManagerSubscriptionCommand.cs | 6 - ...UpdateSecretsManagerSubscriptionCommand.cs | 6 - .../AutoFixture/OrganizationFixtures.cs | 1 - .../CountNewSmSeatsRequiredQueryTests.cs | 21 - .../OrganizationLicenseFileFixtures.cs | 1 - ...dSecretsManagerSubscriptionCommandTests.cs | 18 - ...eSecretsManagerSubscriptionCommandTests.cs | 17 - ...7_RemoveSMBetaFromOrganization.Designer.cs | 2396 ++++++++++++++++ ...0131215347_RemoveSMBetaFromOrganization.cs | 28 + .../DatabaseContextModelSnapshot.cs | 6 +- ...6_RemoveSMBetaFromOrganization.Designer.cs | 2410 +++++++++++++++++ ...0131215356_RemoveSMBetaFromOrganization.cs | 28 + .../DatabaseContextModelSnapshot.cs | 6 +- ...2_RemoveSMBetaFromOrganization.Designer.cs | 2394 ++++++++++++++++ ...0131215352_RemoveSMBetaFromOrganization.cs | 28 + .../DatabaseContextModelSnapshot.cs | 6 +- 25 files changed, 7293 insertions(+), 142 deletions(-) create mode 100644 util/MySqlMigrations/Migrations/20240131215347_RemoveSMBetaFromOrganization.Designer.cs create mode 100644 util/MySqlMigrations/Migrations/20240131215347_RemoveSMBetaFromOrganization.cs create mode 100644 util/PostgresMigrations/Migrations/20240131215356_RemoveSMBetaFromOrganization.Designer.cs create mode 100644 util/PostgresMigrations/Migrations/20240131215356_RemoveSMBetaFromOrganization.cs create mode 100644 util/SqliteMigrations/Migrations/20240131215352_RemoveSMBetaFromOrganization.Designer.cs create mode 100644 util/SqliteMigrations/Migrations/20240131215352_RemoveSMBetaFromOrganization.cs diff --git a/bitwarden_license/src/Commercial.Core/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQuery.cs b/bitwarden_license/src/Commercial.Core/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQuery.cs index cbb8b98f8c..f85006316b 100644 --- a/bitwarden_license/src/Commercial.Core/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQuery.cs +++ b/bitwarden_license/src/Commercial.Core/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQuery.cs @@ -26,7 +26,7 @@ public class CountNewServiceAccountSlotsRequiredQuery : ICountNewServiceAccountS throw new NotFoundException(); } - if (!organization.SmServiceAccounts.HasValue || serviceAccountsToAdd == 0 || organization.SecretsManagerBeta) + if (!organization.SmServiceAccounts.HasValue || serviceAccountsToAdd == 0) { return 0; } diff --git a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQueryTests.cs b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQueryTests.cs index 659e72729a..3445b97413 100644 --- a/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQueryTests.cs +++ b/bitwarden_license/test/Commercial.Core.Test/SecretsManager/Queries/ServiceAccounts/CountNewServiceAccountSlotsRequiredQueryTests.cs @@ -28,7 +28,6 @@ public class CountNewServiceAccountSlotsRequiredQueryTests { organization.UseSecretsManager = true; organization.SmServiceAccounts = organizationSmServiceAccounts; - organization.SecretsManagerBeta = false; sutProvider.GetDependency() .GetByIdAsync(organization.Id) @@ -62,7 +61,6 @@ public class CountNewServiceAccountSlotsRequiredQueryTests organization.UseSecretsManager = true; organization.SmServiceAccounts = null; - organization.SecretsManagerBeta = false; sutProvider.GetDependency() .GetByIdAsync(organization.Id) @@ -80,27 +78,6 @@ public class CountNewServiceAccountSlotsRequiredQueryTests .GetServiceAccountCountByOrganizationIdAsync(default); } - [Theory, BitAutoData] - public async Task CountNewServiceAccountSlotsRequiredAsync_WithSecretsManagerBeta_ReturnsZero( - int serviceAccountsToAdd, - Organization organization, - SutProvider sutProvider) - { - organization.UseSecretsManager = true; - organization.SecretsManagerBeta = true; - - sutProvider.GetDependency() - .GetByIdAsync(organization.Id) - .Returns(organization); - - var result = await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd); - - Assert.Equal(0, result); - - await sutProvider.GetDependency().DidNotReceiveWithAnyArgs() - .GetServiceAccountCountByOrganizationIdAsync(default); - } - [Theory, BitAutoData] public async Task CountNewServiceAccountSlotsRequiredAsync_WithNonExistentOrganizationId_ThrowsNotFound( Guid organizationId, int serviceAccountsToAdd, diff --git a/src/Admin/Controllers/OrganizationsController.cs b/src/Admin/Controllers/OrganizationsController.cs index d665ebddef..3fba88006d 100644 --- a/src/Admin/Controllers/OrganizationsController.cs +++ b/src/Admin/Controllers/OrganizationsController.cs @@ -213,7 +213,6 @@ public class OrganizationsController : Controller var organization = await GetOrganization(id, model); if (organization.UseSecretsManager && - !organization.SecretsManagerBeta && !StaticStore.GetPlan(organization.PlanType).SupportsSecretsManager) { throw new BadRequestException("Plan does not support Secrets Manager"); @@ -363,7 +362,6 @@ public class OrganizationsController : Controller organization.UseTotp = model.UseTotp; organization.UsersGetPremium = model.UsersGetPremium; organization.UseSecretsManager = model.UseSecretsManager; - organization.SecretsManagerBeta = model.SecretsManagerBeta; //secrets organization.SmSeats = model.SmSeats; diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index 234d8bb157..559b5b6868 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -70,7 +70,6 @@ public class OrganizationEditModel : OrganizationViewModel MaxAutoscaleSmSeats = org.MaxAutoscaleSmSeats; SmServiceAccounts = org.SmServiceAccounts; MaxAutoscaleSmServiceAccounts = org.MaxAutoscaleSmServiceAccounts; - SecretsManagerBeta = org.SecretsManagerBeta; } public BillingInfo BillingInfo { get; set; } @@ -150,8 +149,6 @@ public class OrganizationEditModel : OrganizationViewModel public int? SmServiceAccounts { get; set; } [Display(Name = "Max Autoscale Service Accounts")] public int? MaxAutoscaleSmServiceAccounts { get; set; } - [Display(Name = "Secrets Manager Beta")] - public bool SecretsManagerBeta { get; set; } /** * Creates a Plan[] object for use in Javascript @@ -210,7 +207,6 @@ public class OrganizationEditModel : OrganizationViewModel existingOrganization.MaxAutoscaleSmSeats = MaxAutoscaleSmSeats; existingOrganization.SmServiceAccounts = SmServiceAccounts; existingOrganization.MaxAutoscaleSmServiceAccounts = MaxAutoscaleSmServiceAccounts; - existingOrganization.SecretsManagerBeta = SecretsManagerBeta; return existingOrganization; } } diff --git a/src/Admin/Views/Shared/_OrganizationForm.cshtml b/src/Admin/Views/Shared/_OrganizationForm.cshtml index 97b6b949e0..1438a5aa8c 100644 --- a/src/Admin/Views/Shared/_OrganizationForm.cshtml +++ b/src/Admin/Views/Shared/_OrganizationForm.cshtml @@ -174,10 +174,6 @@ -
- - -
} @@ -217,7 +213,7 @@ @if (canViewPlan) { -