diff --git a/plugins/_bundled/sirsoft-gdpr/resources/js/__tests__/layouts/cookie_banner.test.tsx b/plugins/_bundled/sirsoft-gdpr/resources/js/__tests__/layouts/cookie_banner.test.tsx index 356fd9bb..a6069948 100644 --- a/plugins/_bundled/sirsoft-gdpr/resources/js/__tests__/layouts/cookie_banner.test.tsx +++ b/plugins/_bundled/sirsoft-gdpr/resources/js/__tests__/layouts/cookie_banner.test.tsx @@ -142,6 +142,16 @@ describe('extensions/cookie_banner.json — 쿠키 동의 배너', () => { expect(shown).toBe(true); }); + it('회원이 닫은 뒤 로그아웃하면(게스트로 전환) 배너가 다시 뜬다', () => { + // currentUser 가 undefined 로 바뀌므로 식별자는 fallback 'guest' 로 평가된다. + // dismissedFor 는 이전 회원 uuid 로 남아있어 'guest' 와 불일치 → 재노출(안전측 동작). + const shown = evaluateBannerIf( + { data: { has_consented: false } }, + { gdprBannerDismissedFor: 'user-uuid-1', currentUser: undefined } + ); + expect(shown).toBe(true); + }); + it('서버가 이미 동의 완료(has_consented=true)로 응답하면 dismissedFor 값과 무관하게 배너를 띄우지 않는다', () => { const shown = evaluateBannerIf( { data: { has_consented: true } }, diff --git a/plugins/_bundled/sirsoft-gdpr/src/Console/Commands/PlaywrightSeedGdprGuestLogin.php b/plugins/_bundled/sirsoft-gdpr/src/Console/Commands/PlaywrightSeedGdprGuestLogin.php index cf72c671..e1027525 100644 --- a/plugins/_bundled/sirsoft-gdpr/src/Console/Commands/PlaywrightSeedGdprGuestLogin.php +++ b/plugins/_bundled/sirsoft-gdpr/src/Console/Commands/PlaywrightSeedGdprGuestLogin.php @@ -8,6 +8,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\Config; use Illuminate\Support\Str; use Plugins\Sirsoft\Gdpr\Concerns\IssuesGuestSessionCookie; +use Plugins\Sirsoft\Gdpr\Models\GdprUserConsentHistory; use Plugins\Sirsoft\Gdpr\Services\GdprConsentService; /** @@ -33,11 +34,6 @@ class PlaywrightSeedGdprGuestLogin extends Command { use IssuesGuestSessionCookie; - /** - * 시나리오에서 로그인 폼에 실제로 입력할 고정 비밀번호. - */ - private const MEMBER_PASSWORD = 'e2e-test-password-1234'; - protected $signature = 'playwright:seed-gdpr-guest-login {--json : 결과를 JSON 으로 출력}'; @@ -72,8 +68,10 @@ class PlaywrightSeedGdprGuestLogin extends Command // 배너 자체가 꺼져 있으면 재현이 불가능하므로 명시적으로 켠다. $pluginSettings->save('sirsoft-gdpr', ['banner_enabled' => true]); - // 게스트 세션: 서명된 쿠키 값을 발급하고, 동일 session_id 로 "모두 동의" 이력을 기록한다. - $guestSessionId = (string) Str::uuid(); + // 게스트 세션: 고정 session_id 사용 — 재실행 시 기존 이력을 먼저 삭제해 + // gdpr_user_consent_histories 가 무한히 누적되지 않도록 한다(멱등성 보장). + $guestSessionId = 'e2e-gdpr-guest-login-fixed-session'; + GdprUserConsentHistory::where('session_id', $guestSessionId)->delete(); $signedCookieValue = $this->signGuestSessionId($guestSessionId); $consentService->updateConsents( null, @@ -82,17 +80,22 @@ class PlaywrightSeedGdprGuestLogin extends Command 'banner' ); - // 로그인 대상 회원: 동의 이력이 전혀 없는 신규 계정. - $email = 'e2e-gdpr-guest-login-'.uniqid().'@example.test'; + // 로그인 대상 회원: 동의 이력이 전혀 없는 신규 계정. 고정 이메일 사용 — 재실행 시 + // 기존 계정을 먼저 삭제해 계정이 무한히 누적되지 않도록 한다(멱등성 보장). + // 비밀번호는 실행마다 무작위 생성 — 고정값이 코드에 남아있으면 실수로 프로덕션 DB + // 에서 실행됐을 때 알려진 비밀번호로 로그인 가능한 계정이 남는다. + $email = 'e2e-gdpr-guest-login@example.test'; + User::where('email', $email)->delete(); + $plainPassword = Str::random(32); $member = User::factory()->create([ 'email' => $email, - 'password' => bcrypt(self::MEMBER_PASSWORD), + 'password' => bcrypt($plainPassword), ]); $result = [ 'guest_session_cookie_value' => $signedCookieValue, 'member_email' => $member->email, - 'member_password' => self::MEMBER_PASSWORD, + 'member_password' => $plainPassword, ]; if ($this->option('json')) { @@ -103,4 +106,4 @@ class PlaywrightSeedGdprGuestLogin extends Command return self::SUCCESS; } -} \ No newline at end of file +}