qbo_auth: вебхук cloudevents+json (был 415), страница тестов по секретной ссылке, allowedRealmIds; требования Intuit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,26 @@ describe("токены", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("защита от чужой компании", () => {
|
||||
it("realmId вне списка отклоняется до обмена кода; из списка подключается", async () => {
|
||||
const st = new MemoryStore();
|
||||
const f = fakeFetch([{ body: tokens(1) }]);
|
||||
const notes: string[] = [];
|
||||
const auth = new QboAuth({
|
||||
store: st, fetchFn: f.fn, env: "sandbox", clientId: "cid", clientSecret: "csec", redirectUri: "https://x/cb", scope: "s", keepAliveHours: 20,
|
||||
allowedRealmIds: ["R-OK"], notify: async (t) => { notes.push(t); },
|
||||
});
|
||||
const s1 = new URL((await auth.startConnect()).url).searchParams.get("state")!;
|
||||
await expect(auth.handleCallback({ code: "c", state: s1, realmId: "R-OTHER" })).rejects.toThrow(/allowedRealmIds/);
|
||||
expect(f.calls.length).toBe(0);
|
||||
expect(notes[0]).toContain("R-OTHER");
|
||||
expect(await st.read("sandbox")).toBeNull();
|
||||
const s2 = new URL((await auth.startConnect()).url).searchParams.get("state")!;
|
||||
await auth.handleCallback({ code: "c", state: s2, realmId: "R-OK" });
|
||||
expect((await st.read("sandbox"))?.realmId).toBe("R-OK");
|
||||
});
|
||||
});
|
||||
|
||||
describe("HTTP", () => {
|
||||
it("служебные ручки требуют токен; /healthz и /callback открыты; в status нет секретов", async () => {
|
||||
const ctx = mk([{ body: tokens(1) }]);
|
||||
|
||||
Reference in New Issue
Block a user