feat: 启用百度云 SMS 真实验证码发送
- SmsService: 从开发桩改为调用 BceSmsClient.SendAsync 真实发送 - AuthService.SendCodeAsync: 加 60 秒冷却 + 发送结果检查(失败返回 40010) - Program.cs: 注册 BceSmsClient 到 DI(AddHttpClient + 10s 超时) - auth_tests.cs: 加 CreateSmsService helper 适配构造注入 移动号实测可收到验证码,联通号运营商环节待报备
This commit is contained in:
@@ -5,6 +5,7 @@ using Health.Infrastructure.Data;
|
||||
using Health.Infrastructure.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace Health.Tests;
|
||||
|
||||
@@ -32,12 +33,16 @@ public class AuthTests
|
||||
return new ConfigurationBuilder().AddInMemoryCollection(settings).Build();
|
||||
}
|
||||
|
||||
private static SmsService CreateSmsService() =>
|
||||
new(new BceSmsClient(new HttpClient(), new ConfigurationBuilder().Build(), NullLogger<BceSmsClient>.Instance),
|
||||
NullLogger<SmsService>.Instance);
|
||||
|
||||
[Fact]
|
||||
public async Task SendSms_Should_Create_VerificationCode()
|
||||
{
|
||||
// Arrange
|
||||
using var db = CreateDbContext();
|
||||
var sms = new SmsService();
|
||||
var sms = CreateSmsService();
|
||||
|
||||
// Act
|
||||
var code = sms.GenerateCode();
|
||||
@@ -148,7 +153,7 @@ public class AuthTests
|
||||
var service = new AuthService(
|
||||
db,
|
||||
jwt,
|
||||
new SmsService(),
|
||||
CreateSmsService(),
|
||||
new AppleTokenValidator(config));
|
||||
|
||||
var result = await service.RefreshAsync(oldRefresh, CancellationToken.None);
|
||||
|
||||
Reference in New Issue
Block a user