X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Factivitypub%2Fhelpers.ts;h=60d95b823f2f916257b82f2d38676b2340a0da67;hb=9129b7694d577322327ee79e9b9aa64deee92765;hp=61084624784674585b1b99ab6c53e4c967238550;hpb=df66d81583e07ce049daeeef1edc6a87b57b3684;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 610846247..60d95b823 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts @@ -1,8 +1,8 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' import { expect } from 'chai' -import { buildRequestStub } from '../../utils' +import { buildRequestStub } from '../../../../shared/extra-utils/miscs/stubs' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' import { cloneDeep } from 'lodash' import { buildSignedActivity } from '../../../helpers/activitypub' @@ -53,19 +53,6 @@ describe('Test activity pub helpers', function () { expect(result).to.be.false }) - it('Should fail with an invalid PeerTube URL', async function () { - const keys = require('./json/peertube/keys.json') - const body = require('./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 fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9003/accounts/peertube' } - const result = await isJsonLDSignatureVerified(fromActor as any, signedBody) - - expect(result).to.be.false - }) - it('Should succeed with a valid PeerTube signature', async function () { const keys = require('./json/peertube/keys.json') const body = require('./json/peertube/announce-without-context.json') @@ -89,9 +76,8 @@ describe('Test activity pub helpers', function () { const mastodonObject = cloneDeep(require('./json/mastodon/bad-http-signature.json')) req.body = mastodonObject.body req.headers = mastodonObject.headers - req.headers.signature = 'Signature ' + req.headers.signature - const parsed = parseHTTPSignature(req, 3600 * 365 * 3) + const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) const publicKey = require('./json/mastodon/public-key.json').publicKey const actor = { publicKey } @@ -108,9 +94,8 @@ describe('Test activity pub helpers', function () { const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) req.body = mastodonObject.body req.headers = mastodonObject.headers - req.headers.signature = 'Signature ' + req.headers.signature - const parsed = parseHTTPSignature(req, 3600 * 365 * 3) + const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) const publicKey = require('./json/mastodon/bad-public-key.json').publicKey const actor = { publicKey } @@ -127,7 +112,6 @@ describe('Test activity pub helpers', function () { const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) req.body = mastodonObject.body req.headers = mastodonObject.headers - req.headers.signature = 'Signature ' + req.headers.signature let errored = false try { @@ -139,7 +123,7 @@ describe('Test activity pub helpers', function () { expect(errored).to.be.true }) - it('Should fail without scheme', async function () { + it('Should with a scheme', async function () { const req = buildRequestStub() req.method = 'POST' req.url = '/accounts/ronan/inbox' @@ -147,10 +131,11 @@ describe('Test activity pub helpers', function () { const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) req.body = mastodonObject.body req.headers = mastodonObject.headers + req.headers = 'Signature ' + mastodonObject.headers let errored = false try { - parseHTTPSignature(req, 3600 * 365 * 3) + parseHTTPSignature(req, 3600 * 1000 * 365 * 10) } catch { errored = true } @@ -166,9 +151,8 @@ describe('Test activity pub helpers', function () { const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) req.body = mastodonObject.body req.headers = mastodonObject.headers - req.headers.signature = 'Signature ' + req.headers.signature - const parsed = parseHTTPSignature(req, 3600 * 365 * 3) + const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) const publicKey = require('./json/mastodon/public-key.json').publicKey const actor = { publicKey }