mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(security): harden auth and outbound fetches
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const safeFetchMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../../../apps/api/src/lib/ssrf.js", () => ({
|
||||
safeFetch: safeFetchMock,
|
||||
}));
|
||||
|
||||
describe("webhook delivery", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.resetModules();
|
||||
safeFetchMock.mockReset();
|
||||
safeFetchMock.mockImplementation((url, options) => fetch(url, options));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -21,6 +29,7 @@ describe("webhook delivery", () => {
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.attempts).toBe(1);
|
||||
expect(safeFetchMock).toHaveBeenCalledOnce();
|
||||
expect(fetchMock).toHaveBeenCalledOnce();
|
||||
const [url, opts] = fetchMock.mock.calls[0];
|
||||
expect(url).toBe("https://siem.example.com/input");
|
||||
|
||||
Reference in New Issue
Block a user