From ad85526379a0c30511c5560782dac90f8fff9a1b Mon Sep 17 00:00:00 2001 From: Javier Campos Date: Sun, 29 Dec 2019 17:40:54 +0100 Subject: [PATCH] feat: add ConfigureAwait(false) to all await calls --- .../Abp/Identity/IdentityRoleAppService.cs | 23 +- .../Abp/Identity/IdentityUserAppService.cs | 52 ++-- .../Identity/IdentityUserLookupAppService.cs | 4 +- .../Volo/Abp/Identity/ProfileAppService.cs | 22 +- .../Abp/Identity/AbpIdentityOptionsFactory.cs | 22 +- .../Identity/AbpUserClaimsPrincipalFactory.cs | 2 +- .../Abp/Identity/IdentityClaimTypeManager.cs | 8 +- .../Volo/Abp/Identity/IdentityDataSeeder.cs | 10 +- .../Volo/Abp/Identity/IdentityRoleManager.cs | 6 +- .../Volo/Abp/Identity/IdentityRoleStore.cs | 12 +- .../Volo/Abp/Identity/IdentityUserManager.cs | 8 +- ...sitoryExternalUserLookupServiceProvider.cs | 4 +- .../Volo/Abp/Identity/IdentityUserStore.cs | 44 +-- .../Volo/Abp/Identity/UserRoleFinder.cs | 2 +- .../EfCoreIdentityClaimTypeRepository.cs | 4 +- .../EfCoreIdentityRoleRepository.cs | 4 +- .../EfCoreIdentityUserRepository.cs | 20 +- .../Abp/Identity/HttpClientUserRoleFinder.cs | 2 +- .../MongoIdentityClaimTypeRepository.cs | 6 +- .../MongoDB/MongoIdentityRoleRepository.cs | 4 +- .../MongoDB/MongoIdentityUserRepository.cs | 26 +- .../AbpIdentityWebMainMenuContributor.cs | 4 +- .../Identity/Roles/CreateModal.cshtml.cs | 2 +- .../Pages/Identity/Roles/EditModal.cshtml.cs | 4 +- .../Identity/Users/CreateModal.cshtml.cs | 4 +- .../Pages/Identity/Users/EditModal.cshtml.cs | 8 +- .../RolePermissionManagementProvider.cs | 4 +- .../Identity/IdentityRoleAppService_Tests.cs | 22 +- .../Identity/IdentityUserAppService_Tests.cs | 28 +- .../IdentityUserLookupAppService_Tests.cs | 12 +- .../Abp/Identity/ProfileAppService_Tests.cs | 4 +- .../Distributed_User_Change_Event_Tests.cs | 6 +- .../IdentityClaimTypeManager_Tests.cs | 14 +- .../Abp/Identity/IdentityRoleManager_Tests.cs | 12 +- .../Abp/Identity/IdentityRoleStore_Tests.cs | 56 ++-- .../Abp/Identity/IdentityUserManager_Tests.cs | 16 +- .../Abp/Identity/IdentityUserStore_Tests.cs | 276 +++++++++--------- .../Abp/Identity/PermissionManager_Tests.cs | 28 +- .../Abp/Identity/TestPermissionDataBuilder.cs | 20 +- .../Volo/Abp/Identity/UserRoleFinder_Tests.cs | 2 +- .../Abp/Identity/AbpIdentityTestBaseModule.cs | 4 +- .../Identity/AbpIdentityTestDataBuilder.cs | 24 +- .../IdentityClaimTypeRepository_Tests.cs | 4 +- .../Abp/Identity/IdentityDataSeeder_Tests.cs | 8 +- .../Identity/IdentityRoleRepository_Tests.cs | 10 +- .../Identity/IdentityUserRepository_Tests.cs | 42 +-- .../Volo/Abp/Identity/LazyLoading_Tests.cs | 8 +- 47 files changed, 453 insertions(+), 454 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index f2b902d271..44b97a82ea 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -24,14 +24,13 @@ namespace Volo.Abp.Identity public virtual async Task GetAsync(Guid id) { return ObjectMapper.Map( - await _roleManager.GetByIdAsync(id) - ); + await _roleManager.GetByIdAsync(id).ConfigureAwait(false)); } public virtual async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount); - var totalCount = await _roleRepository.GetCountAsync(); + var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false); + var totalCount = await _roleRepository.GetCountAsync().ConfigureAwait(false); return new PagedResultDto( totalCount, @@ -47,8 +46,8 @@ namespace Volo.Abp.Identity role.IsDefault = input.IsDefault; role.IsPublic = input.IsPublic; - (await _roleManager.CreateAsync(role)).CheckErrors(); - await CurrentUnitOfWork.SaveChangesAsync(); + (await _roleManager.CreateAsync(role).ConfigureAwait(false)).CheckErrors(); + await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false); return ObjectMapper.Map(role); } @@ -56,16 +55,16 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Roles.Update)] public virtual async Task UpdateAsync(Guid id, IdentityRoleUpdateDto input) { - var role = await _roleManager.GetByIdAsync(id); + var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false); role.ConcurrencyStamp = input.ConcurrencyStamp; - (await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors(); + (await _roleManager.SetRoleNameAsync(role, input.Name).ConfigureAwait(false)).CheckErrors(); role.IsDefault = input.IsDefault; role.IsPublic = input.IsPublic; - (await _roleManager.UpdateAsync(role)).CheckErrors(); - await CurrentUnitOfWork.SaveChangesAsync(); + (await _roleManager.UpdateAsync(role).ConfigureAwait(false)).CheckErrors(); + await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false); return ObjectMapper.Map(role); } @@ -73,13 +72,13 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Roles.Delete)] public virtual async Task DeleteAsync(Guid id) { - var role = await _roleManager.FindByIdAsync(id.ToString()); + var role = await _roleManager.FindByIdAsync(id.ToString()).ConfigureAwait(false); if (role == null) { return; } - (await _roleManager.DeleteAsync(role)).CheckErrors(); + (await _roleManager.DeleteAsync(role).ConfigureAwait(false)).CheckErrors(); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index c1d0f8f28b..365fac604f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -26,14 +26,14 @@ namespace Volo.Abp.Identity { return ObjectMapper.Map( await _userManager.GetByIdAsync(id) - ); +.ConfigureAwait(false)); } [Authorize(IdentityPermissions.Users.Default)] public virtual async Task> GetListAsync(GetIdentityUsersInput input) { - var count = await _userRepository.GetCountAsync(input.Filter); - var list = await _userRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter); + var count = await _userRepository.GetCountAsync(input.Filter).ConfigureAwait(false); + var list = await _userRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter).ConfigureAwait(false); return new PagedResultDto( count, @@ -44,7 +44,7 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Users.Default)] public virtual async Task> GetRolesAsync(Guid id) { - var roles = await _userRepository.GetRolesAsync(id); + var roles = await _userRepository.GetRolesAsync(id).ConfigureAwait(false); return new ListResultDto( ObjectMapper.Map, List>(roles) ); @@ -55,10 +55,10 @@ namespace Volo.Abp.Identity { var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id); - (await _userManager.CreateAsync(user, input.Password)).CheckErrors(); - await UpdateUserByInput(user, input); + (await _userManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors(); + await UpdateUserByInput(user, input).ConfigureAwait(false); - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false); return ObjectMapper.Map(user); } @@ -66,20 +66,20 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Users.Update)] public virtual async Task UpdateAsync(Guid id, IdentityUserUpdateDto input) { - var user = await _userManager.GetByIdAsync(id); + var user = await _userManager.GetByIdAsync(id).ConfigureAwait(false); user.ConcurrencyStamp = input.ConcurrencyStamp; - (await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); - await UpdateUserByInput(user, input); - (await _userManager.UpdateAsync(user)).CheckErrors(); + (await _userManager.SetUserNameAsync(user, input.UserName).ConfigureAwait(false)).CheckErrors(); + await UpdateUserByInput(user, input).ConfigureAwait(false); + (await _userManager.UpdateAsync(user).ConfigureAwait(false)).CheckErrors(); if (!input.Password.IsNullOrEmpty()) { - (await _userManager.RemovePasswordAsync(user)).CheckErrors(); - (await _userManager.AddPasswordAsync(user, input.Password)).CheckErrors(); + (await _userManager.RemovePasswordAsync(user).ConfigureAwait(false)).CheckErrors(); + (await _userManager.AddPasswordAsync(user, input.Password).ConfigureAwait(false)).CheckErrors(); } - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false); return ObjectMapper.Map(user); } @@ -92,21 +92,21 @@ namespace Volo.Abp.Identity throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion); } - var user = await _userManager.FindByIdAsync(id.ToString()); + var user = await _userManager.FindByIdAsync(id.ToString()).ConfigureAwait(false); if (user == null) { return; } - (await _userManager.DeleteAsync(user)).CheckErrors(); + (await _userManager.DeleteAsync(user).ConfigureAwait(false)).CheckErrors(); } [Authorize(IdentityPermissions.Users.Update)] public virtual async Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input) { - var user = await _userManager.GetByIdAsync(id); - (await _userManager.SetRolesAsync(user, input.RoleNames)).CheckErrors(); - await _userRepository.UpdateAsync(user); + var user = await _userManager.GetByIdAsync(id).ConfigureAwait(false); + (await _userManager.SetRolesAsync(user, input.RoleNames).ConfigureAwait(false)).CheckErrors(); + await _userRepository.UpdateAsync(user).ConfigureAwait(false); } [Authorize(IdentityPermissions.Users.Default)] @@ -114,7 +114,7 @@ namespace Volo.Abp.Identity { return ObjectMapper.Map( await _userManager.FindByNameAsync(username) - ); +.ConfigureAwait(false)); } [Authorize(IdentityPermissions.Users.Default)] @@ -122,30 +122,30 @@ namespace Volo.Abp.Identity { return ObjectMapper.Map( await _userManager.FindByEmailAsync(email) - ); +.ConfigureAwait(false)); } private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input) { if (!string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase)) { - (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); + (await _userManager.SetEmailAsync(user, input.Email).ConfigureAwait(false)).CheckErrors(); } if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) { - (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); + (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber).ConfigureAwait(false)).CheckErrors(); } - (await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors(); - (await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors(); + (await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled).ConfigureAwait(false)).CheckErrors(); + (await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled).ConfigureAwait(false)).CheckErrors(); user.Name = input.Name; user.Surname = input.Surname; if (input.RoleNames != null) { - (await _userManager.SetRolesAsync(user, input.RoleNames)).CheckErrors(); + (await _userManager.SetRolesAsync(user, input.RoleNames).ConfigureAwait(false)).CheckErrors(); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs index 48d42c4579..ca2b25f83b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs @@ -18,7 +18,7 @@ namespace Volo.Abp.Identity public virtual async Task FindByIdAsync(Guid id) { - var userData = await UserLookupServiceProvider.FindByIdAsync(id); + var userData = await UserLookupServiceProvider.FindByIdAsync(id).ConfigureAwait(false); if (userData == null) { return null; @@ -29,7 +29,7 @@ namespace Volo.Abp.Identity public virtual async Task FindByUserNameAsync(string userName) { - var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName); + var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName).ConfigureAwait(false); if (userData == null) { return null; diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs index 0b8712b93d..04d2c55a0b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs @@ -21,39 +21,39 @@ namespace Volo.Abp.Identity { return ObjectMapper.Map( await _userManager.GetByIdAsync(CurrentUser.GetId()) - ); +.ConfigureAwait(false)); } public virtual async Task UpdateAsync(UpdateProfileDto input) { - var user = await _userManager.GetByIdAsync(CurrentUser.GetId()); + var user = await _userManager.GetByIdAsync(CurrentUser.GetId()).ConfigureAwait(false); - if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled)) + if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled).ConfigureAwait(false)) { - (await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); + (await _userManager.SetUserNameAsync(user, input.UserName).ConfigureAwait(false)).CheckErrors(); } - if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled)) + if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled).ConfigureAwait(false)) { - (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); + (await _userManager.SetEmailAsync(user, input.Email).ConfigureAwait(false)).CheckErrors(); } - (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); + (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber).ConfigureAwait(false)).CheckErrors(); user.Name = input.Name; user.Surname = input.Surname; - (await _userManager.UpdateAsync(user)).CheckErrors(); + (await _userManager.UpdateAsync(user).ConfigureAwait(false)).CheckErrors(); - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false); return ObjectMapper.Map(user); } public virtual async Task ChangePasswordAsync(ChangePasswordInput input) { - var currentUser = await _userManager.GetByIdAsync(CurrentUser.GetId()); - (await _userManager.ChangePasswordAsync(currentUser, input.CurrentPassword, input.NewPassword)).CheckErrors(); + var currentUser = await _userManager.GetByIdAsync(CurrentUser.GetId()).ConfigureAwait(false); + (await _userManager.ChangePasswordAsync(currentUser, input.CurrentPassword, input.NewPassword).ConfigureAwait(false)).CheckErrors(); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs index 89f2b11bc2..3836783a01 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs @@ -39,19 +39,19 @@ namespace Volo.Abp.Identity protected virtual async Task OverrideOptionsAsync(IdentityOptions options) { - options.Password.RequiredLength = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength); - options.Password.RequiredUniqueChars = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars); - options.Password.RequireNonAlphanumeric = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric); - options.Password.RequireLowercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase); - options.Password.RequireUppercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase); - options.Password.RequireDigit = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit); - - options.Lockout.AllowedForNewUsers = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers); + options.Password.RequiredLength = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength).ConfigureAwait(false); + options.Password.RequiredUniqueChars = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars).ConfigureAwait(false); + options.Password.RequireNonAlphanumeric = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric).ConfigureAwait(false); + options.Password.RequireLowercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase).ConfigureAwait(false); + options.Password.RequireUppercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase).ConfigureAwait(false); + options.Password.RequireDigit = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit).ConfigureAwait(false); + + options.Lockout.AllowedForNewUsers = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers).ConfigureAwait(false); options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(await _settingProvider.GetAsync(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To())); - options.Lockout.MaxFailedAccessAttempts = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts); + options.Lockout.MaxFailedAccessAttempts = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts).ConfigureAwait(false); - options.SignIn.RequireConfirmedEmail = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail); - options.SignIn.RequireConfirmedPhoneNumber = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber); + options.SignIn.RequireConfirmedEmail = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail).ConfigureAwait(false); + options.SignIn.RequireConfirmedPhoneNumber = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber).ConfigureAwait(false); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs index 8db2b95942..9425a91cdc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.Identity [UnitOfWork] public override async Task CreateAsync(IdentityUser user) { - var principal = await base.CreateAsync(user); + var principal = await base.CreateAsync(user).ConfigureAwait(false); if (user.TenantId.HasValue) { diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs index 6e79b29d98..ae468d272a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs @@ -15,17 +15,17 @@ namespace Volo.Abp.Identity public virtual async Task CreateAsync(IdentityClaimType claimType) { - if (await _identityClaimTypeRepository.AnyAsync(claimType.Name)) + if (await _identityClaimTypeRepository.AnyAsync(claimType.Name).ConfigureAwait(false)) { throw new AbpException($"Name Exist: {claimType.Name}"); } - return await _identityClaimTypeRepository.InsertAsync(claimType); + return await _identityClaimTypeRepository.InsertAsync(claimType).ConfigureAwait(false); } public virtual async Task UpdateAsync(IdentityClaimType claimType) { - if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id)) + if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id).ConfigureAwait(false)) { throw new AbpException($"Name Exist: {claimType.Name}"); } @@ -36,7 +36,7 @@ namespace Volo.Abp.Identity } - return await _identityClaimTypeRepository.UpdateAsync(claimType); + return await _identityClaimTypeRepository.UpdateAsync(claimType).ConfigureAwait(false); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs index 70945c2546..92ebe6adfb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs @@ -47,7 +47,7 @@ namespace Volo.Abp.Identity const string adminUserName = "admin"; var adminUser = await _userRepository.FindByNormalizedUserNameAsync( _lookupNormalizer.NormalizeName(adminUserName) - ); + ).ConfigureAwait(false); if (adminUser != null) { @@ -64,12 +64,12 @@ namespace Volo.Abp.Identity Name = adminUserName }; - (await _userManager.CreateAsync(adminUser, adminPassword)).CheckErrors(); + (await _userManager.CreateAsync(adminUser, adminPassword).ConfigureAwait(false)).CheckErrors(); result.CreatedAdminUser = true; //"admin" role const string adminRoleName = "admin"; - var adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(adminRoleName)); + var adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(adminRoleName)).ConfigureAwait(false); if (adminRole == null) { adminRole = new IdentityRole( @@ -82,11 +82,11 @@ namespace Volo.Abp.Identity IsPublic = true }; - (await _roleManager.CreateAsync(adminRole)).CheckErrors(); + (await _roleManager.CreateAsync(adminRole).ConfigureAwait(false)).CheckErrors(); result.CreatedAdminRole = true; } - (await _userManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors(); + (await _userManager.AddToRoleAsync(adminUser, adminRoleName).ConfigureAwait(false)).CheckErrors(); return result; } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs index 92e6d9893c..17f1b817aa 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs @@ -41,7 +41,7 @@ namespace Volo.Abp.Identity public virtual async Task GetByIdAsync(Guid id) { - var role = await Store.FindByIdAsync(id.ToString(), CancellationToken); + var role = await Store.FindByIdAsync(id.ToString(), CancellationToken).ConfigureAwait(false); if (role == null) { throw new EntityNotFoundException(typeof(IdentityRole), id); @@ -57,7 +57,7 @@ namespace Volo.Abp.Identity throw new BusinessException(_localizer["Identity.StaticRoleRenamingErrorMessage"]); // TODO: localize & change exception type } - return await base.SetRoleNameAsync(role,name); + return await base.SetRoleNameAsync(role, name).ConfigureAwait(false); } public override async Task DeleteAsync(IdentityRole role) @@ -67,7 +67,7 @@ namespace Volo.Abp.Identity throw new BusinessException(_localizer["Identity.StaticRoleDeletionErrorMessage"]); // TODO: localize & change exception type } - return await base.DeleteAsync(role); + return await base.DeleteAsync(role).ConfigureAwait(false); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs index 175b051a48..1ca46b0830 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs @@ -67,7 +67,7 @@ namespace Volo.Abp.Identity Check.NotNull(role, nameof(role)); - await _roleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken); + await _roleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken).ConfigureAwait(false); return IdentityResult.Success; } @@ -86,7 +86,7 @@ namespace Volo.Abp.Identity try { - await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken); + await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken).ConfigureAwait(false); } catch (AbpDbConcurrencyException ex) { @@ -111,7 +111,7 @@ namespace Volo.Abp.Identity try { - await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken); + await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken).ConfigureAwait(false); } catch (AbpDbConcurrencyException ex) { @@ -249,7 +249,7 @@ namespace Volo.Abp.Identity Check.NotNull(role, nameof(role)); - await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken); + await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken).ConfigureAwait(false); return role.Claims.Select(c => c.ToClaim()).ToList(); } @@ -268,7 +268,7 @@ namespace Volo.Abp.Identity Check.NotNull(role, nameof(role)); Check.NotNull(claim, nameof(claim)); - await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken); + await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken).ConfigureAwait(false); role.AddClaim(_guidGenerator, claim); } @@ -285,7 +285,7 @@ namespace Volo.Abp.Identity Check.NotNull(role, nameof(role)); Check.NotNull(claim, nameof(claim)); - await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken); + await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken).ConfigureAwait(false); role.RemoveClaim(claim); } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs index 0f732a8dd7..9e66b7b824 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs @@ -45,7 +45,7 @@ namespace Volo.Abp.Identity public virtual async Task GetByIdAsync(Guid id) { - var user = await Store.FindByIdAsync(id.ToString(), CancellationToken); + var user = await Store.FindByIdAsync(id.ToString(), CancellationToken).ConfigureAwait(false); if (user == null) { throw new EntityNotFoundException(typeof(IdentityUser), id); @@ -59,15 +59,15 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(roleNames, nameof(roleNames)); - var currentRoleNames = await GetRolesAsync(user); + var currentRoleNames = await GetRolesAsync(user).ConfigureAwait(false); - var result = await RemoveFromRolesAsync(user, currentRoleNames.Except(roleNames).Distinct()); + var result = await RemoveFromRolesAsync(user, currentRoleNames.Except(roleNames).Distinct()).ConfigureAwait(false); if (!result.Succeeded) { return result; } - result = await AddToRolesAsync(user, roleNames.Except(currentRoleNames).Distinct()); + result = await AddToRolesAsync(user, roleNames.Except(currentRoleNames).Distinct()).ConfigureAwait(false); if (!result.Succeeded) { return result; diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs index cb380de5c7..1fdc6ff934 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs @@ -30,7 +30,7 @@ namespace Volo.Abp.Identity includeDetails: false, cancellationToken: cancellationToken ) - )?.ToAbpUserData(); +.ConfigureAwait(false))?.ToAbpUserData(); } public virtual async Task FindByUserNameAsync( @@ -43,7 +43,7 @@ namespace Volo.Abp.Identity includeDetails: false, cancellationToken: cancellationToken ) - )?.ToAbpUserData(); +.ConfigureAwait(false))?.ToAbpUserData(); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs index e92f31797d..cb03869ae6 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs @@ -163,7 +163,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.InsertAsync(user, AutoSaveChanges, cancellationToken); + await _userRepository.InsertAsync(user, AutoSaveChanges, cancellationToken).ConfigureAwait(false); return IdentityResult.Success; } @@ -182,7 +182,7 @@ namespace Volo.Abp.Identity try { - await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken); + await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken).ConfigureAwait(false); } catch (AbpDbConcurrencyException ex) { @@ -207,7 +207,7 @@ namespace Volo.Abp.Identity try { - await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken); + await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken).ConfigureAwait(false); } catch (AbpDbConcurrencyException ex) { @@ -313,14 +313,14 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(normalizedRoleName, nameof(normalizedRoleName)); - var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken); + var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken).ConfigureAwait(false); if (role == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Role {0} does not exist!", normalizedRoleName)); } - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken).ConfigureAwait(false); user.AddRole(role.Id); } @@ -343,13 +343,13 @@ namespace Volo.Abp.Identity throw new ArgumentException(nameof(normalizedRoleName) + " can not be null or whitespace"); } - var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken); + var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken).ConfigureAwait(false); if (role == null) { return; } - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken).ConfigureAwait(false); user.RemoveRole(role.Id); } @@ -388,13 +388,13 @@ namespace Volo.Abp.Identity throw new ArgumentException(nameof(normalizedRoleName) + " can not be null or whitespace"); } - var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken); + var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken).ConfigureAwait(false); if (role == null) { return false; } - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken).ConfigureAwait(false); return user.IsInRole(role.Id); } @@ -411,7 +411,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken).ConfigureAwait(false); return user.Claims.Select(c => c.ToClaim()).ToList(); } @@ -430,7 +430,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(claims, nameof(claims)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken).ConfigureAwait(false); user.AddClaims(_guidGenerator, claims); } @@ -451,7 +451,7 @@ namespace Volo.Abp.Identity Check.NotNull(claim, nameof(claim)); Check.NotNull(newClaim, nameof(newClaim)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken).ConfigureAwait(false); user.ReplaceClaim(claim, newClaim); } @@ -470,7 +470,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(claims, nameof(claims)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken).ConfigureAwait(false); user.RemoveClaims(claims); } @@ -489,7 +489,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(login, nameof(login)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken).ConfigureAwait(false); user.AddLogin(login); } @@ -510,7 +510,7 @@ namespace Volo.Abp.Identity Check.NotNull(loginProvider, nameof(loginProvider)); Check.NotNull(providerKey, nameof(providerKey)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken).ConfigureAwait(false); user.RemoveLogin(loginProvider, providerKey); } @@ -529,7 +529,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken).ConfigureAwait(false); return user.Logins.Select(l => l.ToUserLoginInfo()).ToList(); } @@ -988,7 +988,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken).ConfigureAwait(false); user.SetToken(loginProvider, name, value); } @@ -1007,7 +1007,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken).ConfigureAwait(false); user.RemoveToken(loginProvider, name); } @@ -1026,7 +1026,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken); + await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken).ConfigureAwait(false); return user.FindToken(loginProvider, name)?.Value; } @@ -1053,7 +1053,7 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); - var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken) ?? ""; + var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken).ConfigureAwait(false) ?? ""; if (mergedCodes.Length > 0) { return mergedCodes.Split(';').Length; @@ -1090,12 +1090,12 @@ namespace Volo.Abp.Identity Check.NotNull(user, nameof(user)); Check.NotNull(code, nameof(code)); - var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken) ?? ""; + var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken).ConfigureAwait(false) ?? ""; var splitCodes = mergedCodes.Split(';'); if (splitCodes.Contains(code)) { var updatedCodes = new List(splitCodes.Where(s => s != code)); - await ReplaceCodesAsync(user, updatedCodes, cancellationToken); + await ReplaceCodesAsync(user, updatedCodes, cancellationToken).ConfigureAwait(false); return true; } return false; diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs index d2de24a568..c366591a57 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.Identity public virtual async Task GetRolesAsync(Guid userId) { - return (await _identityUserRepository.GetRoleNamesAsync(userId)).ToArray(); + return (await _identityUserRepository.GetRoleNamesAsync(userId).ConfigureAwait(false)).ToArray(); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs index 95b7a7fe42..d7cb57d396 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs @@ -21,7 +21,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { return await DbSet .WhereIf(ignoredId != null, ct => ct.Id != ignoredId) - .CountAsync(ct => ct.Name == name) > 0; + .CountAsync(ct => ct.Name == name).ConfigureAwait(false) > 0; } public async Task> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter) @@ -34,7 +34,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore ) .OrderBy(sorting ?? "name desc") .PageBy(skipCount, maxResultCount) - .ToListAsync(); + .ToListAsync().ConfigureAwait(false); return identityClaimTypes; } diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs index a9850164ef..731cc6df23 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { return await DbSet .IncludeDetails(includeDetails) - .FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); + .FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListAsync( @@ -39,7 +39,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .IncludeDetails(includeDetails) .OrderBy(sorting ?? nameof(IdentityRole.Name)) .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public override IQueryable WithDetails() diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs index cab891bc94..e3dfe6ee8c 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs @@ -28,7 +28,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .FirstOrDefaultAsync( u => u.NormalizedUserName == normalizedUserName, GetCancellationToken(cancellationToken) - ); + ).ConfigureAwait(false); } public virtual async Task> GetRoleNamesAsync( @@ -40,7 +40,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore where userRole.UserId == id select role.Name; - return await query.ToListAsync(GetCancellationToken(cancellationToken)); + return await query.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task FindByLoginAsync( @@ -52,7 +52,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore return await DbSet .IncludeDetails(includeDetails) .Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey)) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task FindByNormalizedEmailAsync( @@ -62,7 +62,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { return await DbSet .IncludeDetails(includeDetails) - .FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)); + .FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListByClaimAsync( @@ -73,7 +73,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore return await DbSet .IncludeDetails(includeDetails) .Where(u => u.Claims.Any(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value)) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListByNormalizedRoleNameAsync( @@ -83,7 +83,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore { var role = await DbContext.Roles .Where(x => x.NormalizedName == normalizedRoleName) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); if (role == null) { @@ -93,7 +93,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore return await DbSet .IncludeDetails(includeDetails) .Where(u => u.Roles.Any(r => r.RoleId == role.Id)) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListAsync( @@ -114,7 +114,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore ) .OrderBy(sorting ?? nameof(IdentityUser.UserName)) .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetRolesAsync( @@ -127,7 +127,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore where userRole.UserId == id select role; - return await query.ToListAsync(GetCancellationToken(cancellationToken)); + return await query.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task GetCountAsync( @@ -140,7 +140,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore u.UserName.Contains(filter) || u.Email.Contains(filter) ) - .LongCountAsync(GetCancellationToken(cancellationToken)); + .LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public override IQueryable WithDetails() diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs index a5fffe9848..1e5934cee5 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.Identity public async Task GetRolesAsync(Guid userId) { - var output = await _userAppService.GetRolesAsync(userId); + var output = await _userAppService.GetRolesAsync(userId).ConfigureAwait(false); return output.Items.Select(r => r.Name).ToArray(); } } diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs index 16ba528412..beed5130f1 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs @@ -22,13 +22,13 @@ namespace Volo.Abp.Identity.MongoDB { return await GetMongoQueryable() .Where(ct => ct.Name == name) - .AnyAsync(); + .AnyAsync().ConfigureAwait(false); } else { return await GetMongoQueryable() .Where(ct => ct.Id != ignoredId && ct.Name == name) - .AnyAsync(); + .AnyAsync().ConfigureAwait(false); } } @@ -43,7 +43,7 @@ namespace Volo.Abp.Identity.MongoDB .OrderBy(sorting ?? nameof(IdentityClaimType.Name)) .As>() .PageBy>(skipCount, maxResultCount) - .ToListAsync(); + .ToListAsync().ConfigureAwait(false); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs index 50c1403a03..4bae372c8e 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs @@ -27,7 +27,7 @@ namespace Volo.Abp.Identity.MongoDB bool includeDetails = true, CancellationToken cancellationToken = default) { - return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); + return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task> GetListAsync( @@ -41,7 +41,7 @@ namespace Volo.Abp.Identity.MongoDB .OrderBy(sorting ?? nameof(IdentityRole.Name)) .As>() .PageBy>(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs index 3d6f188c56..9c3b8bcd0e 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs @@ -32,16 +32,16 @@ namespace Volo.Abp.Identity.MongoDB .FirstOrDefaultAsync( u => u.NormalizedUserName == normalizedUserName, GetCancellationToken(cancellationToken) - ); + ).ConfigureAwait(false); } public async Task> GetRoleNamesAsync( Guid id, CancellationToken cancellationToken = default) { - var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)); + var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)).ConfigureAwait(false); var roleIds = user.Roles.Select(r => r.RoleId).ToArray(); - return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(GetCancellationToken(cancellationToken)); + return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task FindByLoginAsync( @@ -51,8 +51,8 @@ namespace Volo.Abp.Identity.MongoDB CancellationToken cancellationToken = default) { return await GetMongoQueryable() - .Where(u=> u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey)) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + .Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey)) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task FindByNormalizedEmailAsync( @@ -60,7 +60,7 @@ namespace Volo.Abp.Identity.MongoDB bool includeDetails = true, CancellationToken cancellationToken = default) { - return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)); + return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task> GetListByClaimAsync( @@ -70,7 +70,7 @@ namespace Volo.Abp.Identity.MongoDB { return await GetMongoQueryable() .Where(u => u.Claims.Any(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value)) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task> GetListByNormalizedRoleNameAsync( @@ -78,7 +78,7 @@ namespace Volo.Abp.Identity.MongoDB bool includeDetails = false, CancellationToken cancellationToken = default) { - var role = await DbContext.Roles.AsQueryable().Where(x => x.NormalizedName == normalizedRoleName).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + var role = await DbContext.Roles.AsQueryable().Where(x => x.NormalizedName == normalizedRoleName).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); if (role == null) { @@ -87,7 +87,7 @@ namespace Volo.Abp.Identity.MongoDB return await GetMongoQueryable() .Where(u => u.Roles.Any(r => r.RoleId == role.Id)) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task> GetListAsync( @@ -108,7 +108,7 @@ namespace Volo.Abp.Identity.MongoDB .OrderBy(sorting ?? nameof(IdentityUser.UserName)) .As>() .PageBy>(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task> GetRolesAsync( @@ -116,9 +116,9 @@ namespace Volo.Abp.Identity.MongoDB bool includeDetails = false, CancellationToken cancellationToken = default) { - var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)); + var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)).ConfigureAwait(false); var roleIds = user.Roles.Select(r => r.RoleId).ToArray(); - return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).ToListAsync(GetCancellationToken(cancellationToken)); + return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task GetCountAsync( @@ -132,7 +132,7 @@ namespace Volo.Abp.Identity.MongoDB u.UserName.Contains(filter) || u.Email.Contains(filter) ) - .LongCountAsync(GetCancellationToken(cancellationToken)); + .LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs index 34dc3dd4cd..d6d61dcff4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs @@ -18,8 +18,8 @@ namespace Volo.Abp.Identity.Web.Navigation var authorizationService = context.ServiceProvider.GetRequiredService(); - var hasRolePermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default); - var hasUserPermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Users.Default); + var hasRolePermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default).ConfigureAwait(false); + var hasUserPermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Users.Default).ConfigureAwait(false); if (hasRolePermission || hasUserPermission) { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs index b3fdad3a95..4861944c7f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs @@ -21,7 +21,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles ValidateModel(); var input = ObjectMapper.Map(Role); - await _identityRoleAppService.CreateAsync(input); + await _identityRoleAppService.CreateAsync(input).ConfigureAwait(false); return NoContent(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs index 8416e171b0..42f13b4bf5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs @@ -22,7 +22,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles { Role = ObjectMapper.Map( await _identityRoleAppService.GetAsync(id) - ); +.ConfigureAwait(false)); } public async Task OnPostAsync() @@ -30,7 +30,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles ValidateModel(); var input = ObjectMapper.Map(Role); - await _identityRoleAppService.UpdateAsync(Role.Id, input); + await _identityRoleAppService.UpdateAsync(Role.Id, input).ConfigureAwait(false); return NoContent(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index 7b3822e64b..e2dbedc660 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -28,7 +28,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users { UserInfo = new UserInfoViewModel(); - var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()); + var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false); Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList.Items); @@ -45,7 +45,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users var input = ObjectMapper.Map(UserInfo); input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray(); - await _identityUserAppService.CreateAsync(input); + await _identityUserAppService.CreateAsync(input).ConfigureAwait(false); return NoContent(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 4d4adf7a70..7a55711bd3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -28,13 +28,13 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public async Task OnGetAsync(Guid id) { - UserInfo = ObjectMapper.Map(await _identityUserAppService.GetAsync(id)); + UserInfo = ObjectMapper.Map(await _identityUserAppService.GetAsync(id).ConfigureAwait(false)); Roles = ObjectMapper.Map, AssignedRoleViewModel[]>( - (await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto())).Items + (await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false)).Items ); - var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); + var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id).ConfigureAwait(false)).Items.Select(r => r.Name).ToList(); foreach (var role in Roles) { if (userRoleNames.Contains(role.Name)) @@ -50,7 +50,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users var input = ObjectMapper.Map(UserInfo); input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray(); - await _identityUserAppService.UpdateAsync(UserInfo.Id, input); + await _identityUserAppService.UpdateAsync(UserInfo.Id, input).ConfigureAwait(false); return NoContent(); } diff --git a/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs b/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs index 09fb389163..2c7920539c 100644 --- a/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs +++ b/modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs @@ -39,11 +39,11 @@ namespace Volo.Abp.PermissionManagement.Identity if (providerName == UserPermissionValueProvider.ProviderName) { var userId = Guid.Parse(providerKey); - var roleNames = await _userRoleFinder.GetRolesAsync(userId); + var roleNames = await _userRoleFinder.GetRolesAsync(userId).ConfigureAwait(false); foreach (var roleName in roleNames) { - var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, roleName); + var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, roleName).ConfigureAwait(false); if (permissionGrant != null) { return new PermissionValueProviderGrantInfo(true, roleName); diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs index 663cc07786..b743ee54e9 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs @@ -23,11 +23,11 @@ namespace Volo.Abp.Identity { //Arrange - var moderator = await GetRoleAsync("moderator"); + var moderator = await GetRoleAsync("moderator").ConfigureAwait(false); //Act - var result = await _roleAppService.GetAsync(moderator.Id); + var result = await _roleAppService.GetAsync(moderator.Id).ConfigureAwait(false); //Assert @@ -39,7 +39,7 @@ namespace Volo.Abp.Identity { //Act - var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto()); + var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false); //Assert @@ -58,14 +58,14 @@ namespace Volo.Abp.Identity //Act - var result = await _roleAppService.CreateAsync(input); + var result = await _roleAppService.CreateAsync(input).ConfigureAwait(false); //Assert result.Id.ShouldNotBe(Guid.Empty); result.Name.ShouldBe(input.Name); - var role = await _roleRepository.GetAsync(result.Id); + var role = await _roleRepository.GetAsync(result.Id).ConfigureAwait(false); role.Name.ShouldBe(input.Name); } @@ -74,7 +74,7 @@ namespace Volo.Abp.Identity { //Arrange - var moderator = await GetRoleAsync("moderator"); + var moderator = await GetRoleAsync("moderator").ConfigureAwait(false); var input = new IdentityRoleUpdateDto { @@ -86,14 +86,14 @@ namespace Volo.Abp.Identity //Act - var result = await _roleAppService.UpdateAsync(moderator.Id, input); + var result = await _roleAppService.UpdateAsync(moderator.Id, input).ConfigureAwait(false); //Assert result.Id.ShouldBe(moderator.Id); result.Name.ShouldBe(input.Name); - var updatedRole = await _roleRepository.GetAsync(moderator.Id); + var updatedRole = await _roleRepository.GetAsync(moderator.Id).ConfigureAwait(false); updatedRole.Name.ShouldBe(input.Name); } @@ -102,15 +102,15 @@ namespace Volo.Abp.Identity { //Arrange - var moderator = await GetRoleAsync("moderator"); + var moderator = await GetRoleAsync("moderator").ConfigureAwait(false); //Act - await _roleAppService.DeleteAsync(moderator.Id); + await _roleAppService.DeleteAsync(moderator.Id).ConfigureAwait(false); //Assert - (await FindRoleAsync("moderator")).ShouldBeNull(); + (await FindRoleAsync("moderator").ConfigureAwait(false)).ShouldBeNull(); } private async Task GetRoleAsync(string roleName) diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs index 6fbf23ed73..19cfb705fd 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs @@ -28,7 +28,7 @@ namespace Volo.Abp.Identity //Act - var result = await _userAppService.GetAsync(johnNash.Id); + var result = await _userAppService.GetAsync(johnNash.Id).ConfigureAwait(false); //Assert @@ -44,7 +44,7 @@ namespace Volo.Abp.Identity { //Act - var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); + var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()).ConfigureAwait(false); //Assert @@ -69,7 +69,7 @@ namespace Volo.Abp.Identity //Act - var result = await _userAppService.CreateAsync(input); + var result = await _userAppService.CreateAsync(input).ConfigureAwait(false); //Assert @@ -79,7 +79,7 @@ namespace Volo.Abp.Identity result.LockoutEnabled.ShouldBe(input.LockoutEnabled); result.PhoneNumber.ShouldBe(input.PhoneNumber); - var user = await _userRepository.GetAsync(result.Id); + var user = await _userRepository.GetAsync(result.Id).ConfigureAwait(false); user.Id.ShouldBe(result.Id); user.UserName.ShouldBe(input.UserName); user.Email.ShouldBe(input.Email); @@ -110,7 +110,7 @@ namespace Volo.Abp.Identity //Act - var result = await _userAppService.UpdateAsync(johnNash.Id, input); + var result = await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false); //Assert @@ -120,7 +120,7 @@ namespace Volo.Abp.Identity result.LockoutEnabled.ShouldBe(input.LockoutEnabled); result.PhoneNumber.ShouldBe(input.PhoneNumber); - var user = await _userRepository.GetAsync(result.Id); + var user = await _userRepository.GetAsync(result.Id).ConfigureAwait(false); user.Id.ShouldBe(result.Id); user.UserName.ShouldBe(input.UserName); user.Email.ShouldBe(input.Email); @@ -134,7 +134,7 @@ namespace Volo.Abp.Identity public async Task UpdateAsync_Concurrency_Exception() { //Get user - var johnNash = await _userAppService.GetAsync(_testData.UserJohnId); + var johnNash = await _userAppService.GetAsync(_testData.UserJohnId).ConfigureAwait(false); //Act @@ -151,13 +151,13 @@ namespace Volo.Abp.Identity ConcurrencyStamp = johnNash.ConcurrencyStamp }; - await _userAppService.UpdateAsync(johnNash.Id, input); + await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false); //Second update with same input will throw exception because the entity has been modified (await Assert.ThrowsAsync(async () => { - await _userAppService.UpdateAsync(johnNash.Id, input); - })).Message.ShouldContain("Optimistic concurrency failure"); + await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false); + }).ConfigureAwait(false)).Message.ShouldContain("Optimistic concurrency failure"); } [Fact] @@ -169,7 +169,7 @@ namespace Volo.Abp.Identity //Act - await _userAppService.DeleteAsync(johnNash.Id); + await _userAppService.DeleteAsync(johnNash.Id).ConfigureAwait(false); //Assert @@ -185,7 +185,7 @@ namespace Volo.Abp.Identity //Act - var result = await _userAppService.GetRolesAsync(johnNash.Id); + var result = await _userAppService.GetRolesAsync(johnNash.Id).ConfigureAwait(false); //Assert @@ -209,11 +209,11 @@ namespace Volo.Abp.Identity { RoleNames = new[] { "admin", "moderator" } } - ); + ).ConfigureAwait(false); //Assert - var roleNames = await _userRepository.GetRoleNamesAsync(johnNash.Id); + var roleNames = await _userRepository.GetRoleNamesAsync(johnNash.Id).ConfigureAwait(false); roleNames.Count.ShouldBe(2); roleNames.ShouldContain("admin"); roleNames.ShouldContain("moderator"); diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs index 227977cf15..f28c65be83 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs @@ -24,32 +24,32 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByIdAsync() { - var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserLookupAppService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName); + (await _identityUserLookupAppService.FindByIdAsync(user.Id).ConfigureAwait(false)).UserName.ShouldBe(user.UserName); } [Fact] public async Task FindById_NotExist_Should_Return_Null() { - var user = await _identityUserLookupAppService.FindByIdAsync(Guid.NewGuid()); + var user = await _identityUserLookupAppService.FindByIdAsync(Guid.NewGuid()).ConfigureAwait(false); user.ShouldBeNull(); } [Fact] public async Task FindByUserNameAsync() { - var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserLookupAppService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName); + (await _identityUserLookupAppService.FindByUserNameAsync(user.UserName).ConfigureAwait(false)).UserName.ShouldBe(user.UserName); } [Fact] public async Task FindByUserName_NotExist_Should_Return_Null() { - var user = await _identityUserLookupAppService.FindByUserNameAsync(Guid.NewGuid().ToString()); + var user = await _identityUserLookupAppService.FindByUserNameAsync(Guid.NewGuid().ToString()).ConfigureAwait(false); user.ShouldBeNull(); } } diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs index fc0334ce05..c6e2d45055 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs @@ -34,7 +34,7 @@ namespace Volo.Abp.Identity _currentUser.IsAuthenticated.Returns(true); //Act - var result = await _profileAppService.GetAsync(); + var result = await _profileAppService.GetAsync().ConfigureAwait(false); //Assert var johnNash = GetUser("john.nash"); @@ -62,7 +62,7 @@ namespace Volo.Abp.Identity }; //Act - var result = await _profileAppService.UpdateAsync(input); + var result = await _profileAppService.UpdateAsync(input).ConfigureAwait(false); //Assert result.UserName.ShouldBe(input.UserName); diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs index 95e8f925c4..e16228290c 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs @@ -40,11 +40,11 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); - await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io"); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); + await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io").ConfigureAwait(false); _testCounter.GetValue("EntityUpdatedEto").ShouldBe(0); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } _testCounter.GetValue("EntityUpdatedEto").ShouldBe(1); diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityClaimTypeManager_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityClaimTypeManager_Tests.cs index c5c68d40c6..c7622bec8b 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityClaimTypeManager_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityClaimTypeManager_Tests.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.Identity { var claimType = await _claimTypeManager.CreateAsync(new IdentityClaimType(Guid.NewGuid(), "Phone", false, false, null, - null, null, IdentityClaimValueType.String)); + null, null, IdentityClaimValueType.String)).ConfigureAwait(false); claimType.ShouldNotBeNull(); claimType.Name.ShouldBe("Phone"); @@ -36,17 +36,17 @@ namespace Volo.Abp.Identity { await Assert.ThrowsAnyAsync(async () => await _claimTypeManager.CreateAsync( new IdentityClaimType( - Guid.NewGuid(), "Age"))); + Guid.NewGuid(), "Age")).ConfigureAwait(false)).ConfigureAwait(false); } [Fact] public async Task UpdateAsync() { - var ageClaim = await _identityClaimTypeRepository.FindAsync(_testData.AgeClaimId); + var ageClaim = await _identityClaimTypeRepository.FindAsync(_testData.AgeClaimId).ConfigureAwait(false); ageClaim.ShouldNotBeNull(); ageClaim.Description = "this is age"; - var updatedAgeClaimType = await _claimTypeManager.UpdateAsync(ageClaim); + var updatedAgeClaimType = await _claimTypeManager.UpdateAsync(ageClaim).ConfigureAwait(false); updatedAgeClaimType.ShouldNotBeNull(); updatedAgeClaimType.Description.ShouldBe("this is age"); } @@ -57,7 +57,7 @@ namespace Volo.Abp.Identity { await Assert.ThrowsAnyAsync(async () => await _claimTypeManager.UpdateAsync( new IdentityClaimType( - Guid.NewGuid(), "Age"))); + Guid.NewGuid(), "Age")).ConfigureAwait(false)).ConfigureAwait(false); } @@ -65,9 +65,9 @@ namespace Volo.Abp.Identity public async Task Static_IdentityClaimType_Cant_Not_Update() { var phoneClaim = new IdentityClaimType(Guid.NewGuid(), "Phone", true, true); - await _identityClaimTypeRepository.InsertAsync(phoneClaim); + await _identityClaimTypeRepository.InsertAsync(phoneClaim).ConfigureAwait(false); - await Assert.ThrowsAnyAsync(async () => await _claimTypeManager.UpdateAsync(phoneClaim)); + await Assert.ThrowsAnyAsync(async () => await _claimTypeManager.UpdateAsync(phoneClaim).ConfigureAwait(false)).ConfigureAwait(false); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleManager_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleManager_Tests.cs index 4314f3eac6..fbb2a3c023 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleManager_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleManager_Tests.cs @@ -28,7 +28,7 @@ namespace Volo.Abp.Identity [Fact] public async Task GetByIdAsync() { - var role = await _identityRoleManager.FindByIdAsync(_testData.RoleModeratorId.ToString()); + var role = await _identityRoleManager.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false); role.ShouldNotBeNull(); role.Name.ShouldBe("moderator"); @@ -37,10 +37,10 @@ namespace Volo.Abp.Identity [Fact] public async Task SetRoleNameAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - (await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue(); + (await _identityRoleManager.SetRoleNameAsync(role, "teacher").ConfigureAwait(false)).Succeeded.ShouldBeTrue(); role.Name.ShouldBe("teacher"); } @@ -48,12 +48,12 @@ namespace Volo.Abp.Identity [Fact] public async Task DeleteAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - await _identityRoleManager.DeleteAsync(role); + await _identityRoleManager.DeleteAsync(role).ConfigureAwait(false); - (await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"))).ShouldBeNull(); + (await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false)).ShouldBeNull(); } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleStore_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleStore_Tests.cs index 11345a4a46..9a4d9d194d 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleStore_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityRoleStore_Tests.cs @@ -32,9 +32,9 @@ namespace Volo.Abp.Identity { var roleId = Guid.NewGuid(); var role = new IdentityRole(roleId, "teacher"); - (await _identityRoleStore.CreateAsync(role)).Succeeded.ShouldBeTrue(); + (await _identityRoleStore.CreateAsync(role).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); - var teacher = await _identityRoleStore.FindByIdAsync(roleId.ToString()); + var teacher = await _identityRoleStore.FindByIdAsync(roleId.ToString()).ConfigureAwait(false); teacher.ShouldNotBeNull(); teacher.Name.ShouldBe("teacher"); @@ -43,11 +43,11 @@ namespace Volo.Abp.Identity [Fact] public async Task UpdateAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); role.IsDefault = true; - await _identityRoleStore.UpdateAsync(role); + await _identityRoleStore.UpdateAsync(role).ConfigureAwait(false); role.IsDefault.ShouldBeTrue(); } @@ -56,40 +56,40 @@ namespace Volo.Abp.Identity [Fact] public async Task DeleteAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - await _identityRoleStore.DeleteAsync(role); + await _identityRoleStore.DeleteAsync(role).ConfigureAwait(false); - (await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString())).ShouldBeNull(); + (await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task GetRoleIdAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - (await _identityRoleStore.GetRoleIdAsync(role)).ShouldBe(_testData.RoleModeratorId.ToString()); + (await _identityRoleStore.GetRoleIdAsync(role).ConfigureAwait(false)).ShouldBe(_testData.RoleModeratorId.ToString()); } [Fact] public async Task GetRoleNameAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - (await _identityRoleStore.GetRoleNameAsync(role)).ShouldBe(role.Name); + (await _identityRoleStore.GetRoleNameAsync(role).ConfigureAwait(false)).ShouldBe(role.Name); } [Fact] public async Task SetRoleNameAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - await _identityRoleStore.SetRoleNameAsync(role, "teacher"); + await _identityRoleStore.SetRoleNameAsync(role, "teacher").ConfigureAwait(false); role.Name.ShouldBe("teacher"); } @@ -97,7 +97,7 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByIdAsync() { - var role = await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString()); + var role = await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false); role.ShouldNotBeNull(); role.Name.ShouldBe("moderator"); @@ -106,7 +106,7 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByNameAsync() { - var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); role.Name.ShouldBe("moderator"); @@ -115,19 +115,19 @@ namespace Volo.Abp.Identity [Fact] public async Task GetNormalizedRoleNameAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - (await _identityRoleStore.GetNormalizedRoleNameAsync(role)).ShouldBe(role.NormalizedName); + (await _identityRoleStore.GetNormalizedRoleNameAsync(role).ConfigureAwait(false)).ShouldBe(role.NormalizedName); } [Fact] public async Task SetNormalizedRoleNameAsync() { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.NormalizeName("teacher")); + await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.NormalizeName("teacher")).ConfigureAwait(false); role.NormalizedName.ShouldBe(_lookupNormalizer.NormalizeName("teacher")); } @@ -137,15 +137,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - var claims = await _identityRoleStore.GetClaimsAsync(role); + var claims = await _identityRoleStore.GetClaimsAsync(role).ConfigureAwait(false); claims.ShouldNotBeEmpty(); claims.ShouldContain(x => x.Type == "test-claim" && x.Value == "test-value"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -156,7 +156,7 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); role.Claims.Add(new IdentityRoleClaim(Guid.NewGuid(), role.Id, "my-claim", "my-value", role.TenantId)); @@ -164,7 +164,7 @@ namespace Volo.Abp.Identity //role.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -173,7 +173,7 @@ namespace Volo.Abp.Identity throw; } - var role2 = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role2 = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role2.ShouldNotBeNull(); role2.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value"); } @@ -183,14 +183,14 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")); + var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.ShouldNotBeNull(); - await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value")); + await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value")).ConfigureAwait(false); role.Claims.ShouldNotContain(x => x.ClaimType == "test-claim" && x.ClaimValue == "test-value"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs index 761655deb2..bc03f35c49 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.Identity [Fact] public async Task GetByIdAsync() { - var user = await _identityUserManager.GetByIdAsync(_testData.UserJohnId); + var user = await _identityUserManager.GetByIdAsync(_testData.UserJohnId).ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); @@ -43,18 +43,18 @@ namespace Volo.Abp.Identity using (var uow = _unitOfWorkManager.Begin()) { var user = await _identityUserRepository.FindByNormalizedUserNameAsync( - _lookupNormalizer.NormalizeName("david")); + _lookupNormalizer.NormalizeName("david")).ConfigureAwait(false); user.ShouldNotBeNull(); var identityResult = await _identityUserManager.SetRolesAsync(user, new List() { "moderator", - }); + }).ConfigureAwait(false); identityResult.Succeeded.ShouldBeTrue(); user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -64,23 +64,23 @@ namespace Volo.Abp.Identity using (var uow = _unitOfWorkManager.Begin()) { var roleSupporter = - await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("supporter")); + await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("supporter")).ConfigureAwait(false); roleSupporter.ShouldNotBeNull(); var user = await _identityUserRepository.FindByNormalizedUserNameAsync( - _lookupNormalizer.NormalizeName("john.nash")); + _lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var identityResult = await _identityUserManager.SetRolesAsync(user, new List() { "admin", - }); + }).ConfigureAwait(false); identityResult.Succeeded.ShouldBeTrue(); user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId); user.Roles.ShouldNotContain(x => x.RoleId == roleSupporter.Id); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserStore_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserStore_Tests.cs index 6e84a88450..6c7b6610ae 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserStore_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserStore_Tests.cs @@ -29,29 +29,29 @@ namespace Volo.Abp.Identity [Fact] public async Task GetUserIdAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetUserIdAsync(user)).ShouldBe(user.Id.ToString()); + (await _identityUserStore.GetUserIdAsync(user).ConfigureAwait(false)).ShouldBe(user.Id.ToString()); } [Fact] public async Task GetUserNameAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetUserNameAsync(user)).ShouldBe(user.UserName); + (await _identityUserStore.GetUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.UserName); } [Fact] public async Task SetUserNameAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetUserNameAsync(user, "bob.lee"); + await _identityUserStore.SetUserNameAsync(user, "bob.lee").ConfigureAwait(false); user.UserName.ShouldBe("bob.lee"); //user.NormalizedUserName.ShouldBe(_lookupNormalizer.Normalize("bob.lee")); } @@ -60,19 +60,19 @@ namespace Volo.Abp.Identity [Fact] public async Task GetNormalizedUserNameAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetNormalizedUserNameAsync(user)).ShouldBe(user.NormalizedUserName); + (await _identityUserStore.GetNormalizedUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedUserName); } [Fact] public async Task SetNormalizedUserNameAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee")); + await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false); user.NormalizedUserName.ShouldBe(_lookupNormalizer.NormalizeName("bob.lee")); } @@ -83,9 +83,9 @@ namespace Volo.Abp.Identity var userId = Guid.NewGuid(); var user = new IdentityUser(userId, "bob.lee", "bob.lee@abp.io"); - await _identityUserStore.CreateAsync(user); + await _identityUserStore.CreateAsync(user).ConfigureAwait(false); - var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee")); + var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false); bobLee.ShouldNotBeNull(); bobLee.UserName.ShouldBe("bob.lee"); bobLee.Email.ShouldBe("bob.lee@abp.io"); @@ -94,26 +94,26 @@ namespace Volo.Abp.Identity [Fact] public async Task UpdateAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Name = "lee"; - (await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); + (await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); - (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).Name + (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).Name .ShouldBe("lee"); } [Fact] public async Task Update_Concurrency() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); + (await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); user.ConcurrencyStamp = Guid.NewGuid().ToString(); - var identityResult = await _identityUserStore.UpdateAsync(user); + var identityResult = await _identityUserStore.UpdateAsync(user).ConfigureAwait(false); identityResult.Succeeded.ShouldBeFalse(); identityResult.Errors.ShouldContain(x => @@ -126,19 +126,19 @@ namespace Volo.Abp.Identity [Fact] public async Task DeleteAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.DeleteAsync(user)).Succeeded.ShouldBeTrue(); + (await _identityUserStore.DeleteAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); - (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).ShouldBeNull(); + (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task FindByIdAsync() { - var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString()); + var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString()).ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); @@ -148,7 +148,7 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByNameAsync() { - var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); @@ -158,11 +158,11 @@ namespace Volo.Abp.Identity [Fact] public async Task SetPasswordHashAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.PasswordHash.ShouldBeNull(); - await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); + await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); user.PasswordHash.ShouldBe("P@ssw0rd"); } @@ -170,23 +170,23 @@ namespace Volo.Abp.Identity [Fact] public async Task GetPasswordHashAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); + await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); - (await _identityUserStore.GetPasswordHashAsync(user)).ShouldBe("P@ssw0rd"); + (await _identityUserStore.GetPasswordHashAsync(user).ConfigureAwait(false)).ShouldBe("P@ssw0rd"); } [Fact] public async Task HasPasswordAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.HasPasswordAsync(user)).ShouldBeFalse(); + (await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeFalse(); - await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); - (await _identityUserStore.HasPasswordAsync(user)).ShouldBeTrue(); + await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); + (await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeTrue(); } [Fact] @@ -194,15 +194,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Roles.ShouldBeEmpty(); - await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")); + await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -211,15 +211,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); - await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")); + await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -227,10 +227,10 @@ namespace Volo.Abp.Identity [Fact] public async Task GetRolesAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - var roleNames = await _identityUserStore.GetRolesAsync(user); + var roleNames = await _identityUserStore.GetRolesAsync(user).ConfigureAwait(false); roleNames.ShouldNotBeEmpty(); roleNames.ShouldContain(x => x == "moderator"); roleNames.ShouldContain(x => x == "supporter"); @@ -241,13 +241,13 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"))).ShouldBeTrue(); - (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist"))).ShouldBeFalse(); + (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false)).ShouldBeTrue(); + (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist")).ConfigureAwait(false)).ShouldBeFalse(); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -256,14 +256,14 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - var claims = await _identityUserStore.GetClaimsAsync(user); + var claims = await _identityUserStore.GetClaimsAsync(user).ConfigureAwait(false); claims.ShouldNotBeEmpty(); claims.ShouldContain(x => x.Type == "TestClaimType" && x.Value == "42"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -272,18 +272,18 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Claims.ShouldNotContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); await _identityUserStore.AddClaimsAsync(user, new List() { new Claim("MyClaimType", "MyClaimValue") - }); + }).ConfigureAwait(false); user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -292,15 +292,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue")); + await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue")).ConfigureAwait(false); user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42"); user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -309,17 +309,17 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); await _identityUserStore.RemoveClaimsAsync(user, new List() { new Claim("TestClaimType", "42") - }); + }).ConfigureAwait(false); user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -328,15 +328,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Logins.ShouldNotContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john"); - await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash")); + await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash")).ConfigureAwait(false); user.Logins.ShouldContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -345,15 +345,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); - await _identityUserStore.RemoveLoginAsync(user, "github", "john"); + await _identityUserStore.RemoveLoginAsync(user, "github", "john").ConfigureAwait(false); user.Logins.ShouldNotContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -363,16 +363,16 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - var logins = await _identityUserStore.GetLoginsAsync(user); + var logins = await _identityUserStore.GetLoginsAsync(user).ConfigureAwait(false); logins.ShouldNotBeNull(); logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); logins.ShouldContain(x => x.LoginProvider == "twitter" && x.ProviderKey == "johnx"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -380,7 +380,7 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByLoginAsync() { - var user = await _identityUserStore.FindByLoginAsync("github", "john"); + var user = await _identityUserStore.FindByLoginAsync("github", "john").ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); } @@ -389,21 +389,21 @@ namespace Volo.Abp.Identity [Fact] public async Task GetEmailConfirmedAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetEmailConfirmedAsync(user)).ShouldBe(user.EmailConfirmed); + (await _identityUserStore.GetEmailConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.EmailConfirmed); } [Fact] public async Task SetEmailConfirmedAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var emailConfirmed = user.EmailConfirmed; - await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed); + await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed).ConfigureAwait(false); user.EmailConfirmed.ShouldBe(!emailConfirmed); } @@ -411,10 +411,10 @@ namespace Volo.Abp.Identity [Fact] public async Task SetEmailAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io"); + await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io").ConfigureAwait(false); user.Email.ShouldBe("john.nash.kobe@abp.io"); //user.NormalizedEmail.ShouldBe(_lookupNormalizer.Normalize("john.nash.kobe@abp.io")); @@ -423,28 +423,28 @@ namespace Volo.Abp.Identity [Fact] public async Task GetEmailAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetEmailAsync(user)).ShouldBe(user.Email); + (await _identityUserStore.GetEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.Email); } [Fact] public async Task GetNormalizedEmailAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetNormalizedEmailAsync(user)).ShouldBe(user.NormalizedEmail); + (await _identityUserStore.GetNormalizedEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedEmail); } [Fact] public async Task SetNormalizedEmailAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")); + await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")).ConfigureAwait(false); user.NormalizedEmail.ShouldBe(_lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")); } @@ -452,7 +452,7 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByEmailAsync() { - var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io")); + var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io")).ConfigureAwait(false); user.ShouldNotBeNull(); user.Email.ShouldBe("john.nash@abp.io"); @@ -461,19 +461,19 @@ namespace Volo.Abp.Identity [Fact] public async Task GetLockoutEndDateAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetLockoutEndDateAsync(user)).ShouldBe(user.LockoutEnd); + (await _identityUserStore.GetLockoutEndDateAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnd); } [Fact] public async Task SetLockoutEndDateAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")); + await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")).ConfigureAwait(false); user.LockoutEnd.ShouldBe(DateTimeOffset.Parse("01/01/2019")); } @@ -482,11 +482,11 @@ namespace Volo.Abp.Identity [Fact] public async Task IncrementAccessFailedCountAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var count = user.AccessFailedCount; - await _identityUserStore.IncrementAccessFailedCountAsync(user); + await _identityUserStore.IncrementAccessFailedCountAsync(user).ConfigureAwait(false); user.AccessFailedCount.ShouldBe(count + 1); } @@ -494,10 +494,10 @@ namespace Volo.Abp.Identity [Fact] public async Task ResetAccessFailedCountAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.ResetAccessFailedCountAsync(user); + await _identityUserStore.ResetAccessFailedCountAsync(user).ConfigureAwait(false); user.AccessFailedCount.ShouldBe(0); } @@ -505,29 +505,29 @@ namespace Volo.Abp.Identity [Fact] public async Task GetAccessFailedCountAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetAccessFailedCountAsync(user)).ShouldBe(user.AccessFailedCount); + (await _identityUserStore.GetAccessFailedCountAsync(user).ConfigureAwait(false)).ShouldBe(user.AccessFailedCount); } [Fact] public async Task GetLockoutEnabledAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetLockoutEnabledAsync(user)).ShouldBe(user.LockoutEnabled); + (await _identityUserStore.GetLockoutEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnabled); } [Fact] public async Task SetLockoutEnabledAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var lockoutEnabled = user.LockoutEnabled; - await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled); + await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled).ConfigureAwait(false); user.LockoutEnabled.ShouldBe(!lockoutEnabled); } @@ -536,10 +536,10 @@ namespace Volo.Abp.Identity [Fact] public async Task SetPhoneNumberAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetPhoneNumberAsync(user, "13800138000"); + await _identityUserStore.SetPhoneNumberAsync(user, "13800138000").ConfigureAwait(false); user.PhoneNumber.ShouldBe("13800138000"); } @@ -548,30 +548,30 @@ namespace Volo.Abp.Identity [Fact] public async Task GetPhoneNumberAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetPhoneNumberAsync(user)).ShouldBe(user.PhoneNumber); + (await _identityUserStore.GetPhoneNumberAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumber); } [Fact] public async Task GetPhoneNumberConfirmedAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetPhoneNumberConfirmedAsync(user)).ShouldBe(user.PhoneNumberConfirmed); + (await _identityUserStore.GetPhoneNumberConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumberConfirmed); } [Fact] public async Task SetPhoneNumberConfirmedAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var phoneNumberConfirmed = user.PhoneNumberConfirmed; - await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed); + await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed).ConfigureAwait(false); user.PhoneNumberConfirmed.ShouldBe(!phoneNumberConfirmed); } @@ -580,11 +580,11 @@ namespace Volo.Abp.Identity [Fact] public async Task SetSecurityStampAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var securityStamp = Guid.NewGuid().ToString(); - await _identityUserStore.SetSecurityStampAsync(user, securityStamp); + await _identityUserStore.SetSecurityStampAsync(user, securityStamp).ConfigureAwait(false); user.SecurityStamp.ShouldBe(securityStamp); } @@ -592,21 +592,21 @@ namespace Volo.Abp.Identity [Fact] public async Task GetSecurityStampAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetSecurityStampAsync(user)).ShouldBe(user.SecurityStamp); + (await _identityUserStore.GetSecurityStampAsync(user).ConfigureAwait(false)).ShouldBe(user.SecurityStamp); } [Fact] public async Task SetTwoFactorEnabledAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); var twoFactorEnabled = user.TwoFactorEnabled; - await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled); + await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled).ConfigureAwait(false); user.TwoFactorEnabled.ShouldBe(!twoFactorEnabled); } @@ -615,16 +615,16 @@ namespace Volo.Abp.Identity [Fact] public async Task GetTwoFactorEnabledAsync() { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetTwoFactorEnabledAsync(user)).ShouldBe(user.TwoFactorEnabled); + (await _identityUserStore.GetTwoFactorEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.TwoFactorEnabled); } [Fact] public async Task GetUsersForClaimAsync() { - var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42")); + var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42")).ConfigureAwait(false); user.ShouldNotBeNull(); user.ShouldNotBeEmpty(); user.ShouldContain(x => x.UserName == "john.nash"); @@ -633,7 +633,7 @@ namespace Volo.Abp.Identity [Fact] public async Task GetUsersInRoleAsync() { - var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator")); + var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); user.ShouldNotBeNull(); user.ShouldContain(x => x.UserName == "john.nash"); } @@ -643,15 +643,15 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123"); + await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123").ConfigureAwait(false); user.Tokens.ShouldNotBeEmpty(); user.Tokens.ShouldContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -660,14 +660,14 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name"); + await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false); user.Tokens.ShouldNotContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -676,12 +676,12 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - (await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name")).ShouldBe("test-value"); + (await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false)).ShouldBe("test-value"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -690,14 +690,14 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); + await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false); user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "AuthenticatorKey" && x.Value == "testKey"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -706,13 +706,13 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); + await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false); - (await _identityUserStore.GetAuthenticatorKeyAsync(user)).ShouldBe("testKey"); + (await _identityUserStore.GetAuthenticatorKeyAsync(user).ConfigureAwait(false)).ShouldBe("testKey"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -722,13 +722,13 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); + await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false); - (await _identityUserStore.CountCodesAsync(user)).ShouldBe(2); + (await _identityUserStore.CountCodesAsync(user).ConfigureAwait(false)).ShouldBe(2); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -737,18 +737,18 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); await _identityUserStore.ReplaceCodesAsync(user, new List() { "testKey", "testKey2" - }); + }).ConfigureAwait(false); user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "RecoveryCodes" && x.Value == "testKey;testKey2"); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -757,13 +757,13 @@ namespace Volo.Abp.Identity { using (var uow = _unitOfWorkManager.Begin()) { - var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); + var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); user.ShouldNotBeNull(); - await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); + await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false); - (await _identityUserStore.RedeemCodeAsync(user, "testKey")).ShouldBeTrue(); + (await _identityUserStore.RedeemCodeAsync(user, "testKey").ConfigureAwait(false)).ShouldBeTrue(); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/PermissionManager_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/PermissionManager_Tests.cs index 621cb4621f..a098ba92c6 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/PermissionManager_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/PermissionManager_Tests.cs @@ -24,19 +24,19 @@ namespace Volo.Abp.Identity public async Task Roles_Should_Have_Configured_Permissions() { //admin - var grantInfos = await _permissionManager.GetAllForRoleAsync("admin"); + var grantInfos = await _permissionManager.GetAllForRoleAsync("admin").ConfigureAwait(false); RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission1); RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2); RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2_ChildPermission1); //moderator - grantInfos = await _permissionManager.GetAllForRoleAsync("moderator"); + grantInfos = await _permissionManager.GetAllForRoleAsync("moderator").ConfigureAwait(false); RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission1); RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission2); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1); //supporter - grantInfos = await _permissionManager.GetAllForRoleAsync("supporter"); + grantInfos = await _permissionManager.GetAllForRoleAsync("supporter").ConfigureAwait(false); RoleShouldHavePermission(grantInfos, "supporter", TestPermissionNames.MyPermission1); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1); @@ -45,21 +45,21 @@ namespace Volo.Abp.Identity [Fact] public async Task Should_Grant_Permission_To_Role() { - (await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2)).IsGranted.ShouldBeFalse(); - (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter")).ShouldBeFalse(); + (await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2).ConfigureAwait(false)).IsGranted.ShouldBeFalse(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false)).ShouldBeFalse(); - await _permissionManager.SetForRoleAsync("supporter", TestPermissionNames.MyPermission2, true); + await _permissionManager.SetForRoleAsync("supporter", TestPermissionNames.MyPermission2, true).ConfigureAwait(false); - (await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2)).IsGranted.ShouldBeTrue(); - (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter")).ShouldBeTrue(); + (await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2).ConfigureAwait(false)).IsGranted.ShouldBeTrue(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false)).ShouldBeTrue(); } [Fact] public async Task Should_Revoke_Permission_From_Role() { - (await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1)).IsGranted.ShouldBeTrue(); - await _permissionManager.SetForRoleAsync("moderator", TestPermissionNames.MyPermission1, false); - (await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse(); + (await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1).ConfigureAwait(false)).IsGranted.ShouldBeTrue(); + await _permissionManager.SetForRoleAsync("moderator", TestPermissionNames.MyPermission1, false).ConfigureAwait(false); + (await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1).ConfigureAwait(false)).IsGranted.ShouldBeFalse(); } [Fact] @@ -67,21 +67,21 @@ namespace Volo.Abp.Identity { //administrator var user = GetUser("administrator"); - var grantInfos = await _permissionManager.GetAllForUserAsync(user.Id); + var grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1, "admin"); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2, "admin"); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2_ChildPermission1, "admin"); //john.nash user = GetUser("john.nash"); - grantInfos = await _permissionManager.GetAllForUserAsync(user.Id); + grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1, "moderator", "supporter"); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2, "moderator"); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1); //john.nash user = GetUser("david"); - grantInfos = await _permissionManager.GetAllForUserAsync(user.Id); + grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false); UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2); ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1); diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/TestPermissionDataBuilder.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/TestPermissionDataBuilder.cs index ad94e914b5..c53592d567 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/TestPermissionDataBuilder.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/TestPermissionDataBuilder.cs @@ -29,26 +29,26 @@ namespace Volo.Abp.Identity public async Task Build() { - await AddRolePermissions(); - await AddUserPermissions(); + await AddRolePermissions().ConfigureAwait(false); + await AddUserPermissions().ConfigureAwait(false); } private async Task AddRolePermissions() { - await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "admin"); - await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "admin"); - await AddPermission(TestPermissionNames.MyPermission2_ChildPermission1, RolePermissionValueProvider.ProviderName, "admin"); + await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false); + await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false); + await AddPermission(TestPermissionNames.MyPermission2_ChildPermission1, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false); - await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "moderator"); - await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "moderator"); + await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "moderator").ConfigureAwait(false); + await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "moderator").ConfigureAwait(false); - await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "supporter"); + await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false); } private async Task AddUserPermissions() { var david = AsyncHelper.RunSync(() => _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david"))); - await AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString()); + await AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString()).ConfigureAwait(false); } private async Task AddPermission(string permissionName, string providerName, string providerKey) @@ -60,7 +60,7 @@ namespace Volo.Abp.Identity providerName, providerKey ) - ); + ).ConfigureAwait(false); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/UserRoleFinder_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/UserRoleFinder_Tests.cs index ef06949500..a8f2159fc2 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/UserRoleFinder_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/UserRoleFinder_Tests.cs @@ -21,7 +21,7 @@ namespace Volo.Abp.Identity [Fact] public async Task GetRolesAsync() { - var roleNames = await _userRoleFinder.GetRolesAsync(_testData.UserJohnId); + var roleNames = await _userRoleFinder.GetRolesAsync(_testData.UserJohnId).ConfigureAwait(false); roleNames.ShouldNotBeEmpty(); roleNames.ShouldContain(x => x == "moderator"); roleNames.ShouldContain(x => x == "supporter"); diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs index 4b956ab16d..0c8c545b8c 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs @@ -32,10 +32,10 @@ namespace Volo.Abp.Identity var dataSeeder = scope.ServiceProvider.GetRequiredService(); AsyncHelper.RunSync(async () => { - await dataSeeder.SeedAsync(); + await dataSeeder.SeedAsync().ConfigureAwait(false); await scope.ServiceProvider .GetRequiredService() - .Build(); + .Build().ConfigureAwait(false); }); } } diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs index 69361ff5a8..ad36fe69a7 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs @@ -37,21 +37,21 @@ namespace Volo.Abp.Identity public async Task Build() { - await AddRoles(); - await AddUsers(); - await AddClaimTypes(); + await AddRoles().ConfigureAwait(false); + await AddUsers().ConfigureAwait(false); + await AddClaimTypes().ConfigureAwait(false); } private async Task AddRoles() { - _adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin")); + _adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false); _moderator = new IdentityRole(_testData.RoleModeratorId, "moderator"); _moderator.AddClaim(_guidGenerator, new Claim("test-claim", "test-value")); - await _roleRepository.InsertAsync(_moderator); + await _roleRepository.InsertAsync(_moderator).ConfigureAwait(false); _supporterRole = new IdentityRole(_guidGenerator.Create(), "supporter"); - await _roleRepository.InsertAsync(_supporterRole); + await _roleRepository.InsertAsync(_supporterRole).ConfigureAwait(false); } private async Task AddUsers() @@ -59,7 +59,7 @@ namespace Volo.Abp.Identity var adminUser = new IdentityUser(_guidGenerator.Create(), "administrator", "admin@abp.io"); adminUser.AddRole(_adminRole.Id); adminUser.AddClaim(_guidGenerator, new Claim("TestClaimType", "42")); - await _userRepository.InsertAsync(adminUser); + await _userRepository.InsertAsync(adminUser).ConfigureAwait(false); var john = new IdentityUser(_testData.UserJohnId, "john.nash", "john.nash@abp.io"); john.AddRole(_moderator.Id); @@ -68,23 +68,23 @@ namespace Volo.Abp.Identity john.AddLogin(new UserLoginInfo("twitter", "johnx", "John Nash")); john.AddClaim(_guidGenerator, new Claim("TestClaimType", "42")); john.SetToken("test-provider", "test-name", "test-value"); - await _userRepository.InsertAsync(john); + await _userRepository.InsertAsync(john).ConfigureAwait(false); var david = new IdentityUser(_testData.UserDavidId, "david", "david@abp.io"); - await _userRepository.InsertAsync(david); + await _userRepository.InsertAsync(david).ConfigureAwait(false); var neo = new IdentityUser(_testData.UserNeoId, "neo", "neo@abp.io"); neo.AddRole(_supporterRole.Id); neo.AddClaim(_guidGenerator, new Claim("TestClaimType", "43")); - await _userRepository.InsertAsync(neo); + await _userRepository.InsertAsync(neo).ConfigureAwait(false); } private async Task AddClaimTypes() { var ageClaim = new IdentityClaimType(_testData.AgeClaimId, "Age", false, false, null, null, null,IdentityClaimValueType.Int); - await _identityClaimTypeRepository.InsertAsync(ageClaim); + await _identityClaimTypeRepository.InsertAsync(ageClaim).ConfigureAwait(false); var educationClaim = new IdentityClaimType(_testData.EducationClaimId, "Education", true, false, null, null, null); - await _identityClaimTypeRepository.InsertAsync(educationClaim); + await _identityClaimTypeRepository.InsertAsync(educationClaim).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs index 3250c0b04a..afe117d421 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs @@ -28,11 +28,11 @@ namespace Volo.Abp.Identity { var claim = (await ClaimTypeRepository.GetListAsync()).FirstOrDefault(); - var result1 = await ClaimTypeRepository.AnyAsync(claim.Name); + var result1 = await ClaimTypeRepository.AnyAsync(claim.Name).ConfigureAwait(false); result1.ShouldBe(true); - var result2 = await ClaimTypeRepository.AnyAsync(Guid.NewGuid().ToString()); + var result2 = await ClaimTypeRepository.AnyAsync(Guid.NewGuid().ToString()).ConfigureAwait(false); result2.ShouldBe(false); } diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityDataSeeder_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityDataSeeder_Tests.cs index 65eac5bc9d..0b6692f419 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityDataSeeder_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityDataSeeder_Tests.cs @@ -25,11 +25,11 @@ namespace Volo.Abp.Identity [Fact] public async Task Should_Create_Admin_User_And_Role() { - await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*"); + await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*").ConfigureAwait(false); - (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull(); - (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).Name.ShouldBe("admin"); - (await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull(); + (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull(); + (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).Name.ShouldBe("admin"); + (await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull(); } } } diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs index e4a15d15f1..cd7ee1eb32 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs @@ -23,14 +23,14 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByNormalizedNameAsync() { - (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull(); - (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role"))).ShouldBeNull(); + (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull(); + (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role")).ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task GetListAsync() { - var roles = await RoleRepository.GetListAsync(); + var roles = await RoleRepository.GetListAsync().ConfigureAwait(false); roles.ShouldContain(r => r.Name == "admin"); roles.ShouldContain(r => r.Name == "moderator"); roles.ShouldContain(r => r.Name == "supporter"); @@ -39,13 +39,13 @@ namespace Volo.Abp.Identity [Fact] public async Task GetCountAsync() { - (await RoleRepository.GetCountAsync()).ShouldBeGreaterThan(0); + (await RoleRepository.GetCountAsync().ConfigureAwait(false)).ShouldBeGreaterThan(0); } [Fact] public async Task Should_Eager_Load_Role_Collections() { - var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator")); + var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); role.Claims.ShouldNotBeNull(); role.Claims.Any().ShouldBeTrue(); } diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs index 4fa407a512..98f25f6aee 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs @@ -25,23 +25,23 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByNormalizedUserNameAsync() { - (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"))).ShouldNotBeNull(); - (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("undefined-user"))).ShouldBeNull(); + (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).ShouldNotBeNull(); + (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("undefined-user")).ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task FindByNormalizedEmailAsync() { - (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("john.nash@abp.io"))).ShouldNotBeNull(); - (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("david@abp.io"))).ShouldNotBeNull(); - (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("undefined-user@abp.io"))).ShouldBeNull(); + (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("john.nash@abp.io")).ConfigureAwait(false)).ShouldNotBeNull(); + (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("david@abp.io")).ConfigureAwait(false)).ShouldNotBeNull(); + (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("undefined-user@abp.io")).ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task GetRoleNamesAsync() { - var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")); - var roles = await UserRepository.GetRoleNamesAsync(john.Id); + var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); + var roles = await UserRepository.GetRoleNamesAsync(john.Id).ConfigureAwait(false); roles.Count.ShouldBe(2); roles.ShouldContain("moderator"); roles.ShouldContain("supporter"); @@ -50,37 +50,37 @@ namespace Volo.Abp.Identity [Fact] public async Task FindByLoginAsync() { - var user = await UserRepository.FindByLoginAsync("github", "john"); + var user = await UserRepository.FindByLoginAsync("github", "john").ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); - user = await UserRepository.FindByLoginAsync("twitter", "johnx"); + user = await UserRepository.FindByLoginAsync("twitter", "johnx").ConfigureAwait(false); user.ShouldNotBeNull(); user.UserName.ShouldBe("john.nash"); - (await UserRepository.FindByLoginAsync("github", "undefinedid")).ShouldBeNull(); + (await UserRepository.FindByLoginAsync("github", "undefinedid").ConfigureAwait(false)).ShouldBeNull(); } [Fact] public async Task GetListByClaimAsync() { - var users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "42")); + var users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "42")).ConfigureAwait(false); users.Count.ShouldBe(2); users.ShouldContain(u => u.UserName == "administrator"); users.ShouldContain(u => u.UserName == "john.nash"); - users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "43")); + users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "43")).ConfigureAwait(false); users.Count.ShouldBe(1); users.ShouldContain(u => u.UserName == "neo"); - users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "undefined")); + users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "undefined")).ConfigureAwait(false); users.Count.ShouldBe(0); } [Fact] public async Task GetListByNormalizedRoleNameAsync() { - var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.NormalizeName("supporter")); + var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.NormalizeName("supporter")).ConfigureAwait(false); users.Count.ShouldBe(2); users.ShouldContain(u => u.UserName == "john.nash"); users.ShouldContain(u => u.UserName == "neo"); @@ -89,7 +89,7 @@ namespace Volo.Abp.Identity [Fact] public async Task GetListAsync() { - var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n"); + var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n").ConfigureAwait(false); users.Count.ShouldBeGreaterThan(1); users.Count.ShouldBeLessThanOrEqualTo(5); @@ -107,15 +107,15 @@ namespace Volo.Abp.Identity ).ShouldBeGreaterThan(0); } - users = await UserRepository.GetListAsync(null, 999, 0, "undefined-username"); + users = await UserRepository.GetListAsync(null, 999, 0, "undefined-username").ConfigureAwait(false); users.Count.ShouldBe(0); } [Fact] public async Task GetRolesAsync() { - var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")); - var roles = await UserRepository.GetRolesAsync(john.Id); + var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); + var roles = await UserRepository.GetRolesAsync(john.Id).ConfigureAwait(false); roles.Count.ShouldBe(2); roles.ShouldContain(r => r.Name == "moderator"); roles.ShouldContain(r => r.Name == "supporter"); @@ -124,14 +124,14 @@ namespace Volo.Abp.Identity [Fact] public async Task GetCountAsync() { - (await UserRepository.GetCountAsync("n")).ShouldBeGreaterThan(1); - (await UserRepository.GetCountAsync("undefined-username")).ShouldBe(0); + (await UserRepository.GetCountAsync("n").ConfigureAwait(false)).ShouldBeGreaterThan(1); + (await UserRepository.GetCountAsync("undefined-username").ConfigureAwait(false)).ShouldBe(0); } [Fact] public async Task Should_Eager_Load_User_Collections() { - var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")); + var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); john.Roles.ShouldNotBeNull(); john.Roles.Any().ShouldBeTrue(); diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs index 1ae671dd4f..3313803436 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs @@ -28,11 +28,11 @@ namespace Volo.Abp.Identity { using (var uow = GetRequiredService().Begin()) { - var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"), includeDetails: false); + var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"), includeDetails: false).ConfigureAwait(false); role.Claims.ShouldNotBeNull(); role.Claims.Any().ShouldBeTrue(); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } @@ -41,7 +41,7 @@ namespace Volo.Abp.Identity { using (var uow = GetRequiredService().Begin()) { - var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"), includeDetails: false); + var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"), includeDetails: false).ConfigureAwait(false); john.Roles.ShouldNotBeNull(); john.Roles.Any().ShouldBeTrue(); @@ -55,7 +55,7 @@ namespace Volo.Abp.Identity john.Tokens.ShouldNotBeNull(); john.Tokens.Any().ShouldBeTrue(); - await uow.CompleteAsync(); + await uow.CompleteAsync().ConfigureAwait(false); } } }