Task 1-1: Guard / Remove Test Endpoints
Phase: 1 Priority: High Module:
webmarketplaceDepends on: Không có Reference: docs/BountyHunter-Backend/details/feature-nft-management/SPEC.md
Background
NftRentalController có 2 test endpoints không nên tồn tại trên production:
1. PUT /api/nft-rental/finish-rental-order/{id} - manually finish rental (bỏ qua business logic)
2. POST /api/nft-rental/test-change-owner - thay đổi ownership NFT tùy ý
Tasks
DI Note:
NftRentalControllerđã injectNftRentalOrderService(hoặc tương đương) để xử lý requests.@Profile("!main")là Spring annotation — không cần thêm dependency. Chỉ cần importorg.springframework.context.annotation.Profile.
File: webmarketplace/controllers/nft_rental/NftRentalController.java
- [ ] Xác nhận tên Spring profile dùng trên production: thường là
main,prod, hoặcproduction— grepspring.profiles.activetrong deployment config hoặcapplication.yamlđể xác nhận -
[ ] Thêm
@Profile("!main")guard cho cả 2 endpoints (thaymainbằng profile production thực tế):@Profile("!main") // Chỉ active trên non-production environments @PutMapping("/finish-rental-order/{id}") public Result<NftRentalOrderModel> finishRental(@PathVariable String id) { ... } @Profile("!main") // Chỉ active trên non-production environments @PostMapping("/test-change-owner") public Result<?> testChangeOwner(...) { ... } -
[ ] Nếu cần trên prod cho admin: move sang
adminmodule với proper admin auth (tách thành task riêng) - [ ] Thêm comment giải thích lý do guard:
// TEST ONLY: Not active on production profile "main" @Profile("!main")
Verification / Acceptance Criteria
- [ ] Với
spring.profiles.active=main→PUT /api/nft-rental/finish-rental-order/{id}trả 404 - [ ] Với
spring.profiles.active=main→POST /api/nft-rental/test-change-ownertrả 404 - [ ] Với
spring.profiles.active=dev(hoặc non-main) → cả 2 endpoints vẫn hoạt động bình thường - [ ] Application khởi động với profile
mainkhông lỗi - [ ] Code review: không còn test endpoint nào exposed trên production profile
Files to Modify
webmarketplace/src/main/java/com/figpop/webmarketplace/controllers/nft_rental/NftRentalController.java