From 3a0c8159df1f846c3b5a91e0748b1e4248eede0b Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Fri, 27 Jan 2023 13:38:42 +0100 Subject: [PATCH] test: Check the correct WebID in the WebHookEmitter tests --- src/server/notifications/NotificationChannel.ts | 2 +- .../WebHookSubscription2021/WebHookEmitter.test.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/server/notifications/NotificationChannel.ts b/src/server/notifications/NotificationChannel.ts index 743b649aa..a3b03da55 100644 --- a/src/server/notifications/NotificationChannel.ts +++ b/src/server/notifications/NotificationChannel.ts @@ -1,7 +1,7 @@ /** * Internal representation of a notification channel. * Most of the fields are those defined in - * https://solid.github.io/notifications/protocol#notification-channel-data-model + * https://solidproject.org/TR/2022/notifications-protocol-20221231#notification-channel-data-model * * We only support notification channels with a single topic. */ diff --git a/test/unit/server/notifications/WebHookSubscription2021/WebHookEmitter.test.ts b/test/unit/server/notifications/WebHookSubscription2021/WebHookEmitter.test.ts index 4e6c4c15b..0382c79f2 100644 --- a/test/unit/server/notifications/WebHookSubscription2021/WebHookEmitter.test.ts +++ b/test/unit/server/notifications/WebHookSubscription2021/WebHookEmitter.test.ts @@ -29,7 +29,8 @@ jest.mock('../../../../../src/logging/LogUtil', (): any => { describe('A WebHookEmitter', (): void => { const fetchMock: jest.Mock = fetch as any; const baseUrl = 'http://example.com/'; - const webIdRoute = new AbsolutePathInteractionRoute('http://example.com/.notifcations/webhooks/webid'); + const serverWebId = 'http://example.com/.notifcations/webhooks/webid'; + const webIdRoute = new AbsolutePathInteractionRoute(serverWebId); const notification: Notification = { '@context': [ 'https://www.w3.org/ns/activitystreams', @@ -46,7 +47,7 @@ describe('A WebHookEmitter', (): void => { topic: 'http://example.com/foo', type: NOTIFY.WebHookSubscription2021, target: 'http://example.org/somewhere-else', - webId: webIdRoute.getPath(), + webId: 'http://example.org/other/#me', // eslint-disable-next-line @typescript-eslint/naming-convention unsubscribe_endpoint: 'http://example.org/unsubscribe', }; @@ -103,13 +104,13 @@ describe('A WebHookEmitter', (): void => { // Check all the DPoP token fields const decodedDpopToken = await jwtVerify(encodedDpopToken, publicObject, { issuer: trimTrailingSlashes(baseUrl) }); expect(decodedDpopToken.payload).toMatchObject({ - webid: channel.webId, - azp: channel.webId, - sub: channel.webId, + webid: serverWebId, + azp: serverWebId, + sub: serverWebId, cnf: { jkt: await calculateJwkThumbprint(publicJwk, 'sha256') }, iat: now, exp: now + (20 * 60 * 1000), - aud: [ channel.webId, 'solid' ], + aud: [ serverWebId, 'solid' ], jti: expect.stringContaining('-'), }); expect(decodedDpopToken.protectedHeader).toMatchObject({