From 10ea2cb3eb417077fcff86b5a733ce559e8588f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Tom=C3=A9?= <108268980+r-tome@users.noreply.github.com> Date: Wed, 2 Apr 2025 11:47:44 +0100 Subject: [PATCH] [PM-17473] Refactor AuthRequestService to remove admin notification feature flag (#5549) --- .../Implementations/AuthRequestService.cs | 6 -- .../Auth/Services/AuthRequestServiceTests.cs | 77 +------------------ 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/src/Core/Auth/Services/Implementations/AuthRequestService.cs b/src/Core/Auth/Services/Implementations/AuthRequestService.cs index c10fa6ce92..42d51a88f5 100644 --- a/src/Core/Auth/Services/Implementations/AuthRequestService.cs +++ b/src/Core/Auth/Services/Implementations/AuthRequestService.cs @@ -287,12 +287,6 @@ public class AuthRequestService : IAuthRequestService private async Task NotifyAdminsOfDeviceApprovalRequestAsync(OrganizationUser organizationUser, User user) { - if (!_featureService.IsEnabled(FeatureFlagKeys.DeviceApprovalRequestAdminNotifications)) - { - _logger.LogWarning("Skipped sending device approval notification to admins - feature flag disabled"); - return; - } - var adminEmails = await GetAdminAndAccountRecoveryEmailsAsync(organizationUser.OrganizationId); await _mailService.SendDeviceApprovalRequestedNotificationEmailAsync( diff --git a/test/Core.Test/Auth/Services/AuthRequestServiceTests.cs b/test/Core.Test/Auth/Services/AuthRequestServiceTests.cs index 5e99ecf171..edd7a06fa7 100644 --- a/test/Core.Test/Auth/Services/AuthRequestServiceTests.cs +++ b/test/Core.Test/Auth/Services/AuthRequestServiceTests.cs @@ -273,78 +273,7 @@ public class AuthRequestServiceTests /// each of them. /// [Theory, BitAutoData] - public async Task CreateAuthRequestAsync_AdminApproval_CreatesForEachOrganization( - SutProvider sutProvider, - AuthRequestCreateRequestModel createModel, - User user, - OrganizationUser organizationUser1, - OrganizationUser organizationUser2) - { - createModel.Type = AuthRequestType.AdminApproval; - user.Email = createModel.Email; - organizationUser1.UserId = user.Id; - organizationUser2.UserId = user.Id; - - sutProvider.GetDependency() - .GetByEmailAsync(user.Email) - .Returns(user); - - sutProvider.GetDependency() - .DeviceType - .Returns(DeviceType.ChromeExtension); - - sutProvider.GetDependency() - .UserId - .Returns(user.Id); - - sutProvider.GetDependency() - .PasswordlessAuth.KnownDevicesOnly - .Returns(false); - - - sutProvider.GetDependency() - .GetManyByUserAsync(user.Id) - .Returns(new List - { - organizationUser1, - organizationUser2, - }); - - sutProvider.GetDependency() - .CreateAsync(Arg.Any()) - .Returns(c => c.ArgAt(0)); - - var authRequest = await sutProvider.Sut.CreateAuthRequestAsync(createModel); - - Assert.Equal(organizationUser1.OrganizationId, authRequest.OrganizationId); - - await sutProvider.GetDependency() - .Received(1) - .CreateAsync(Arg.Is(o => o.OrganizationId == organizationUser1.OrganizationId)); - - await sutProvider.GetDependency() - .Received(1) - .CreateAsync(Arg.Is(o => o.OrganizationId == organizationUser2.OrganizationId)); - - await sutProvider.GetDependency() - .Received(2) - .CreateAsync(Arg.Any()); - - await sutProvider.GetDependency() - .Received(1) - .LogUserEventAsync(user.Id, EventType.User_RequestedDeviceApproval); - - await sutProvider.GetDependency() - .DidNotReceiveWithAnyArgs() - .SendDeviceApprovalRequestedNotificationEmailAsync( - Arg.Any>(), - Arg.Any(), - Arg.Any(), - Arg.Any()); - } - - [Theory, BitAutoData] - public async Task CreateAuthRequestAsync_AdminApproval_WithAdminNotifications_CreatesForEachOrganization_SendsEmails( + public async Task CreateAuthRequestAsync_AdminApproval_CreatesForEachOrganization_SendsEmails( SutProvider sutProvider, AuthRequestCreateRequestModel createModel, User user, @@ -369,10 +298,6 @@ public class AuthRequestServiceTests ManageResetPassword = true, }); - sutProvider.GetDependency() - .IsEnabled(FeatureFlagKeys.DeviceApprovalRequestAdminNotifications) - .Returns(true); - sutProvider.GetDependency() .GetByEmailAsync(user.Email) .Returns(user);