diff --git a/bitwarden_license/src/Scim/Users/PostUserCommand.cs b/bitwarden_license/src/Scim/Users/PostUserCommand.cs index d8132ac670..da81f9a543 100644 --- a/bitwarden_license/src/Scim/Users/PostUserCommand.cs +++ b/bitwarden_license/src/Scim/Users/PostUserCommand.cs @@ -62,7 +62,7 @@ public class PostUserCommand( return await InviteScimOrganizationUserAsync(model.ToRequest( scimProvider: scimProvider, hasSecretsManager: hasStandaloneSecretsManager, - organization: OrganizationDto.FromOrganization(organization), + organization: new OrganizationDto(organization), performedAt: timeProvider.GetUtcNow())); } diff --git a/src/Core/AdminConsole/Models/Business/OrganizationDto.cs b/src/Core/AdminConsole/Models/Business/OrganizationDto.cs index 88c813badc..8558a8a97d 100644 --- a/src/Core/AdminConsole/Models/Business/OrganizationDto.cs +++ b/src/Core/AdminConsole/Models/Business/OrganizationDto.cs @@ -16,17 +16,21 @@ public record OrganizationDto public string GatewaySubscriptionId { get; init; } public bool UseSecretsManager { get; init; } - public static OrganizationDto FromOrganization(Organization organization) => - new() - { - OrganizationId = organization.Id, - Seats = organization.Seats, - MaxAutoScaleSeats = organization.MaxAutoscaleSeats, - SmSeats = organization.SmSeats, - SmMaxAutoScaleSeats = organization.MaxAutoscaleSmSeats, - Plan = StaticStore.GetPlan(organization.PlanType), - GatewayCustomerId = organization.GatewayCustomerId, - GatewaySubscriptionId = organization.GatewaySubscriptionId, - UseSecretsManager = organization.UseSecretsManager - }; + public OrganizationDto() + { + + } + + public OrganizationDto(Organization organization) + { + OrganizationId = organization.Id; + Seats = organization.Seats; + MaxAutoScaleSeats = organization.MaxAutoscaleSeats; + SmSeats = organization.SmSeats; + SmMaxAutoScaleSeats = organization.MaxAutoscaleSmSeats; + Plan = StaticStore.GetPlan(organization.PlanType); + GatewayCustomerId = organization.GatewayCustomerId; + GatewaySubscriptionId = organization.GatewaySubscriptionId; + UseSecretsManager = organization.UseSecretsManager; + } } diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs index 369dae409d..d13b587134 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/InviteOrganizationUserCommandTests.cs @@ -38,7 +38,7 @@ public class InviteOrganizationUserCommandTests // Arrange user.Email = address.Address; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, @@ -86,7 +86,7 @@ public class InviteOrganizationUserCommandTests // Arrange user.Email = address.Address; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, @@ -139,7 +139,7 @@ public class InviteOrganizationUserCommandTests user.Email = address.Address; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, @@ -194,7 +194,7 @@ public class InviteOrganizationUserCommandTests organization.MaxAutoscaleSeats = 2; ownerDetails.Type = OrganizationUserType.Owner; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, @@ -250,7 +250,7 @@ public class InviteOrganizationUserCommandTests organization.MaxAutoscaleSeats = 2; ownerDetails.Type = OrganizationUserType.Owner; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, @@ -313,7 +313,7 @@ public class InviteOrganizationUserCommandTests organization.MaxAutoscaleSeats = 2; ownerDetails.Type = OrganizationUserType.Owner; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var request = new InviteScimOrganizationUserRequest(user.Email, true, diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserOrganizationValidationTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserOrganizationValidationTests.cs index 0eff87c15f..4016c58446 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserOrganizationValidationTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserOrganizationValidationTests.cs @@ -12,7 +12,7 @@ public class InviteUserOrganizationValidationTests [BitAutoData] public void Validate_WhenOrganizationIsFreeTier_ShouldReturnValidResponse(Organization organization) { - var result = InvitingUserOrganizationValidation.Validate(OrganizationDto.FromOrganization(organization)); + var result = InvitingUserOrganizationValidation.Validate(new OrganizationDto(organization)); Assert.IsType>(result); } @@ -24,7 +24,7 @@ public class InviteUserOrganizationValidationTests { organization.GatewayCustomerId = string.Empty; - var result = InvitingUserOrganizationValidation.Validate(OrganizationDto.FromOrganization(organization)); + var result = InvitingUserOrganizationValidation.Validate(new OrganizationDto(organization)); Assert.IsType>(result); Assert.Equal(InviteUserValidationErrorMessages.NoPaymentMethodFoundError, result.ErrorMessageString); @@ -37,7 +37,7 @@ public class InviteUserOrganizationValidationTests { organization.GatewaySubscriptionId = string.Empty; - var result = InvitingUserOrganizationValidation.Validate(OrganizationDto.FromOrganization(organization)); + var result = InvitingUserOrganizationValidation.Validate(new OrganizationDto(organization)); Assert.IsType>(result); Assert.Equal(InviteUserValidationErrorMessages.NoSubscriptionFoundError, result.ErrorMessageString); diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserPaymentValidationTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserPaymentValidationTests.cs index 8615aee379..871ae2af4b 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserPaymentValidationTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteUserPaymentValidationTests.cs @@ -20,7 +20,7 @@ public class InviteUserPaymentValidationTests var result = InviteUserPaymentValidation.Validate(new PaymentSubscriptionDto { SubscriptionStatus = StripeConstants.SubscriptionStatus.Active, - ProductTierType = OrganizationDto.FromOrganization(organization).Plan.ProductTier + ProductTierType = new OrganizationDto(organization).Plan.ProductTier }); Assert.IsType>(result); diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManagerInviteUserValidationTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManagerInviteUserValidationTests.cs index 449984e4f6..ccb0b0325e 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManagerInviteUserValidationTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManagerInviteUserValidationTests.cs @@ -17,7 +17,7 @@ public class PasswordManagerInviteUserValidationTests { organization.Seats = null; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); @@ -35,7 +35,7 @@ public class PasswordManagerInviteUserValidationTests var seatsOccupiedByUsers = 4; var additionalSeats = 4; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, seatsOccupiedByUsers, additionalSeats); @@ -54,7 +54,7 @@ public class PasswordManagerInviteUserValidationTests var seatsOccupiedByUsers = 4; var additionalSeats = 1; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, seatsOccupiedByUsers, additionalSeats); @@ -73,7 +73,7 @@ public class PasswordManagerInviteUserValidationTests var additionalSeats = 4; organization.PlanType = PlanType.Free; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, seatsOccupiedByUsers, additionalSeats); diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManagerInviteUserValidationTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManagerInviteUserValidationTests.cs index 2241558c1a..df3d6a4836 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManagerInviteUserValidationTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManagerInviteUserValidationTests.cs @@ -21,7 +21,7 @@ public class SecretsManagerInviteUserValidationTests { organization.UseSecretsManager = false; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); var request = new InviteUserOrganizationValidationRequest @@ -48,7 +48,7 @@ public class SecretsManagerInviteUserValidationTests { organization.UseSecretsManager = false; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); var invite = OrganizationUserInvite.Create(["email@test.com"], [], OrganizationUserType.User, new Permissions(), string.Empty, true); @@ -79,7 +79,7 @@ public class SecretsManagerInviteUserValidationTests organization.SmSeats = null; organization.UseSecretsManager = true; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); var request = new InviteUserOrganizationValidationRequest @@ -109,7 +109,7 @@ public class SecretsManagerInviteUserValidationTests organization.UseSecretsManager = true; organization.PlanType = PlanType.EnterpriseAnnually; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); var request = new InviteUserOrganizationValidationRequest @@ -140,7 +140,7 @@ public class SecretsManagerInviteUserValidationTests organization.UseSecretsManager = true; organization.PlanType = PlanType.EnterpriseAnnually; - var organizationDto = OrganizationDto.FromOrganization(organization); + var organizationDto = new OrganizationDto(organization); var subscriptionUpdate = PasswordManagerSubscriptionUpdate.Create(organizationDto, 0, 0); var request = new InviteUserOrganizationValidationRequest