1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

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
This commit is contained in:
Colton Hurst 2024-02-05 15:51:31 -05:00 committed by GitHub
parent 9bdb76d84b
commit 7cbe888b82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 7293 additions and 142 deletions

View File

@ -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;
}

View File

@ -28,7 +28,6 @@ public class CountNewServiceAccountSlotsRequiredQueryTests
{
organization.UseSecretsManager = true;
organization.SmServiceAccounts = organizationSmServiceAccounts;
organization.SecretsManagerBeta = false;
sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
@ -62,7 +61,6 @@ public class CountNewServiceAccountSlotsRequiredQueryTests
organization.UseSecretsManager = true;
organization.SmServiceAccounts = null;
organization.SecretsManagerBeta = false;
sutProvider.GetDependency<IOrganizationRepository>()
.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<CountNewServiceAccountSlotsRequiredQuery> sutProvider)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = true;
sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);
var result = await sutProvider.Sut.CountNewServiceAccountSlotsRequiredAsync(organization.Id, serviceAccountsToAdd);
Assert.Equal(0, result);
await sutProvider.GetDependency<IServiceAccountRepository>().DidNotReceiveWithAnyArgs()
.GetServiceAccountCountByOrganizationIdAsync(default);
}
[Theory, BitAutoData]
public async Task CountNewServiceAccountSlotsRequiredAsync_WithNonExistentOrganizationId_ThrowsNotFound(
Guid organizationId, int serviceAccountsToAdd,

View File

@ -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;

View File

@ -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;
}
}

View File

@ -174,10 +174,6 @@
<input type="checkbox" class="form-check-input" asp-for="UseSecretsManager" disabled='@(canEditPlan ? null : "disabled")'>
<label class="form-check-label" asp-for="UseSecretsManager"></label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" asp-for="SecretsManagerBeta" disabled='@(canEditPlan ? null : "disabled")'>
<label class="form-check-label" asp-for="SecretsManagerBeta"></label>
</div>
</div>
</div>
}
@ -217,7 +213,7 @@
@if (canViewPlan)
{
<div id="organization-secrets-configuration" hidden="@(!Model.UseSecretsManager || Model.SecretsManagerBeta)">
<div id="organization-secrets-configuration" hidden="@(!Model.UseSecretsManager)">
<h2>Secrets Manager Configuration</h2>
<div class="row">
<div class="col-sm">

View File

@ -46,24 +46,8 @@
return;
}
// SM beta requires SM access
document.getElementById('@(nameof(Model.SecretsManagerBeta))').checked = false;
clearSecretsManagerConfiguration();
});
document.getElementById('@(nameof(Model.SecretsManagerBeta))').addEventListener('change', (event) => {
document.getElementById('organization-secrets-configuration').hidden = event.target.checked;
if (event.target.checked) {
// SM beta requires SM access
document.getElementById('@(nameof(Model.UseSecretsManager))').checked = true;
// SM Beta orgs do not have subscription limits
clearSecretsManagerConfiguration();
return;
}
setInitialSecretsManagerConfiguration();
});
})();
function togglePlanFeatures(planType) {

View File

@ -110,7 +110,6 @@ public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
CoreHelpers.ReadableBytesSize(organization.Storage.Value) : null;
StorageGb = organization.Storage.HasValue ?
Math.Round(organization.Storage.Value / 1073741824D, 2) : 0; // 1 GB
SecretsManagerBeta = organization.SecretsManagerBeta;
}
public OrganizationSubscriptionResponseModel(Organization organization, SubscriptionInfo subscription, bool hideSensitiveData)
@ -127,8 +126,6 @@ public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
Subscription.Items = null;
UpcomingInvoice.Amount = null;
}
SecretsManagerBeta = organization.SecretsManagerBeta;
}
public OrganizationSubscriptionResponseModel(Organization organization, OrganizationLicense license) :
@ -143,8 +140,6 @@ public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
license.Expires?.AddDays(-Constants
.OrganizationSelfHostSubscriptionGracePeriodDays);
}
SecretsManagerBeta = organization.SecretsManagerBeta;
}
public string StorageName { get; set; }
@ -162,6 +157,4 @@ public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
/// Date when a self-hosted organization expires (includes grace period).
/// </summary>
public DateTime? Expiration { get; set; }
public bool SecretsManagerBeta { get; set; }
}

View File

@ -78,7 +78,6 @@ public class Organization : ITableObject<Guid>, ISubscriber, IStorable, IStorabl
public int? SmServiceAccounts { get; set; }
public int? MaxAutoscaleSmSeats { get; set; }
public int? MaxAutoscaleSmServiceAccounts { get; set; }
public bool SecretsManagerBeta { get; set; }
/// <summary>
/// Refers to the ability for an organization to limit collection creation and deletion to owners and admins only
/// </summary>

View File

@ -34,7 +34,7 @@ public class CountNewSmSeatsRequiredQuery : ICountNewSmSeatsRequiredQuery
throw new BadRequestException("Organization does not use Secrets Manager");
}
if (!organization.SmSeats.HasValue || organization.SecretsManagerBeta)
if (!organization.SmSeats.HasValue)
{
return 0;
}

View File

@ -68,12 +68,6 @@ public class AddSecretsManagerSubscriptionCommand : IAddSecretsManagerSubscripti
throw new NotFoundException();
}
if (organization.SecretsManagerBeta)
{
throw new BadRequestException("Organization is enrolled in Secrets Manager Beta. " +
"Please contact Customer Success to add Secrets Manager to your subscription.");
}
if (organization.UseSecretsManager)
{
throw new BadRequestException("Organization already uses Secrets Manager.");

View File

@ -165,12 +165,6 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs
throw new BadRequestException("Organization has no access to Secrets Manager.");
}
if (organization.SecretsManagerBeta)
{
throw new BadRequestException("Organization is enrolled in Secrets Manager Beta. " +
"Please contact Customer Success to add Secrets Manager to your subscription.");
}
if (update.Plan.Product == ProductType.Free)
{
// No need to check the organization is set up with Stripe

View File

@ -141,7 +141,6 @@ public class SecretsManagerOrganizationCustomization : ICustomization
fixture.Customize<Organization>(composer => composer
.With(o => o.Id, organizationId)
.With(o => o.UseSecretsManager, true)
.With(o => o.SecretsManagerBeta, false)
.With(o => o.PlanType, planType)
.With(o => o.Plan, StaticStore.GetPlan(planType).Name)
.With(o => o.MaxAutoscaleSmSeats, (int?)null)

View File

@ -86,25 +86,4 @@ public class CountNewSmSeatsRequiredQueryTests
await sutProvider.Sut.CountNewSmSeatsRequiredAsync(organization.Id, usersToAdd));
Assert.Contains("Organization does not use Secrets Manager", exception.Message);
}
[Theory, BitAutoData]
public async Task CountNewSmSeatsRequiredAsync_WithSecretsManagerBeta_ReturnsZero(
int usersToAdd,
Organization organization,
SutProvider<CountNewSmSeatsRequiredQuery> sutProvider)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = true;
sutProvider.GetDependency<IOrganizationRepository>()
.GetByIdAsync(organization.Id)
.Returns(organization);
var result = await sutProvider.Sut.CountNewSmSeatsRequiredAsync(organization.Id, usersToAdd);
Assert.Equal(0, result);
await sutProvider.GetDependency<IOrganizationUserRepository>().DidNotReceiveWithAnyArgs()
.GetOccupiedSmSeatCountByOrganizationIdAsync(default);
}
}

View File

@ -110,7 +110,6 @@ public static class OrganizationLicenseFileFixtures
SmServiceAccounts = 8,
MaxAutoscaleSmSeats = 101,
MaxAutoscaleSmServiceAccounts = 102,
SecretsManagerBeta = true,
LimitCollectionCreationDeletion = true,
AllowAdminAccessToAllCollectionItems = true,
};

View File

@ -107,22 +107,6 @@ public class AddSecretsManagerSubscriptionCommandTests
await VerifyDependencyNotCalledAsync(sutProvider);
}
[Theory]
[BitAutoData]
public async Task SignUpAsync_ThrowsException_WhenOrganizationEnrolledInSmBeta(
SutProvider<AddSecretsManagerSubscriptionCommand> sutProvider,
Organization organization)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = true;
var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.SignUpAsync(organization, 10, 10));
Assert.Contains("Organization is enrolled in Secrets Manager Beta", exception.Message);
await VerifyDependencyNotCalledAsync(sutProvider);
}
[Theory]
[BitAutoData]
public async Task SignUpAsync_ThrowsException_WhenOrganizationAlreadyHasSecretsManager(
@ -130,7 +114,6 @@ public class AddSecretsManagerSubscriptionCommandTests
Organization organization)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = false;
var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.SignUpAsync(organization, 10, 10));
@ -147,7 +130,6 @@ public class AddSecretsManagerSubscriptionCommandTests
Provider provider)
{
organization.UseSecretsManager = false;
organization.SecretsManagerBeta = false;
provider.Type = ProviderType.Msp;
sutProvider.GetDependency<IProviderRepository>().GetByOrganizationIdAsync(organization.Id).Returns(provider);

View File

@ -166,23 +166,6 @@ public class UpdateSecretsManagerSubscriptionCommandTests
await VerifyDependencyNotCalledAsync(sutProvider);
}
[Theory]
[BitAutoData]
public async Task UpdateSubscriptionAsync_OrganizationEnrolledInSmBeta_ThrowsException(
SutProvider<UpdateSecretsManagerSubscriptionCommand> sutProvider,
Organization organization)
{
organization.UseSecretsManager = true;
organization.SecretsManagerBeta = true;
var update = new SecretsManagerSubscriptionUpdate(organization, false);
var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.UpdateSubscriptionAsync(update));
Assert.Contains("Organization is enrolled in Secrets Manager Beta", exception.Message);
await VerifyDependencyNotCalledAsync(sutProvider);
}
[Theory]
[BitAutoData(PlanType.EnterpriseAnnually2019)]
[BitAutoData(PlanType.EnterpriseAnnually2020)]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class RemoveSMBetaFromOrganization : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SecretsManagerBeta",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "SecretsManagerBeta",
table: "Organization",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
}

View File

@ -17,7 +17,7 @@ namespace Bit.MySqlMigrations.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.14")
.HasAnnotation("ProductVersion", "7.0.15")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", b =>
@ -136,9 +136,6 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<int?>("Seats")
.HasColumnType("int");
b.Property<bool>("SecretsManagerBeta")
.HasColumnType("tinyint(1)");
b.Property<bool>("SelfHost")
.HasColumnType("tinyint(1)");
@ -533,6 +530,7 @@ namespace Bit.MySqlMigrations.Migrations
.HasColumnType("varchar(50)");
b.HasKey("Id")
.HasName("PK_Grant")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("ExpirationDate")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class RemoveSMBetaFromOrganization : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SecretsManagerBeta",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "SecretsManagerBeta",
table: "Organization",
type: "boolean",
nullable: false,
defaultValue: false);
}
}

View File

@ -18,7 +18,7 @@ namespace Bit.PostgresMigrations.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:CollationDefinition:postgresIndetermanisticCollation", "en-u-ks-primary,en-u-ks-primary,icu,False")
.HasAnnotation("ProductVersion", "7.0.14")
.HasAnnotation("ProductVersion", "7.0.15")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -140,9 +140,6 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<int?>("Seats")
.HasColumnType("integer");
b.Property<bool>("SecretsManagerBeta")
.HasColumnType("boolean");
b.Property<bool>("SelfHost")
.HasColumnType("boolean");
@ -539,6 +536,7 @@ namespace Bit.PostgresMigrations.Migrations
.HasColumnType("character varying(50)");
b.HasKey("Id")
.HasName("PK_Grant")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("ExpirationDate")

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class RemoveSMBetaFromOrganization : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SecretsManagerBeta",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "SecretsManagerBeta",
table: "Organization",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
}

View File

@ -16,7 +16,7 @@ namespace Bit.SqliteMigrations.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.14");
modelBuilder.HasAnnotation("ProductVersion", "7.0.15");
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.AdminConsole.Models.Organization", b =>
{
@ -134,9 +134,6 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<int?>("Seats")
.HasColumnType("INTEGER");
b.Property<bool>("SecretsManagerBeta")
.HasColumnType("INTEGER");
b.Property<bool>("SelfHost")
.HasColumnType("INTEGER");
@ -531,6 +528,7 @@ namespace Bit.SqliteMigrations.Migrations
.HasColumnType("TEXT");
b.HasKey("Id")
.HasName("PK_Grant")
.HasAnnotation("SqlServer:Clustered", true);
b.HasIndex("ExpirationDate")