Upgrade Identity to net core 3.0

pull/1810/head
Halil İbrahim Kalkan 5 years ago
parent 8192c1b6a7
commit db7fc04ff3

@ -14,7 +14,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -14,7 +14,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -16,9 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" /> <ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
</ItemGroup> </ItemGroup>

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53901/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Volo.Abp.Identity.AspNetCore": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:53902/"
}
}
}

@ -1,20 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.AspNetCore</AssemblyName> <AssemblyName>Volo.Abp.Identity.AspNetCore</AssemblyName>
<PackageId>Volo.Abp.Identity.AspNetCore</PackageId> <PackageId>Volo.Abp.Identity.AspNetCore</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<RootNamespace /> <RootNamespace />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
</ItemGroup> </ItemGroup>

@ -2,21 +2,24 @@
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity.AspNetCore
{ {
public class AbpSecurityStampValidator : SecurityStampValidator<IdentityUser> public class AbpSecurityStampValidator : SecurityStampValidator<IdentityUser>
{ {
public AbpSecurityStampValidator( public AbpSecurityStampValidator(
IOptions<SecurityStampValidatorOptions> options, IOptions<SecurityStampValidatorOptions> options,
SignInManager<IdentityUser> signInManager, SignInManager<IdentityUser> signInManager,
ISystemClock systemClock) ISystemClock systemClock,
ILoggerFactory loggerFactory)
: base( : base(
options, options,
signInManager, signInManager,
systemClock) systemClock,
loggerFactory)
{ {
} }

@ -15,15 +15,11 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Volo\Abp\Identity\Localization\*.json" /> <EmbeddedResource Include="Volo\Abp\Identity\Localization\*.json" />
</ItemGroup>
<ItemGroup>
<Content Remove="Volo\Abp\Identity\Localization\*.json" /> <Content Remove="Volo\Abp\Identity\Localization\*.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain.Shared\Volo.Abp.Users.Domain.Shared.csproj" /> <ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain.Shared\Volo.Abp.Users.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Localization\Volo.Abp.Localization.csproj" />
</ItemGroup> </ItemGroup>

@ -28,7 +28,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.0.0-preview9.19424.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -20,11 +20,6 @@ namespace Volo.Abp.Identity
/// </summary> /// </summary>
public virtual string ClaimValue { get; protected set; } public virtual string ClaimValue { get; protected set; }
public virtual bool Equals([NotNull] string claimType, [NotNull] string claimValue)
{
return ClaimType == claimType && ClaimValue == claimValue;
}
protected IdentityClaim() protected IdentityClaim()
{ {

@ -46,7 +46,7 @@ namespace Volo.Abp.Identity
//"admin" user //"admin" user
const string adminUserName = "admin"; const string adminUserName = "admin";
var adminUser = await _userRepository.FindByNormalizedUserNameAsync( var adminUser = await _userRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.Normalize(adminUserName) _lookupNormalizer.NormalizeName(adminUserName)
); );
if (adminUser != null) if (adminUser != null)
@ -69,7 +69,7 @@ namespace Volo.Abp.Identity
//"admin" role //"admin" role
const string adminRoleName = "admin"; const string adminRoleName = "admin";
var adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize(adminRoleName)); var adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(adminRoleName));
if (adminRole == null) if (adminRole == null)
{ {
adminRole = new IdentityRole( adminRole = new IdentityRole(

@ -39,7 +39,7 @@ namespace Volo.Abp.Identity
{ {
return ( return (
await _userRepository.FindByNormalizedUserNameAsync( await _userRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.Normalize(userName), _lookupNormalizer.NormalizeName(userName),
includeDetails: false, includeDetails: false,
cancellationToken: cancellationToken cancellationToken: cancellationToken
) )

@ -3,7 +3,7 @@
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>Volo.Abp.Identity.EntityFrameworkCore</AssemblyName> <AssemblyName>Volo.Abp.Identity.EntityFrameworkCore</AssemblyName>
<PackageId>Volo.Abp.Identity.EntityFrameworkCore</PackageId> <PackageId>Volo.Abp.Identity.EntityFrameworkCore</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
@ -15,7 +15,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.EntityFrameworkCore\Volo.Abp.Users.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.EntityFrameworkCore\Volo.Abp.Users.EntityFrameworkCore.csproj" />
</ItemGroup> </ItemGroup>

@ -48,6 +48,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
b.ToTable(options.TablePrefix + "UserClaims", options.Schema); b.ToTable(options.TablePrefix + "UserClaims", options.Schema);
b.Property(x => x.Id).ValueGeneratedNever();
b.Property(uc => uc.ClaimType).HasMaxLength(IdentityUserClaimConsts.MaxClaimTypeLength).IsRequired(); b.Property(uc => uc.ClaimType).HasMaxLength(IdentityUserClaimConsts.MaxClaimTypeLength).IsRequired();
b.Property(uc => uc.ClaimValue).HasMaxLength(IdentityUserClaimConsts.MaxClaimValueLength); b.Property(uc => uc.ClaimValue).HasMaxLength(IdentityUserClaimConsts.MaxClaimValueLength);
@ -112,6 +114,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
b.ToTable(options.TablePrefix + "RoleClaims", options.Schema); b.ToTable(options.TablePrefix + "RoleClaims", options.Schema);
b.Property(x => x.Id).ValueGeneratedNever();
b.Property(uc => uc.ClaimType).HasMaxLength(IdentityRoleClaimConsts.MaxClaimTypeLength).IsRequired(); b.Property(uc => uc.ClaimType).HasMaxLength(IdentityRoleClaimConsts.MaxClaimTypeLength).IsRequired();
b.Property(uc => uc.ClaimValue).HasMaxLength(IdentityRoleClaimConsts.MaxClaimValueLength); b.Property(uc => uc.ClaimValue).HasMaxLength(IdentityRoleClaimConsts.MaxClaimValueLength);

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53978/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Volo.Abp.Identity.HttpApi.Client": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:53980/"
}
}
}

@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.HttpApi.Client</AssemblyName> <AssemblyName>Volo.Abp.Identity.HttpApi.Client</AssemblyName>
<PackageId>Volo.Abp.Identity.HttpApi.Client</PackageId> <PackageId>Volo.Abp.Identity.HttpApi.Client</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<RootNamespace /> <RootNamespace />
</PropertyGroup> </PropertyGroup>

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53977/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Volo.Abp.Identity.HttpApi": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:53979/"
}
}
}

@ -1,21 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.HttpApi</AssemblyName> <AssemblyName>Volo.Abp.Identity.HttpApi</AssemblyName>
<PackageId>Volo.Abp.Identity.HttpApi</PackageId> <PackageId>Volo.Abp.Identity.HttpApi</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<RootNamespace /> <RootNamespace />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
</ItemGroup> </ItemGroup>

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
@ -15,7 +15,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.MongoDB\Volo.Abp.Users.MongoDB.csproj" /> <ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.MongoDB\Volo.Abp.Users.MongoDB.csproj" />
</ItemGroup> </ItemGroup>

@ -3,19 +3,21 @@
<Import Project="..\..\..\..\common.props" /> <Import Project="..\..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.Web</AssemblyName> <AssemblyName>Volo.Abp.Identity.Web</AssemblyName>
<PackageId>Volo.Abp.Identity.Web</PackageId> <PackageId>Volo.Abp.Identity.Web</PackageId>
<IsPackable>true</IsPackable>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\**\*.*" Exclude="*.cs" /> <EmbeddedResource Include="Pages\**\*.cshtml" />
<EmbeddedResource Include="Pages\**\*.js" />
<EmbeddedResource Include="Pages\**\*.css" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.Application.Tests</AssemblyName> <AssemblyName>Volo.Abp.Identity.Application.Tests</AssemblyName>
<PackageId>Volo.Abp.Identity.Application.Tests</PackageId> <PackageId>Volo.Abp.Identity.Application.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -17,7 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -24,7 +24,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByIdAsync() public async Task FindByIdAsync()
{ {
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserLookupAppService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName); (await _identityUserLookupAppService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName);
@ -40,7 +40,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByUserNameAsync() public async Task FindByUserNameAsync()
{ {
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserLookupAppService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName); (await _identityUserLookupAppService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName);

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.Domain.Tests</AssemblyName> <AssemblyName>Volo.Abp.Identity.Domain.Tests</AssemblyName>
<PackageId>Volo.Abp.Identity.Domain.Tests</PackageId> <PackageId>Volo.Abp.Identity.Domain.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -18,7 +18,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -40,7 +40,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io"); await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io");
_testCounter.GetValue("EntityUpdatedEto<UserEto>").ShouldBe(0); _testCounter.GetValue("EntityUpdatedEto<UserEto>").ShouldBe(0);

@ -37,7 +37,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetRoleNameAsync() public async Task SetRoleNameAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
(await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue(); (await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue();
@ -48,12 +48,12 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task DeleteAsync() public async Task DeleteAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
await _identityRoleManager.DeleteAsync(role); await _identityRoleManager.DeleteAsync(role);
(await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"))).ShouldBeNull(); (await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"))).ShouldBeNull();
} }
} }

@ -43,7 +43,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task UpdateAsync() public async Task UpdateAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
role.IsDefault = true; role.IsDefault = true;
@ -56,7 +56,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task DeleteAsync() public async Task DeleteAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
await _identityRoleStore.DeleteAsync(role); await _identityRoleStore.DeleteAsync(role);
@ -67,7 +67,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetRoleIdAsync() public async Task GetRoleIdAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleIdAsync(role)).ShouldBe(_testData.RoleModeratorId.ToString()); (await _identityRoleStore.GetRoleIdAsync(role)).ShouldBe(_testData.RoleModeratorId.ToString());
@ -76,7 +76,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetRoleNameAsync() public async Task GetRoleNameAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleNameAsync(role)).ShouldBe(role.Name); (await _identityRoleStore.GetRoleNameAsync(role)).ShouldBe(role.Name);
@ -86,7 +86,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetRoleNameAsync() public async Task SetRoleNameAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
await _identityRoleStore.SetRoleNameAsync(role, "teacher"); await _identityRoleStore.SetRoleNameAsync(role, "teacher");
@ -106,7 +106,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByNameAsync() public async Task FindByNameAsync()
{ {
var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
role.Name.ShouldBe("moderator"); role.Name.ShouldBe("moderator");
@ -115,7 +115,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetNormalizedRoleNameAsync() public async Task GetNormalizedRoleNameAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
(await _identityRoleStore.GetNormalizedRoleNameAsync(role)).ShouldBe(role.NormalizedName); (await _identityRoleStore.GetNormalizedRoleNameAsync(role)).ShouldBe(role.NormalizedName);
@ -124,12 +124,12 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetNormalizedRoleNameAsync() public async Task SetNormalizedRoleNameAsync()
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.Normalize("teacher")); await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.NormalizeName("teacher"));
role.NormalizedName.ShouldBe(_lookupNormalizer.Normalize("teacher")); role.NormalizedName.ShouldBe(_lookupNormalizer.NormalizeName("teacher"));
} }
[Fact] [Fact]
@ -137,7 +137,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
var claims = await _identityRoleStore.GetClaimsAsync(role); var claims = await _identityRoleStore.GetClaimsAsync(role);
@ -149,30 +149,41 @@ namespace Volo.Abp.Identity
} }
} }
[Fact] [Fact]
public async Task AddClaimAsync() public async Task AddClaimAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) try
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); using (var uow = _unitOfWorkManager.Begin())
role.ShouldNotBeNull(); {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
await _identityRoleStore.AddClaimAsync(role, new Claim("my-claim", "my-value")); role.Claims.Add(new IdentityRoleClaim(Guid.NewGuid(), role.Id, "my-claim", "my-value", role.TenantId));
//await _identityRoleStore.AddClaimAsync(role, new Claim("my-claim", "my-value"));
role.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value"); //role.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value");
await uow.CompleteAsync(); await uow.CompleteAsync();
}
}
catch (Exception e)
{
throw;
} }
var role2 = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role2.ShouldNotBeNull();
role2.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value");
} }
[Fact] [Fact]
public async Task RemoveClaimAsync() public async Task RemoveClaimAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator")); var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull(); role.ShouldNotBeNull();
await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value")); await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value"));

@ -43,7 +43,7 @@ namespace Volo.Abp.Identity
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _identityUserRepository.FindByNormalizedUserNameAsync( var user = await _identityUserRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.Normalize("david")); _lookupNormalizer.NormalizeName("david"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>() var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>()
@ -64,11 +64,11 @@ namespace Volo.Abp.Identity
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var roleSupporter = var roleSupporter =
await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("supporter")); await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("supporter"));
roleSupporter.ShouldNotBeNull(); roleSupporter.ShouldNotBeNull();
var user = await _identityUserRepository.FindByNormalizedUserNameAsync( var user = await _identityUserRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.Normalize("john.nash")); _lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>() var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>()

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Claims; using System.Security.Claims;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Shouldly; using Shouldly;
using Volo.Abp.Guids;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Xunit; using Xunit;
@ -31,7 +29,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetUserIdAsync() public async Task GetUserIdAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetUserIdAsync(user)).ShouldBe(user.Id.ToString()); (await _identityUserStore.GetUserIdAsync(user)).ShouldBe(user.Id.ToString());
@ -41,7 +39,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetUserNameAsync() public async Task GetUserNameAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetUserNameAsync(user)).ShouldBe(user.UserName); (await _identityUserStore.GetUserNameAsync(user)).ShouldBe(user.UserName);
@ -50,7 +48,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetUserNameAsync() public async Task SetUserNameAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetUserNameAsync(user, "bob.lee"); await _identityUserStore.SetUserNameAsync(user, "bob.lee");
@ -62,7 +60,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetNormalizedUserNameAsync() public async Task GetNormalizedUserNameAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetNormalizedUserNameAsync(user)).ShouldBe(user.NormalizedUserName); (await _identityUserStore.GetNormalizedUserNameAsync(user)).ShouldBe(user.NormalizedUserName);
@ -71,12 +69,12 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetNormalizedUserNameAsync() public async Task SetNormalizedUserNameAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.Normalize("bob.lee")); await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee"));
user.NormalizedUserName.ShouldBe(_lookupNormalizer.Normalize("bob.lee")); user.NormalizedUserName.ShouldBe(_lookupNormalizer.NormalizeName("bob.lee"));
} }
[Fact] [Fact]
@ -87,7 +85,7 @@ namespace Volo.Abp.Identity
await _identityUserStore.CreateAsync(user); await _identityUserStore.CreateAsync(user);
var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("bob.lee")); var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee"));
bobLee.ShouldNotBeNull(); bobLee.ShouldNotBeNull();
bobLee.UserName.ShouldBe("bob.lee"); bobLee.UserName.ShouldBe("bob.lee");
bobLee.Email.ShouldBe("bob.lee@abp.io"); bobLee.Email.ShouldBe("bob.lee@abp.io");
@ -96,20 +94,20 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task UpdateAsync() public async Task UpdateAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Name = "lee"; user.Name = "lee";
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); (await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash"))).Name (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).Name
.ShouldBe("lee"); .ShouldBe("lee");
} }
[Fact] [Fact]
public async Task Update_Concurrency() public async Task Update_Concurrency()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); (await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue();
@ -128,12 +126,12 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task DeleteAsync() public async Task DeleteAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.DeleteAsync(user)).Succeeded.ShouldBeTrue(); (await _identityUserStore.DeleteAsync(user)).Succeeded.ShouldBeTrue();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash"))).ShouldBeNull(); (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).ShouldBeNull();
} }
@ -150,7 +148,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByNameAsync() public async Task FindByNameAsync()
{ {
var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash"); user.UserName.ShouldBe("john.nash");
@ -160,7 +158,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetPasswordHashAsync() public async Task SetPasswordHashAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.PasswordHash.ShouldBeNull(); user.PasswordHash.ShouldBeNull();
@ -172,7 +170,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetPasswordHashAsync() public async Task GetPasswordHashAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd");
@ -183,7 +181,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task HasPasswordAsync() public async Task HasPasswordAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeFalse(); (await _identityUserStore.HasPasswordAsync(user)).ShouldBeFalse();
@ -191,17 +189,16 @@ namespace Volo.Abp.Identity
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeTrue(); (await _identityUserStore.HasPasswordAsync(user)).ShouldBeTrue();
} }
[Fact] [Fact]
public async Task AddToRoleAsync() public async Task AddToRoleAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("david")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Roles.ShouldBeEmpty(); user.Roles.ShouldBeEmpty();
await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.Normalize("moderator")); await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"));
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);
@ -209,17 +206,16 @@ namespace Volo.Abp.Identity
} }
} }
[Fact] [Fact]
public async Task RemoveFromRoleAsync() public async Task RemoveFromRoleAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);
await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.Normalize("moderator")); await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"));
user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId); user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId);
@ -231,7 +227,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetRolesAsync() public async Task GetRolesAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var roleNames = await _identityUserStore.GetRolesAsync(user); var roleNames = await _identityUserStore.GetRolesAsync(user);
@ -245,23 +241,22 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.Normalize("moderator"))).ShouldBeTrue(); (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"))).ShouldBeTrue();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.Normalize("moderatorNotExist"))).ShouldBeFalse(); (await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist"))).ShouldBeFalse();
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
} }
[Fact] [Fact]
public async Task GetClaimsAsync() public async Task GetClaimsAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var claims = await _identityUserStore.GetClaimsAsync(user); var claims = await _identityUserStore.GetClaimsAsync(user);
@ -277,8 +272,9 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Claims.ShouldNotContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue");
await _identityUserStore.AddClaimsAsync(user, new List<Claim>() await _identityUserStore.AddClaimsAsync(user, new List<Claim>()
{ {
@ -291,13 +287,12 @@ namespace Volo.Abp.Identity
} }
} }
[Fact] [Fact]
public async Task ReplaceClaimAsync() public async Task ReplaceClaimAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); 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"));
@ -308,14 +303,13 @@ namespace Volo.Abp.Identity
await uow.CompleteAsync(); await uow.CompleteAsync();
} }
} }
[Fact] [Fact]
public async Task RemoveClaimsAsync() public async Task RemoveClaimsAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.RemoveClaimsAsync(user, new List<Claim>() await _identityUserStore.RemoveClaimsAsync(user, new List<Claim>()
@ -329,13 +323,12 @@ namespace Volo.Abp.Identity
} }
} }
[Fact] [Fact]
public async Task AddLoginAsync() public async Task AddLoginAsync()
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Logins.ShouldNotContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john"); user.Logins.ShouldNotContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john");
@ -352,7 +345,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); user.Logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john");
@ -370,7 +363,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var logins = await _identityUserStore.GetLoginsAsync(user); var logins = await _identityUserStore.GetLoginsAsync(user);
@ -396,7 +389,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetEmailConfirmedAsync() public async Task GetEmailConfirmedAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetEmailConfirmedAsync(user)).ShouldBe(user.EmailConfirmed); (await _identityUserStore.GetEmailConfirmedAsync(user)).ShouldBe(user.EmailConfirmed);
@ -406,7 +399,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetEmailConfirmedAsync() public async Task SetEmailConfirmedAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var emailConfirmed = user.EmailConfirmed; var emailConfirmed = user.EmailConfirmed;
@ -418,7 +411,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetEmailAsync() public async Task SetEmailAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io"); await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io");
@ -430,7 +423,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetEmailAsync() public async Task GetEmailAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetEmailAsync(user)).ShouldBe(user.Email); (await _identityUserStore.GetEmailAsync(user)).ShouldBe(user.Email);
@ -439,7 +432,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetNormalizedEmailAsync() public async Task GetNormalizedEmailAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetNormalizedEmailAsync(user)).ShouldBe(user.NormalizedEmail); (await _identityUserStore.GetNormalizedEmailAsync(user)).ShouldBe(user.NormalizedEmail);
@ -448,18 +441,18 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetNormalizedEmailAsync() public async Task SetNormalizedEmailAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.Normalize("john.nash.kobe@abp.io")); await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io"));
user.NormalizedEmail.ShouldBe(_lookupNormalizer.Normalize("john.nash.kobe@abp.io")); user.NormalizedEmail.ShouldBe(_lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io"));
} }
[Fact] [Fact]
public async Task FindByEmailAsync() public async Task FindByEmailAsync()
{ {
var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.Normalize("john.nash@abp.io")); var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.Email.ShouldBe("john.nash@abp.io"); user.Email.ShouldBe("john.nash@abp.io");
@ -468,7 +461,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetLockoutEndDateAsync() public async Task GetLockoutEndDateAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetLockoutEndDateAsync(user)).ShouldBe(user.LockoutEnd); (await _identityUserStore.GetLockoutEndDateAsync(user)).ShouldBe(user.LockoutEnd);
@ -477,7 +470,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetLockoutEndDateAsync() public async Task SetLockoutEndDateAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")); await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019"));
@ -489,7 +482,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task IncrementAccessFailedCountAsync() public async Task IncrementAccessFailedCountAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var count = user.AccessFailedCount; var count = user.AccessFailedCount;
@ -501,7 +494,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task ResetAccessFailedCountAsync() public async Task ResetAccessFailedCountAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.ResetAccessFailedCountAsync(user); await _identityUserStore.ResetAccessFailedCountAsync(user);
@ -512,7 +505,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetAccessFailedCountAsync() public async Task GetAccessFailedCountAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetAccessFailedCountAsync(user)).ShouldBe(user.AccessFailedCount); (await _identityUserStore.GetAccessFailedCountAsync(user)).ShouldBe(user.AccessFailedCount);
@ -521,7 +514,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetLockoutEnabledAsync() public async Task GetLockoutEnabledAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetLockoutEnabledAsync(user)).ShouldBe(user.LockoutEnabled); (await _identityUserStore.GetLockoutEnabledAsync(user)).ShouldBe(user.LockoutEnabled);
@ -530,7 +523,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetLockoutEnabledAsync() public async Task SetLockoutEnabledAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var lockoutEnabled = user.LockoutEnabled; var lockoutEnabled = user.LockoutEnabled;
@ -543,7 +536,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetPhoneNumberAsync() public async Task SetPhoneNumberAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetPhoneNumberAsync(user, "13800138000"); await _identityUserStore.SetPhoneNumberAsync(user, "13800138000");
@ -555,7 +548,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetPhoneNumberAsync() public async Task GetPhoneNumberAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetPhoneNumberAsync(user)).ShouldBe(user.PhoneNumber); (await _identityUserStore.GetPhoneNumberAsync(user)).ShouldBe(user.PhoneNumber);
@ -564,7 +557,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetPhoneNumberConfirmedAsync() public async Task GetPhoneNumberConfirmedAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetPhoneNumberConfirmedAsync(user)).ShouldBe(user.PhoneNumberConfirmed); (await _identityUserStore.GetPhoneNumberConfirmedAsync(user)).ShouldBe(user.PhoneNumberConfirmed);
@ -574,7 +567,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetPhoneNumberConfirmedAsync() public async Task SetPhoneNumberConfirmedAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var phoneNumberConfirmed = user.PhoneNumberConfirmed; var phoneNumberConfirmed = user.PhoneNumberConfirmed;
@ -587,7 +580,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetSecurityStampAsync() public async Task SetSecurityStampAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var securityStamp = Guid.NewGuid().ToString(); var securityStamp = Guid.NewGuid().ToString();
@ -599,7 +592,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetSecurityStampAsync() public async Task GetSecurityStampAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetSecurityStampAsync(user)).ShouldBe(user.SecurityStamp); (await _identityUserStore.GetSecurityStampAsync(user)).ShouldBe(user.SecurityStamp);
@ -609,7 +602,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task SetTwoFactorEnabledAsync() public async Task SetTwoFactorEnabledAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
var twoFactorEnabled = user.TwoFactorEnabled; var twoFactorEnabled = user.TwoFactorEnabled;
@ -622,7 +615,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetTwoFactorEnabledAsync() public async Task GetTwoFactorEnabledAsync()
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetTwoFactorEnabledAsync(user)).ShouldBe(user.TwoFactorEnabled); (await _identityUserStore.GetTwoFactorEnabledAsync(user)).ShouldBe(user.TwoFactorEnabled);
@ -640,7 +633,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetUsersInRoleAsync() public async Task GetUsersInRoleAsync()
{ {
var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.Normalize("moderator")); var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
user.ShouldContain(x => x.UserName == "john.nash"); user.ShouldContain(x => x.UserName == "john.nash");
} }
@ -650,7 +643,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123"); await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123");
@ -667,7 +660,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name"); await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name");
@ -683,7 +676,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
(await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name")).ShouldBe("test-value"); (await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name")).ShouldBe("test-value");
@ -697,7 +690,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey");
@ -713,7 +706,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey");
@ -729,7 +722,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2");
@ -744,7 +737,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.ReplaceCodesAsync(user, new List<string>() await _identityUserStore.ReplaceCodesAsync(user, new List<string>()
@ -764,7 +757,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = _unitOfWorkManager.Begin()) using (var uow = _unitOfWorkManager.Begin())
{ {
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("john.nash")); var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull(); user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2");

@ -45,7 +45,7 @@ namespace Volo.Abp.Identity
private void AddUserPermissions() private void AddUserPermissions()
{ {
var david = _userRepository.FindByNormalizedUserName(_lookupNormalizer.Normalize("david")); var david = _userRepository.FindByNormalizedUserName(_lookupNormalizer.NormalizeName("david"));
AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString()); AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString());
} }

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.EntityFrameworkCore.Tests</AssemblyName> <AssemblyName>Volo.Abp.Identity.EntityFrameworkCore.Tests</AssemblyName>
<PackageId>Volo.Abp.Identity.EntityFrameworkCore.Tests</PackageId> <PackageId>Volo.Abp.Identity.EntityFrameworkCore.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -20,10 +20,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.0" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0-preview9.19423.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview9.19423.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.0.0-preview9.19423.6" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.MongoDB.Tests</AssemblyName> <AssemblyName>Volo.Abp.Identity.MongoDB.Tests</AssemblyName>
<PackageId>Volo.Abp.Identity.MongoDB.Tests</PackageId> <PackageId>Volo.Abp.Identity.MongoDB.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -19,8 +19,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.TestBase</AssemblyName> <AssemblyName>Volo.Abp.Identity.TestBase</AssemblyName>
<PackageId>Volo.Abp.Identity.TestBase</PackageId> <PackageId>Volo.Abp.Identity.TestBase</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -19,7 +19,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NSubstitute" Version="3.1.0" /> <PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="Shouldly" Version="3.0.2" /> <PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />

@ -43,7 +43,7 @@ namespace Volo.Abp.Identity
private void AddRoles() private void AddRoles()
{ {
_adminRole = _roleRepository.FindByNormalizedName(_lookupNormalizer.Normalize("admin")); _adminRole = _roleRepository.FindByNormalizedName(_lookupNormalizer.NormalizeName("admin"));
_moderator = new IdentityRole(_testData.RoleModeratorId, "moderator"); _moderator = new IdentityRole(_testData.RoleModeratorId, "moderator");
_moderator.AddClaim(_guidGenerator, new Claim("test-claim", "test-value")); _moderator.AddClaim(_guidGenerator, new Claim("test-claim", "test-value"));

@ -27,9 +27,9 @@ namespace Volo.Abp.Identity
{ {
await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*"); await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*");
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("admin"))).ShouldNotBeNull(); (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("admin"))).Name.ShouldBe("admin"); (await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).Name.ShouldBe("admin");
(await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("admin"))).ShouldNotBeNull(); (await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
} }
} }
} }

@ -23,8 +23,8 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByNormalizedNameAsync() public async Task FindByNormalizedNameAsync()
{ {
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("admin"))).ShouldNotBeNull(); (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("undefined-role"))).ShouldBeNull(); (await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role"))).ShouldBeNull();
} }
[Fact] [Fact]
@ -45,7 +45,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task Should_Eager_Load_Role_Collections() public async Task Should_Eager_Load_Role_Collections()
{ {
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("moderator")); var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"));
role.Claims.ShouldNotBeNull(); role.Claims.ShouldNotBeNull();
role.Claims.Any().ShouldBeTrue(); role.Claims.Any().ShouldBeTrue();
} }

@ -25,22 +25,22 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task FindByNormalizedUserNameAsync() public async Task FindByNormalizedUserNameAsync()
{ {
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("john.nash"))).ShouldNotBeNull(); (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("undefined-user"))).ShouldBeNull(); (await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("undefined-user"))).ShouldBeNull();
} }
[Fact] [Fact]
public async Task FindByNormalizedEmailAsync() public async Task FindByNormalizedEmailAsync()
{ {
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.Normalize("john.nash@abp.io"))).ShouldNotBeNull(); (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("john.nash@abp.io"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.Normalize("david@abp.io"))).ShouldNotBeNull(); (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("david@abp.io"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.Normalize("undefined-user@abp.io"))).ShouldBeNull(); (await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("undefined-user@abp.io"))).ShouldBeNull();
} }
[Fact] [Fact]
public async Task GetRoleNamesAsync() public async Task GetRoleNamesAsync()
{ {
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("john.nash")); var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
var roles = await UserRepository.GetRoleNamesAsync(john.Id); var roles = await UserRepository.GetRoleNamesAsync(john.Id);
roles.Count.ShouldBe(2); roles.Count.ShouldBe(2);
roles.ShouldContain("moderator"); roles.ShouldContain("moderator");
@ -80,7 +80,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetListByNormalizedRoleNameAsync() public async Task GetListByNormalizedRoleNameAsync()
{ {
var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.Normalize("supporter")); var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.NormalizeName("supporter"));
users.Count.ShouldBe(2); users.Count.ShouldBe(2);
users.ShouldContain(u => u.UserName == "john.nash"); users.ShouldContain(u => u.UserName == "john.nash");
users.ShouldContain(u => u.UserName == "neo"); users.ShouldContain(u => u.UserName == "neo");
@ -114,7 +114,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task GetRolesAsync() public async Task GetRolesAsync()
{ {
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("john.nash")); var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
var roles = await UserRepository.GetRolesAsync(john.Id); var roles = await UserRepository.GetRolesAsync(john.Id);
roles.Count.ShouldBe(2); roles.Count.ShouldBe(2);
roles.ShouldContain(r => r.Name == "moderator"); roles.ShouldContain(r => r.Name == "moderator");
@ -131,7 +131,7 @@ namespace Volo.Abp.Identity
[Fact] [Fact]
public async Task Should_Eager_Load_User_Collections() public async Task Should_Eager_Load_User_Collections()
{ {
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("john.nash")); var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
john.Roles.ShouldNotBeNull(); john.Roles.ShouldNotBeNull();
john.Roles.Any().ShouldBeTrue(); john.Roles.Any().ShouldBeTrue();

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin()) using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin())
{ {
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("moderator"), includeDetails: false); var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"), includeDetails: false);
role.Claims.ShouldNotBeNull(); role.Claims.ShouldNotBeNull();
role.Claims.Any().ShouldBeTrue(); role.Claims.Any().ShouldBeTrue();
@ -41,7 +41,7 @@ namespace Volo.Abp.Identity
{ {
using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin()) using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin())
{ {
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.Normalize("john.nash"), includeDetails: false); var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"), includeDetails: false);
john.Roles.ShouldNotBeNull(); john.Roles.ShouldNotBeNull();
john.Roles.Any().ShouldBeTrue(); john.Roles.Any().ShouldBeTrue();

@ -18,7 +18,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -18,7 +18,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -19,7 +19,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Mongo2Go" Version="2.2.8" /> <PackageReference Include="Mongo2Go" Version="2.2.11" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Loading…
Cancel
Save