Skip to content

test: 보안 핵심 기능 단위 테스트 추가 및 CI 파이프라인 개선 - #64

Merged
rolldeep-stepmerrily merged 4 commits into
developfrom
test/high-priority-unit-tests
Mar 10, 2026
Merged

rolldeep-stepmerrily merged 4 commits into
developfrom
test/high-priority-unit-tests

Conversation

@rolldeep-stepmerrily

Copy link
Copy Markdown
Owner

Summary

  • Redis 리팩토링: RedisThrottlerStorage가 raw Redis 클라이언트 대신 RedisService를 NestJS DI로 주입받도록 변경
  • 단위 테스트 49개 추가: 보안 핵심 기능(인증, Redis, Rate Limiting) 전반 커버
  • CI 파이프라인 개선: lint → test → build 순서로 test 단계 추가

변경 내용

Redis 리팩토링 (refactor)

  • RedisThrottlerStorage 생성자: Redis 클라이언트 직접 주입 → RedisService 주입 후 getClient() 사용
  • RedisModule: RedisThrottlerStorage를 provider/export에 등록
  • AppModule ThrottlerModule: new RedisThrottlerStorage(redisService.getClient()) → DI로 주입

단위 테스트 (test)

파일 테스트 수 핵심 검증 포인트
redis.service.spec.ts 4개 TTL ≤ 0 스킵, blacklist:{token} 키 형식, 존재 여부 판별
redis-throttler.storage.spec.ts 6개 차단 상태 유지, 첫 요청 TTL 설정, limit 초과 시 blockKey 생성
jwt.strategy.spec.ts 5개 블랙리스트 토큰 → REVOKED_TOKEN, 미존재 유저 → USER_NOT_FOUND
sign-up.use-case.spec.ts 7개 이메일 중복 검증, bcrypt 해싱, 토큰 발급 및 DB 저장
login.use-case.spec.ts 6개 OAuth 계정 비밀번호 null, 불일치 → INVALID_CREDENTIALS
logout.use-case.spec.ts 6개 TTL 계산, 빈 토큰/exp 없음 → 블랙리스트 스킵
refresh.use-case.spec.ts 4개 토큰 rotation 순서 (Delete → Save), payload 구성
find-or-create-github-user.use-case.spec.ts 11개 기존 OAuth/이메일 연결/완전 신규/이메일 없음 4가지 분기

CI 파이프라인 (ci)

  • .github/workflows/lint.yaml에 test job 추가
  • 실행 순서: lint → test → build (이전: lint → build)
  • pnpm --filter @repo/api test 실행

jest 설정

  • apps/api/package.json에 moduleNameMapper 추가 (@@*, src/* path alias 처리)

Test plan

  • pnpm --filter @repo/api test → 49개 통과 확인
  • GitHub Actions CI에서 lint → test → build 순서로 실행되는지 확인
  • PR 머지 후 develop 브랜치에서 정상 동작 확인

🤖 Generated with Claude Code

rolldeep-stepmerrily and others added 2 commits March 10, 2026 13:02
- Redis 블랙리스트(addToBlacklist, isBlacklisted) 테스트
- RedisThrottlerStorage increment 로직 테스트 (차단/TTL/limit 초과)
- JwtStrategy.validate 테스트 (블랙리스트/사용자 미존재/정상)
- SignUpUseCase 테스트 (이메일 중복/bcrypt 해싱/토큰 발급)
- LoginUseCase 테스트 (USER_NOT_FOUND/INVALID_CREDENTIALS/정상 로그인)
- LogoutUseCase 테스트 (TTL 계산/블랙리스트 추가/엣지 케이스)
- RefreshUseCase 테스트 (토큰 rotation/새 토큰 발급)
- FindOrCreateGithubUserUseCase 테스트 (4가지 분기 시나리오)
- jest moduleNameMapper에 @@* 및 src/* 경로 alias 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- RedisThrottlerStorage가 Redis 클라이언트를 직접 받던 방식을
  RedisService를 주입받아 getClient()로 사용하는 방식으로 변경
- RedisModule에 RedisThrottlerStorage provider/export 추가
- AppModule ThrottlerModule 설정에서 RedisThrottlerStorage를 DI로 주입
- GitHub Actions CI 파이프라인에 test 단계 추가 (lint → test → build 순서)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dev-toolkit Ready Ready Preview, Comment Mar 10, 2026 4:16am

- jwt.strategy.spec.ts mock 클래스 빈 생성자에 biome-ignore 추가
- require로 지연 import한 JwtStrategy 변수/타입 프로퍼티 naming convention biome-ignore 추가
- auto-fix로 spec 파일 상수명 SCREAMING_SNAKE_CASE → PascalCase 변경

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
테스트 실행 전 Prisma Client를 생성하지 않아
PrismaService 타입 에러로 ts-jest 컴파일 실패하는 문제 수정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rolldeep-stepmerrily
rolldeep-stepmerrily merged commit 330dd08 into develop Mar 10, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview — e1908959 Deployed Mar 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant