Skip to content

test(identity): add handler tests for auth-critical flows#1204

Merged
iammukeshm merged 3 commits intodevelopfrom
test/identity-handler-tests
Feb 2, 2026
Merged

test(identity): add handler tests for auth-critical flows#1204
iammukeshm merged 3 commits intodevelopfrom
test/identity-handler-tests

Conversation

@iammukeshm
Copy link
Member

Summary

Adds comprehensive handler tests for the Identity module's auth-critical handlers.

New Test Files (1,470 lines)

  • GenerateTokenCommandHandlerTests.cs - login flow
  • RefreshTokenCommandHandlerTests.cs - token refresh
  • RegisterUserCommandHandlerTests.cs - user registration
  • RevokeSessionCommandHandlerTests.cs - session management
  • ChangePasswordCommandHandlerTests.cs - password change

Coverage Per Handler

  • ✅ Happy path (success scenarios)
  • ✅ Invalid input handling (null checks)
  • ✅ Exception scenarios (service failures)
  • ✅ CancellationToken propagation
  • ✅ Edge cases

Testing Stack

Uses existing patterns: xUnit, Shouldly, NSubstitute, AutoFixture

Addresses #1173 (partial - 5 of 60+ handlers now tested)

- Added GenerateTokenCommandHandler tests (login flow)
- Added RefreshTokenCommandHandler tests (token refresh)
- Added RegisterUserCommandHandler tests (user registration)
- Added RevokeSessionCommandHandler tests (session management)
- Added ChangePasswordCommandHandler tests (password change)

Tests include:
- Happy path scenarios
- Invalid input handling (null checks)
- Exception scenarios
- CancellationToken propagation
- Edge cases and error conditions

Following existing test patterns from Multitenancy module:
- Uses xUnit, Shouldly, NSubstitute, AutoFixture
- Arrange/Act/Assert pattern
- Comprehensive test coverage per handler

Addresses issue #1173
jarvis added 2 commits February 2, 2026 05:25
- Added using NSubstitute.ExceptionExtensions to:
  - RevokeSessionCommandHandlerTests.cs
  - ChangePasswordCommandHandlerTests.cs
  - GenerateTokenCommandHandlerTests.cs
  - RegisterUserCommandHandlerTests.cs
- Fixed IIntegrationEvent type in outboxStore assertions
- Make ConfigureRecipients and CreateBasicClaims static (CA1822)
- Cache JsonSerializerOptions in VersionCommand (CA1869)
- Delete unused TemplateEngineTests.cs debug file
- Add NoWarn for false-positive warnings in CLI project:
  - CA1812: Classes instantiated via DI
  - CA1031: Intentional catch-all in TryLoad/IsValid methods
  - CA1303: CLI is not localized
  - CA1308: ToLowerInvariant intentional for identifiers
  - Other code style warnings that don't apply to CLI tools
@iammukeshm iammukeshm merged commit 713a0f2 into develop Feb 2, 2026
8 checks passed
@iammukeshm iammukeshm deleted the test/identity-handler-tests branch February 2, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant