|
|
@@ -65,12 +65,12 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-04 正常:绑定家庭待审核列表 → 200(teacherId 取登录用户)")
|
|
|
void guidePlan_pending_正常() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("teacher", 7L, 1L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("teacher", null, 7L, 1L)).thenReturn(null);
|
|
|
when(healthPlanSvc.listPendingReviewPlans(1L, 7L))
|
|
|
.thenReturn(Collections.singletonList(healthPlan(88L, 1L, "pending_review")));
|
|
|
|
|
|
Result<List<HealthPlan>> r = guidePlanController.listPendingPlans(
|
|
|
- new HashMap<>(), "teacher", 7L, 1L);
|
|
|
+ new HashMap<>(), "teacher", 7L, 1L, null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals(1, r.getData().size());
|
|
|
assertEquals("pending_review", r.getData().get(0).getStatus());
|
|
|
@@ -79,11 +79,11 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-04 权限:非 teacher/admin 查待审核列表 → 403 无权访问")
|
|
|
void guidePlan_pending_权限_非teacher() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("parent", 7L, 1L))
|
|
|
+ when(accessGuard.checkFamilyAccess("parent", null, 7L, 1L))
|
|
|
.thenReturn(Result.error(403, "无权访问该家庭数据"));
|
|
|
|
|
|
Result<List<HealthPlan>> r = guidePlanController.listPendingPlans(
|
|
|
- new HashMap<>(), "parent", 7L, 1L);
|
|
|
+ new HashMap<>(), "parent", 7L, 1L, null);
|
|
|
assertEquals(403, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("无权访问"));
|
|
|
}
|
|
|
@@ -91,14 +91,14 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-14 正常:规划师编辑已绑定客户方案 → 200")
|
|
|
void guidePlan_update_正常() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("teacher", 7L, 1L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("teacher", null, 7L, 1L)).thenReturn(null);
|
|
|
HealthPlan p = healthPlan(88L, 1L, "pending_review");
|
|
|
when(healthPlanSvc.getPlanForFamily(88L, 1L)).thenReturn(p);
|
|
|
when(healthPlanSvc.updatePlanContent(88L, "新内容", null)).thenReturn(p);
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planContent", "新内容");
|
|
|
- Result<HealthPlan> r = guidePlanController.updatePlan(body, "teacher", 7L, 1L, 88L);
|
|
|
+ Result<HealthPlan> r = guidePlanController.updatePlan(body, "teacher", 7L, 1L, 88L, null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertNotNull(r.getData());
|
|
|
}
|
|
|
@@ -106,12 +106,12 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-14 权限:planId 不属于路径 familyId → 403 无权访问(IDOR 防护)")
|
|
|
void guidePlan_update_权限_planId跨家庭() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("teacher", 7L, 1L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("teacher", null, 7L, 1L)).thenReturn(null);
|
|
|
when(healthPlanSvc.getPlanForFamily(88L, 1L)).thenReturn(null);
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planContent", "新内容");
|
|
|
- Result<HealthPlan> r = guidePlanController.updatePlan(body, "teacher", 7L, 1L, 88L);
|
|
|
+ Result<HealthPlan> r = guidePlanController.updatePlan(body, "teacher", 7L, 1L, 88L, null);
|
|
|
assertEquals(403, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("无权访问该方案"));
|
|
|
verify(healthPlanSvc, never()).updatePlanContent(anyLong(), any(), any());
|
|
|
@@ -120,7 +120,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-X-09/SC-T-04 正常:审核通过并发布 → 200 DTO")
|
|
|
void guidePlan_approve_正常() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("teacher", 7L, 1L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("teacher", null, 7L, 1L)).thenReturn(null);
|
|
|
HealthPlan p = healthPlan(88L, 1L, "pending_review");
|
|
|
when(healthPlanSvc.getPlanForFamily(88L, 1L)).thenReturn(p);
|
|
|
PlanApproveResultDTO dto = new PlanApproveResultDTO();
|
|
|
@@ -131,7 +131,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("comment", "ok");
|
|
|
- Result<PlanApproveResultDTO> r = guidePlanController.approvePlan(body, "teacher", 7L, 1L, 88L);
|
|
|
+ Result<PlanApproveResultDTO> r = guidePlanController.approvePlan(body, "teacher", 7L, 1L, 88L, null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals("published", r.getData().getStatus());
|
|
|
assertTrue(r.getData().getTaskGenerated());
|
|
|
@@ -140,18 +140,18 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-04 权限:非 teacher 审核通过 → 403")
|
|
|
void guidePlan_approve_权限_非teacher() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("parent", 7L, 1L))
|
|
|
+ when(accessGuard.checkFamilyAccess("parent", null, 7L, 1L))
|
|
|
.thenReturn(Result.error(403, "无权访问该家庭数据"));
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("comment", "ok");
|
|
|
- Result<PlanApproveResultDTO> r = guidePlanController.approvePlan(body, "parent", 7L, 1L, 88L);
|
|
|
+ Result<PlanApproveResultDTO> r = guidePlanController.approvePlan(body, "parent", 7L, 1L, 88L, null);
|
|
|
assertEquals(403, r.getCode());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@DisplayName("SC-T-04 正常:驳回方案 → 200 rejected")
|
|
|
void guidePlan_reject_正常() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("teacher", 7L, 1L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("teacher", null, 7L, 1L)).thenReturn(null);
|
|
|
HealthPlan p = healthPlan(88L, 1L, "pending_review");
|
|
|
when(healthPlanSvc.getPlanForFamily(88L, 1L)).thenReturn(p);
|
|
|
HealthPlan rejected = healthPlan(88L, 1L, "rejected");
|
|
|
@@ -159,7 +159,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("comment", "补数据");
|
|
|
- Result<HealthPlan> r = guidePlanController.rejectPlan(body, "teacher", 7L, 1L, 88L);
|
|
|
+ Result<HealthPlan> r = guidePlanController.rejectPlan(body, "teacher", 7L, 1L, 88L, null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals("rejected", r.getData().getStatus());
|
|
|
}
|
|
|
@@ -167,12 +167,12 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
@Test
|
|
|
@DisplayName("SC-T-04 权限:admin 跳过归属校验放行 → 200")
|
|
|
void guidePlan_pending_权限_admin放行() throws Exception {
|
|
|
- when(accessGuard.checkFamilyAccess("admin", 1L, 2L)).thenReturn(null);
|
|
|
+ when(accessGuard.checkFamilyAccess("admin", null, 1L, 2L)).thenReturn(null);
|
|
|
when(healthPlanSvc.listPendingReviewPlans(2L, null))
|
|
|
.thenReturn(Collections.singletonList(healthPlan(88L, 2L, "pending_review")));
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
- Result<List<HealthPlan>> r = guidePlanController.listPendingPlans(body, "admin", 1L, 2L);
|
|
|
+ Result<List<HealthPlan>> r = guidePlanController.listPendingPlans(body, "admin", 1L, 2L, null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals(1, r.getData().size());
|
|
|
}
|
|
|
@@ -196,7 +196,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
body.put("planId", 88L);
|
|
|
body.put("approved", true);
|
|
|
body.put("comment", "ok");
|
|
|
- Result<String> r = c.reviewPlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.reviewPlan(body, 7L, "teacher", null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals("方案已批准", r.getData());
|
|
|
assertEquals("reviewed", plan.getStatus());
|
|
|
@@ -219,7 +219,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
body.put("approved", false);
|
|
|
- Result<String> r = c.reviewPlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.reviewPlan(body, 7L, "teacher", null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals("方案已驳回", r.getData());
|
|
|
assertEquals("rejected", plan.getStatus());
|
|
|
@@ -239,7 +239,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
body.put("approved", true);
|
|
|
- Result<String> r = c.reviewPlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.reviewPlan(body, 7L, "teacher", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("方案状态异常"));
|
|
|
}
|
|
|
@@ -258,7 +258,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
body.put("approved", true);
|
|
|
- Result<String> r = c.reviewPlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.reviewPlan(body, 7L, "teacher", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("方案不存在"));
|
|
|
}
|
|
|
@@ -274,7 +274,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
- Result<String> r = c.reviewPlan(body, 1L, "parent");
|
|
|
+ Result<String> r = c.reviewPlan(body, 1L, "parent", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("无权限"));
|
|
|
}
|
|
|
@@ -294,7 +294,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
- Result<String> r = c.activatePlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.activatePlan(body, 7L, "teacher", null);
|
|
|
assertEquals(200, r.getCode());
|
|
|
assertEquals("方案已激活", r.getData());
|
|
|
verify(actSvc).activate(88L, 7L);
|
|
|
@@ -315,7 +315,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
- Result<String> r = c.activatePlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.activatePlan(body, 7L, "teacher", null);
|
|
|
assertEquals(403, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("认证"));
|
|
|
}
|
|
|
@@ -331,7 +331,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
- Result<String> r = c.activatePlan(body, 1L, "parent");
|
|
|
+ Result<String> r = c.activatePlan(body, 1L, "parent", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("无权限"));
|
|
|
}
|
|
|
@@ -353,7 +353,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
body.put("planId", 88L);
|
|
|
- Result<String> r = c.activatePlan(body, 7L, "teacher");
|
|
|
+ Result<String> r = c.activatePlan(body, 7L, "teacher", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("方案状态异常"));
|
|
|
}
|
|
|
@@ -369,7 +369,7 @@ class PlanReviewTeacherContractTest extends AssessmentPlanContractTestBase {
|
|
|
inject(c, "planActivationService", mock(PlanActivationService.class));
|
|
|
inject(c, "plannerCertificationGuard", mock(PlannerCertificationGuard.class));
|
|
|
|
|
|
- Result<String> r = c.activatePlan(new HashMap<>(), 7L, "teacher");
|
|
|
+ Result<String> r = c.activatePlan(new HashMap<>(), 7L, "teacher", null);
|
|
|
assertEquals(500, r.getCode());
|
|
|
assertTrue(r.getMessage().contains("planId required"));
|
|
|
}
|