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>
<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>
</Project>

@ -8,7 +8,7 @@
<ItemGroup>
<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>

@ -8,7 +8,7 @@
<ItemGroup>
<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>

@ -14,7 +14,7 @@
<ItemGroup>
<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>
</Project>

@ -16,9 +16,7 @@
<ItemGroup>
<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="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
</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" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.AspNetCore</AssemblyName>
<PackageId>Volo.Abp.Identity.AspNetCore</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
</ItemGroup>

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

@ -15,15 +15,11 @@
<ItemGroup>
<EmbeddedResource Include="Volo\Abp\Identity\Localization\*.json" />
</ItemGroup>
<ItemGroup>
<Content Remove="Volo\Abp\Identity\Localization\*.json" />
</ItemGroup>
<ItemGroup>
<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" />
</ItemGroup>

@ -28,7 +28,7 @@
</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>
</Project>

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

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

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

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

@ -48,6 +48,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
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.ClaimValue).HasMaxLength(IdentityUserClaimConsts.MaxClaimValueLength);
@ -112,6 +114,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
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.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" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.HttpApi.Client</AssemblyName>
<PackageId>Volo.Abp.Identity.HttpApi.Client</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<RootNamespace />
</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" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.HttpApi</AssemblyName>
<PackageId>Volo.Abp.Identity.HttpApi</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<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" />
</ItemGroup>

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

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

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

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

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

@ -40,7 +40,7 @@ namespace Volo.Abp.Identity
{
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");
_testCounter.GetValue("EntityUpdatedEto<UserEto>").ShouldBe(0);

@ -37,7 +37,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
(await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue();
@ -48,12 +48,12 @@ namespace Volo.Abp.Identity
[Fact]
public async Task DeleteAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
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]
public async Task UpdateAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
role.IsDefault = true;
@ -56,7 +56,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task DeleteAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
await _identityRoleStore.DeleteAsync(role);
@ -67,7 +67,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetRoleIdAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleIdAsync(role)).ShouldBe(_testData.RoleModeratorId.ToString());
@ -76,7 +76,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleNameAsync(role)).ShouldBe(role.Name);
@ -86,7 +86,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
await _identityRoleStore.SetRoleNameAsync(role, "teacher");
@ -106,7 +106,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNameAsync()
{
var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
role.Name.ShouldBe("moderator");
@ -115,7 +115,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetNormalizedRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
(await _identityRoleStore.GetNormalizedRoleNameAsync(role)).ShouldBe(role.NormalizedName);
@ -124,12 +124,12 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetNormalizedRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
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]
@ -137,7 +137,7 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
var claims = await _identityRoleStore.GetClaimsAsync(role);
@ -149,30 +149,41 @@ namespace Volo.Abp.Identity
}
}
[Fact]
public async Task AddClaimAsync()
{
using (var uow = _unitOfWorkManager.Begin())
try
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
role.ShouldNotBeNull();
using (var uow = _unitOfWorkManager.Begin())
{
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]
public async Task RemoveClaimAsync()
{
using (var uow = _unitOfWorkManager.Begin())
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
role.ShouldNotBeNull();
await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value"));

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

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

@ -45,7 +45,7 @@ namespace Volo.Abp.Identity
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());
}

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

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Volo.Abp.Identity.TestBase</AssemblyName>
<PackageId>Volo.Abp.Identity.TestBase</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@ -19,7 +19,7 @@
</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="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />

@ -43,7 +43,7 @@ namespace Volo.Abp.Identity
private void AddRoles()
{
_adminRole = _roleRepository.FindByNormalizedName(_lookupNormalizer.Normalize("admin"));
_adminRole = _roleRepository.FindByNormalizedName(_lookupNormalizer.NormalizeName("admin"));
_moderator = new IdentityRole(_testData.RoleModeratorId, "moderator");
_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 _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("admin"))).Name.ShouldBe("admin");
(await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.Normalize("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).Name.ShouldBe("admin");
(await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
}
}
}

@ -23,8 +23,8 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNormalizedNameAsync()
{
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("admin"))).ShouldNotBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.Normalize("undefined-role"))).ShouldBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role"))).ShouldBeNull();
}
[Fact]
@ -45,7 +45,7 @@ namespace Volo.Abp.Identity
[Fact]
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.Any().ShouldBeTrue();
}

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

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity
{
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.Any().ShouldBeTrue();
@ -41,7 +41,7 @@ namespace Volo.Abp.Identity
{
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.Any().ShouldBeTrue();

@ -18,7 +18,7 @@
<ItemGroup>
<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>
</Project>

@ -18,7 +18,7 @@
<ItemGroup>
<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>
</Project>

@ -19,7 +19,7 @@
<ItemGroup>
<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>
</Project>

Loading…
Cancel
Save