add-in: request docver token via /api/auth/token (short path)
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m22s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 5s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m22s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 5s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
- ticketService.requestDocverToken fetches withBasePath("/api/auth/token")
instead of /api/documents/token — same handler, shorter URL
- update referencing comments in authService/apiClient/config
- ticket-auth-flow test now asserts the actual URL hit, guarding a silent
revert to the old path
- versioning endpoints (/api/documents/versions*) unchanged — no short-path
equivalents exist
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
545c9d5703
commit
3162b0d947
5 changed files with 14 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// @vitest-environment jsdom
|
||||
// ticket auth ของ add-in (PLAN-ADDIN-AUTH.md §5 — contract 2026-11-04) — คุมพฤติกรรม
|
||||
// service layer: pre-check ฝั่ง client (missing/ฟอร์แม็ต/หมดอายุ+ไม่มี session ไม่ยิง API),
|
||||
// ยิง /api/documents/token ทุกครั้งที่เปิดเอกสารแล้วแยกทางตาม status (200/400/401/403),
|
||||
// ยิง /api/auth/token ทุกครั้งที่เปิดเอกสารแล้วแยกทางตาม status (200/400/401/403),
|
||||
// memory fallback ของ session, ทุก fail path ต้องคืน result ไม่ใช่ throw
|
||||
// (ไม่มีการตรวจ HMAC ฝั่ง client อีกต่อไป — PLAN-SSO.md D13: secret เป็นของ server
|
||||
// อย่างเดียว "ไฟล์ถูกแก้" ตรวจจาก 400/401 ของ server)
|
||||
|
|
@ -10,6 +10,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|||
|
||||
import * as authService from "@/wordaddin/services/authService";
|
||||
import * as ticketService from "@/wordaddin/services/ticketService";
|
||||
import { withBasePath } from "@/utils/base-path";
|
||||
|
||||
// จับ error ทุกทาง (window error / unhandled rejection) — flow ต้องไม่ปล่อยอะไรหลุดเลย
|
||||
const errors: unknown[] = [];
|
||||
|
|
@ -157,13 +158,15 @@ describe("signInWithTicket — pre-check ฝั่ง client (เตะโดย
|
|||
describe("signInWithTicket — ยิง /token ทุกครั้งที่เปิดเอกสาร", () => {
|
||||
it("happy-path: ไม่มี session + 200 → ok และสร้าง session ใหม่ครบ userId/userName/tokens[fid]", async () => {
|
||||
trapErrors();
|
||||
const fetchMock = vi.fn(async () => tokenResponse("token-1"));
|
||||
const fetchMock = vi.fn(async (_url: string | URL | Request) => tokenResponse("token-1"));
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const { ticketData, ticketHmac } = makeTicket();
|
||||
const result = await authService.signInWithTicket({ ticketData, ticketHmac });
|
||||
expect(result.ok, JSON.stringify(result)).toBe(true);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
// endpoint ที่ยิงจริง = path สั้น /api/auth/token (เปลี่ยนจาก /api/documents/token 2026-11-05)
|
||||
expect(fetchMock.mock.calls[0][0]).toBe(withBasePath("/api/auth/token"));
|
||||
|
||||
const stored = JSON.parse(window.localStorage.getItem("wordaddin-auth") ?? "{}");
|
||||
expect(stored.userId).toBe("oom");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue