fix: Use correct type for Webhook notifications

This commit is contained in:
Joachim Van Herwegen
2023-06-12 09:34:38 +02:00
parent 9584ab7549
commit c0a881b980
11 changed files with 32 additions and 33 deletions

View File

@@ -21,14 +21,13 @@ import {
removeFolder,
} from './Config';
import quad = DataFactory.quad;
import namedNode = DataFactory.namedNode;
const port = getPort('WebHookChannel2023');
const baseUrl = `http://localhost:${port}/`;
const clientPort = getPort('WebHookChannel2023-client');
const target = `http://localhost:${clientPort}/`;
const webId = 'http://example.com/card/#me';
const notificationType = NOTIFY.WebHookChannel2023;
const notificationType = NOTIFY.WebhookChannel2023;
const rootFilePath = getTestFolder('WebHookChannel2023');
const stores: [string, any][] = [
@@ -99,7 +98,7 @@ describe.each(stores)('A server supporting WebHookChannel2023 using %s', (name,
// Find the notification channel for websockets
const subscriptions = quads.getObjects(null, NOTIFY.terms.subscription, null);
const webhookSubscriptions = subscriptions.filter((channel): boolean => quads.has(
quad(channel as NamedNode, NOTIFY.terms.channelType, namedNode(`${NOTIFY.namespace}WebHookChannel2023`)),
quad(channel as NamedNode, NOTIFY.terms.channelType, NOTIFY.terms.WebhookChannel2023),
));
expect(webhookSubscriptions).toHaveLength(1);
subscriptionUrl = webhookSubscriptions[0].value;

View File

@@ -88,7 +88,7 @@ describe.each(stores)('A server supporting WebSocketChannel2023 using %s', (name
// Find the notification channel for websockets
const subscriptions = quads.getObjects(null, NOTIFY.terms.subscription, null);
const websocketSubscriptions = subscriptions.filter((channel): boolean => quads.has(
quad(channel as NamedNode, NOTIFY.terms.channelType, namedNode(`${NOTIFY.namespace}WebSocketChannel2023`)),
quad(channel as NamedNode, NOTIFY.terms.channelType, NOTIFY.terms.WebSocketChannel2023),
));
expect(websocketSubscriptions).toHaveLength(1);
subscriptionUrl = websocketSubscriptions[0].value;

View File

@@ -43,14 +43,14 @@ describe('A WebhookChannel2023Type', (): void => {
beforeEach(async(): Promise<void> => {
data = new Store();
data.addQuad(quad(subject, RDF.terms.type, NOTIFY.terms.WebHookChannel2023));
data.addQuad(quad(subject, RDF.terms.type, NOTIFY.terms.WebhookChannel2023));
data.addQuad(quad(subject, NOTIFY.terms.topic, namedNode(topic)));
data.addQuad(quad(subject, NOTIFY.terms.sendTo, namedNode(sendTo)));
const id = 'http://example.com/webhooks/4c9b88c1-7502-4107-bb79-2a3a590c7aa3';
channel = {
id,
type: NOTIFY.WebHookChannel2023,
type: NOTIFY.WebhookChannel2023,
topic: 'https://storage.example/resource',
sendTo,
};
@@ -79,7 +79,7 @@ describe('A WebhookChannel2023Type', (): void => {
CONTEXT_NOTIFICATION,
],
id: channel.id,
type: NOTIFY.WebHookChannel2023,
type: NOTIFY.WebhookChannel2023,
sendTo,
topic,
sender: 'http://example.com/webhooks/webid',

View File

@@ -45,7 +45,7 @@ describe('A WebHookEmitter', (): void => {
const channel: WebhookChannel2023 = {
id: 'id',
topic: 'http://example.com/foo',
type: NOTIFY.WebHookChannel2023,
type: NOTIFY.WebhookChannel2023,
sendTo: 'http://example.org/somewhere-else',
};

View File

@@ -2,7 +2,7 @@ import { fetch } from 'cross-fetch';
/**
* Subscribes to a notification channel.
* @param type - The type of the notification channel, e.g., "NOTIFY.WebHookChannel2023".
* @param type - The type of the notification channel, e.g., "NOTIFY.WebhookChannel2023".
* @param webId - The WebID to spoof in the authorization header. This assumes the config uses the debug auth import.
* @param subscriptionUrl - The subscription URL to which the request needs to be sent.
* @param topic - The topic to subscribe to.