Skip to content

[VALIDATION FAIL] 본인 소유 검증 누락으로 인한 멤버/디바이스 권한 문제 수정#68

Closed
jhan0121 wants to merge 2 commits intobe/devfrom
refactor/device-auth
Closed

[VALIDATION FAIL] 본인 소유 검증 누락으로 인한 멤버/디바이스 권한 문제 수정#68
jhan0121 wants to merge 2 commits intobe/devfrom
refactor/device-auth

Conversation

@jhan0121
Copy link
Collaborator

🚀 작업 내용

  • GET /api/v1/members 조회 기준을 email에서 X-Device-Id로 전환
  • DELETE /api/v1/device에 요청자-디바이스 소유권 검증 추가
  • 본인 소유가 아닌 디바이스 삭제 요청 시 404 반환 정책 적용
  • MemberFindInput, DeviceDeleteInput 정리 (email 의존 제거)
  • 멤버/디바이스 관련 테스트 및 문서 업데이트

📸 이슈 번호

✍ 궁금한 점

  • X

- 멤버 디바이스 조회 기능 수정
- RequestParam email 제거
- 인증된 디바이스 식별자로 멤버 조회하도록 변경

- 디바이스 삭제 기능 수정
- 인증된 디바이스 식별자로 요청자 식별
- 삭제 대상 디바이스 소유권 검증 로직 추가

- Service Input DTO 이메일 필드 제거
- MemberFindInput, DeviceDeleteInput
@jhan0121 jhan0121 added this to the 1.1.* milestone Feb 13, 2026
@jhan0121 jhan0121 requested a review from Copilot February 13, 2026 06:01
@jhan0121 jhan0121 self-assigned this Feb 13, 2026
@jhan0121 jhan0121 added the 🛠 fix 버그 수정 label Feb 13, 2026
@github-actions
Copy link

🧪 테스트 커버리지 리포트

Overall Project 96.48% -1% 🍏
Files changed 83.04% 🍏

File Coverage
MemberController.java 100% 🍏
DeviceController.java 100% 🍏
MemberService.java 88.85% -6.62% 🍏

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

GET /api/v1/membersDELETE /api/v1/device에서 요청자 본인 기준(디바이스 식별자 기반)으로 권한 검증을 강화해, 타 계정 조회/타 소유 디바이스 삭제가 가능했던 문제(#67)를 해결하려는 PR입니다.

Changes:

  • 멤버 디바이스 조회 기준을 emailX-Device-Id(@AuthDevice)로 전환
  • 디바이스 삭제 시 요청자-디바이스 소유권 검증 추가(비소유자 요청은 404 정책)
  • 관련 입력 DTO(MemberFindInput, DeviceDeleteInput)의 email 의존 제거 및 테스트/문서 갱신

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/main/java/com/recyclestudy/member/service/MemberService.java 멤버 조회를 device identifier 기반으로 변경, 디바이스 삭제 시 소유권 검증 추가
src/main/java/com/recyclestudy/member/controller/MemberController.java 멤버 조회에서 email query param 제거하고 @AuthDevice만 사용
src/main/java/com/recyclestudy/member/controller/DeviceController.java 삭제 입력 생성 시 email 제거(헤더 식별자 + target만 사용)
src/main/java/com/recyclestudy/member/service/input/MemberFindInput.java 조회 입력에서 email 제거
src/main/java/com/recyclestudy/member/service/input/DeviceDeleteInput.java 삭제 입력에서 email 제거
src/test/java/com/recyclestudy/member/service/MemberServiceTest.java 새로운 인증/소유권 정책에 맞춰 서비스 테스트 갱신 및 케이스 추가
src/test/java/com/recyclestudy/member/controller/MemberControllerTest.java GET /members 문서/테스트를 헤더 기반 인증 흐름에 맞게 변경(일부 불일치 존재)
src/test/java/com/recyclestudy/member/controller/DeviceControllerTest.java 디바이스 인증/삭제 문구 및 삭제 요청 필드(email optional) 문서 갱신

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +368 to +373
@DisplayName("이메일 파라미터가 누락된 경우 400 응답을 반환한다")
void findAllMemberDevices_NullEmail() {
// given
final String headerIdentifier = "device-identifier";
final MemberFindOutput output = new MemberFindOutput(
Email.from("test@test.com"),
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이메일 누락 케이스도 이제 200 OK를 기대하도록 변경됐는데 @DisplayName은 여전히 "이메일 파라미터가 누락된 경우 400"으로 남아 있습니다. 현재 정책(이메일 미사용/레거시 호환)과 맞게 테스트 이름을 수정해서 의미가 일치하도록 해주세요.

Copilot uses AI. Check for mistakes.
assertThatThrownBy(() -> memberService.authenticateDevice(otherEmail, deviceIdentifier))
.isInstanceOf(BadRequestException.class)
.hasMessage("이미 인증되었습니다");
.isInstanceOf(BadRequestException.class);
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authenticateDevice_already_auth에서도 예외 메시지 검증이 제거되어(이 케이스는 메시지가 상수라 특히) 회귀를 잡기 어렵습니다. 서비스 메시지가 바뀐 것이라면 hasMessage("이미 인증된 디바이스입니다")처럼 업데이트해서 테스트 강도를 유지해주세요.

Suggested change
.isInstanceOf(BadRequestException.class);
.isInstanceOf(BadRequestException.class)
.hasMessage("이미 인증된 디바이스입니다");

Copilot uses AI. Check for mistakes.
Comment on lines 178 to 182
headerWithName("X-Device-Id").description("디바이스 식별자")
)
.queryParameters(
parameterWithName("email").description("이메일")
parameterWithName("email").description("이메일 (다음 버전에서 제거 예정)")
)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET /api/v1/members는 컨트롤러 시그니처에서 email query parameter를 더 이상 받지 않는데, 여기 RestDocs에서는 email을 query parameter로 필수처럼 문서화하고 있어 실제 API와 불일치합니다. 또한 현재 MemberService.findAllMemberDevices()는 식별자 조회 실패 시 UnauthorizedException(401)을 던지도록 변경되어, 이 테스트가 가정하는 "존재하지 않는 멤버" 404 시나리오는 실제로는 발생하지 않을 가능성이 큽니다. email을 레거시로 남길 거면 optional()로 문서화하고, 404 케이스는 실제 발생 조건에 맞게 재정의(또는 제거/401로 정리)해 주세요.

Copilot uses AI. Check for mistakes.
Comment on lines 240 to 246
final String invalidEmail = "invalid-email";
final String headerIdentifier = "device-identifier";
final MemberFindOutput output = new MemberFindOutput(
Email.from("test@test.com"),
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 테스트는 이제 200 OK를 기대하도록 바뀌었는데 @DisplayName은 여전히 "유효하지 않은 이메일 형식이면 400"이라고 되어 있어 테스트 의도/스펙이 혼동됩니다. 이메일 파라미터가 더 이상 권한 판단에 사용되지 않는 정책에 맞게 DisplayName(및 필요하면 설명/문서)을 갱신하거나, 400을 유지하려는 의도라면 컨트롤러/검증 로직을 다시 맞춰주세요.

Copilot uses AI. Check for mistakes.
Comment on lines 352 to 356
fieldWithPath("message").type(JsonFieldType.STRING).description("에러 메시지")
),
queryParameters(
parameterWithName("email").description("이메일")
parameterWithName("email").description("이메일 (다음 버전에서 제거 예정)")
)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET /api/v1/members에서 "존재하지 않는 디바이스 식별자"는 @AuthDevice argument resolver 단계에서 UnauthorizedException(401)로 처리되는 흐름이라, 여기처럼 memberService.findAllMemberDevices()NotFoundException(404)을 던지는 케이스는 실제 동작/문서와 어긋날 가능성이 큽니다. 이 테스트/문서는 401(유효하지 않은 디바이스) 시나리오로 바꾸기 위해 deviceRepository.findByIdentifier(...)Optional.empty()로 세팅하고 응답 코드/메시지를 맞추거나, 불필요해졌다면 제거해 주세요.

Copilot uses AI. Check for mistakes.
- MemberServiceTest 예외 메시지 검증 구체화
- MemberControllerTest 불필요한 테스트 및 파라미터 제거
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빌드 또는 테스트 커버리지 검증에 실패했습니다.

@github-actions github-actions bot changed the title 본인 소유 검증 누락으로 인한 멤버/디바이스 권한 문제 수정 [VALIDATION FAIL] 본인 소유 검증 누락으로 인한 멤버/디바이스 권한 문제 수정 Feb 13, 2026
@github-actions github-actions bot closed this Feb 13, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in recycle-study Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠 fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant