Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public async Task<IReadOnlyList<OrganizationUser>> ValidateAsync(User user,
}

// Exclude any account recovery that do not have a key.
existing = existing.Where(o => o.ResetPasswordKey != null).ToList();
Comment thread
mzieniukbw marked this conversation as resolved.

existing = existing.Where(o => !string.IsNullOrEmpty(o.ResetPasswordKey)).ToList();

foreach (var ou in existing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,44 @@ public async Task ValidateAsync_NoOrgUsers_ReturnsEmptyList(
Assert.Empty(result);
}

[Theory]
[BitAutoData([null])]
[BitAutoData("")]
public async Task ValidateAsync_OrgUsersWithNullOrEmptyResetPasswordKey_FiltersOutInvalidKeys(
string? invalidResetPasswordKey,
SutProvider<OrganizationUserRotationValidator> sutProvider, User user,
ResetPasswordWithOrgIdRequestModel validResetPasswordKey)
{
// Arrange
var existingUserResetPassword = new List<OrganizationUser>
{
// Valid org user with reset password key
new OrganizationUser
{
Id = Guid.NewGuid(),
OrganizationId = validResetPasswordKey.OrganizationId,
ResetPasswordKey = validResetPasswordKey.ResetPasswordKey
},
// Invalid org user with null or empty reset password key - should be filtered out
new OrganizationUser
{
Id = Guid.NewGuid(),
OrganizationId = Guid.NewGuid(),
ResetPasswordKey = invalidResetPasswordKey
}
};
sutProvider.GetDependency<IOrganizationUserRepository>().GetManyByUserAsync(user.Id)
.Returns(existingUserResetPassword);

// Act
var result = await sutProvider.Sut.ValidateAsync(user, new[] { validResetPasswordKey });

// Assert
Assert.NotNull(result);
Assert.Single(result);
Assert.Equal(validResetPasswordKey.OrganizationId, result[0].OrganizationId);
}

[Theory]
[BitAutoData]
public async Task ValidateAsync_MissingResetPassword_Throws(
Expand Down
Loading