X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Factivitypub%2Fhelpers.ts;h=bad86ef47bfda41d05abc0a369d9075aed6b6c49;hb=0a8a79552cf59c800011c9f63eaa8658230acddc;hp=57b1cab23c21d3ebd5308d83c9f0c4d865f6a232;hpb=ac27887774e63d99f4e227fbe18846f143cc4b3c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 57b1cab23..bad86ef47 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts @@ -1,13 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { expect } from 'chai' import { cloneDeep } from 'lodash' -import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/extra-utils' -import { buildSignedActivity } from '../../../helpers/activitypub' +import { signAndContextify } from '@server/lib/activitypub/send' +import { buildRequestStub } from '@server/tests/shared' +import { buildAbsoluteFixturePath } from '@shared/core-utils' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' describe('Test activity pub helpers', function () { + describe('When checking the Linked Signature', function () { it('Should fail with an invalid Mastodon signature', async function () { @@ -45,7 +46,7 @@ describe('Test activity pub helpers', function () { const body = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } - const signedBody = await buildSignedActivity(actorSignature as any, body) + const signedBody = await signAndContextify(actorSignature as any, body, 'Announce') const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, signedBody) @@ -58,7 +59,7 @@ describe('Test activity pub helpers', function () { const body = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } - const signedBody = await buildSignedActivity(actorSignature as any, body) + const signedBody = await signAndContextify(actorSignature as any, body, 'Announce') const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, signedBody)