mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Check the correct WebID in the WebHookEmitter tests
This commit is contained in:
parent
c36f15e2da
commit
3a0c8159df
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Internal representation of a notification channel.
|
* Internal representation of a notification channel.
|
||||||
* Most of the fields are those defined in
|
* 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.
|
* We only support notification channels with a single topic.
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,8 @@ jest.mock('../../../../../src/logging/LogUtil', (): any => {
|
|||||||
describe('A WebHookEmitter', (): void => {
|
describe('A WebHookEmitter', (): void => {
|
||||||
const fetchMock: jest.Mock = fetch as any;
|
const fetchMock: jest.Mock = fetch as any;
|
||||||
const baseUrl = 'http://example.com/';
|
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 = {
|
const notification: Notification = {
|
||||||
'@context': [
|
'@context': [
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
@ -46,7 +47,7 @@ describe('A WebHookEmitter', (): void => {
|
|||||||
topic: 'http://example.com/foo',
|
topic: 'http://example.com/foo',
|
||||||
type: NOTIFY.WebHookSubscription2021,
|
type: NOTIFY.WebHookSubscription2021,
|
||||||
target: 'http://example.org/somewhere-else',
|
target: 'http://example.org/somewhere-else',
|
||||||
webId: webIdRoute.getPath(),
|
webId: 'http://example.org/other/#me',
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
unsubscribe_endpoint: 'http://example.org/unsubscribe',
|
unsubscribe_endpoint: 'http://example.org/unsubscribe',
|
||||||
};
|
};
|
||||||
@ -103,13 +104,13 @@ describe('A WebHookEmitter', (): void => {
|
|||||||
// Check all the DPoP token fields
|
// Check all the DPoP token fields
|
||||||
const decodedDpopToken = await jwtVerify(encodedDpopToken, publicObject, { issuer: trimTrailingSlashes(baseUrl) });
|
const decodedDpopToken = await jwtVerify(encodedDpopToken, publicObject, { issuer: trimTrailingSlashes(baseUrl) });
|
||||||
expect(decodedDpopToken.payload).toMatchObject({
|
expect(decodedDpopToken.payload).toMatchObject({
|
||||||
webid: channel.webId,
|
webid: serverWebId,
|
||||||
azp: channel.webId,
|
azp: serverWebId,
|
||||||
sub: channel.webId,
|
sub: serverWebId,
|
||||||
cnf: { jkt: await calculateJwkThumbprint(publicJwk, 'sha256') },
|
cnf: { jkt: await calculateJwkThumbprint(publicJwk, 'sha256') },
|
||||||
iat: now,
|
iat: now,
|
||||||
exp: now + (20 * 60 * 1000),
|
exp: now + (20 * 60 * 1000),
|
||||||
aud: [ channel.webId, 'solid' ],
|
aud: [ serverWebId, 'solid' ],
|
||||||
jti: expect.stringContaining('-'),
|
jti: expect.stringContaining('-'),
|
||||||
});
|
});
|
||||||
expect(decodedDpopToken.protectedHeader).toMatchObject({
|
expect(decodedDpopToken.protectedHeader).toMatchObject({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user