v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Extension\IdentityVerification\DTO;
|
||||
|
||||
use App\Extension\IdentityVerification\DTO\VerificationChallenge;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* VerificationChallenge DTO 의 maxAttempts 필드 회귀 차단.
|
||||
*
|
||||
* 이슈 #275 — DB 의 max_attempts 가 환경설정값으로 정상 저장되었음에도 응답 페이로드에
|
||||
* 노출되지 않아 프론트 launcher 가 maxAttempts:5 하드코딩으로 fallback 하여 사용자
|
||||
* 모달에 "5회 남음" 으로 표시되던 결함을 차단한다.
|
||||
*
|
||||
* DTO 가 maxAttempts 필드를 보유 + toArray() 가 max_attempts 키로 노출하는지 검증.
|
||||
*/
|
||||
class VerificationChallengeMaxAttemptsTest extends TestCase
|
||||
{
|
||||
public function test_dto_accepts_max_attempts_via_named_argument(): void
|
||||
{
|
||||
$challenge = new VerificationChallenge(
|
||||
id: 'uuid-1',
|
||||
providerId: 'g7:core.mail',
|
||||
purpose: 'signup',
|
||||
channel: 'email',
|
||||
targetHash: hash('sha256', 'user@example.com'),
|
||||
expiresAt: Carbon::parse('2026-05-14T10:00:00+00:00'),
|
||||
renderHint: 'text_code',
|
||||
maxAttempts: 12,
|
||||
);
|
||||
|
||||
$this->assertSame(12, $challenge->maxAttempts);
|
||||
}
|
||||
|
||||
public function test_dto_defaults_max_attempts_to_zero(): void
|
||||
{
|
||||
// 기본값 0 — popup/SDK 형 provider (이니시스 등) 가 named args 로 호출 시 별도 지정 없이도 동작
|
||||
$challenge = new VerificationChallenge(
|
||||
id: 'uuid-2',
|
||||
providerId: 'inicis',
|
||||
purpose: 'signup',
|
||||
channel: 'ipin',
|
||||
targetHash: hash('sha256', 'user@example.com'),
|
||||
expiresAt: Carbon::now(),
|
||||
renderHint: 'text_code',
|
||||
);
|
||||
|
||||
$this->assertSame(0, $challenge->maxAttempts);
|
||||
}
|
||||
|
||||
public function test_to_array_exposes_max_attempts_key(): void
|
||||
{
|
||||
$challenge = new VerificationChallenge(
|
||||
id: 'uuid-3',
|
||||
providerId: 'g7:core.mail',
|
||||
purpose: 'signup',
|
||||
channel: 'email',
|
||||
targetHash: hash('sha256', 'a@b.com'),
|
||||
expiresAt: Carbon::parse('2026-05-14T11:00:00+00:00'),
|
||||
renderHint: 'text_code',
|
||||
maxAttempts: 7,
|
||||
);
|
||||
|
||||
$arr = $challenge->toArray();
|
||||
|
||||
$this->assertArrayHasKey('max_attempts', $arr);
|
||||
$this->assertSame(7, $arr['max_attempts']);
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,11 @@ class IdentityVerificationManagerTest extends TestCase
|
||||
return ['email'];
|
||||
}
|
||||
|
||||
public function getChannelLabels(): array
|
||||
{
|
||||
return ['email' => 'Email'];
|
||||
}
|
||||
|
||||
public function getRenderHint(): string
|
||||
{
|
||||
return 'text_code';
|
||||
|
||||
@@ -123,6 +123,65 @@ class MailIdentityProviderTest extends TestCase
|
||||
$this->assertSame(1, $log->attempts);
|
||||
}
|
||||
|
||||
public function test_verify_returns_max_attempts_on_final_wrong_attempt(): void
|
||||
{
|
||||
/** @var IdentityVerificationLogRepositoryInterface $repo */
|
||||
$repo = $this->app->make(IdentityVerificationLogRepositoryInterface::class);
|
||||
|
||||
$challenge = $this->provider->requestChallenge(
|
||||
['email' => 'user@example.com'],
|
||||
['purpose' => 'sensitive_action'],
|
||||
);
|
||||
|
||||
// max_attempts 를 2 로 낮춰 빠르게 소진. 1회차는 INVALID_CODE, 2회차(소진)는 MAX_ATTEMPTS 안내.
|
||||
$repo->updateById($challenge->id, [
|
||||
'metadata' => ['code_hash' => password_hash('123456', PASSWORD_BCRYPT)],
|
||||
'status' => IdentityVerificationStatus::Sent->value,
|
||||
'max_attempts' => 2,
|
||||
]);
|
||||
|
||||
// 1회차 오답 — 아직 소진 전이므로 일반 오답 안내.
|
||||
$first = $this->provider->verify($challenge->id, ['code' => '999999']);
|
||||
$this->assertFalse($first->success);
|
||||
$this->assertSame('INVALID_CODE', $first->failureCode);
|
||||
$this->assertSame('identity.errors.invalid_code', $first->failureReason);
|
||||
|
||||
// 2회차 오답 — 이번 시도로 max_attempts 도달(소진). 사용자에게 "최대 시도 초과 + 재요청" 안내가 도달해야 함.
|
||||
$second = $this->provider->verify($challenge->id, ['code' => '999999']);
|
||||
$this->assertFalse($second->success);
|
||||
$this->assertSame('MAX_ATTEMPTS', $second->failureCode);
|
||||
$this->assertSame('identity.errors.max_attempts', $second->failureReason);
|
||||
|
||||
$log = IdentityVerificationLog::find($challenge->id);
|
||||
$this->assertSame(2, $log->attempts);
|
||||
$this->assertSame(IdentityVerificationStatus::Failed, $log->status);
|
||||
}
|
||||
|
||||
public function test_verify_returns_max_attempts_when_already_exhausted(): void
|
||||
{
|
||||
/** @var IdentityVerificationLogRepositoryInterface $repo */
|
||||
$repo = $this->app->make(IdentityVerificationLogRepositoryInterface::class);
|
||||
|
||||
$challenge = $this->provider->requestChallenge(
|
||||
['email' => 'user@example.com'],
|
||||
['purpose' => 'sensitive_action'],
|
||||
);
|
||||
|
||||
// 이미 소진된 상태(attempts == max_attempts)에서 또 시도 — 코드 대조 전에 차단.
|
||||
$repo->updateById($challenge->id, [
|
||||
'metadata' => ['code_hash' => password_hash('123456', PASSWORD_BCRYPT)],
|
||||
'status' => IdentityVerificationStatus::Sent->value,
|
||||
'attempts' => 5,
|
||||
'max_attempts' => 5,
|
||||
]);
|
||||
|
||||
$result = $this->provider->verify($challenge->id, ['code' => '123456']);
|
||||
|
||||
$this->assertFalse($result->success);
|
||||
$this->assertSame('MAX_ATTEMPTS', $result->failureCode);
|
||||
$this->assertSame('identity.errors.max_attempts', $result->failureReason);
|
||||
}
|
||||
|
||||
public function test_cancel_marks_status_as_cancelled(): void
|
||||
{
|
||||
$challenge = $this->provider->requestChallenge(
|
||||
|
||||
Reference in new issue
Block a user