Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,30 @@ describe('use-penetration-tests hooks', () => {
expect(requestBody.checks).toEqual(['discovery', 'xss']);
});

it('posts webhook and notification fields when creating a report', async () => {
fetchMock.mockResolvedValueOnce(
createJsonResponse({
id: 'run_notifications',
status: 'provisioning',
}),
);

const { result } = renderHook(() => useCreatePenetrationTest('org_123'), { wrapper });

await act(async () => {
await result.current.createReport({
targetUrl: 'https://app.example.com',
webhookUrl: 'https://hooks.example.com/pentest',
notificationEmail: 'security@example.com',
});
});

const init = fetchMock.mock.calls[0][1] as RequestInit;
const requestBody = JSON.parse((init.body ?? '{}') as string);
expect(requestBody.webhookUrl).toBe('https://hooks.example.com/pentest');
expect(requestBody.notificationEmail).toBe('security@example.com');
});

it('supports creating a report without repository URL for black-box mode', async () => {
fetchMock.mockResolvedValueOnce(
createJsonResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ export function useCreatePenetrationTest(organizationId: string): UseCreatePenet
repoUrl: payload.repoUrl,
pipelineTesting: payload.pipelineTesting,
testMode: payload.testMode,
webhookUrl: payload.webhookUrl,
notificationEmail: payload.notificationEmail,
scanDepth: payload.scanDepth,
evidenceLevel: payload.evidenceLevel,
checks: payload.checks,
Expand Down Expand Up @@ -364,7 +366,8 @@ export function useCreatePenetrationTest(organizationId: string): UseCreatePenet
error: null,
failedReason: null,
temporalUiUrl: null,
webhookUrl: null,
webhookUrl: payload.webhookUrl ?? null,
notificationEmail: payload.notificationEmail ?? null,
scanDepth: payload.scanDepth,
evidenceLevel: payload.evidenceLevel,
checks: payload.checks,
Expand Down
Loading