Adjust test
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
using ColaFlow.Modules.Identity.Application.Services;
|
||||
using ColaFlow.Modules.Identity.Infrastructure.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ColaFlow.Modules.Identity.IntegrationTests.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
@@ -24,6 +28,16 @@ public class DatabaseFixture : IDisposable
|
||||
return Factory.CreateClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MockEmailService from the DI container for testing
|
||||
/// </summary>
|
||||
public MockEmailService GetEmailService()
|
||||
{
|
||||
var scope = Factory.Services.CreateScope();
|
||||
var emailService = scope.ServiceProvider.GetRequiredService<IEmailService>();
|
||||
return (MockEmailService)emailService;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Factory?.Dispose();
|
||||
|
||||
@@ -93,6 +93,41 @@ public static class TestAuthHelper
|
||||
return claims.Any(c => c.Type == "role" && c.Value == role) ||
|
||||
claims.Any(c => c.Type == "tenant_role" && c.Value == role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract invitation token from email HTML body
|
||||
/// </summary>
|
||||
public static string? ExtractInvitationTokenFromEmail(string htmlBody)
|
||||
{
|
||||
return ExtractTokenFromEmailBody(htmlBody, "token");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract verification token from email HTML body
|
||||
/// </summary>
|
||||
public static string? ExtractVerificationTokenFromEmail(string htmlBody)
|
||||
{
|
||||
return ExtractTokenFromEmailBody(htmlBody, "token");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract password reset token from email HTML body
|
||||
/// </summary>
|
||||
public static string? ExtractPasswordResetTokenFromEmail(string htmlBody)
|
||||
{
|
||||
return ExtractTokenFromEmailBody(htmlBody, "token");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract token from email HTML body by parameter name
|
||||
/// </summary>
|
||||
private static string? ExtractTokenFromEmailBody(string htmlBody, string tokenParam)
|
||||
{
|
||||
// Pattern to match: token=VALUE or ?token=VALUE or &token=VALUE
|
||||
var pattern = $@"[?&]{tokenParam}=([A-Za-z0-9_-]+)";
|
||||
var match = System.Text.RegularExpressions.Regex.Match(htmlBody, pattern);
|
||||
return match.Success ? match.Groups[1].Value : null;
|
||||
}
|
||||
}
|
||||
|
||||
// Response DTOs
|
||||
|
||||
Reference in New Issue
Block a user