Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Lockout Functionality: Add Test for AccessFailedAsync Incrementing Count #60350

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

shethaadit
Copy link
Contributor

Enhance Lockout Functionality: Add Test for AccessFailedAsync Incrementing Count

PR Description:

This PR enhances the test coverage of the lockout functionality in UserManagerTest.cs by adding a new test case:

  • Test Added: AccessFailedAsync_IncrementsAccessFailedCount
    • Verifies that calling AccessFailedAsync correctly increments the access failed count for a user.
    • Uses Mock<IUserLockoutStore<PocoUser>> to simulate the behavior of the underlying store.
    • Ensures the expected count is returned after an access failure.

This change improves reliability by validating that lockout mechanisms work as expected, aligning with best practices in identity management.

Testing:

  • The new test follows the existing structure and has been validated using mock implementations.
  • Ran the full test suite to confirm no regressions.

Fixes #60181

@Copilot Copilot bot review requested due to automatic review settings February 12, 2025 19:47
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-identity Includes: Identity and providers label Feb 12, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 12, 2025
Copy link
Contributor

Thanks for your PR, @shethaadit. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Identity/Extensions.Core/src/UserManager.cs:1833

  • Add a test to cover the scenario where Options.Lockout.DefaultLockoutTimeSpan is TimeSpan.MaxValue to ensure the lockout end date is set correctly.
if (Options.Lockout.DefaultLockoutTimeSpan == TimeSpan.MaxValue)

Copy link
Contributor

@Rick-Anderson Rick-Anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdykstra review my suggestions please.

@shethaadit
Copy link
Contributor Author

shethaadit commented Feb 13, 2025

Hi @Rick-Anderson, @tdykstra, I committed changes according to suggestions. Could you please review again?

Can you also help fixing build issue? Seems something from platform side.

.dotnet\sdk\10.0.100-preview.2.25102.3\NuGet.targets(175,5): error : (NETCORE_ENGINEERING_TELEMETRY=Build) Cannot create a file when that file already exists.

@shethaadit
Copy link
Contributor Author

Hi @Rick-Anderson, @tdykstra, I committed changes according to suggestions. Could you please review again?

Can you also help fixing build issue? Seems something from platform side.

.dotnet\sdk\10.0.100-preview.2.25102.3\NuGet.targets(175,5): error : (NETCORE_ENGINEERING_TELEMETRY=Build) Cannot create a file when that file already exists.

Hi @Rick-Anderson, @tdykstra, can you please review?

Copy link
Contributor

@Rick-Anderson Rick-Anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for accepting my suggestions. As mentioned previously, I'm only approving the comments. I'm not able to review the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-identity Includes: Identity and providers community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UserManager.AccessFailedAsync results in overflow if DefaultLockoutTimeSpan is too large
2 participants