Implement billing status notification and enhance user management integration
- Added `NotifyBillingStatusChangedAsync` method to `IRealtimeNotifier` for notifying clients about changes in billing status. - Updated `BillingConfigResumer` to call the new notification method after modifying billing configurations, ensuring users receive real-time updates. - Enhanced `ListUsersQueryHandler` to include a `BillingPendingReview` property in `UserSummaryDto`, indicating if a user has a pending payment request awaiting confirmation. - Refactored various command handlers to utilize `AdvisoryLock` for managing concurrent requests, preventing race conditions in billing operations. - Updated tests to cover new notification behaviors and ensure proper functionality in billing status management.
This commit is contained in:
@@ -100,4 +100,41 @@ public class RefreshCommandHandlerTests
|
||||
Assert.False(result.IsSuccess);
|
||||
Assert.Equal(AuthErrors.InvalidRefreshToken, result.Error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_WhenUserBlocked_ReturnsUserBlocked()
|
||||
{
|
||||
var userId = Guid.NewGuid();
|
||||
var profile = new CurrentUserProfile(
|
||||
userId,
|
||||
"alice",
|
||||
Guid.NewGuid(),
|
||||
"user",
|
||||
IsActivated: true,
|
||||
IsBlocked: true,
|
||||
MaxConfigs: 3,
|
||||
MaxIpLimit: RoleQuota.Unlimited,
|
||||
SubscriptionToken: "sub-token",
|
||||
BillingEnabled: false,
|
||||
BillingPaidUntil: null,
|
||||
BillingSuspended: false
|
||||
);
|
||||
var rotated = new RotatedRefreshToken(
|
||||
userId,
|
||||
"new-refresh-token",
|
||||
DateTimeOffset.UtcNow.AddDays(30)
|
||||
);
|
||||
|
||||
_refreshTokenService
|
||||
.RotateAsync("old-token", Arg.Any<CancellationToken>())
|
||||
.Returns(Result.Success(rotated));
|
||||
_identityService.GetProfileAsync(userId, Arg.Any<CancellationToken>()).Returns(profile);
|
||||
|
||||
var result = await CreateHandler()
|
||||
.Handle(new RefreshCommand("old-token"), CancellationToken.None);
|
||||
|
||||
Assert.False(result.IsSuccess);
|
||||
Assert.Equal(AuthErrors.UserBlocked, result.Error);
|
||||
_jwtTokenService.DidNotReceive().GenerateAccessToken(Arg.Any<AuthenticatedUser>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user