Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Webhook pages #1738

Merged
merged 12 commits into from
Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
199 changes: 199 additions & 0 deletions cypress/fixtures/edaWebhooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
{
"count": 12,
"next": "/api/eda/v1/webhooks/?page=2&page_size=10",
"previous": null,
"page_size": 10,
"page": 1,
"results": [
{
"name": "Webhook 1",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Hub-Signature-256",
"hmac_signature_prefix": "sha256=",
"hmac_format": "hex",
"auth_type": "hmac",
"additional_data_headers": null,
"id": 1,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/123a26f5-bddd-4737-a0e7-653949ccce0a/post/",
"type": "GitHub",
"created_at": "2024-03-04T14:51:10.846070Z",
"modified_at": "2024-03-04T14:51:10.846083Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 2",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Gitlab-Token",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 2,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/d0073c32-561f-428b-9461-6e783f3cad4d/post/",
"type": "GitLab",
"created_at": "2024-03-04T14:51:28.010931Z",
"modified_at": "2024-03-04T14:51:28.010942Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 3",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "Authorization",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 3,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/6805007c-bad8-43ce-9afe-db20f1dbf594/post/",
"type": "Service Now",
"created_at": "2024-03-04T14:51:45.682567Z",
"modified_at": "2024-03-04T14:51:45.682577Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 4",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Hub-Signature-256",
"hmac_signature_prefix": "sha256=",
"hmac_format": "hex",
"auth_type": "hmac",
"additional_data_headers": null,
"id": 4,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/123a26f5-bddd-4737-a0e7-653949ccce0a/post/",
"type": "GitHub",
"created_at": "2024-03-04T14:51:10.846070Z",
"modified_at": "2024-03-04T14:51:10.846083Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 5",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Gitlab-Token",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 5,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/d0073c32-561f-428b-9461-6e783f3cad4d/post/",
"type": "GitLab",
"created_at": "2024-03-04T14:51:28.010931Z",
"modified_at": "2024-03-04T14:51:28.010942Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 6",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "Authorization",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 6,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/6805007c-bad8-43ce-9afe-db20f1dbf594/post/",
"type": "Service Now",
"created_at": "2024-03-04T14:51:45.682567Z",
"modified_at": "2024-03-04T14:51:45.682577Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 7",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Hub-Signature-256",
"hmac_signature_prefix": "sha256=",
"hmac_format": "hex",
"auth_type": "hmac",
"additional_data_headers": null,
"id": 7,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/123a26f5-bddd-4737-a0e7-653949ccce0a/post/",
"type": "GitHub",
"created_at": "2024-03-04T14:51:10.846070Z",
"modified_at": "2024-03-04T14:51:10.846083Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 8",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "X-Gitlab-Token",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 8,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/d0073c32-561f-428b-9461-6e783f3cad4d/post/",
"type": "GitLab",
"created_at": "2024-03-04T14:51:28.010931Z",
"modified_at": "2024-03-04T14:51:28.010942Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 9",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "Authorization",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 9,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/6805007c-bad8-43ce-9afe-db20f1dbf594/post/",
"type": "Service Now",
"created_at": "2024-03-04T14:51:45.682567Z",
"modified_at": "2024-03-04T14:51:45.682577Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
},
{
"name": "Webhook 10",
"test_mode": false,
"user": "admin",
"hmac_algorithm": "sha256",
"header_key": "Authorization",
"hmac_signature_prefix": "",
"hmac_format": "hex",
"auth_type": "token",
"additional_data_headers": null,
"id": 10,
"url": "https://ui.eda.local:8443/abc-def-123-34567/api/eda/v1/external_webhook/6805007c-bad8-43ce-9afe-db20f1dbf594/post/",
"type": "Service Now",
"created_at": "2024-03-04T14:51:45.682567Z",
"modified_at": "2024-03-04T14:51:45.682577Z",
"test_content_type": "",
"test_content": "",
"test_error_message": ""
}
]
}
Empty file.
3 changes: 3 additions & 0 deletions frontend/eda/interfaces/EdaWebhook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Webhook, WebhookCreate } from './generated/eda-api';
export type EdaWebhook = Webhook;
export type EdaWebhookCreate = WebhookCreate;
49 changes: 49 additions & 0 deletions frontend/eda/interfaces/generated/eda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface ActivationRead {
is_enabled?: boolean;
decision_environment?: DecisionEnvironmentRef | null;
event_streams?: EventStreamRef[];
webhooks?: WebhookRef[];
credentials?: CredentialRef[];

/**
Expand Down Expand Up @@ -2940,3 +2941,51 @@ export interface EventStreamRead {
restarted_at?: string | null;
status_message?: string | null;
}

/**
*/
export enum WebhookTypeEnum {
GitHub = 'GitHub',
GitLab = 'GitLab',
ServiceNow = 'Service Now',
Generic = 'Generic',
}
export interface Webhook {
name: string;
test_mode?: boolean;
user: string;
hmac_algorithm?: string;
header_key?: string;
hmac_signature_prefix: string;
hmac_format?: string;
auth_type: string;
additional_data_headers?: string[];
id: number;
url: string;
created_at: string;
modified_at: string;
test_content_type?: string;
test_content?: string;
test_error_message?: string;
}

export interface WebhookCreate {
type: WebhookTypeEnum;
name: string;
hmac_algorithm?: string;
header_key?: string;
auth_type?: string;
hmac_signature_prefix?: string;
hmac_format?: string;
secret: string;
test_mode?: boolean;
additional_data_headers?: string[];
}

/** Serializer for Webhook reference. */
export interface WebhookRef {
id: number;
name: string;
description?: string;
webhook_type?: WebhookTypeEnum;
}
6 changes: 6 additions & 0 deletions frontend/eda/main/EdaRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,11 @@ export enum EdaRoute {

CreateControllerToken = 'eda-create-controller-token',

Webhooks = 'eda-webhooks',
CreateWebhook = 'eda-create-webhook',
EditWebhook = 'eda-edit-webhook',
WebhookPage = 'eda-webhook-page',
WebhookDetails = 'eda-webhook-details',

Login = 'eda-login',
}
53 changes: 17 additions & 36 deletions frontend/eda/main/useEdaNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ import { RulebookActivationHistory } from '../rulebook-activations/RulebookActiv
import { RulebookActivationPage } from '../rulebook-activations/RulebookActivationPage/RulebookActivationPage';
import { RulebookActivations } from '../rulebook-activations/RulebookActivations';
import { EdaRoute } from './EdaRoutes';
import { CreateEventStream } from '../event-streams/EventStreamForm';
import { EventStreamPage } from '../event-streams/EventStreamPage/EventStreamPage';
import { EventStreamDetails } from '../event-streams/EventStreamPage/EventStreamDetails';
import { EventStreams } from '../event-streams/EventStreams';
import { EventStreamInstanceDetails } from '../event-streams/EventStreamInstancePage/EventStreamInstanceDetails';
import { EventStreamInstancePage } from '../event-streams/EventStreamInstancePage/EventStreamInstancePage';
import { EventStreamHistory } from '../event-streams/EventStreamPage/EventStreamHistory';
import { CreateWebhook, EditWebhook } from '../webhooks/EditWebhook';
import { WebhookPage } from '../webhooks/WebhookPage/WebhookPage';
import { WebhookDetails } from '../webhooks/WebhookPage/WebhookDetails';
import { Webhooks } from '../webhooks/Webhooks';

export function useEdaNavigation() {
const { t } = useTranslation();
Expand Down Expand Up @@ -224,45 +221,29 @@ export function useEdaNavigation() {
],
},
{
id: EdaRoute.EventStreams,
label: t('Event Streams'),
path: 'event-streams',
id: EdaRoute.Webhooks,
label: t('Webhooks'),
path: 'webhooks',
children: [
{
id: EdaRoute.CreateEventStream,
id: EdaRoute.CreateWebhook,
path: 'create',
element: <CreateEventStream />,
element: <CreateWebhook />,
},
{
id: EdaRoute.EventStreamInstancePage,
path: ':id/history/:instanceId',
element: <EventStreamInstancePage />,
children: [
{
id: EdaRoute.EventStreamInstanceDetails,
path: 'details',
element: <EventStreamInstanceDetails />,
},
{
path: '',
element: <Navigate to="details" />,
},
],
id: EdaRoute.EditWebhook,
path: 'edit/:id',
element: <EditWebhook />,
},
{
id: EdaRoute.EventStreamPage,
id: EdaRoute.WebhookPage,
path: ':id',
element: <EventStreamPage />,
element: <WebhookPage />,
children: [
{
id: EdaRoute.EventStreamDetails,
id: EdaRoute.WebhookDetails,
path: 'details',
element: <EventStreamDetails />,
},
{
id: EdaRoute.EventStreamHistory,
path: 'history',
element: <EventStreamHistory />,
element: <WebhookDetails />,
},
{
path: '',
Expand All @@ -272,7 +253,7 @@ export function useEdaNavigation() {
},
{
path: '',
element: <EventStreams />,
element: <Webhooks />,
},
],
},
Expand Down