]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/helpers.ts
Refactor video rights checker
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / helpers.ts
index 25e1d982343b34c7805cd92d72af1459ea01fee9..56de7a87913f1eb65c1c663d9d97c635a8ac94d2 100644 (file)
@@ -3,12 +3,13 @@
 import 'mocha'
 import { expect } from 'chai'
 import { cloneDeep } from 'lodash'
+import { signAndContextify } from '@server/lib/activitypub/send'
 import { buildRequestStub } from '@server/tests/shared'
 import { buildAbsoluteFixturePath } from '@shared/core-utils'
-import { buildSignedActivity } from '../../../helpers/activitypub'
 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 () {
@@ -46,7 +47,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)
@@ -59,7 +60,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)