From 11d3cc64453b7419d8888c36f1f92924ab85926b Mon Sep 17 00:00:00 2001 From: chym1217 Date: Wed, 29 Jul 2026 16:52:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(sirsoft-gdpr):=20E2E=20=EC=8B=9C=EB=93=9C?= =?UTF-8?q?=20=EC=BB=A4=EB=A7=A8=EB=93=9C=20=EB=B3=B4=EC=95=88=C2=B7?= =?UTF-8?q?=EB=A9=B1=EB=93=B1=EC=84=B1=20=EA=B2=B0=ED=95=A8=202=EA=B1=B4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR 생성 직전 마지막 점검으로 변경분 전체를 라인 단위 재검토한 결과, 직전 커밋에서 신규 작성한 게스트→로그인 배너 재노출 E2E 시드 커맨드 (PlaywrightSeedGdprGuestLogin)에서 2건을 발견해 수정한다. - 로그인 테스트 계정 비밀번호가 코드에 고정 문자열로 박혀 있어, 실수로 프로덕션 DB에서 실행되면 알려진 비밀번호로 로그인 가능한 계정이 남는 위험이 있었다. 실행마다 Str::random(32)로 무작위 생성하도록 변경. - 이메일/게스트 세션 ID를 매번 새로 발급해 재실행할 때마다 계정과 동의 이력이 계속 누적됐다. 고정값으로 바꾸고 재실행 시 기존 데이터를 먼저 삭제하도록 변경(sirsoft-page 모듈의 선삭제 패턴과 동일). 2회 연속 실행 후 DB 조회로 누적되지 않음을 확인. 부수: cookie_banner.json 의 배너 재노출 조건에 "회원 로그인 후 로그아웃" 케이스가 회귀 테스트로 고정되어 있지 않아 추가 (로직 자체는 기존에도 정상 동작 확인됨 — 커버리지 보강). --- .../__tests__/layouts/cookie_banner.test.tsx | 10 +++++++ .../Commands/PlaywrightSeedGdprGuestLogin.php | 27 ++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) 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 +}