#!/usr/bin/env python3
"""
JWT 테스트 토큰 생성 스크립트
Event Service API 테스트용
"""

import jwt
import datetime
import uuid

# JWT Secret (run-event-service.ps1과 동일)
JWT_SECRET = "kt-event-marketing-jwt-secret-key-for-development-only-minimum-256-bits-required"

# 유효기간을 매우 길게 설정 (테스트용)
EXPIRATION_DAYS = 365

# 테스트 사용자 정보
USER_ID = str(uuid.uuid4())
STORE_ID = str(uuid.uuid4())
EMAIL = "test@example.com"
NAME = "Test User"
ROLES = ["ROLE_USER"]

def generate_access_token():
    """Access Token 생성"""
    now = datetime.datetime.utcnow()
    expiry = now + datetime.timedelta(days=EXPIRATION_DAYS)

    payload = {
        'sub': USER_ID,
        'storeId': STORE_ID,
        'email': EMAIL,
        'name': NAME,
        'roles': ROLES,
        'type': 'access',
        'iat': now,
        'exp': expiry
    }

    token = jwt.encode(payload, JWT_SECRET, algorithm='HS256')
    return token

if __name__ == '__main__':
    print("=" * 80)
    print("JWT 테스트 토큰 생성")
    print("=" * 80)
    print()
    print(f"User ID: {USER_ID}")
    print(f"Store ID: {STORE_ID}")
    print(f"Email: {EMAIL}")
    print(f"Name: {NAME}")
    print(f"Roles: {ROLES}")
    print()
    print("=" * 80)
    print("Access Token:")
    print("=" * 80)

    token = generate_access_token()
    print(token)
    print()
    print("=" * 80)
    print("사용 방법:")
    print("=" * 80)
    print("curl -H \"Authorization: Bearer <token>\" http://localhost:8081/api/v1/events")
    print()
