mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
More Managed to Claimed renames.
This commit is contained in:
parent
4e25ee51ce
commit
e78b936782
@ -57,7 +57,7 @@ public class OrganizationUsersController : Controller
|
|||||||
private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery;
|
private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery;
|
||||||
private readonly IRemoveOrganizationUserCommand _removeOrganizationUserCommand;
|
private readonly IRemoveOrganizationUserCommand _removeOrganizationUserCommand;
|
||||||
private readonly IDeleteClaimedOrganizationUserAccountCommand _deleteClaimedOrganizationUserAccountCommand;
|
private readonly IDeleteClaimedOrganizationUserAccountCommand _deleteClaimedOrganizationUserAccountCommand;
|
||||||
private readonly IGetOrganizationUsersManagementStatusQuery _getOrganizationUsersManagementStatusQuery;
|
private readonly IGetOrganizationUsersClaimedStatusQuery _getOrganizationUsersClaimedStatusQuery;
|
||||||
private readonly IPolicyRequirementQuery _policyRequirementQuery;
|
private readonly IPolicyRequirementQuery _policyRequirementQuery;
|
||||||
private readonly IFeatureService _featureService;
|
private readonly IFeatureService _featureService;
|
||||||
private readonly IPricingClient _pricingClient;
|
private readonly IPricingClient _pricingClient;
|
||||||
@ -84,7 +84,7 @@ public class OrganizationUsersController : Controller
|
|||||||
ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
|
ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
|
||||||
IRemoveOrganizationUserCommand removeOrganizationUserCommand,
|
IRemoveOrganizationUserCommand removeOrganizationUserCommand,
|
||||||
IDeleteClaimedOrganizationUserAccountCommand deleteClaimedOrganizationUserAccountCommand,
|
IDeleteClaimedOrganizationUserAccountCommand deleteClaimedOrganizationUserAccountCommand,
|
||||||
IGetOrganizationUsersManagementStatusQuery getOrganizationUsersManagementStatusQuery,
|
IGetOrganizationUsersClaimedStatusQuery getOrganizationUsersClaimedStatusQuery,
|
||||||
IPolicyRequirementQuery policyRequirementQuery,
|
IPolicyRequirementQuery policyRequirementQuery,
|
||||||
IFeatureService featureService,
|
IFeatureService featureService,
|
||||||
IPricingClient pricingClient,
|
IPricingClient pricingClient,
|
||||||
@ -110,7 +110,7 @@ public class OrganizationUsersController : Controller
|
|||||||
_twoFactorIsEnabledQuery = twoFactorIsEnabledQuery;
|
_twoFactorIsEnabledQuery = twoFactorIsEnabledQuery;
|
||||||
_removeOrganizationUserCommand = removeOrganizationUserCommand;
|
_removeOrganizationUserCommand = removeOrganizationUserCommand;
|
||||||
_deleteClaimedOrganizationUserAccountCommand = deleteClaimedOrganizationUserAccountCommand;
|
_deleteClaimedOrganizationUserAccountCommand = deleteClaimedOrganizationUserAccountCommand;
|
||||||
_getOrganizationUsersManagementStatusQuery = getOrganizationUsersManagementStatusQuery;
|
_getOrganizationUsersClaimedStatusQuery = getOrganizationUsersClaimedStatusQuery;
|
||||||
_policyRequirementQuery = policyRequirementQuery;
|
_policyRequirementQuery = policyRequirementQuery;
|
||||||
_featureService = featureService;
|
_featureService = featureService;
|
||||||
_pricingClient = pricingClient;
|
_pricingClient = pricingClient;
|
||||||
@ -127,11 +127,11 @@ public class OrganizationUsersController : Controller
|
|||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var managedByOrganization = await GetManagedByOrganizationStatusAsync(
|
var claimedByOrganizationStatus = await GetClaimedByOrganizationStatusAsync(
|
||||||
organizationUser.OrganizationId,
|
organizationUser.OrganizationId,
|
||||||
[organizationUser.Id]);
|
[organizationUser.Id]);
|
||||||
|
|
||||||
var response = new OrganizationUserDetailsResponseModel(organizationUser, managedByOrganization[organizationUser.Id], collections);
|
var response = new OrganizationUserDetailsResponseModel(organizationUser, claimedByOrganizationStatus[organizationUser.Id], collections);
|
||||||
|
|
||||||
if (includeGroups)
|
if (includeGroups)
|
||||||
{
|
{
|
||||||
@ -175,7 +175,7 @@ public class OrganizationUsersController : Controller
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
var organizationUsersTwoFactorEnabled = await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(organizationUsers);
|
var organizationUsersTwoFactorEnabled = await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(organizationUsers);
|
||||||
var organizationUsersManagementStatus = await GetManagedByOrganizationStatusAsync(orgId, organizationUsers.Select(o => o.Id));
|
var organizationUsersManagementStatus = await GetClaimedByOrganizationStatusAsync(orgId, organizationUsers.Select(o => o.Id));
|
||||||
var responses = organizationUsers
|
var responses = organizationUsers
|
||||||
.Select(o =>
|
.Select(o =>
|
||||||
{
|
{
|
||||||
@ -717,14 +717,14 @@ public class OrganizationUsersController : Controller
|
|||||||
new OrganizationUserBulkResponseModel(r.Item1.Id, r.Item2)));
|
new OrganizationUserBulkResponseModel(r.Item1.Id, r.Item2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IDictionary<Guid, bool>> GetManagedByOrganizationStatusAsync(Guid orgId, IEnumerable<Guid> userIds)
|
private async Task<IDictionary<Guid, bool>> GetClaimedByOrganizationStatusAsync(Guid orgId, IEnumerable<Guid> userIds)
|
||||||
{
|
{
|
||||||
if (!_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning))
|
if (!_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning))
|
||||||
{
|
{
|
||||||
return userIds.ToDictionary(kvp => kvp, kvp => false);
|
return userIds.ToDictionary(kvp => kvp, kvp => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var usersOrganizationManagementStatus = await _getOrganizationUsersManagementStatusQuery.GetUsersOrganizationManagementStatusAsync(orgId, userIds);
|
var usersOrganizationManagementStatus = await _getOrganizationUsersClaimedStatusQuery.GetUsersOrganizationClaimedStatusAsync(orgId, userIds);
|
||||||
return usersOrganizationManagementStatus;
|
return usersOrganizationManagementStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,24 +66,30 @@ public class OrganizationUserDetailsResponseModel : OrganizationUserResponseMode
|
|||||||
{
|
{
|
||||||
public OrganizationUserDetailsResponseModel(
|
public OrganizationUserDetailsResponseModel(
|
||||||
OrganizationUser organizationUser,
|
OrganizationUser organizationUser,
|
||||||
bool managedByOrganization,
|
bool claimedByOrganization,
|
||||||
IEnumerable<CollectionAccessSelection> collections)
|
IEnumerable<CollectionAccessSelection> collections)
|
||||||
: base(organizationUser, "organizationUserDetails")
|
: base(organizationUser, "organizationUserDetails")
|
||||||
{
|
{
|
||||||
ManagedByOrganization = managedByOrganization;
|
ClaimedByOrganization = claimedByOrganization;
|
||||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrganizationUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
|
public OrganizationUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
|
||||||
bool managedByOrganization,
|
bool claimedByOrganization,
|
||||||
IEnumerable<CollectionAccessSelection> collections)
|
IEnumerable<CollectionAccessSelection> collections)
|
||||||
: base(organizationUser, "organizationUserDetails")
|
: base(organizationUser, "organizationUserDetails")
|
||||||
{
|
{
|
||||||
ManagedByOrganization = managedByOrganization;
|
ClaimedByOrganization = claimedByOrganization;
|
||||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ManagedByOrganization { get; set; }
|
[Obsolete("Please use ClaimedByOrganization instead. This property will be removed in a future version.")]
|
||||||
|
public bool ManagedByOrganization
|
||||||
|
{
|
||||||
|
get => ClaimedByOrganization;
|
||||||
|
set => ClaimedByOrganization = value;
|
||||||
|
}
|
||||||
|
public bool ClaimedByOrganization { get; set; }
|
||||||
|
|
||||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||||
|
|
||||||
|
@ -133,16 +133,11 @@ public class ProfileOrganizationResponseModel : ResponseModel
|
|||||||
public bool LimitItemDeletion { get; set; }
|
public bool LimitItemDeletion { get; set; }
|
||||||
public bool AllowAdminAccessToAllCollectionItems { get; set; }
|
public bool AllowAdminAccessToAllCollectionItems { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the organization claims the user.
|
/// Obsolete.
|
||||||
|
///
|
||||||
|
/// See <see cref="UserIsClaimedByOrganization"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
[Obsolete("Please use UserIsClaimedByOrganization instead. This property will be removed in a future version.")]
|
||||||
/// An organization claims a user if the user's email domain is verified by the organization and the user is a member of it.
|
|
||||||
/// The organization must be enabled and able to have verified domains.
|
|
||||||
/// </remarks>
|
|
||||||
/// <returns>
|
|
||||||
/// False if the Account Deprovisioning feature flag is disabled.
|
|
||||||
/// </returns>
|
|
||||||
[Obsolete]
|
|
||||||
public bool UserIsManagedByOrganization
|
public bool UserIsManagedByOrganization
|
||||||
{
|
{
|
||||||
get => UserIsClaimedByOrganization;
|
get => UserIsClaimedByOrganization;
|
||||||
|
@ -19,7 +19,7 @@ public class DeleteClaimedOrganizationUserAccountCommand : IDeleteClaimedOrganiz
|
|||||||
{
|
{
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
private readonly IEventService _eventService;
|
private readonly IEventService _eventService;
|
||||||
private readonly IGetOrganizationUsersManagementStatusQuery _getOrganizationUsersManagementStatusQuery;
|
private readonly IGetOrganizationUsersClaimedStatusQuery _getOrganizationUsersClaimedStatusQuery;
|
||||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||||
private readonly IUserRepository _userRepository;
|
private readonly IUserRepository _userRepository;
|
||||||
private readonly ICurrentContext _currentContext;
|
private readonly ICurrentContext _currentContext;
|
||||||
@ -31,7 +31,7 @@ public class DeleteClaimedOrganizationUserAccountCommand : IDeleteClaimedOrganiz
|
|||||||
public DeleteClaimedOrganizationUserAccountCommand(
|
public DeleteClaimedOrganizationUserAccountCommand(
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
IEventService eventService,
|
IEventService eventService,
|
||||||
IGetOrganizationUsersManagementStatusQuery getOrganizationUsersManagementStatusQuery,
|
IGetOrganizationUsersClaimedStatusQuery getOrganizationUsersClaimedStatusQuery,
|
||||||
IOrganizationUserRepository organizationUserRepository,
|
IOrganizationUserRepository organizationUserRepository,
|
||||||
IUserRepository userRepository,
|
IUserRepository userRepository,
|
||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
@ -43,7 +43,7 @@ public class DeleteClaimedOrganizationUserAccountCommand : IDeleteClaimedOrganiz
|
|||||||
{
|
{
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_eventService = eventService;
|
_eventService = eventService;
|
||||||
_getOrganizationUsersManagementStatusQuery = getOrganizationUsersManagementStatusQuery;
|
_getOrganizationUsersClaimedStatusQuery = getOrganizationUsersClaimedStatusQuery;
|
||||||
_organizationUserRepository = organizationUserRepository;
|
_organizationUserRepository = organizationUserRepository;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
@ -62,7 +62,7 @@ public class DeleteClaimedOrganizationUserAccountCommand : IDeleteClaimedOrganiz
|
|||||||
throw new NotFoundException("Member not found.");
|
throw new NotFoundException("Member not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var managementStatus = await _getOrganizationUsersManagementStatusQuery.GetUsersOrganizationManagementStatusAsync(organizationId, new[] { organizationUserId });
|
var managementStatus = await _getOrganizationUsersClaimedStatusQuery.GetUsersOrganizationClaimedStatusAsync(organizationId, new[] { organizationUserId });
|
||||||
var hasOtherConfirmedOwners = await _hasConfirmedOwnersExceptQuery.HasConfirmedOwnersExceptAsync(organizationId, new[] { organizationUserId }, includeProvider: true);
|
var hasOtherConfirmedOwners = await _hasConfirmedOwnersExceptQuery.HasConfirmedOwnersExceptAsync(organizationId, new[] { organizationUserId }, includeProvider: true);
|
||||||
|
|
||||||
await ValidateDeleteUserAsync(organizationId, organizationUser, deletingUserId, managementStatus, hasOtherConfirmedOwners);
|
await ValidateDeleteUserAsync(organizationId, organizationUser, deletingUserId, managementStatus, hasOtherConfirmedOwners);
|
||||||
@ -83,7 +83,7 @@ public class DeleteClaimedOrganizationUserAccountCommand : IDeleteClaimedOrganiz
|
|||||||
var userIds = orgUsers.Where(ou => ou.UserId.HasValue).Select(ou => ou.UserId!.Value).ToList();
|
var userIds = orgUsers.Where(ou => ou.UserId.HasValue).Select(ou => ou.UserId!.Value).ToList();
|
||||||
var users = await _userRepository.GetManyAsync(userIds);
|
var users = await _userRepository.GetManyAsync(userIds);
|
||||||
|
|
||||||
var managementStatus = await _getOrganizationUsersManagementStatusQuery.GetUsersOrganizationManagementStatusAsync(organizationId, orgUserIds);
|
var managementStatus = await _getOrganizationUsersClaimedStatusQuery.GetUsersOrganizationClaimedStatusAsync(organizationId, orgUserIds);
|
||||||
var hasOtherConfirmedOwners = await _hasConfirmedOwnersExceptQuery.HasConfirmedOwnersExceptAsync(organizationId, orgUserIds, includeProvider: true);
|
var hasOtherConfirmedOwners = await _hasConfirmedOwnersExceptQuery.HasConfirmedOwnersExceptAsync(organizationId, orgUserIds, includeProvider: true);
|
||||||
|
|
||||||
var results = new List<(Guid OrganizationUserId, string? ErrorMessage)>();
|
var results = new List<(Guid OrganizationUserId, string? ErrorMessage)>();
|
||||||
|
@ -4,12 +4,12 @@ using Bit.Core.Services;
|
|||||||
|
|
||||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers;
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers;
|
||||||
|
|
||||||
public class GetOrganizationUsersManagementStatusQuery : IGetOrganizationUsersManagementStatusQuery
|
public class GetOrganizationUsersClaimedStatusQuery : IGetOrganizationUsersClaimedStatusQuery
|
||||||
{
|
{
|
||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||||
|
|
||||||
public GetOrganizationUsersManagementStatusQuery(
|
public GetOrganizationUsersClaimedStatusQuery(
|
||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
IOrganizationUserRepository organizationUserRepository)
|
IOrganizationUserRepository organizationUserRepository)
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ public class GetOrganizationUsersManagementStatusQuery : IGetOrganizationUsersMa
|
|||||||
_organizationUserRepository = organizationUserRepository;
|
_organizationUserRepository = organizationUserRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IDictionary<Guid, bool>> GetUsersOrganizationManagementStatusAsync(Guid organizationId, IEnumerable<Guid> organizationUserIds)
|
public async Task<IDictionary<Guid, bool>> GetUsersOrganizationClaimedStatusAsync(Guid organizationId, IEnumerable<Guid> organizationUserIds)
|
||||||
{
|
{
|
||||||
if (organizationUserIds.Any())
|
if (organizationUserIds.Any())
|
||||||
{
|
{
|
@ -1,19 +1,19 @@
|
|||||||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces;
|
||||||
|
|
||||||
public interface IGetOrganizationUsersManagementStatusQuery
|
public interface IGetOrganizationUsersClaimedStatusQuery
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether each user in the provided list of organization user IDs is managed by the specified organization.
|
/// Checks whether each user in the provided list of organization user IDs is claimed by the specified organization.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="organizationId">The unique identifier of the organization to check against.</param>
|
/// <param name="organizationId">The unique identifier of the organization to check against.</param>
|
||||||
/// <param name="organizationUserIds">A list of OrganizationUserIds to be checked.</param>
|
/// <param name="organizationUserIds">A list of OrganizationUserIds to be checked.</param>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// A managed user is a user whose email domain matches one of the Organization's verified domains.
|
/// A claimed user is a user whose email domain matches one of the Organization's verified domains.
|
||||||
/// The organization must be enabled and be on an Enterprise plan.
|
/// The organization must be enabled and be on an Enterprise plan.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A dictionary containing the OrganizationUserId and a boolean indicating if the user is managed by the organization.
|
/// A dictionary containing the OrganizationUserId and a boolean indicating if the user is claimed by the organization.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IDictionary<Guid, bool>> GetUsersOrganizationManagementStatusAsync(Guid organizationId,
|
Task<IDictionary<Guid, bool>> GetUsersOrganizationClaimedStatusAsync(Guid organizationId,
|
||||||
IEnumerable<Guid> organizationUserIds);
|
IEnumerable<Guid> organizationUserIds);
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
|||||||
private readonly IPushRegistrationService _pushRegistrationService;
|
private readonly IPushRegistrationService _pushRegistrationService;
|
||||||
private readonly ICurrentContext _currentContext;
|
private readonly ICurrentContext _currentContext;
|
||||||
private readonly IHasConfirmedOwnersExceptQuery _hasConfirmedOwnersExceptQuery;
|
private readonly IHasConfirmedOwnersExceptQuery _hasConfirmedOwnersExceptQuery;
|
||||||
private readonly IGetOrganizationUsersManagementStatusQuery _getOrganizationUsersManagementStatusQuery;
|
private readonly IGetOrganizationUsersClaimedStatusQuery _getOrganizationUsersClaimedStatusQuery;
|
||||||
private readonly IFeatureService _featureService;
|
private readonly IFeatureService _featureService;
|
||||||
private readonly TimeProvider _timeProvider;
|
private readonly TimeProvider _timeProvider;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
|||||||
IPushRegistrationService pushRegistrationService,
|
IPushRegistrationService pushRegistrationService,
|
||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
IHasConfirmedOwnersExceptQuery hasConfirmedOwnersExceptQuery,
|
IHasConfirmedOwnersExceptQuery hasConfirmedOwnersExceptQuery,
|
||||||
IGetOrganizationUsersManagementStatusQuery getOrganizationUsersManagementStatusQuery,
|
IGetOrganizationUsersClaimedStatusQuery getOrganizationUsersClaimedStatusQuery,
|
||||||
IFeatureService featureService,
|
IFeatureService featureService,
|
||||||
TimeProvider timeProvider)
|
TimeProvider timeProvider)
|
||||||
{
|
{
|
||||||
@ -48,7 +48,7 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
|||||||
_pushRegistrationService = pushRegistrationService;
|
_pushRegistrationService = pushRegistrationService;
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
_hasConfirmedOwnersExceptQuery = hasConfirmedOwnersExceptQuery;
|
_hasConfirmedOwnersExceptQuery = hasConfirmedOwnersExceptQuery;
|
||||||
_getOrganizationUsersManagementStatusQuery = getOrganizationUsersManagementStatusQuery;
|
_getOrganizationUsersClaimedStatusQuery = getOrganizationUsersClaimedStatusQuery;
|
||||||
_featureService = featureService;
|
_featureService = featureService;
|
||||||
_timeProvider = timeProvider;
|
_timeProvider = timeProvider;
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
|||||||
|
|
||||||
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) && deletingUserId.HasValue && eventSystemUser == null)
|
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) && deletingUserId.HasValue && eventSystemUser == null)
|
||||||
{
|
{
|
||||||
var managementStatus = await _getOrganizationUsersManagementStatusQuery.GetUsersOrganizationManagementStatusAsync(orgUser.OrganizationId, new[] { orgUser.Id });
|
var managementStatus = await _getOrganizationUsersClaimedStatusQuery.GetUsersOrganizationClaimedStatusAsync(orgUser.OrganizationId, new[] { orgUser.Id });
|
||||||
if (managementStatus.TryGetValue(orgUser.Id, out var isManaged) && isManaged)
|
if (managementStatus.TryGetValue(orgUser.Id, out var isManaged) && isManaged)
|
||||||
{
|
{
|
||||||
throw new BadRequestException(RemoveClaimedAccountErrorMessage);
|
throw new BadRequestException(RemoveClaimedAccountErrorMessage);
|
||||||
@ -209,7 +209,7 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
var managementStatus = _featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) && deletingUserId.HasValue && eventSystemUser == null
|
var managementStatus = _featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) && deletingUserId.HasValue && eventSystemUser == null
|
||||||
? await _getOrganizationUsersManagementStatusQuery.GetUsersOrganizationManagementStatusAsync(organizationId, filteredUsers.Select(u => u.Id))
|
? await _getOrganizationUsersClaimedStatusQuery.GetUsersOrganizationClaimedStatusAsync(organizationId, filteredUsers.Select(u => u.Id))
|
||||||
: filteredUsers.ToDictionary(u => u.Id, u => false);
|
: filteredUsers.ToDictionary(u => u.Id, u => false);
|
||||||
var result = new List<(OrganizationUser OrganizationUser, string ErrorMessage)>();
|
var result = new List<(OrganizationUser OrganizationUser, string ErrorMessage)>();
|
||||||
foreach (var orgUser in filteredUsers)
|
foreach (var orgUser in filteredUsers)
|
||||||
|
@ -167,7 +167,7 @@ public static class OrganizationServiceCollectionExtensions
|
|||||||
services.AddScoped<ICountNewSmSeatsRequiredQuery, CountNewSmSeatsRequiredQuery>();
|
services.AddScoped<ICountNewSmSeatsRequiredQuery, CountNewSmSeatsRequiredQuery>();
|
||||||
services.AddScoped<IAcceptOrgUserCommand, AcceptOrgUserCommand>();
|
services.AddScoped<IAcceptOrgUserCommand, AcceptOrgUserCommand>();
|
||||||
services.AddScoped<IOrganizationUserUserDetailsQuery, OrganizationUserUserDetailsQuery>();
|
services.AddScoped<IOrganizationUserUserDetailsQuery, OrganizationUserUserDetailsQuery>();
|
||||||
services.AddScoped<IGetOrganizationUsersManagementStatusQuery, GetOrganizationUsersManagementStatusQuery>();
|
services.AddScoped<IGetOrganizationUsersClaimedStatusQuery, GetOrganizationUsersClaimedStatusQuery>();
|
||||||
|
|
||||||
services.AddScoped<IRestoreOrganizationUserCommand, RestoreOrganizationUserCommand>();
|
services.AddScoped<IRestoreOrganizationUserCommand, RestoreOrganizationUserCommand>();
|
||||||
|
|
||||||
|
@ -260,14 +260,15 @@ public class OrganizationUsersControllerTests
|
|||||||
.GetDetailsByIdWithCollectionsAsync(organizationUser.Id)
|
.GetDetailsByIdWithCollectionsAsync(organizationUser.Id)
|
||||||
.Returns((organizationUser, collections));
|
.Returns((organizationUser, collections));
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(organizationUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(organizationUser.Id)))
|
.GetUsersOrganizationClaimedStatusAsync(organizationUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(organizationUser.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, true } });
|
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, true } });
|
||||||
|
|
||||||
var response = await sutProvider.Sut.Get(organizationUser.Id, false);
|
var response = await sutProvider.Sut.Get(organizationUser.Id, false);
|
||||||
|
|
||||||
Assert.Equal(organizationUser.Id, response.Id);
|
Assert.Equal(organizationUser.Id, response.Id);
|
||||||
Assert.Equal(accountDeprovisioningEnabled, response.ManagedByOrganization);
|
Assert.Equal(accountDeprovisioningEnabled, response.ManagedByOrganization);
|
||||||
|
Assert.Equal(accountDeprovisioningEnabled, response.ClaimedByOrganization);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
@ -34,8 +34,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests
|
|||||||
.GetByIdAsync(organizationUser.Id)
|
.GetByIdAsync(organizationUser.Id)
|
||||||
.Returns(organizationUser);
|
.Returns(organizationUser);
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(
|
.GetUsersOrganizationClaimedStatusAsync(
|
||||||
organizationUser.OrganizationId,
|
organizationUser.OrganizationId,
|
||||||
Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(organizationUser.Id)))
|
Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(organizationUser.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, true } });
|
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, true } });
|
||||||
@ -218,8 +218,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests
|
|||||||
sutProvider.GetDependency<IUserRepository>().GetByIdAsync(user.Id)
|
sutProvider.GetDependency<IUserRepository>().GetByIdAsync(user.Id)
|
||||||
.Returns(user);
|
.Returns(user);
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(organizationUser.OrganizationId, Arg.Any<IEnumerable<Guid>>())
|
.GetUsersOrganizationClaimedStatusAsync(organizationUser.OrganizationId, Arg.Any<IEnumerable<Guid>>())
|
||||||
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, false } });
|
.Returns(new Dictionary<Guid, bool> { { organizationUser.Id, false } });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -253,8 +253,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests
|
|||||||
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(user1.Id) && ids.Contains(user2.Id)))
|
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(user1.Id) && ids.Contains(user2.Id)))
|
||||||
.Returns(new[] { user1, user2 });
|
.Returns(new[] { user1, user2 });
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(organizationId, Arg.Any<IEnumerable<Guid>>())
|
.GetUsersOrganizationClaimedStatusAsync(organizationId, Arg.Any<IEnumerable<Guid>>())
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, true }, { orgUser2.Id, true } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, true }, { orgUser2.Id, true } });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -435,8 +435,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests
|
|||||||
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(orgUser.UserId.Value)))
|
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(orgUser.UserId.Value)))
|
||||||
.Returns(new[] { user });
|
.Returns(new[] { user });
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(Arg.Any<Guid>(), Arg.Any<IEnumerable<Guid>>())
|
.GetUsersOrganizationClaimedStatusAsync(Arg.Any<Guid>(), Arg.Any<IEnumerable<Guid>>())
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, false } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, false } });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -474,8 +474,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests
|
|||||||
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(user1.Id) && ids.Contains(user3.Id)))
|
.GetManyAsync(Arg.Is<IEnumerable<Guid>>(ids => ids.Contains(user1.Id) && ids.Contains(user3.Id)))
|
||||||
.Returns(new[] { user1, user3 });
|
.Returns(new[] { user1, user3 });
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(organizationId, Arg.Any<IEnumerable<Guid>>())
|
.GetUsersOrganizationClaimedStatusAsync(organizationId, Arg.Any<IEnumerable<Guid>>())
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, true }, { orgUser3.Id, false } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, true }, { orgUser3.Id, false } });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
@ -12,14 +12,14 @@ using Xunit;
|
|||||||
namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.OrganizationUsers;
|
namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.OrganizationUsers;
|
||||||
|
|
||||||
[SutProviderCustomize]
|
[SutProviderCustomize]
|
||||||
public class GetOrganizationUsersManagementStatusQueryTests
|
public class GetOrganizationUsersClaimedStatusQueryTests
|
||||||
{
|
{
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
public async Task GetUsersOrganizationManagementStatusAsync_WithNoUsers_ReturnsEmpty(
|
public async Task GetUsersOrganizationManagementStatusAsync_WithNoUsers_ReturnsEmpty(
|
||||||
Organization organization,
|
Organization organization,
|
||||||
SutProvider<GetOrganizationUsersManagementStatusQuery> sutProvider)
|
SutProvider<GetOrganizationUsersClaimedStatusQuery> sutProvider)
|
||||||
{
|
{
|
||||||
var result = await sutProvider.Sut.GetUsersOrganizationManagementStatusAsync(organization.Id, new List<Guid>());
|
var result = await sutProvider.Sut.GetUsersOrganizationClaimedStatusAsync(organization.Id, new List<Guid>());
|
||||||
|
|
||||||
Assert.Empty(result);
|
Assert.Empty(result);
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
public async Task GetUsersOrganizationManagementStatusAsync_WithUseSsoEnabled_Success(
|
public async Task GetUsersOrganizationManagementStatusAsync_WithUseSsoEnabled_Success(
|
||||||
Organization organization,
|
Organization organization,
|
||||||
ICollection<OrganizationUser> usersWithClaimedDomain,
|
ICollection<OrganizationUser> usersWithClaimedDomain,
|
||||||
SutProvider<GetOrganizationUsersManagementStatusQuery> sutProvider)
|
SutProvider<GetOrganizationUsersClaimedStatusQuery> sutProvider)
|
||||||
{
|
{
|
||||||
organization.Enabled = true;
|
organization.Enabled = true;
|
||||||
organization.UseSso = true;
|
organization.UseSso = true;
|
||||||
@ -44,7 +44,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
||||||
.Returns(usersWithClaimedDomain);
|
.Returns(usersWithClaimedDomain);
|
||||||
|
|
||||||
var result = await sutProvider.Sut.GetUsersOrganizationManagementStatusAsync(organization.Id, userIdsToCheck);
|
var result = await sutProvider.Sut.GetUsersOrganizationClaimedStatusAsync(organization.Id, userIdsToCheck);
|
||||||
|
|
||||||
Assert.All(usersWithClaimedDomain, ou => Assert.True(result[ou.Id]));
|
Assert.All(usersWithClaimedDomain, ou => Assert.True(result[ou.Id]));
|
||||||
Assert.False(result[userIdWithoutClaimedDomain]);
|
Assert.False(result[userIdWithoutClaimedDomain]);
|
||||||
@ -54,7 +54,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
public async Task GetUsersOrganizationManagementStatusAsync_WithUseSsoDisabled_ReturnsAllFalse(
|
public async Task GetUsersOrganizationManagementStatusAsync_WithUseSsoDisabled_ReturnsAllFalse(
|
||||||
Organization organization,
|
Organization organization,
|
||||||
ICollection<OrganizationUser> usersWithClaimedDomain,
|
ICollection<OrganizationUser> usersWithClaimedDomain,
|
||||||
SutProvider<GetOrganizationUsersManagementStatusQuery> sutProvider)
|
SutProvider<GetOrganizationUsersClaimedStatusQuery> sutProvider)
|
||||||
{
|
{
|
||||||
organization.Enabled = true;
|
organization.Enabled = true;
|
||||||
organization.UseSso = false;
|
organization.UseSso = false;
|
||||||
@ -70,7 +70,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
||||||
.Returns(usersWithClaimedDomain);
|
.Returns(usersWithClaimedDomain);
|
||||||
|
|
||||||
var result = await sutProvider.Sut.GetUsersOrganizationManagementStatusAsync(organization.Id, userIdsToCheck);
|
var result = await sutProvider.Sut.GetUsersOrganizationClaimedStatusAsync(organization.Id, userIdsToCheck);
|
||||||
|
|
||||||
Assert.All(result, r => Assert.False(r.Value));
|
Assert.All(result, r => Assert.False(r.Value));
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
public async Task GetUsersOrganizationManagementStatusAsync_WithDisabledOrganization_ReturnsAllFalse(
|
public async Task GetUsersOrganizationManagementStatusAsync_WithDisabledOrganization_ReturnsAllFalse(
|
||||||
Organization organization,
|
Organization organization,
|
||||||
ICollection<OrganizationUser> usersWithClaimedDomain,
|
ICollection<OrganizationUser> usersWithClaimedDomain,
|
||||||
SutProvider<GetOrganizationUsersManagementStatusQuery> sutProvider)
|
SutProvider<GetOrganizationUsersClaimedStatusQuery> sutProvider)
|
||||||
{
|
{
|
||||||
organization.Enabled = false;
|
organization.Enabled = false;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class GetOrganizationUsersManagementStatusQueryTests
|
|||||||
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
.GetManyByOrganizationWithClaimedDomainsAsync(organization.Id)
|
||||||
.Returns(usersWithClaimedDomain);
|
.Returns(usersWithClaimedDomain);
|
||||||
|
|
||||||
var result = await sutProvider.Sut.GetUsersOrganizationManagementStatusAsync(organization.Id, userIdsToCheck);
|
var result = await sutProvider.Sut.GetUsersOrganizationClaimedStatusAsync(organization.Id, userIdsToCheck);
|
||||||
|
|
||||||
Assert.All(result, r => Assert.False(r.Value));
|
Assert.All(result, r => Assert.False(r.Value));
|
||||||
}
|
}
|
@ -41,9 +41,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
await sutProvider.Sut.RemoveUserAsync(deletingUser.OrganizationId, organizationUser.Id, deletingUser.UserId);
|
await sutProvider.Sut.RemoveUserAsync(deletingUser.OrganizationId, organizationUser.Id, deletingUser.UserId);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteAsync(organizationUser);
|
.DeleteAsync(organizationUser);
|
||||||
@ -78,9 +78,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
await sutProvider.Sut.RemoveUserAsync(deletingUser.OrganizationId, organizationUser.Id, deletingUser.UserId);
|
await sutProvider.Sut.RemoveUserAsync(deletingUser.OrganizationId, organizationUser.Id, deletingUser.UserId);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.GetUsersOrganizationManagementStatusAsync(
|
.GetUsersOrganizationClaimedStatusAsync(
|
||||||
organizationUser.OrganizationId,
|
organizationUser.OrganizationId,
|
||||||
Arg.Is<IEnumerable<Guid>>(i => i.Contains(organizationUser.Id)));
|
Arg.Is<IEnumerable<Guid>>(i => i.Contains(organizationUser.Id)));
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
@ -225,17 +225,17 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
sutProvider.GetDependency<IOrganizationUserRepository>()
|
sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.GetByIdAsync(orgUser.Id)
|
.GetByIdAsync(orgUser.Id)
|
||||||
.Returns(orgUser);
|
.Returns(orgUser);
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)))
|
.GetUsersOrganizationClaimedStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, true } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, true } });
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
var exception = await Assert.ThrowsAsync<BadRequestException>(
|
||||||
() => sutProvider.Sut.RemoveUserAsync(orgUser.OrganizationId, orgUser.Id, deletingUserId));
|
() => sutProvider.Sut.RemoveUserAsync(orgUser.OrganizationId, orgUser.Id, deletingUserId));
|
||||||
Assert.Contains(RemoveOrganizationUserCommand.RemoveClaimedAccountErrorMessage, exception.Message);
|
Assert.Contains(RemoveOrganizationUserCommand.RemoveClaimedAccountErrorMessage, exception.Message);
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.GetUsersOrganizationManagementStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)));
|
.GetUsersOrganizationClaimedStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
@ -252,9 +252,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
await sutProvider.Sut.RemoveUserAsync(organizationUser.OrganizationId, organizationUser.Id, eventSystemUser);
|
await sutProvider.Sut.RemoveUserAsync(organizationUser.OrganizationId, organizationUser.Id, eventSystemUser);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteAsync(organizationUser);
|
.DeleteAsync(organizationUser);
|
||||||
@ -280,9 +280,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
await sutProvider.Sut.RemoveUserAsync(organizationUser.OrganizationId, organizationUser.Id, eventSystemUser);
|
await sutProvider.Sut.RemoveUserAsync(organizationUser.OrganizationId, organizationUser.Id, eventSystemUser);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteAsync(organizationUser);
|
.DeleteAsync(organizationUser);
|
||||||
@ -468,8 +468,8 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
sutProvider.GetDependency<ICurrentContext>()
|
sutProvider.GetDependency<ICurrentContext>()
|
||||||
.OrganizationOwner(deletingUser.OrganizationId)
|
.OrganizationOwner(deletingUser.OrganizationId)
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(
|
.GetUsersOrganizationClaimedStatusAsync(
|
||||||
deletingUser.OrganizationId,
|
deletingUser.OrganizationId,
|
||||||
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)))
|
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, false }, { orgUser2.Id, false } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, false }, { orgUser2.Id, false } });
|
||||||
@ -480,9 +480,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, result.Count());
|
Assert.Equal(2, result.Count());
|
||||||
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
||||||
@ -522,8 +522,8 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
sutProvider.GetDependency<ICurrentContext>()
|
sutProvider.GetDependency<ICurrentContext>()
|
||||||
.OrganizationOwner(deletingUser.OrganizationId)
|
.OrganizationOwner(deletingUser.OrganizationId)
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(
|
.GetUsersOrganizationClaimedStatusAsync(
|
||||||
deletingUser.OrganizationId,
|
deletingUser.OrganizationId,
|
||||||
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)))
|
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, false }, { orgUser2.Id, false } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser1.Id, false }, { orgUser2.Id, false } });
|
||||||
@ -534,9 +534,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, result.Count());
|
Assert.Equal(2, result.Count());
|
||||||
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.GetUsersOrganizationManagementStatusAsync(
|
.GetUsersOrganizationClaimedStatusAsync(
|
||||||
deletingUser.OrganizationId,
|
deletingUser.OrganizationId,
|
||||||
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
@ -636,8 +636,8 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
.HasConfirmedOwnersExceptAsync(orgUser.OrganizationId, Arg.Any<IEnumerable<Guid>>())
|
.HasConfirmedOwnersExceptAsync(orgUser.OrganizationId, Arg.Any<IEnumerable<Guid>>())
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.GetUsersOrganizationManagementStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)))
|
.GetUsersOrganizationClaimedStatusAsync(orgUser.OrganizationId, Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser.Id)))
|
||||||
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, true } });
|
.Returns(new Dictionary<Guid, bool> { { orgUser.Id, true } });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -701,9 +701,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, result.Count());
|
Assert.Equal(2, result.Count());
|
||||||
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
||||||
@ -746,9 +746,9 @@ public class RemoveOrganizationUserCommandTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, result.Count());
|
Assert.Equal(2, result.Count());
|
||||||
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
Assert.All(result, r => Assert.Empty(r.ErrorMessage));
|
||||||
await sutProvider.GetDependency<IGetOrganizationUsersManagementStatusQuery>()
|
await sutProvider.GetDependency<IGetOrganizationUsersClaimedStatusQuery>()
|
||||||
.DidNotReceiveWithAnyArgs()
|
.DidNotReceiveWithAnyArgs()
|
||||||
.GetUsersOrganizationManagementStatusAsync(default, default);
|
.GetUsersOrganizationClaimedStatusAsync(default, default);
|
||||||
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
await sutProvider.GetDependency<IOrganizationUserRepository>()
|
||||||
.Received(1)
|
.Received(1)
|
||||||
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
.DeleteManyAsync(Arg.Is<IEnumerable<Guid>>(i => i.Contains(orgUser1.Id) && i.Contains(orgUser2.Id)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user