-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
GetUserNameFromEmailAsync
to IdentityUserManager
.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
|
@@ -422,6 +423,34 @@ public async Task GetRandomUserNameAsync() | |
username.All(c => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+".Contains(c)).ShouldBeTrue(); | ||
} | ||
Check warning on line 424 in modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs Codecov / codecov/patchmodules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs#L420-L424
|
||
|
||
[Fact] | ||
public async Task GetUserNameFromEmailAsync() | ||
{ | ||
_identityUserManager.Options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
var username = await _identityUserManager.GetUserNameFromEmailAsync("[email protected]"); | ||
username.Length.ShouldBe(9); //admin and random 4 numbers | ||
username.ShouldContain("admin"); | ||
Regex.IsMatch(username, @"\d{4}$").ShouldBeTrue(); | ||
Check warning on line 433 in modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs Codecov / codecov/patchmodules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs#L428-L433
|
||
|
||
_identityUserManager.Options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyz"; | ||
username = await _identityUserManager.GetUserNameFromEmailAsync("[email protected]"); | ||
username.Length.ShouldBe(9); //admin and random 4 characters | ||
username.ShouldContain("admin"); | ||
Regex.IsMatch(username, @"[a-z]{4}$").ShouldBeTrue(); | ||
Check warning on line 439 in modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs Codecov / codecov/patchmodules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs#L435-L439
|
||
|
||
_identityUserManager.Options.User.AllowedUserNameCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
username = await _identityUserManager.GetUserNameFromEmailAsync("[email protected]"); | ||
username.Length.ShouldBe(9); //admin and random 4 characters | ||
username.ShouldContain("ADMIN"); | ||
Regex.IsMatch(username, @"[A-Z]{4}$").ShouldBeTrue(); | ||
Check warning on line 445 in modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs Codecov / codecov/patchmodules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs#L441-L445
|
||
|
||
_identityUserManager.Options.User.AllowedUserNameCharacters = null!; | ||
username = await _identityUserManager.GetUserNameFromEmailAsync("[email protected]"); | ||
username.Length.ShouldBe(9); //admin and random 4 numbers | ||
username.ShouldContain("admin"); | ||
Regex.IsMatch(username, @"[0-9]{4}$").ShouldBeTrue(); | ||
} | ||
Check warning on line 452 in modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs Codecov / codecov/patchmodules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs#L447-L452
|
||
|
||
private async Task CreateRandomDefaultRoleAsync() | ||
{ | ||
await _identityRoleRepository.InsertAsync( | ||
|