Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Identity/Extensions.Core/src/PasswordValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public PasswordValidator(IdentityErrorDescriber? errors = null)
/// <returns>The task object representing the asynchronous operation.</returns>
public virtual Task<IdentityResult> ValidateAsync(UserManager<TUser> manager, TUser user, string? password)
{
ArgumentNullThrowHelper.ThrowIfNull(password);
ArgumentNullThrowHelper.ThrowIfNull(manager);
List<IdentityError>? errors = null;
var options = manager.Options.Password;
password ??= "";
if (string.IsNullOrWhiteSpace(password) || password.Length < options.RequiredLength)
{
errors ??= new List<IdentityError>();
Expand Down
10 changes: 5 additions & 5 deletions src/Identity/test/Identity.Test/PasswordValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public async Task ValidateThrowsWithNullTest()

// Act
// Assert
await Assert.ThrowsAsync<ArgumentNullException>("password", () => validator.ValidateAsync(null, null, null));
await Assert.ThrowsAsync<ArgumentNullException>("manager", () => validator.ValidateAsync(null, null, "foo"));
}

[Theory]
[InlineData("")]
[InlineData("abc")]
[InlineData("abcde")]
public async Task FailsIfTooShortTests(string input)
[InlineData(null)]
[InlineData("")]
[InlineData("abc")]
[InlineData("abcde")]
public async Task FailsIfPasswordIsNullOrTooShort(string input)
{
const string error = "Passwords must be at least 6 characters.";
var manager = MockHelpers.TestUserManager<PocoUser>();
Expand Down
Loading