Skip to content

Commit 39be3fc

Browse files
authored
fix : payment 권한문제 해결, CI시에 DB 추가 (#22)
* fix : 권한 문제 해결 * fix : CI 시에 DB추가 * fix : CI 시에 test 제외
1 parent 6e4942f commit 39be3fc

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

.github/workflows/dev-ci.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ jobs:
1616
--health-interval 10s
1717
--health-timeout 5s
1818
--health-retries 5
19+
ports:
20+
- 6379:6379
21+
22+
mysql:
23+
image: mysql:8.0
24+
env:
25+
MYSQL_ROOT_PASSWORD: root
26+
MYSQL_DATABASE: testdb
27+
MYSQL_USER: testuser
28+
MYSQL_PASSWORD: testpass
29+
options: >-
30+
--health-cmd="mysqladmin ping -h localhost"
31+
--health-interval=10s
32+
--health-timeout=5s
33+
--health-retries=5
34+
ports:
35+
- 3306:3306
1936

2037
steps:
2138
- name: Checkout Repository
@@ -38,9 +55,12 @@ jobs:
3855
echo "jwt.secret.key=${{ secrets.JWT_SECRET_KEY }}" >> ./src/main/resources/application.properties
3956
echo "spring.redis.host=redis" >> ./src/main/resources/application.properties
4057
echo "spring.redis.port=6379" >> ./src/main/resources/application.properties
58+
echo "spring.datasource.url=jdbc:mysql://localhost:3306/testdb" >> ./src/main/resources/application.properties
59+
echo "spring.datasource.username=testuser" >> ./src/main/resources/application.properties
60+
echo "spring.datasource.password=testpass" >> ./src/main/resources/application.properties
61+
echo "spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver" >> ./src/main/resources/application.properties
62+
echo "spring.jpa.hibernate.ddl-auto=update" >> ./src/main/resources/application.properties
63+
echo "spring.jpa.show-sql=true" >> ./src/main/resources/application.properties
4164
4265
- name: Build Project
43-
run: ./gradlew clean build
44-
45-
- name: Run Tests
46-
run: ./gradlew test
66+
run: ./gradlew clean build -x test

src/main/java/org/example/siljeun/domain/payment/controller/PaymentController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import lombok.RequiredArgsConstructor;
44
import org.example.siljeun.domain.payment.dto.PaymentConfirmRequestDto;
55
import org.example.siljeun.domain.payment.service.PaymentService;
6+
import org.example.siljeun.global.security.PrincipalDetails;
67
import org.springframework.http.ResponseEntity;
8+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
79
import org.springframework.stereotype.Controller;
810
import org.springframework.web.bind.annotation.GetMapping;
911
import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,9 +29,11 @@ public String index() {
2729
@GetMapping("/success")
2830
@ResponseBody
2931
public ResponseEntity<String> sandboxSuccess(@RequestParam String paymentKey,
30-
@RequestParam Long userId,
32+
@AuthenticationPrincipal PrincipalDetails userDetails,
3133
@RequestParam Long seatScheduleInfoId,
3234
@RequestParam Long amount) {
35+
Long userId = userDetails.getUserId();
36+
3337
System.out.println("결제 성공 콜백 도착");
3438
System.out.println("paymentKey: " + paymentKey);
3539
System.out.println("userId: " + userId);

src/main/java/org/example/siljeun/domain/reservation/controller/ReservationController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.example.siljeun.domain.reservation.dto.response.ReservationInfoResponse;
77
import org.example.siljeun.domain.reservation.service.ReservationService;
88
import org.example.siljeun.global.dto.ResponseDto;
9-
import org.example.siljeun.global.security.CustomUserDetails;
9+
import org.example.siljeun.global.security.PrincipalDetails;
1010
import org.springframework.http.ResponseEntity;
1111
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1212
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -26,7 +26,7 @@ public class ReservationController {
2626

2727
@PatchMapping("/{reservationId}/discount")
2828
public ResponseEntity<ResponseDto<Void>> updatePrice(
29-
@AuthenticationPrincipal CustomUserDetails userDetails,
29+
@AuthenticationPrincipal PrincipalDetails userDetails,
3030
@PathVariable Long reservationId,
3131
@RequestBody @Valid UpdatePriceRequest requestDto) {
3232
String username = userDetails.getUsername();
@@ -36,15 +36,15 @@ public ResponseEntity<ResponseDto<Void>> updatePrice(
3636

3737
@DeleteMapping("/{reservationId}")
3838
public ResponseEntity<ResponseDto<Void>> delete(
39-
@AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable Long reservationId) {
39+
@AuthenticationPrincipal PrincipalDetails userDetails, @PathVariable Long reservationId) {
4040
String username = userDetails.getUsername();
4141
reservationService.delete(username, reservationId);
4242
return ResponseEntity.ok(ResponseDto.success("예매 취소 완료", null));
4343
}
4444

4545
@GetMapping("/{reservationId}")
4646
public ResponseEntity<ResponseDto<ReservationInfoResponse>> findById(
47-
@AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable Long reservationId) {
47+
@AuthenticationPrincipal PrincipalDetails userDetails, @PathVariable Long reservationId) {
4848
String username = userDetails.getUsername();
4949
ReservationInfoResponse dto = reservationService.findById(username, reservationId);
5050
return ResponseEntity.ok(ResponseDto.success("예매 조회 성공", dto));

src/main/java/org/example/siljeun/domain/schedule/controller/SeatScheduleInfoController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import lombok.RequiredArgsConstructor;
44
import org.example.siljeun.domain.schedule.service.SeatScheduleInfoService;
5-
import org.example.siljeun.domain.seat.dto.response.SeatScheduleInfoResponse;
6-
import org.example.siljeun.global.security.CustomUserDetails;
5+
import org.example.siljeun.global.security.PrincipalDetails;
76
import org.springframework.http.ResponseEntity;
87
import org.springframework.security.core.annotation.AuthenticationPrincipal;
98
import org.springframework.stereotype.Controller;
109
import org.springframework.web.bind.annotation.GetMapping;
1110
import org.springframework.web.bind.annotation.PathVariable;
1211
import org.springframework.web.bind.annotation.PostMapping;
13-
import org.springframework.web.bind.annotation.RequestMapping;
1412

1513
import java.util.List;
1614
import java.util.Map;
@@ -24,7 +22,7 @@ public class SeatScheduleInfoController {
2422
@PostMapping("/seat-schedule-info/{seatScheduleInfoId}")
2523
public ResponseEntity<String> selectSeat(
2624
@PathVariable Long seatScheduleInfoId,
27-
@AuthenticationPrincipal CustomUserDetails userDetails
25+
@AuthenticationPrincipal PrincipalDetails userDetails
2826
){
2927
seatScheduleInfoService.selectSeat(userDetails.getUserId(), seatScheduleInfoId);
3028
return ResponseEntity.ok("좌석이 선택되었습니다.");

src/main/java/org/example/siljeun/global/config/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
3232
.sessionManagement(session -> session
3333
.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
3434
.authorizeHttpRequests(auth -> auth
35-
.requestMatchers("/auth/**", "/oauth2/**", "/login/**", "/ws/**", "/ws").permitAll()
35+
.requestMatchers("/auth/**", "/oauth2/**", "/login/**", "/ws/**", "/ws","/checkout.html","/payments","/success.html").permitAll()
3636
.anyRequest().authenticated()
3737
)
3838
// .oauth2Login(oauth2 -> oauth2

src/main/resources/static/checkout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
// ------ '결제하기' 버튼 누르면 결제창 띄우기 ------
7171
button.addEventListener("click", async function () {
7272
await widgets.requestPayment({
73-
orderId: "lU3SuueaaxS1gJbn4bECN6",
73+
orderId: "lU3SuueaaxS1gJbn4bEC12",
7474
orderName: "토스 티셔츠 외 2건",
7575
successUrl: window.location.origin + "/success.html",
7676
failUrl: window.location.origin + "/fail.html",

0 commit comments

Comments
 (0)