Files
Arcrun/cypher-executor/tests/credentials.test.ts
T
uncle6me-web 7ba78552a4 D38:credential 目錄改走 KBDB API(零原生 SQL)+舊表退場;測試刻意留紅燈
存取層:credentials.ts / auth-dispatcher.ts / portal.ts 全改走 kbdbBase()+fetch
到 /entries(照 execution-logger.ts 既有慣例),.prepare/.exec/.batch 命中 0。
資料層:0005 seed credential template;0006 把舊表資料搬進 entries 後拆表;
0002 標退役、deploy.ts 不再套用(加 kbdb-sql-ok 留痕,純歷史對照)。

總管親驗四項(不聽 agent 自評):
1 三個檔 .prepare/.exec/.batch 命中 0;六個檔全部通過 kbdb-api-wall-guard
2 0006 的 INSERT 欄位(id/entry_type/owner_id/page_name/metadata_json/
  created_at/updated_at)與 0001_base 的 entries 表逐一對得上
3 不可逆風險查官方:D1 batch 是 transaction、任一句失敗整批 rollback;
  exec 出錯則「執行停止、後續不執行」=> 兩種語意下 INSERT 失敗都不會跑到
  DROP TABLE,用戶 credential 目錄不會遺失
4 0006 搬在拆之前、冪等(NOT EXISTS 防重複)、豁免標記有留痕且理由正當
  (拆表是牆內施工,API 不提供也不該提供拆表)

🔴 抓到一個假綠並修正:agent 中途被中斷,把 111 行的 credentials.test.ts
砍成一行「// placeholder — see edit below」,那個 edit 從來沒發生,
且 setup.ts 被刪。vitest 對這種檔案回報「Tests: no tests」,
很容易被讀成「沒失敗=通過」——正是 CP 記過的
「這條 route 曾整條消失過沒人發現」同型。
處置:還原 setup.ts/vitest.config.ts,credentials.test.ts 改成
**刻意會失敗的紅燈**並在檔頭列出要補的五項。空檔會被誤認為綠,紅燈不會。

未部署。本批要先上 stage 驗過才進 prod(leo 08-07 定)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 17:27:18 +08:00

34 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* credentials 路由測試 —— 🔴 待重寫(D38 圍牆修復後)
*
* 【為什麼是紅燈而不是空檔】
* 2026-08-07 D38 圍牆修復把 credential 目錄從「獨立 credentials 表 + 原生 SQL」
* 改成「KBDB entriesentry_type='credential'+ HTTP API」。原本 111 行的測試
* 測的是舊的 SQL 實作,全部不再適用。
*
* 施工的 agent 中途被中斷,留下一行 `// placeholder — see edit below` ——
* 那個 "edit below" 從來沒發生。vitest 對這種檔案回報 `Tests: no tests`
* **很容易被讀成「沒失敗=通過」**,正是 CP 記過的
* 「這條 route 曾整條消失過沒人發現」同型。
*
* ⇒ 這裡刻意留一個**會失敗**的測試:空檔會被誤認為綠,紅燈不會。
*
* 【重寫時要涵蓋什麼】(照新實作 routes/credentials.ts
* 1. 寫入走 KBDB HTTP API,且 owner_id = api_key(租戶隔離)
* 2. 讀取查得回 secret_ref,且查不到別的租戶的
* 3. 刪除是真的刪(不是 deprecated
* 4. **零原生 SQL**:整支檔案不得出現 .prepare/.exec/.batch
* 5. 密文本體不落 KBDB(只有 secret_ref 指標)—— D19 不變
*/
import { describe, it, expect } from 'vitest';
describe('credentials 路由(D38 改走 KBDB API 後)', () => {
it('🔴 測試待重寫 —— 見本檔頭部清單(刻意紅燈,別刪掉改成空檔)', () => {
expect.fail(
'D38 圍牆修復後 credential 改走 KBDB entries + HTTP API' +
'舊的 SQL 版測試已作廢、新測試尚未寫。' +
'要補的五項見本檔頭部註解。',
);
});
});