Skip to content

Commit 69fd6e4

Browse files
authored
Merge pull request #214 from Runnect/tests/record-service-unit-tests
test: RecordService λ‹¨μœ„ ν…ŒμŠ€νŠΈ μΆ”κ°€ + updateRecord IDOR μˆ˜μ •
2 parents 5754c13 + dd4eb9e commit 69fd6e4

3 files changed

Lines changed: 441 additions & 0 deletions

File tree

β€Žsrc/main/java/org/runnect/server/common/constant/ErrorStatus.javaβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public enum ErrorStatus {
5555
*/
5656
PERMISSION_DENIED_PUBLIC_COURSE_DELETE_EXCEPTION(HttpStatus.FORBIDDEN, "퍼블릭 μ½”μŠ€λ₯Ό μ‚­μ œν•  κΆŒν•œμ΄ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
5757
PERMISSION_DENIED_RECORD_DELETE_EXCEPTION(HttpStatus.FORBIDDEN, "기둝을 μ‚­μ œν•  κΆŒν•œμ΄ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
58+
PERMISSION_DENIED_RECORD_UPDATE_EXCEPTION(HttpStatus.FORBIDDEN, "기둝을 μˆ˜μ •ν•  κΆŒν•œμ΄ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
5859
PERMISSION_DENIED_HEALTH_DATA_EXCEPTION(HttpStatus.FORBIDDEN, "건강 데이터에 λŒ€ν•œ μ ‘κ·Ό κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€"),
5960

6061
/**

β€Žsrc/main/java/org/runnect/server/record/service/RecordService.javaβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ public UpdateRecordResponseDto updateRecord(Long userId, Long recordId, UpdateRe
138138
Record record = recordRepository.findById(recordId)
139139
.orElseThrow(()->new NotFoundException(ErrorStatus.NOT_FOUND_RECORD_EXCEPTION, ErrorStatus.NOT_FOUND_RECORD_EXCEPTION.getMessage()));
140140

141+
if (!record.getRunnectUser().getId().equals(userId)) {
142+
throw new PermissionDeniedException(ErrorStatus.PERMISSION_DENIED_RECORD_UPDATE_EXCEPTION,
143+
ErrorStatus.PERMISSION_DENIED_RECORD_UPDATE_EXCEPTION.getMessage());
144+
}
145+
141146
record.updateRecord(request.getTitle());
142147

143148
return UpdateRecordResponseDto.of(UpdateRecordResponse.of(record.getId(), request.getTitle()));

0 commit comments

Comments
Β (0)