From e176e6e06eead447f8fa8b2aa1427d471426841f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Tom=C3=A9?= <108268980+r-tome@users.noreply.github.com> Date: Fri, 4 Apr 2025 14:52:57 +0100 Subject: [PATCH 1/2] [PM-17615] Refactor OrganizationService to remove feature flag check for PushSyncOrgKeysOnRevokeRestore (#5547) * Refactor OrganizationService to remove feature flag check for PushSyncOrgKeysOnRevokeRestore * Remove redundant tests * Remove unused IFeatureService dependency from RestoreOrganizationUserCommand class --- .../v1/RestoreOrganizationUserCommand.cs | 10 ++--- .../Implementations/OrganizationService.cs | 6 +-- .../RestoreOrganizationUserCommandTests.cs | 39 ------------------- .../Services/OrganizationServiceTests.cs | 39 ------------------- 4 files changed, 6 insertions(+), 88 deletions(-) diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/v1/RestoreOrganizationUserCommand.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/v1/RestoreOrganizationUserCommand.cs index f122463a98..74165a5a71 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/v1/RestoreOrganizationUserCommand.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/v1/RestoreOrganizationUserCommand.cs @@ -16,7 +16,6 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.RestoreUs public class RestoreOrganizationUserCommand( ICurrentContext currentContext, IEventService eventService, - IFeatureService featureService, IPushNotificationService pushNotificationService, IOrganizationUserRepository organizationUserRepository, IOrganizationRepository organizationRepository, @@ -41,8 +40,7 @@ public class RestoreOrganizationUserCommand( await RepositoryRestoreUserAsync(organizationUser); await eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Restored); - if (featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && - organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } @@ -54,8 +52,7 @@ public class RestoreOrganizationUserCommand( await eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Restored, systemUser); - if (featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && - organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } @@ -219,8 +216,7 @@ public class RestoreOrganizationUserCommand( await organizationUserRepository.RestoreAsync(organizationUser.Id, status); organizationUser.Status = status; await eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Restored); - if (featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && - organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } diff --git a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs index 32fcbb0608..78f880b15c 100644 --- a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs +++ b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs @@ -1791,7 +1791,7 @@ public class OrganizationService : IOrganizationService await RepositoryRevokeUserAsync(organizationUser); await _eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Revoked); - if (_featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await _pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } @@ -1803,7 +1803,7 @@ public class OrganizationService : IOrganizationService await RepositoryRevokeUserAsync(organizationUser); await _eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Revoked, systemUser); - if (_featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await _pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } @@ -1872,7 +1872,7 @@ public class OrganizationService : IOrganizationService await _organizationUserRepository.RevokeAsync(organizationUser.Id); organizationUser.Status = OrganizationUserStatusType.Revoked; await _eventService.LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Revoked); - if (_featureService.IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) && organizationUser.UserId.HasValue) + if (organizationUser.UserId.HasValue) { await _pushNotificationService.PushSyncOrgKeysAsync(organizationUser.UserId.Value); } diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/RestoreOrganizationUserCommandTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/RestoreOrganizationUserCommandTests.cs index f91ca779a8..d6880a3a12 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/RestoreOrganizationUserCommandTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/RestoreOrganizationUserCommandTests.cs @@ -31,26 +31,6 @@ public class RestoreOrganizationUserCommandTests await sutProvider.Sut.RestoreUserAsync(organizationUser, owner.Id); - await sutProvider.GetDependency() - .Received(1) - .RestoreAsync(organizationUser.Id, OrganizationUserStatusType.Invited); - await sutProvider.GetDependency() - .Received(1) - .LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Restored); - } - - [Theory, BitAutoData] - public async Task RestoreUser_WithPushSyncOrgKeysOnRevokeRestoreEnabled_Success(Organization organization, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, - [OrganizationUser(OrganizationUserStatusType.Revoked)] OrganizationUser organizationUser, SutProvider sutProvider) - { - RestoreUser_Setup(organization, owner, organizationUser, sutProvider); - - sutProvider.GetDependency() - .IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) - .Returns(true); - - await sutProvider.Sut.RestoreUserAsync(organizationUser, owner.Id); - await sutProvider.GetDependency() .Received(1) .RestoreAsync(organizationUser.Id, OrganizationUserStatusType.Invited); @@ -69,25 +49,6 @@ public class RestoreOrganizationUserCommandTests await sutProvider.Sut.RestoreUserAsync(organizationUser, eventSystemUser); - await sutProvider.GetDependency() - .Received(1) - .RestoreAsync(organizationUser.Id, OrganizationUserStatusType.Invited); - await sutProvider.GetDependency() - .Received(1) - .LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Restored, eventSystemUser); - } - - [Theory, BitAutoData] - public async Task RestoreUser_WithEventSystemUser_WithPushSyncOrgKeysOnRevokeRestoreEnabled_Success(Organization organization, [OrganizationUser(OrganizationUserStatusType.Revoked)] OrganizationUser organizationUser, EventSystemUser eventSystemUser, SutProvider sutProvider) - { - RestoreUser_Setup(organization, null, organizationUser, sutProvider); - - sutProvider.GetDependency() - .IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) - .Returns(true); - - await sutProvider.Sut.RestoreUserAsync(organizationUser, eventSystemUser); - await sutProvider.GetDependency() .Received(1) .RestoreAsync(organizationUser.Id, OrganizationUserStatusType.Invited); diff --git a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs index bd8ae1daaf..53101900e5 100644 --- a/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs +++ b/test/Core.Test/AdminConsole/Services/OrganizationServiceTests.cs @@ -1162,26 +1162,6 @@ OrganizationUserInvite invite, SutProvider sutProvider) await sutProvider.Sut.RevokeUserAsync(organizationUser, owner.Id); - await sutProvider.GetDependency() - .Received(1) - .RevokeAsync(organizationUser.Id); - await sutProvider.GetDependency() - .Received(1) - .LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Revoked); - } - - [Theory, BitAutoData] - public async Task RevokeUser_WithPushSyncOrgKeysOnRevokeRestoreEnabled_Success(Organization organization, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, - [OrganizationUser] OrganizationUser organizationUser, SutProvider sutProvider) - { - RestoreRevokeUser_Setup(organization, owner, organizationUser, sutProvider); - - sutProvider.GetDependency() - .IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) - .Returns(true); - - await sutProvider.Sut.RevokeUserAsync(organizationUser, owner.Id); - await sutProvider.GetDependency() .Received(1) .RevokeAsync(organizationUser.Id); @@ -1200,25 +1180,6 @@ OrganizationUserInvite invite, SutProvider sutProvider) await sutProvider.Sut.RevokeUserAsync(organizationUser, eventSystemUser); - await sutProvider.GetDependency() - .Received(1) - .RevokeAsync(organizationUser.Id); - await sutProvider.GetDependency() - .Received(1) - .LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Revoked, eventSystemUser); - } - - [Theory, BitAutoData] - public async Task RevokeUser_WithEventSystemUser_WithPushSyncOrgKeysOnRevokeRestoreEnabled_Success(Organization organization, [OrganizationUser] OrganizationUser organizationUser, EventSystemUser eventSystemUser, SutProvider sutProvider) - { - RestoreRevokeUser_Setup(organization, null, organizationUser, sutProvider); - - sutProvider.GetDependency() - .IsEnabled(FeatureFlagKeys.PushSyncOrgKeysOnRevokeRestore) - .Returns(true); - - await sutProvider.Sut.RevokeUserAsync(organizationUser, eventSystemUser); - await sutProvider.GetDependency() .Received(1) .RevokeAsync(organizationUser.Id); From 39ac93326db1622447f8305a776fffc8d91cef16 Mon Sep 17 00:00:00 2001 From: Andy Pixley <3723676+pixman20@users.noreply.github.com> Date: Fri, 4 Apr 2025 09:53:12 -0400 Subject: [PATCH 2/2] [BRE-457] Updating CODEOWNERS for self-host ownership (#5593) --- .github/CODEOWNERS | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index aa868cd1b5..03dbb7aac4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -20,12 +20,19 @@ # Database Operations for database changes src/Sql/** @bitwarden/dept-dbops util/EfShared/** @bitwarden/dept-dbops -util/Migrator/** @bitwarden/dept-dbops +util/Migrator/** @bitwarden/team-platform-dev # The Platform team owns the Migrator project code +util/Migrator/DbScripts/** @bitwarden/dept-dbops +util/Migrator/DbScripts_finalization/** @bitwarden/dept-dbops +util/Migrator/DbScripts_transition/** @bitwarden/dept-dbops +util/Migrator/MySql/** @bitwarden/dept-dbops util/MySqlMigrations/** @bitwarden/dept-dbops util/PostgresMigrations/** @bitwarden/dept-dbops util/SqlServerEFScaffold/** @bitwarden/dept-dbops util/SqliteMigrations/** @bitwarden/dept-dbops +# Shared util projects +util/Setup/** @bitwarden/dept-bre @bitwarden/team-platform-dev + # Auth team **/Auth @bitwarden/team-auth-dev bitwarden_license/src/Sso @bitwarden/team-auth-dev