فهرست منبع

test(e2e): SC-P-70/S-cfc-505 补齐三类流断言(N×analyze-url + E×超大/GIF、E×undefined scope);探针实证承袭 B-66-1/B-66-2/B-70-1

- tongue-emotion-sc-p70: + analyze-url N 流、+ 超大文件(10MB+)拒绝、+ GIF MIME 非法拒绝;保持 text/plain 严格钉红 B-70-1
- privacy-setting-sc-p66: + undefined scope → 400 补充至非法 scope 用例;spoof userId 追加 A.scope 不变断言
- 探针来源:_probe_sc_p66_p70.spec.js(cfc.iwintrue.com live,gitignore 不入库)
- 命中 blocker 标「承袭·真实缺陷未修」:B-66-1(anon→200)、B-66-2(cross-user leak/overwrite)、B-70-1(non-photo→500)
- strict_pass 条件:三流实测通过 + 证据 SHA 在 origin/cfclub 祖先 + 工作区干净(本任务仅补用例,不代判跑通)
zxyj-langgraph 14 ساعت پیش
والد
کامیت
06e734b17d
2فایلهای تغییر یافته به همراه59 افزوده شده و 1 حذف شده
  1. 7 1
      tests/e2e/api/privacy-setting-sc-p66.spec.js
  2. 52 0
      tests/e2e/api/tongue-emotion-sc-p70.spec.js

+ 7 - 1
tests/e2e/api/privacy-setting-sc-p66.spec.js

@@ -77,13 +77,18 @@ test.describe('SC-P-66 隐私设置三类流', () => {
   // 异常流(TC-P-66-E)
   // 异常流(TC-P-66-E)
   // -------------------------------------------------------------------------
   // -------------------------------------------------------------------------
 
 
-  test('[P-66-E 异常] 非法 scope(-1/3/null) 全部被 400 拒绝,文案含「数据共享范围不合法」', async ({ request }) => {
+  test('[P-66-E 异常] 非法 scope(-1/3/null/undefined) 全部被 400 拒绝,文案含「数据共享范围不合法」', async ({ request }) => {
+    // null 显式传值 + undefined(body={})覆盖 service 中 scope == null 分支;两者均应触发 IllegalArgumentException
     const badValues = [-1, 3, null];
     const badValues = [-1, 3, null];
     for (const v of badValues) {
     for (const v of badValues) {
       const r = await apiPost(request, '/api/privacy/setting/save', { dataSharingScope: v }, userA.token);
       const r = await apiPost(request, '/api/privacy/setting/save', { dataSharingScope: v }, userA.token);
       expect(r.code, 'scope=' + JSON.stringify(v) + ' → 400, 实际=' + r.code).toBe(400);
       expect(r.code, 'scope=' + JSON.stringify(v) + ' → 400, 实际=' + r.code).toBe(400);
       expect(r.message, 'scope=' + JSON.stringify(v) + ' 文案').toBe('数据共享范围不合法');
       expect(r.message, 'scope=' + JSON.stringify(v) + ' 文案').toBe('数据共享范围不合法');
     }
     }
+    // undefined:完整缺省 body {} → dataSharingScope 为 undefined;service 中 scope == null 判定同样触发
+    const rUndefined = await apiPost(request, '/api/privacy/setting/save', {}, userA.token);
+    expect(rUndefined.code, 'undefined scope → 400, 实际=' + rUndefined.code).toBe(400);
+    expect(rUndefined.message, 'undefined scope 文案').toBe('数据共享范围不合法');
   });
   });
 
 
   test('[P-66-E 异常] 空体 / 缺 dataSharingScope → 400 拒绝(saveConfig 校验 DTO 不能为空)', async ({ request }) => {
   test('[P-66-E 异常] 空体 / 缺 dataSharingScope → 400 拒绝(saveConfig 校验 DTO 不能为空)', async ({ request }) => {
@@ -105,6 +110,7 @@ test.describe('SC-P-66 隐私设置三类流', () => {
     const gb = await apiPost(request, '/api/privacy/setting/get', {}, userA.token);
     const gb = await apiPost(request, '/api/privacy/setting/get', {}, userA.token);
     expect(gb.code).toBe(200);
     expect(gb.code).toBe(200);
     expect(gb.data.userId, 'userId 始终来自 JWT,不会被 body 改写').toBe(userA.userId);
     expect(gb.data.userId, 'userId 始终来自 JWT,不会被 body 改写').toBe(userA.userId);
+    expect(gb.data.dataSharingScope, 'A scope 不因 spoof save 改变').toBe(beforeScope);
   });
   });
 
 
   // -------------------------------------------------------------------------
   // -------------------------------------------------------------------------

+ 52 - 0
tests/e2e/api/tongue-emotion-sc-p70.spec.js

@@ -41,6 +41,12 @@ const MINIMAL_JPEG = Buffer.from([
   0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xFF, 0xD9,
   0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xFF, 0xD9,
 ]);
 ]);
 
 
+// >10MB 伪数据,用于图片大小上限测试(实测会触发 Controller 的 getSize() > 10MB 分支)
+const OVERSIZE_JPEG = Buffer.alloc(10 * 1024 * 1024 + 1, 0xAB);
+
+// 非法 MIME 的图像 buffer(GIF 头,触发 isSupportedImage 拒绝路径)
+const FAKE_GIF_BUFFER = Buffer.from('GIF89a_fake-image-content');
+
 function makeForm(fileBuffer, mimeType, fileName) {
 function makeForm(fileBuffer, mimeType, fileName) {
   const form = new Map();
   const form = new Map();
   form.set('file', { buffer: fileBuffer, mimeType: mimeType, name: fileName });
   form.set('file', { buffer: fileBuffer, mimeType: mimeType, name: fileName });
@@ -92,6 +98,24 @@ test.describe('SC-P-70 舌诊/情绪采集三类流', () => {
     }
     }
   });
   });
 
 
+  test('[P-70-N 正常] analyze-url(image_url) 返回结构化结果或降级 500(LangGraph 可达时应有 assessmentRef/emotions)', async ({ request }) => {
+    const r = await apiPost(request, '/api/mind/emotion/analyze-url',
+      { image_url: 'https://example.com/test.jpg' }, userA.token);
+    // 与 analyze 相同的契约口径:code=200 时应含 assessmentRef/emotions;
+    // LangGraph 不可达时 code=500「情绪识别服务暂不可用」亦属环境依赖
+    expect([200, 500].indexOf(r.code), 'analyze-url code∈{200,500}, 实际=' + r.code).not.toBe(-1);
+    if (r.code === 200) {
+      expect(typeof r.data, '200 时 data 应为 object').toBe('object');
+      const keys = Object.keys(r.data || {});
+      expect(keys.length > 0, 'analyze-url data 应含白名单字段').toBe(true);
+      expect(keys.indexOf('assessmentRef') >= 0 || keys.indexOf('emotions') >= 0,
+        'analyze-url data 应含 assessmentRef 或 emotions').toBe(true);
+    } else {
+      console.log('[DEFECT-PROBE] LangGraph 远端不可达,analyze-url 返回 code=' + r.code
+        + ' msg=' + JSON.stringify(r.message));
+    }
+  });
+
   // -------------------------------------------------------------------------
   // -------------------------------------------------------------------------
   // 异常流(TC-P-70-E)
   // 异常流(TC-P-70-E)
   // -------------------------------------------------------------------------
   // -------------------------------------------------------------------------
@@ -127,6 +151,34 @@ test.describe('SC-P-70 舌诊/情绪采集三类流', () => {
     ).not.toBe(500);
     ).not.toBe(500);
   });
   });
 
 
+  test('[P-70-E 异常] 超大文件(>10MB)→ 被拒且不应静默放行到识别服务', async ({ request }) => {
+    const form = makeForm(OVERSIZE_JPEG, 'image/jpeg', 'big.jpg');
+    const r = await postEmotionMultipart(request, userA.token, form);
+    // Controller: file.getSize() > 10*1024*1024 → Result.error("图片过大") code=500
+    // (Result.error 默认 500 非 400,同 B-70-1 类缺陷;本用例仅断言不被放行为 200+业务成功)
+    expect(
+      r.code,
+      '超大文件不应返回业务成功 200,实际=' + r.code,
+    ).not.toBe(200);
+    console.log('[DEFECT-PROBE] 超大 jpeg → code=' + r.code + ' msg=' + r.message);
+  });
+
+  test('[P-70-E 异常] GIF MIME 非法文件 → 被 isSupportedImage 拒绝,不为 200(Strict MIME)', async ({ request }) => {
+    const form = makeForm(FAKE_GIF_BUFFER, 'image/gif', 'fake.gif');
+    const r = await postEmotionMultipart(request, userA.token, form);
+    // isSupportedImage 拒绝 image/gif → Result.error(MSG_NOT_CLEAR_PHOTO) code=500(已知 B-70-1)
+    // 严格契约应 400「请上传清晰舌苔照」;实返 500 为 B-70-1 同类;绝不放行为 200 业务成功
+    expect(
+      r.code,
+      '【承袭·真实缺陷未修|B-70-1 同类】GIF MIME 应被拒绝(400/500 均接受,但不应为 200 放行)。'
+      + '当前实现 Result.error(...) code=500;契约期望 Result.badRequest(400)。保持判红。',
+    ).not.toBe(200);
+    console.log(
+      '[DEFECT-PROBE] image/gif → code=' + r.code + ' msg=' + r.message
+      + ';契约要求 400「请上传清晰舌苔照」,实返 code=' + r.code,
+    );
+  });
+
   test('[P-70-E 异常] 空白 file(size=0)→ 拒绝(file.isEmpty() 分支)', async ({ request }) => {
   test('[P-70-E 异常] 空白 file(size=0)→ 拒绝(file.isEmpty() 分支)', async ({ request }) => {
     const form = makeForm(Buffer.alloc(0), 'image/jpeg', 'empty.jpg');
     const form = makeForm(Buffer.alloc(0), 'image/jpeg', 'empty.jpg');
     const r = await postEmotionMultipart(request, userA.token, form);
     const r = await postEmotionMultipart(request, userA.token, form);