|
|
|
@ -29,29 +29,29 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetUserIdAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetUserIdAsync(user)).ShouldBe(user.Id.ToString()); |
|
|
|
(await _identityUserStore.GetUserIdAsync(user).ConfigureAwait(false)).ShouldBe(user.Id.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetUserNameAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetUserNameAsync(user)).ShouldBe(user.UserName); |
|
|
|
(await _identityUserStore.GetUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.UserName); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetUserNameAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetUserNameAsync(user, "bob.lee"); |
|
|
|
await _identityUserStore.SetUserNameAsync(user, "bob.lee").ConfigureAwait(false); |
|
|
|
user.UserName.ShouldBe("bob.lee"); |
|
|
|
//user.NormalizedUserName.ShouldBe(_lookupNormalizer.Normalize("bob.lee"));
|
|
|
|
} |
|
|
|
@ -60,19 +60,19 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetNormalizedUserNameAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetNormalizedUserNameAsync(user)).ShouldBe(user.NormalizedUserName); |
|
|
|
(await _identityUserStore.GetNormalizedUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedUserName); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetNormalizedUserNameAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee")); |
|
|
|
await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.NormalizedUserName.ShouldBe(_lookupNormalizer.NormalizeName("bob.lee")); |
|
|
|
} |
|
|
|
@ -83,9 +83,9 @@ namespace Volo.Abp.Identity |
|
|
|
var userId = Guid.NewGuid(); |
|
|
|
var user = new IdentityUser(userId, "bob.lee", "bob.lee@abp.io"); |
|
|
|
|
|
|
|
await _identityUserStore.CreateAsync(user); |
|
|
|
await _identityUserStore.CreateAsync(user).ConfigureAwait(false); |
|
|
|
|
|
|
|
var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee")); |
|
|
|
var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false); |
|
|
|
bobLee.ShouldNotBeNull(); |
|
|
|
bobLee.UserName.ShouldBe("bob.lee"); |
|
|
|
bobLee.Email.ShouldBe("bob.lee@abp.io"); |
|
|
|
@ -94,26 +94,26 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task UpdateAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
user.Name = "lee"; |
|
|
|
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); |
|
|
|
(await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); |
|
|
|
|
|
|
|
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).Name |
|
|
|
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).Name |
|
|
|
.ShouldBe("lee"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Update_Concurrency() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue(); |
|
|
|
(await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); |
|
|
|
|
|
|
|
user.ConcurrencyStamp = Guid.NewGuid().ToString(); |
|
|
|
var identityResult = await _identityUserStore.UpdateAsync(user); |
|
|
|
var identityResult = await _identityUserStore.UpdateAsync(user).ConfigureAwait(false); |
|
|
|
|
|
|
|
identityResult.Succeeded.ShouldBeFalse(); |
|
|
|
identityResult.Errors.ShouldContain(x => |
|
|
|
@ -126,19 +126,19 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task DeleteAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.DeleteAsync(user)).Succeeded.ShouldBeTrue(); |
|
|
|
(await _identityUserStore.DeleteAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue(); |
|
|
|
|
|
|
|
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).ShouldBeNull(); |
|
|
|
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).ShouldBeNull(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task FindByIdAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString()); |
|
|
|
var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString()).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.UserName.ShouldBe("john.nash"); |
|
|
|
@ -148,7 +148,7 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task FindByNameAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.UserName.ShouldBe("john.nash"); |
|
|
|
@ -158,11 +158,11 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task SetPasswordHashAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.PasswordHash.ShouldBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); |
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); |
|
|
|
user.PasswordHash.ShouldBe("P@ssw0rd"); |
|
|
|
} |
|
|
|
|
|
|
|
@ -170,23 +170,23 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetPasswordHashAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); |
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); |
|
|
|
|
|
|
|
(await _identityUserStore.GetPasswordHashAsync(user)).ShouldBe("P@ssw0rd"); |
|
|
|
(await _identityUserStore.GetPasswordHashAsync(user).ConfigureAwait(false)).ShouldBe("P@ssw0rd"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task HasPasswordAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeFalse(); |
|
|
|
(await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeFalse(); |
|
|
|
|
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd"); |
|
|
|
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeTrue(); |
|
|
|
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false); |
|
|
|
(await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeTrue(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -194,15 +194,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Roles.ShouldBeEmpty(); |
|
|
|
|
|
|
|
await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")); |
|
|
|
await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -211,15 +211,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId); |
|
|
|
|
|
|
|
await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")); |
|
|
|
await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -227,10 +227,10 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetRolesAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
var roleNames = await _identityUserStore.GetRolesAsync(user); |
|
|
|
var roleNames = await _identityUserStore.GetRolesAsync(user).ConfigureAwait(false); |
|
|
|
roleNames.ShouldNotBeEmpty(); |
|
|
|
roleNames.ShouldContain(x => x == "moderator"); |
|
|
|
roleNames.ShouldContain(x => x == "supporter"); |
|
|
|
@ -241,13 +241,13 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"))).ShouldBeTrue(); |
|
|
|
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist"))).ShouldBeFalse(); |
|
|
|
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false)).ShouldBeTrue(); |
|
|
|
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist")).ConfigureAwait(false)).ShouldBeFalse(); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -256,14 +256,14 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
var claims = await _identityUserStore.GetClaimsAsync(user); |
|
|
|
var claims = await _identityUserStore.GetClaimsAsync(user).ConfigureAwait(false); |
|
|
|
claims.ShouldNotBeEmpty(); |
|
|
|
claims.ShouldContain(x => x.Type == "TestClaimType" && x.Value == "42"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -272,18 +272,18 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Claims.ShouldNotContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); |
|
|
|
|
|
|
|
await _identityUserStore.AddClaimsAsync(user, new List<Claim>() |
|
|
|
{ |
|
|
|
new Claim("MyClaimType", "MyClaimValue") |
|
|
|
}); |
|
|
|
}).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -292,15 +292,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue")); |
|
|
|
await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42"); |
|
|
|
user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -309,17 +309,17 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.RemoveClaimsAsync(user, new List<Claim>() |
|
|
|
{ |
|
|
|
new Claim("TestClaimType", "42") |
|
|
|
}); |
|
|
|
}).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -328,15 +328,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Logins.ShouldNotContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john"); |
|
|
|
|
|
|
|
await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash")); |
|
|
|
await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Logins.ShouldContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -345,15 +345,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); |
|
|
|
|
|
|
|
await _identityUserStore.RemoveLoginAsync(user, "github", "john"); |
|
|
|
await _identityUserStore.RemoveLoginAsync(user, "github", "john").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Logins.ShouldNotContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -363,16 +363,16 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
var logins = await _identityUserStore.GetLoginsAsync(user); |
|
|
|
var logins = await _identityUserStore.GetLoginsAsync(user).ConfigureAwait(false); |
|
|
|
|
|
|
|
logins.ShouldNotBeNull(); |
|
|
|
logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john"); |
|
|
|
logins.ShouldContain(x => x.LoginProvider == "twitter" && x.ProviderKey == "johnx"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -380,7 +380,7 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task FindByLoginAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.FindByLoginAsync("github", "john"); |
|
|
|
var user = await _identityUserStore.FindByLoginAsync("github", "john").ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.UserName.ShouldBe("john.nash"); |
|
|
|
} |
|
|
|
@ -389,21 +389,21 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetEmailConfirmedAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetEmailConfirmedAsync(user)).ShouldBe(user.EmailConfirmed); |
|
|
|
(await _identityUserStore.GetEmailConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.EmailConfirmed); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetEmailConfirmedAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var emailConfirmed = user.EmailConfirmed; |
|
|
|
|
|
|
|
await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed); |
|
|
|
await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.EmailConfirmed.ShouldBe(!emailConfirmed); |
|
|
|
} |
|
|
|
@ -411,10 +411,10 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task SetEmailAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io"); |
|
|
|
await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Email.ShouldBe("john.nash.kobe@abp.io"); |
|
|
|
//user.NormalizedEmail.ShouldBe(_lookupNormalizer.Normalize("john.nash.kobe@abp.io"));
|
|
|
|
@ -423,28 +423,28 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetEmailAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetEmailAsync(user)).ShouldBe(user.Email); |
|
|
|
(await _identityUserStore.GetEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.Email); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetNormalizedEmailAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetNormalizedEmailAsync(user)).ShouldBe(user.NormalizedEmail); |
|
|
|
(await _identityUserStore.GetNormalizedEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedEmail); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetNormalizedEmailAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")); |
|
|
|
await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.NormalizedEmail.ShouldBe(_lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")); |
|
|
|
} |
|
|
|
@ -452,7 +452,7 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task FindByEmailAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io")); |
|
|
|
var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.Email.ShouldBe("john.nash@abp.io"); |
|
|
|
@ -461,19 +461,19 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetLockoutEndDateAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetLockoutEndDateAsync(user)).ShouldBe(user.LockoutEnd); |
|
|
|
(await _identityUserStore.GetLockoutEndDateAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnd); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetLockoutEndDateAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")); |
|
|
|
await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.LockoutEnd.ShouldBe(DateTimeOffset.Parse("01/01/2019")); |
|
|
|
} |
|
|
|
@ -482,11 +482,11 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task IncrementAccessFailedCountAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var count = user.AccessFailedCount; |
|
|
|
|
|
|
|
await _identityUserStore.IncrementAccessFailedCountAsync(user); |
|
|
|
await _identityUserStore.IncrementAccessFailedCountAsync(user).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.AccessFailedCount.ShouldBe(count + 1); |
|
|
|
} |
|
|
|
@ -494,10 +494,10 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task ResetAccessFailedCountAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.ResetAccessFailedCountAsync(user); |
|
|
|
await _identityUserStore.ResetAccessFailedCountAsync(user).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.AccessFailedCount.ShouldBe(0); |
|
|
|
} |
|
|
|
@ -505,29 +505,29 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetAccessFailedCountAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetAccessFailedCountAsync(user)).ShouldBe(user.AccessFailedCount); |
|
|
|
(await _identityUserStore.GetAccessFailedCountAsync(user).ConfigureAwait(false)).ShouldBe(user.AccessFailedCount); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetLockoutEnabledAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetLockoutEnabledAsync(user)).ShouldBe(user.LockoutEnabled); |
|
|
|
(await _identityUserStore.GetLockoutEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnabled); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetLockoutEnabledAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var lockoutEnabled = user.LockoutEnabled; |
|
|
|
|
|
|
|
await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled); |
|
|
|
await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.LockoutEnabled.ShouldBe(!lockoutEnabled); |
|
|
|
} |
|
|
|
@ -536,10 +536,10 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task SetPhoneNumberAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetPhoneNumberAsync(user, "13800138000"); |
|
|
|
await _identityUserStore.SetPhoneNumberAsync(user, "13800138000").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.PhoneNumber.ShouldBe("13800138000"); |
|
|
|
} |
|
|
|
@ -548,30 +548,30 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetPhoneNumberAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetPhoneNumberAsync(user)).ShouldBe(user.PhoneNumber); |
|
|
|
(await _identityUserStore.GetPhoneNumberAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumber); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetPhoneNumberConfirmedAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetPhoneNumberConfirmedAsync(user)).ShouldBe(user.PhoneNumberConfirmed); |
|
|
|
(await _identityUserStore.GetPhoneNumberConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumberConfirmed); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetPhoneNumberConfirmedAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var phoneNumberConfirmed = user.PhoneNumberConfirmed; |
|
|
|
|
|
|
|
await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed); |
|
|
|
await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.PhoneNumberConfirmed.ShouldBe(!phoneNumberConfirmed); |
|
|
|
} |
|
|
|
@ -580,11 +580,11 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task SetSecurityStampAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var securityStamp = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
await _identityUserStore.SetSecurityStampAsync(user, securityStamp); |
|
|
|
await _identityUserStore.SetSecurityStampAsync(user, securityStamp).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.SecurityStamp.ShouldBe(securityStamp); |
|
|
|
} |
|
|
|
@ -592,21 +592,21 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetSecurityStampAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetSecurityStampAsync(user)).ShouldBe(user.SecurityStamp); |
|
|
|
(await _identityUserStore.GetSecurityStampAsync(user).ConfigureAwait(false)).ShouldBe(user.SecurityStamp); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SetTwoFactorEnabledAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
var twoFactorEnabled = user.TwoFactorEnabled; |
|
|
|
|
|
|
|
await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled); |
|
|
|
await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.TwoFactorEnabled.ShouldBe(!twoFactorEnabled); |
|
|
|
} |
|
|
|
@ -615,16 +615,16 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetTwoFactorEnabledAsync() |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetTwoFactorEnabledAsync(user)).ShouldBe(user.TwoFactorEnabled); |
|
|
|
(await _identityUserStore.GetTwoFactorEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.TwoFactorEnabled); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetUsersForClaimAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42")); |
|
|
|
var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.ShouldNotBeEmpty(); |
|
|
|
user.ShouldContain(x => x.UserName == "john.nash"); |
|
|
|
@ -633,7 +633,7 @@ namespace Volo.Abp.Identity |
|
|
|
[Fact] |
|
|
|
public async Task GetUsersInRoleAsync() |
|
|
|
{ |
|
|
|
var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator")); |
|
|
|
var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
user.ShouldContain(x => x.UserName == "john.nash"); |
|
|
|
} |
|
|
|
@ -643,15 +643,15 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123"); |
|
|
|
await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Tokens.ShouldNotBeEmpty(); |
|
|
|
user.Tokens.ShouldContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -660,14 +660,14 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name"); |
|
|
|
await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Tokens.ShouldNotContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -676,12 +676,12 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
(await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name")).ShouldBe("test-value"); |
|
|
|
(await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false)).ShouldBe("test-value"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -690,14 +690,14 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); |
|
|
|
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "AuthenticatorKey" && x.Value == "testKey"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -706,13 +706,13 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey"); |
|
|
|
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false); |
|
|
|
|
|
|
|
(await _identityUserStore.GetAuthenticatorKeyAsync(user)).ShouldBe("testKey"); |
|
|
|
(await _identityUserStore.GetAuthenticatorKeyAsync(user).ConfigureAwait(false)).ShouldBe("testKey"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@ -722,13 +722,13 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); |
|
|
|
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false); |
|
|
|
|
|
|
|
(await _identityUserStore.CountCodesAsync(user)).ShouldBe(2); |
|
|
|
(await _identityUserStore.CountCodesAsync(user).ConfigureAwait(false)).ShouldBe(2); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -737,18 +737,18 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _identityUserStore.ReplaceCodesAsync(user, new List<string>() |
|
|
|
{ |
|
|
|
"testKey", |
|
|
|
"testKey2" |
|
|
|
}); |
|
|
|
}).ConfigureAwait(false); |
|
|
|
|
|
|
|
user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "RecoveryCodes" && x.Value == "testKey;testKey2"); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -757,13 +757,13 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); |
|
|
|
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false); |
|
|
|
user.ShouldNotBeNull(); |
|
|
|
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2"); |
|
|
|
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false); |
|
|
|
|
|
|
|
(await _identityUserStore.RedeemCodeAsync(user, "testKey")).ShouldBeTrue(); |
|
|
|
(await _identityUserStore.RedeemCodeAsync(user, "testKey").ConfigureAwait(false)).ShouldBeTrue(); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
await uow.CompleteAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|