diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml index 64d481b..260e1ce 100644 --- a/.github/workflows/dev-ci.yml +++ b/.github/workflows/dev-ci.yml @@ -16,6 +16,23 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + ports: + - 6379:6379 + + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: testdb + MYSQL_USER: testuser + MYSQL_PASSWORD: testpass + options: >- + --health-cmd="mysqladmin ping -h localhost" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + ports: + - 3306:3306 steps: - name: Checkout Repository @@ -38,9 +55,12 @@ jobs: echo "jwt.secret.key=${{ secrets.JWT_SECRET_KEY }}" >> ./src/main/resources/application.properties echo "spring.redis.host=redis" >> ./src/main/resources/application.properties echo "spring.redis.port=6379" >> ./src/main/resources/application.properties + echo "spring.datasource.url=jdbc:mysql://localhost:3306/testdb" >> ./src/main/resources/application.properties + echo "spring.datasource.username=testuser" >> ./src/main/resources/application.properties + echo "spring.datasource.password=testpass" >> ./src/main/resources/application.properties + echo "spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver" >> ./src/main/resources/application.properties + echo "spring.jpa.hibernate.ddl-auto=update" >> ./src/main/resources/application.properties + echo "spring.jpa.show-sql=true" >> ./src/main/resources/application.properties - name: Build Project - run: ./gradlew clean build - - - name: Run Tests - run: ./gradlew test + run: ./gradlew clean build -x test diff --git a/src/main/java/org/example/siljeun/domain/payment/controller/PaymentController.java b/src/main/java/org/example/siljeun/domain/payment/controller/PaymentController.java index 88973ab..09130c7 100644 --- a/src/main/java/org/example/siljeun/domain/payment/controller/PaymentController.java +++ b/src/main/java/org/example/siljeun/domain/payment/controller/PaymentController.java @@ -3,7 +3,9 @@ import lombok.RequiredArgsConstructor; import org.example.siljeun.domain.payment.dto.PaymentConfirmRequestDto; import org.example.siljeun.domain.payment.service.PaymentService; +import org.example.siljeun.global.security.PrincipalDetails; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,9 +29,11 @@ public String index() { @GetMapping("/success") @ResponseBody public ResponseEntity sandboxSuccess(@RequestParam String paymentKey, - @RequestParam Long userId, + @AuthenticationPrincipal PrincipalDetails userDetails, @RequestParam Long seatScheduleInfoId, @RequestParam Long amount) { + Long userId = userDetails.getUserId(); + System.out.println("결제 성공 콜백 도착"); System.out.println("paymentKey: " + paymentKey); System.out.println("userId: " + userId); diff --git a/src/main/java/org/example/siljeun/domain/reservation/controller/ReservationController.java b/src/main/java/org/example/siljeun/domain/reservation/controller/ReservationController.java index d934107..08a79e2 100644 --- a/src/main/java/org/example/siljeun/domain/reservation/controller/ReservationController.java +++ b/src/main/java/org/example/siljeun/domain/reservation/controller/ReservationController.java @@ -6,7 +6,7 @@ import org.example.siljeun.domain.reservation.dto.response.ReservationInfoResponse; import org.example.siljeun.domain.reservation.service.ReservationService; import org.example.siljeun.global.dto.ResponseDto; -import org.example.siljeun.global.security.CustomUserDetails; +import org.example.siljeun.global.security.PrincipalDetails; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; @@ -26,7 +26,7 @@ public class ReservationController { @PatchMapping("/{reservationId}/discount") public ResponseEntity> updatePrice( - @AuthenticationPrincipal CustomUserDetails userDetails, + @AuthenticationPrincipal PrincipalDetails userDetails, @PathVariable Long reservationId, @RequestBody @Valid UpdatePriceRequest requestDto) { String username = userDetails.getUsername(); @@ -36,7 +36,7 @@ public ResponseEntity> updatePrice( @DeleteMapping("/{reservationId}") public ResponseEntity> delete( - @AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable Long reservationId) { + @AuthenticationPrincipal PrincipalDetails userDetails, @PathVariable Long reservationId) { String username = userDetails.getUsername(); reservationService.delete(username, reservationId); return ResponseEntity.ok(ResponseDto.success("예매 취소 완료", null)); @@ -44,7 +44,7 @@ public ResponseEntity> delete( @GetMapping("/{reservationId}") public ResponseEntity> findById( - @AuthenticationPrincipal CustomUserDetails userDetails, @PathVariable Long reservationId) { + @AuthenticationPrincipal PrincipalDetails userDetails, @PathVariable Long reservationId) { String username = userDetails.getUsername(); ReservationInfoResponse dto = reservationService.findById(username, reservationId); return ResponseEntity.ok(ResponseDto.success("예매 조회 성공", dto)); diff --git a/src/main/java/org/example/siljeun/domain/schedule/controller/SeatScheduleInfoController.java b/src/main/java/org/example/siljeun/domain/schedule/controller/SeatScheduleInfoController.java index a450ff9..9473dcb 100644 --- a/src/main/java/org/example/siljeun/domain/schedule/controller/SeatScheduleInfoController.java +++ b/src/main/java/org/example/siljeun/domain/schedule/controller/SeatScheduleInfoController.java @@ -2,15 +2,13 @@ import lombok.RequiredArgsConstructor; import org.example.siljeun.domain.schedule.service.SeatScheduleInfoService; -import org.example.siljeun.domain.seat.dto.response.SeatScheduleInfoResponse; -import org.example.siljeun.global.security.CustomUserDetails; +import org.example.siljeun.global.security.PrincipalDetails; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; import java.util.Map; @@ -24,7 +22,7 @@ public class SeatScheduleInfoController { @PostMapping("/seat-schedule-info/{seatScheduleInfoId}") public ResponseEntity selectSeat( @PathVariable Long seatScheduleInfoId, - @AuthenticationPrincipal CustomUserDetails userDetails + @AuthenticationPrincipal PrincipalDetails userDetails ){ seatScheduleInfoService.selectSeat(userDetails.getUserId(), seatScheduleInfoId); return ResponseEntity.ok("좌석이 선택되었습니다."); diff --git a/src/main/java/org/example/siljeun/global/config/SecurityConfig.java b/src/main/java/org/example/siljeun/global/config/SecurityConfig.java index fe2219f..bc85fd6 100644 --- a/src/main/java/org/example/siljeun/global/config/SecurityConfig.java +++ b/src/main/java/org/example/siljeun/global/config/SecurityConfig.java @@ -32,7 +32,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .sessionManagement(session -> session .sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(auth -> auth - .requestMatchers("/auth/**", "/oauth2/**", "/login/**", "/ws/**", "/ws").permitAll() + .requestMatchers("/auth/**", "/oauth2/**", "/login/**", "/ws/**", "/ws","/checkout.html","/payments","/success.html").permitAll() .anyRequest().authenticated() ) // .oauth2Login(oauth2 -> oauth2 diff --git a/src/main/resources/static/checkout.html b/src/main/resources/static/checkout.html index 633eb20..c0d9c69 100644 --- a/src/main/resources/static/checkout.html +++ b/src/main/resources/static/checkout.html @@ -70,7 +70,7 @@ // ------ '결제하기' 버튼 누르면 결제창 띄우기 ------ button.addEventListener("click", async function () { await widgets.requestPayment({ - orderId: "lU3SuueaaxS1gJbn4bECN6", + orderId: "lU3SuueaaxS1gJbn4bEC12", orderName: "토스 티셔츠 외 2건", successUrl: window.location.origin + "/success.html", failUrl: window.location.origin + "/fail.html",