From 3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Jun 2021 16:52:22 +0200 Subject: Faster ci using compiled ts files --- server/tests/api/activitypub/helpers.ts | 37 ++++----- .../json/mastodon/bad-body-http-signature.json | 93 ---------------------- .../json/mastodon/bad-http-signature.json | 93 ---------------------- .../activitypub/json/mastodon/bad-public-key.json | 3 - .../json/mastodon/create-bad-signature.json | 81 ------------------- .../api/activitypub/json/mastodon/create.json | 81 ------------------- .../activitypub/json/mastodon/http-signature.json | 93 ---------------------- .../api/activitypub/json/mastodon/public-key.json | 3 - .../json/peertube/announce-without-context.json | 13 --- .../activitypub/json/peertube/invalid-keys.json | 6 -- .../tests/api/activitypub/json/peertube/keys.json | 4 - server/tests/api/activitypub/security.ts | 7 +- server/tests/api/check-params/live.ts | 12 +-- server/tests/api/check-params/users.ts | 10 +-- server/tests/api/check-params/video-captions.ts | 11 +-- server/tests/api/check-params/video-channels.ts | 14 ++-- server/tests/api/check-params/video-imports.ts | 18 ++--- server/tests/api/server/contact-form.ts | 4 + server/tests/api/videos/multiple-servers.ts | 6 +- 19 files changed, 62 insertions(+), 527 deletions(-) delete mode 100644 server/tests/api/activitypub/json/mastodon/bad-body-http-signature.json delete mode 100644 server/tests/api/activitypub/json/mastodon/bad-http-signature.json delete mode 100644 server/tests/api/activitypub/json/mastodon/bad-public-key.json delete mode 100644 server/tests/api/activitypub/json/mastodon/create-bad-signature.json delete mode 100644 server/tests/api/activitypub/json/mastodon/create.json delete mode 100644 server/tests/api/activitypub/json/mastodon/http-signature.json delete mode 100644 server/tests/api/activitypub/json/mastodon/public-key.json delete mode 100644 server/tests/api/activitypub/json/peertube/announce-without-context.json delete mode 100644 server/tests/api/activitypub/json/peertube/invalid-keys.json delete mode 100644 server/tests/api/activitypub/json/peertube/keys.json (limited to 'server/tests/api') diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 60d95b823..66d7631b7 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts @@ -6,13 +6,14 @@ 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' +import { buildAbsoluteFixturePath } from '@shared/extra-utils' describe('Test activity pub helpers', function () { describe('When checking the Linked Signature', function () { it('Should fail with an invalid Mastodon signature', async function () { - const body = require('./json/mastodon/create-bad-signature.json') - const publicKey = require('./json/mastodon/public-key.json').publicKey + const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create-bad-signature.json')) + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -21,8 +22,8 @@ describe('Test activity pub helpers', function () { }) it('Should fail with an invalid public key', async function () { - const body = require('./json/mastodon/create.json') - const publicKey = require('./json/mastodon/bad-public-key.json').publicKey + const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -31,8 +32,8 @@ describe('Test activity pub helpers', function () { }) it('Should succeed with a valid Mastodon signature', async function () { - const body = require('./json/mastodon/create.json') - const publicKey = require('./json/mastodon/public-key.json').publicKey + const body = require(buildAbsoluteFixturePath('./ap-json/mastodon/create.json')) + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const fromActor = { publicKey, url: 'http://localhost:9002/accounts/peertube' } const result = await isJsonLDSignatureVerified(fromActor as any, body) @@ -41,8 +42,8 @@ describe('Test activity pub helpers', function () { }) it('Should fail with an invalid PeerTube signature', async function () { - const keys = require('./json/peertube/invalid-keys.json') - const body = require('./json/peertube/announce-without-context.json') + const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) + 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) @@ -54,8 +55,8 @@ describe('Test activity pub helpers', function () { }) 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') + const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) + 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) @@ -73,12 +74,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require('./json/mastodon/bad-http-signature.json')) + const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require('./json/mastodon/public-key.json').publicKey + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) @@ -91,12 +92,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) + const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require('./json/mastodon/bad-public-key.json').publicKey + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/bad-public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) @@ -109,7 +110,7 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) + const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers @@ -128,7 +129,7 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) + const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers req.headers = 'Signature ' + mastodonObject.headers @@ -148,12 +149,12 @@ describe('Test activity pub helpers', function () { req.method = 'POST' req.url = '/accounts/ronan/inbox' - const mastodonObject = cloneDeep(require('./json/mastodon/http-signature.json')) + const mastodonObject = cloneDeep(require(buildAbsoluteFixturePath('./ap-json/mastodon/http-signature.json'))) req.body = mastodonObject.body req.headers = mastodonObject.headers const parsed = parseHTTPSignature(req, 3600 * 1000 * 365 * 10) - const publicKey = require('./json/mastodon/public-key.json').publicKey + const publicKey = require(buildAbsoluteFixturePath('./ap-json/mastodon/public-key.json')).publicKey const actor = { publicKey } const verified = isHTTPSignatureVerified(parsed, actor as any) diff --git a/server/tests/api/activitypub/json/mastodon/bad-body-http-signature.json b/server/tests/api/activitypub/json/mastodon/bad-body-http-signature.json deleted file mode 100644 index 4e7bc3af5..000000000 --- a/server/tests/api/activitypub/json/mastodon/bad-body-http-signature.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "headers": { - "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)", - "host": "localhost", - "date": "Mon, 22 Oct 2018 13:34:22 GMT", - "accept-encoding": "gzip", - "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=", - "content-type": "application/activity+json", - "signature": "keyId=\"http://localhost:3000/users/ronan2#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"oLKbgxdFXdXsHJ3x/UsG9Svu7oa8Dyqiy6Jif4wqNuhAqRVMRaG18f+dd2OcfFX3XRGF8p8flZkU6vvoEQBauTwGRGcgXAJuKC1zYIWGk+PeiW8lNUnE4qGapWcTiFnIo7FKauNdsgqg/tvgs1pQIdHkDDjZMI64twP7sTN/4vG1PCq+kyqi/DM+ORLi/W7vFuLVHt2Iz7ikfw/R3/mMtS4FwLops+tVYBQ2iQ9DVRhTwLKVbeL/LLVB/tdGzNZ4F4nImBAQQ9I7WpPM6J/k+cBmoEbrUKs8ptx9gbX3OSsl5wlvPVMNzU9F9yb2MrB/Y/J4qssKz+LbiaktKGj7OQ==\"", - "content-length": "2815" - }, - "body": { - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", - "sensitive": "as:sensitive", - "movedTo": { - "@id": "as:movedTo", - "@type": "@id" - }, - "Hashtag": "as:Hashtag", - "ostatus": "http://ostatus.org#", - "atomUri": "ostatus:atomUri", - "inReplyToAtomUri": "ostatus:inReplyToAtomUri", - "conversation": "ostatus:conversation", - "toot": "http://joinmastodon.org/ns#", - "Emoji": "toot:Emoji", - "focalPoint": { - "@container": "@list", - "@id": "toot:focalPoint" - }, - "featured": { - "@id": "toot:featured", - "@type": "@id" - }, - "schema": "http://schema.org#", - "PropertyValue": "schema:PropertyValue", - "value": "schema:value" - } - ], - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity", - "type": "Create", - "actor": "http://localhost:3000/users/ronan2", - "published": "2018-10-22T13:34:18Z", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "object": { - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "type": "Note", - "summary": null, - "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "published": "2018-10-22T13:34:18Z", - "url": "http://localhost:3000/@ronan2/100939547203370948", - "attributedTo": "http://localhost:3000/users/ronan2", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "sensitive": false, - "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation", - "content": "

@ronan zergzerg

", - "contentMap": { - "en": "

@ronan zergzerg

" - }, - "attachment": [], - "tag": [ - { - "type": "Mention", - "href": "http://localhost:9000/accounts/ronan", - "name": "@ronan@localhost:9000" - } - ] - }, - "signature": { - "type": "RsaSignature2017", - "creator": "http://localhost:3000/users/ronan2#main-key", - "created": "2018-10-22T13:34:19Z", - "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q==" - } - } -} diff --git a/server/tests/api/activitypub/json/mastodon/bad-http-signature.json b/server/tests/api/activitypub/json/mastodon/bad-http-signature.json deleted file mode 100644 index 098597db0..000000000 --- a/server/tests/api/activitypub/json/mastodon/bad-http-signature.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "headers": { - "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)", - "host": "localhost", - "date": "Mon, 22 Oct 2018 13:34:22 GMT", - "accept-encoding": "gzip", - "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=", - "content-type": "application/activity+json", - "signature": "keyId=\"http://localhost:3000/users/ronan2#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"oLKbgxdFXdXsHJ3x/UsG9Svu7oa8Dyqiy6Jif4wqNuhAqRVMRaG18f+dd2OcfFX3XRGF8p8flZkU6vvoEQBauTwGRGcgXAJuKC1zYIWGk+PeiW8lNUnE4qGapWcTiFnIo7FKauNdsgqg/tvgs1pQIdHkDDjZMI64twP7sTN/4vG1PCq+kyqi/DM+ORLi/W7vFuLVHt2Iz7ikfw/R3/mMtS4FwLops+tVYBQ2iQ9DVRhTwLKVbeL/LLVB/tdGzNZ4F4nImBAQQ9I7WpPM6J/k+cBmoEbrUKs8ptx9gbX3OSsl4wlvPVMNzU9F9yb2MrB/Y/J4qssKz+LbiaktKGj7OQ==\"", - "content-length": "2815" - }, - "body": { - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", - "sensitive": "as:sensitive", - "movedTo": { - "@id": "as:movedTo", - "@type": "@id" - }, - "Hashtag": "as:Hashtag", - "ostatus": "http://ostatus.org#", - "atomUri": "ostatus:atomUri", - "inReplyToAtomUri": "ostatus:inReplyToAtomUri", - "conversation": "ostatus:conversation", - "toot": "http://joinmastodon.org/ns#", - "Emoji": "toot:Emoji", - "focalPoint": { - "@container": "@list", - "@id": "toot:focalPoint" - }, - "featured": { - "@id": "toot:featured", - "@type": "@id" - }, - "schema": "http://schema.org#", - "PropertyValue": "schema:PropertyValue", - "value": "schema:value" - } - ], - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity", - "type": "Create", - "actor": "http://localhost:3000/users/ronan2", - "published": "2018-10-22T13:34:18Z", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "object": { - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "type": "Note", - "summary": null, - "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "published": "2018-10-22T13:34:18Z", - "url": "http://localhost:3000/@ronan2/100939547203370948", - "attributedTo": "http://localhost:3000/users/ronan2", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "sensitive": false, - "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation", - "content": "

@ronan zergzerg

", - "contentMap": { - "en": "

@ronan zergzerg

" - }, - "attachment": [], - "tag": [ - { - "type": "Mention", - "href": "http://localhost:9000/accounts/ronan", - "name": "@ronan@localhost:9000" - } - ] - }, - "signature": { - "type": "RsaSignature2017", - "creator": "http://localhost:3000/users/ronan2#main-key", - "created": "2018-10-22T13:34:19Z", - "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q==" - } - } -} diff --git a/server/tests/api/activitypub/json/mastodon/bad-public-key.json b/server/tests/api/activitypub/json/mastodon/bad-public-key.json deleted file mode 100644 index 73d18b3ad..000000000 --- a/server/tests/api/activitypub/json/mastodon/bad-public-key.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0YyuthHtWWgDe0Fdgdp2\ndC5dTJsRqW6pFw5omIYYYjoES/WRewhVxEA54BhmxD3L1zChfx131N1TS8jVowhW\nm999jpUffKCCvLgYKIXETJDHiDeMONVx8wp7v9fS1HiFXo/E5und39gUMs14CMFZ\n6PE5jRV3r4XIKQJHQl7/X5n5FOb2934K+1TKUeBkbft/AushlKatYQakt3qHxpwx\nFvE+JjGo7QTnzdjaOx/e5QvojdGi2Kx4+jl77j2WVcSo5lOBz04OAVJtChtn82vS\nulPdDh3hZcDn+WK67yAhGP6AnzvOybZZS4zowlKiQ3kqjVVXKdl8gAsL4Y7MZ40R\nJQIDAQAB\n-----END PUBLIC KEY-----\n" -} diff --git a/server/tests/api/activitypub/json/mastodon/create-bad-signature.json b/server/tests/api/activitypub/json/mastodon/create-bad-signature.json deleted file mode 100644 index 2cd037241..000000000 --- a/server/tests/api/activitypub/json/mastodon/create-bad-signature.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", - "sensitive": "as:sensitive", - "movedTo": { - "@id": "as:movedTo", - "@type": "@id" - }, - "Hashtag": "as:Hashtag", - "ostatus": "http://ostatus.org#", - "atomUri": "ostatus:atomUri", - "inReplyToAtomUri": "ostatus:inReplyToAtomUri", - "conversation": "ostatus:conversation", - "toot": "http://joinmastodon.org/ns#", - "Emoji": "toot:Emoji", - "focalPoint": { - "@container": "@list", - "@id": "toot:focalPoint" - }, - "featured": { - "@id": "toot:featured", - "@type": "@id" - }, - "schema": "http://schema.org#", - "PropertyValue": "schema:PropertyValue", - "value": "schema:value" - } - ], - "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698/activity", - "type": "Create", - "actor": "http://localhost:3000/users/ronan2", - "published": "2018-10-22T12:43:07Z", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "object": { - "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698", - "type": "Note", - "summary": null, - "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "published": "2018-10-22T12:43:07Z", - "url": "http://localhost:3000/@ronan2/100939345950887698", - "attributedTo": "http://localhost:3000/users/ronan2", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "sensitive": false, - "atomUri": "http://localhost:3000/users/ronan2/statuses/100939345950887698", - "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation", - "content": "

@ronan zerg

", - "contentMap": { - "en": "

@ronan zerg

" - }, - "attachment": [], - "tag": [ - { - "type": "Mention", - "href": "http://localhost:9000/accounts/ronan", - "name": "@ronan@localhost:9000" - } - ] - }, - "signature": { - "type": "RsaSignature2017", - "creator": "http://localhost:3000/users/ronan2#main-key", - "created": "2018-10-22T12:43:08Z", - "signatureValue": "Vgr8nA0agPr9TcA4BlX+MWhmuE+rBcoIJLpnPbm3E5SnOCXbgjEfEaTLqfuzzkKNsR3PBbkvi3YWK4/DxJ0zmpzSB7yy4NRzluQMVQHqJiFKXAX3Sr3fIrK24xkWW9/F207c1NpFajSGbgnFKBdtFE0e5VqwSrSoOJkZukZW/2ATSnsyzblieuUmvTWpD0PqpUOsynPjw+RqZnqPn0cjw1z2Dm7ZRt3trnyMTXFYZw5U/YuqMY2kpadD6vq780md8kXlJIylxG6ZrlO2jz9fJdnfuVq43d4QFNsBm1K1r2WtNqX+i+wiqh+u3PjF4pzXtl/a3hJOH18IfZnK7I21mQ==" - } -} diff --git a/server/tests/api/activitypub/json/mastodon/create.json b/server/tests/api/activitypub/json/mastodon/create.json deleted file mode 100644 index 0be271bb8..000000000 --- a/server/tests/api/activitypub/json/mastodon/create.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", - "sensitive": "as:sensitive", - "movedTo": { - "@id": "as:movedTo", - "@type": "@id" - }, - "Hashtag": "as:Hashtag", - "ostatus": "http://ostatus.org#", - "atomUri": "ostatus:atomUri", - "inReplyToAtomUri": "ostatus:inReplyToAtomUri", - "conversation": "ostatus:conversation", - "toot": "http://joinmastodon.org/ns#", - "Emoji": "toot:Emoji", - "focalPoint": { - "@container": "@list", - "@id": "toot:focalPoint" - }, - "featured": { - "@id": "toot:featured", - "@type": "@id" - }, - "schema": "http://schema.org#", - "PropertyValue": "schema:PropertyValue", - "value": "schema:value" - } - ], - "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698/activity", - "type": "Create", - "actor": "http://localhost:3000/users/ronan2", - "published": "2018-10-22T12:43:07Z", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "object": { - "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698", - "type": "Note", - "summary": null, - "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "published": "2018-10-22T12:43:07Z", - "url": "http://localhost:3000/@ronan2/100939345950887698", - "attributedTo": "http://localhost:3000/users/ronan2", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "sensitive": false, - "atomUri": "http://localhost:3000/users/ronan2/statuses/100939345950887698", - "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation", - "content": "

@ronan zerg

", - "contentMap": { - "en": "

@ronan zerg

" - }, - "attachment": [], - "tag": [ - { - "type": "Mention", - "href": "http://localhost:9000/accounts/ronan", - "name": "@ronan@localhost:9000" - } - ] - }, - "signature": { - "type": "RsaSignature2017", - "creator": "http://localhost:3000/users/ronan2#main-key", - "created": "2018-10-22T12:43:08Z", - "signatureValue": "VgR8nA0agPr9TcA4BlX+MWhmuE+rBcoIJLpnPbm3E5SnOCXbgjEfEaTLqfuzzkKNsR3PBbkvi3YWK4/DxJ0zmpzSB7yy4NRzluQMVQHqJiFKXAX3Sr3fIrK24xkWW9/F207c1NpFajSGbgnFKBdtFE0e5VqwSrSoOJkZukZW/2ATSnsyzblieuUmvTWpD0PqpUOsynPjw+RqZnqPn0cjw1z2Dm7ZRt3trnyMTXFYZw5U/YuqMY2kpadD6vq780md8kXlJIylxG6ZrlO2jz9fJdnfuVq43d4QFNsBm1K1r2WtNqX+i+wiqh+u3PjF4pzXtl/a3hJOH18IfZnK7I21mQ==" - } -} diff --git a/server/tests/api/activitypub/json/mastodon/http-signature.json b/server/tests/api/activitypub/json/mastodon/http-signature.json deleted file mode 100644 index 4e7bc3af5..000000000 --- a/server/tests/api/activitypub/json/mastodon/http-signature.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "headers": { - "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)", - "host": "localhost", - "date": "Mon, 22 Oct 2018 13:34:22 GMT", - "accept-encoding": "gzip", - "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=", - "content-type": "application/activity+json", - "signature": "keyId=\"http://localhost:3000/users/ronan2#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"oLKbgxdFXdXsHJ3x/UsG9Svu7oa8Dyqiy6Jif4wqNuhAqRVMRaG18f+dd2OcfFX3XRGF8p8flZkU6vvoEQBauTwGRGcgXAJuKC1zYIWGk+PeiW8lNUnE4qGapWcTiFnIo7FKauNdsgqg/tvgs1pQIdHkDDjZMI64twP7sTN/4vG1PCq+kyqi/DM+ORLi/W7vFuLVHt2Iz7ikfw/R3/mMtS4FwLops+tVYBQ2iQ9DVRhTwLKVbeL/LLVB/tdGzNZ4F4nImBAQQ9I7WpPM6J/k+cBmoEbrUKs8ptx9gbX3OSsl5wlvPVMNzU9F9yb2MrB/Y/J4qssKz+LbiaktKGj7OQ==\"", - "content-length": "2815" - }, - "body": { - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - { - "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", - "sensitive": "as:sensitive", - "movedTo": { - "@id": "as:movedTo", - "@type": "@id" - }, - "Hashtag": "as:Hashtag", - "ostatus": "http://ostatus.org#", - "atomUri": "ostatus:atomUri", - "inReplyToAtomUri": "ostatus:inReplyToAtomUri", - "conversation": "ostatus:conversation", - "toot": "http://joinmastodon.org/ns#", - "Emoji": "toot:Emoji", - "focalPoint": { - "@container": "@list", - "@id": "toot:focalPoint" - }, - "featured": { - "@id": "toot:featured", - "@type": "@id" - }, - "schema": "http://schema.org#", - "PropertyValue": "schema:PropertyValue", - "value": "schema:value" - } - ], - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity", - "type": "Create", - "actor": "http://localhost:3000/users/ronan2", - "published": "2018-10-22T13:34:18Z", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "object": { - "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "type": "Note", - "summary": null, - "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "published": "2018-10-22T13:34:18Z", - "url": "http://localhost:3000/@ronan2/100939547203370948", - "attributedTo": "http://localhost:3000/users/ronan2", - "to": [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "cc": [ - "http://localhost:3000/users/ronan2/followers", - "http://localhost:9000/accounts/ronan" - ], - "sensitive": false, - "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948", - "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752", - "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation", - "content": "

@ronan zergzerg

", - "contentMap": { - "en": "

@ronan zergzerg

" - }, - "attachment": [], - "tag": [ - { - "type": "Mention", - "href": "http://localhost:9000/accounts/ronan", - "name": "@ronan@localhost:9000" - } - ] - }, - "signature": { - "type": "RsaSignature2017", - "creator": "http://localhost:3000/users/ronan2#main-key", - "created": "2018-10-22T13:34:19Z", - "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q==" - } - } -} diff --git a/server/tests/api/activitypub/json/mastodon/public-key.json b/server/tests/api/activitypub/json/mastodon/public-key.json deleted file mode 100644 index b7b9b8308..000000000 --- a/server/tests/api/activitypub/json/mastodon/public-key.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0YyuthHtWWgDe0Fdgdp2\ndC5dTJsRqW6pFw5omIYYYjoES/WRewhVxEA54BhmxD3L1zChfx131N1TS8jVowhW\nm999jpUffKCCvLgYKIXETJDHiDeMONVx8wp7v9fS1HiFXo/E5und39gUMs14CMFZ\n6PE5jRV3r4XIKQJHQl7/X5n5FOb2934K+1TKUeBkbft/AushlKatYQakt3qHxpwx\nFvE+JjGo7QTnzdjaOx/e5QvojdGi2Kx4+jl87j2WVcSo5lOBz04OAVJtChtn82vS\nulPdDh3hZcDn+WK67yAhGP6AnzvOybZZS4zowlKiQ3kqjVVXKdl8gAsL4Y7MZ40R\nJQIDAQAB\n-----END PUBLIC KEY-----\n" -} diff --git a/server/tests/api/activitypub/json/peertube/announce-without-context.json b/server/tests/api/activitypub/json/peertube/announce-without-context.json deleted file mode 100644 index 5f2af0cde..000000000 --- a/server/tests/api/activitypub/json/peertube/announce-without-context.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "Announce", - "id": "http://localhost:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05/announces/1", - "actor": "http://localhost:9002/accounts/peertube", - "object": "http://localhost:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05", - "to": [ - "https://www.w3.org/ns/activitystreams#Public", - "http://localhost:9002/accounts/peertube/followers", - "http://localhost:9002/video-channels/root_channel/followers", - "http://localhost:9002/accounts/root/followers" - ], - "cc": [] -} diff --git a/server/tests/api/activitypub/json/peertube/invalid-keys.json b/server/tests/api/activitypub/json/peertube/invalid-keys.json deleted file mode 100644 index 0544e96b9..000000000 --- a/server/tests/api/activitypub/json/peertube/invalid-keys.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqjQGdH6D3naKmSbbr/Df\nEh1H42F3WlHYXuxKLkm5Bemjdde+GwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYO\nwAyc3Zoy7afPNa4bZXqhJ1Im41rMGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55s\nIkczDkseJuadTvG+A1e4uNY2lnRmVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/F\npP5S75TS5l1DfJQIq2lp8RwrH6FvGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM\n7mS7eP8zF8lKXYUu8cjIscKm+XqGmyRoPyw2Pp53tew29idRUocVQHGBnlNbpKdd\naQIDAQAB\n-----END PUBLIC KEY-----\n", - "privateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAqjQGdH6D3naKmSbbr/DfEh1H42F3WlHYXuxKLkm5Bemjdde+\nGwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYOwAyc3Zoy7afPNa4bZXqhJ1Im41rM\nGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55sIkczDkseJuadTvG+A1e4uNY2lnRm\nVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/FpP5S75TS5l1DfJQIq2lp8RwrH6Fv\nGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM7mS7eP8zF8lKXYUu8cjIscKm+XqG\nmyRoPyw3Pp53tew29idRUocVQHGBnlNbpKddaQIDAQABAoIBAQCnBZawCtbtH/ay\ng+dhqEW/SOyavbKZ92cU/1tsQPxISRYXNjdf2VfK7HmVqC2S7NqBanz+AVZPHmda\n7OfamkSvQbFN5VvEy8ATNV+9HbG3HG78/MT9hZcGigmyJkcZuy4wILgoXCxfpxlD\netla60PB/4yioiRcmEIWjjOgpByphDJ7RuuuptyEvgjUjpPtvHK47O/loaD2HFJk\nbIYbRirbjUjITRjQxGVIvanqiwPG9pB26YDLxDOoXEumcnzRcEFWNdvoleaLgquS\nn/zVsXWEq4+1i7t44DDstWUt/2Bw5ksIkSdayQ6oy3vzre3YFHwvbVZ7qtQQgpru\nx+NIolZhAoGBAN1RgNj8zy9Py3SJdsoXtnuCItfD7eo7LWXUa06cM/NS695Q+/to\naa5i3cJnRlv+b+b3VvnhkhIBLfFQW+hWwPnnxJEehcm09ddN9zbWrZ4Yv9yYu+8d\nTLGyWL8kPFF1dz+29DcrSv3tXEOwxByX/O4U/X/i3wl2WhkybxVFnCuvAoGBAMTf\n91BgLzvcYKOxH+vRPOJY7g2HKGFe35R91M4E+9Eq1rq4LUQHBb3fhRh4+scNu0yb\nNfN1Zdx2nbgCXdTKomF1Ahxp58/A2iU65vVzL6hYfWXEGSmoBqsGCIpIxQ9jgB9k\nCl7t/Ban8Z/ORHTjI9fpHlSZyCWJ3ajepiM2a1ZnAoGAPpDO6wi1DXvyWVSPF1yS\nwuGsNfD2rjPihpoBZ+yypwP3GBcu1QjUb28Vn+KQOmt4eQPNO8DwCVT6BvEfulPk\nJAHISPom+jnFEgPBcmhIFpyKiLNI1bUjvExd2FNHFgQuHP38ligQAC782Un8dtTk\ntO2MKH4bbVJe8CaYzpuqJZMCgYABZyMpBHZxs8FQiUuT75rCdiXEHOlxwC5RrY/d\no/VzaR28mOFhsbcdwkD9iqcm0fc6tYRt5rFCH+pBzGqEwKjljuLj9vE67sHfMAtD\nRn3Zcj/6gKo5PMRHZbSb36bf1DKuhpT4VjPMqYe0PtEIEDJKMJQRwELH2bKlqGiA\nqbucEwKBgQCkS85JnpHEV/tSylsEEn2W3CQCx58zl7iZNV7h/tWMR4AyrcI0HqP6\nllJ7V/Cfw66MgelPnosKgagwLVI6gsqDtjnzYo3XuMRVlYIySJ/jV3eiUNkV2Ky2\nfp/gA9sVgp38QSr+xB9E0LNStcbqDzoCCcDRws/SK7PbkQH9KV47tQ==\n-----END RSA PRIVATE KEY-----" -} - - diff --git a/server/tests/api/activitypub/json/peertube/keys.json b/server/tests/api/activitypub/json/peertube/keys.json deleted file mode 100644 index 1a7700865..000000000 --- a/server/tests/api/activitypub/json/peertube/keys.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqjQGdH6D3naKmSbbr/Df\nEh1H42F3WlHYXuxKLkm5Bemjdde+GwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYO\nwAyc3Zoy7afPNa4bZXqhJ1Im41rMGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55s\nIkczDkseJuadTvG+A1e4uNY2lnRmVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/F\npP5S75TS5l1DfJQIq2lp8RwrH6FvGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM\n7mS7eP8zF8lKXYUu8cjIscKm+XqGmyRoPyw3Pp53tew29idRUocVQHGBnlNbpKdd\naQIDAQAB\n-----END PUBLIC KEY-----\n", - "privateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAqjQGdH6D3naKmSbbr/DfEh1H42F3WlHYXuxKLkm5Bemjdde+\nGwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYOwAyc3Zoy7afPNa4bZXqhJ1Im41rM\nGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55sIkczDkseJuadTvG+A1e4uNY2lnRm\nVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/FpP5S75TS5l1DfJQIq2lp8RwrH6Fv\nGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM7mS7eP8zF8lKXYUu8cjIscKm+XqG\nmyRoPyw3Pp53tew29idRUocVQHGBnlNbpKddaQIDAQABAoIBAQCnBZawCtbtH/ay\ng+dhqEW/SOyavbKZ92cU/1tsQPxISRYXNjdf2VfK7HmVqC2S7NqBanz+AVZPHmda\n7OfamkSvQbFN5VvEy8ATNV+9HbG3HG78/MT9hZcGigmyJkcZuy4wILgoXCxfpxlD\netla60PB/4yioiRcmEIWjjOgpByphDJ7RuuuptyEvgjUjpPtvHK47O/loaD2HFJk\nbIYbRirbjUjITRjQxGVIvanqiwPG9pB26YDLxDOoXEumcnzRcEFWNdvoleaLgquS\nn/zVsXWEq4+1i7t44DDstWUt/2Bw5ksIkSdayQ6oy3vzre3YFHwvbVZ7qtQQgpru\nx+NIolZhAoGBAN1RgNj8zy9Py3SJdsoXtnuCItfD7eo7LWXUa06cM/NS695Q+/to\naa5i3cJnRlv+b+b3VvnhkhIBLfFQW+hWwPnnxJEehcm09ddN9zbWrZ4Yv9yYu+8d\nTLGyWL8kPFF1dz+29DcrSv3tXEOwxByX/O4U/X/i3wl2WhkybxVFnCuvAoGBAMTf\n91BgLzvcYKOxH+vRPOJY7g2HKGFe35R91M4E+9Eq1rq4LUQHBb3fhRh4+scNu0yb\nNfN1Zdx2nbgCXdTKomF1Ahxp58/A2iU65vVzL6hYfWXEGSmoBqsGCIpIxQ9jgB9k\nCl7t/Ban8Z/ORHTjI9fpHlSZyCWJ3ajepiM2a1ZnAoGAPpDO6wi1DXvyWVSPF1yS\nwuGsNfD2rjPihpoBZ+yypwP3GBcu1QjUb28Vn+KQOmt4eQPNO8DwCVT6BvEfulPk\nJAHISPom+jnFEgPBcmhIFpyKiLNI1bUjvExd2FNHFgQuHP38ligQAC782Un8dtTk\ntO2MKH4bbVJe8CaYzpuqJZMCgYABZyMpBHZxs8FQiUuT75rCdiXEHOlxwC5RrY/d\no/VzaR28mOFhsbcdwkD9iqcm0fc6tYRt5rFCH+pBzGqEwKjljuLj9vE67sHfMAtD\nRn3Zcj/6gKo5PMRHZbSb36bf1DKuhpT4VjPMqYe0PtEIEDJKMJQRwELH2bKlqGiA\nqbucEwKBgQCkS85JnpHEV/tSylsEEn2W3CQCx58zl7iZNV7h/tWMR4AyrcI0HqP6\nllJ7V/Cfw66MgelPnosKgagwLVI6gsqDtjnzYo3XuMRVlYIySJ/jV3eiUNkV2Ky2\nfp/gA9sVgp38QSr+xB9E0LNStcbqDzoCCcDRws/SK7PbkQH9KV47tQ==\n-----END RSA PRIVATE KEY-----" -} diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 364b53e0f..61db272f6 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts @@ -5,6 +5,7 @@ import * as chai from 'chai' import { buildDigest } from '@server/helpers/peertube-crypto' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, closeAllSequelize, flushAndRunMultipleServers, @@ -40,7 +41,7 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat } function getAnnounceWithoutContext (server: ServerInfo) { - const json = require('./json/peertube/announce-without-context.json') + const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const result: typeof json = {} for (const key of Object.keys(json)) { @@ -58,8 +59,8 @@ describe('Test ActivityPub security', function () { let servers: ServerInfo[] let url: string - const keys = require('./json/peertube/keys.json') - const invalidKeys = require('./json/peertube/invalid-keys.json') + const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) + const invalidKeys = require(buildAbsoluteFixturePath('./ap-json/peertube/invalid-keys.json')) const baseHttpSignature = () => ({ algorithm: HTTP_SIGNATURE.ALGORITHM, authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index c171b1f81..32233c9da 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts @@ -2,9 +2,10 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' import { LiveVideo, VideoPrivacy } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -24,7 +25,6 @@ import { userLogin, waitUntilLivePublished } from '../../../../shared/extra-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video lives API validator', function () { const path = '/api/v1/videos/live' @@ -180,7 +180,7 @@ describe('Test video lives API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -189,7 +189,7 @@ describe('Test video lives API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + thumbnailfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -198,7 +198,7 @@ describe('Test video lives API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -207,7 +207,7 @@ describe('Test video lives API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + previewfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index dcff0d52b..36482ee17 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -2,12 +2,12 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' import { User, UserRole } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoChannel, blockUser, + buildAbsoluteFixturePath, cleanupTests, createUser, deleteMe, @@ -600,7 +600,7 @@ describe('Test users API validators', function () { it('Should fail without an incorrect input file', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + avatarfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -608,7 +608,7 @@ describe('Test users API validators', function () { it('Should fail with a big file', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + avatarfile: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -616,7 +616,7 @@ describe('Test users API validators', function () { it('Should fail with an unauthenticated user', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + avatarfile: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, @@ -630,7 +630,7 @@ describe('Test users API validators', function () { it('Should succeed with the correct params', async function () { const fields = {} const attaches = { - avatarfile: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + avatarfile: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 2f049c03d..1ce2202d2 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -1,7 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' + +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -13,9 +16,7 @@ import { uploadVideo, userLogin } from '../../../../shared/extra-utils' -import { join } from 'path' import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' @@ -51,7 +52,7 @@ describe('Test video captions API validator', function () { describe('When adding video caption', function () { const fields = { } const attaches = { - captionfile: join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt') + captionfile: buildAbsoluteFixturePath('subtitle-good1.vtt') } it('Should fail without a valid uuid', async function () { @@ -129,7 +130,7 @@ describe('Test video captions API validator', function () { // We accept any file now // it('Should fail with an invalid captionfile extension', async function () { // const attaches = { - // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt') + // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') // } // // const captionPath = path + videoUUID + '/captions/fr' @@ -171,7 +172,7 @@ describe('Test video captions API validator', function () { // We don't check the file validity yet // it('Should fail with an invalid captionfile srt', async function () { // const attaches = { - // 'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt') + // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') // } // // const captionPath = path + videoUUID + '/captions/fr' diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index bc2e6192e..5c02afd31 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -1,9 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import 'mocha' import * as chai from 'chai' import { omit } from 'lodash' -import 'mocha' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, deleteVideoChannel, @@ -23,9 +25,7 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { join } from 'path' import { VideoChannelUpdate } from '../../../../shared/models/videos' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect @@ -246,7 +246,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + [type + 'file']: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) @@ -257,7 +257,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + [type + 'file']: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path: `${path}/${type}/pick`, token: server.accessToken, fields, attaches }) } @@ -267,7 +267,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + [type + 'file']: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, @@ -283,7 +283,7 @@ describe('Test video channels API validator', function () { for (const type of types) { const fields = {} const attaches = { - [type + 'file']: join(__dirname, '..', '..', 'fixtures', 'avatar.png') + [type + 'file']: buildAbsoluteFixturePath('avatar.png') } await makeUploadRequest({ url: server.url, diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 6de6b40c8..a27b624d0 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -2,8 +2,9 @@ import 'mocha' import { omit } from 'lodash' -import { join } from 'path' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { + buildAbsoluteFixturePath, cleanupTests, createUser, flushAndRunServer, @@ -22,9 +23,8 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' +import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports' import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' @@ -201,7 +201,7 @@ describe('Test video imports API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + thumbnailfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -210,7 +210,7 @@ describe('Test video imports API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - thumbnailfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + thumbnailfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -219,7 +219,7 @@ describe('Test video imports API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') + previewfile: buildAbsoluteFixturePath('video_short.mp4') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -228,7 +228,7 @@ describe('Test video imports API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - previewfile: join(__dirname, '..', '..', 'fixtures', 'preview-big.png') + previewfile: buildAbsoluteFixturePath('preview-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -237,7 +237,7 @@ describe('Test video imports API validator', function () { it('Should fail with an invalid torrent file', async function () { const fields = omit(baseCorrectParams, 'targetUrl') const attaches = { - torrentfile: join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + torrentfile: buildAbsoluteFixturePath('avatar-big.png') } await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) @@ -312,7 +312,7 @@ describe('Test video imports API validator', function () { fields = omit(fields, 'magnetUri') const attaches = { - torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent') + torrentfile: buildAbsoluteFixturePath('video-720p.torrent') } await makeUploadRequest({ diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index 9b4af1915..8851ad55e 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts @@ -54,6 +54,10 @@ describe('Test contact form', function () { }) it('Should not be able to send another contact form because of the anti spam checker', async function () { + this.timeout(10000) + + await wait(1000) + await sendContactForm({ url: server.url, fromEmail: 'toto@example.com', diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index e80d69cf3..a8c8a889b 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -2,11 +2,11 @@ import 'mocha' import * as chai from 'chai' -import { join } from 'path' import * as request from 'supertest' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoChannel, + buildAbsoluteFixturePath, checkTmpIsEmpty, checkVideoFilesWereRemoved, cleanupTests, @@ -1018,9 +1018,7 @@ describe('Test multiple servers', function () { .field('privacy', '1') .field('channelId', '1') - const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') - - await req.attach('videofile', filePath) + await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm')) .expect(HttpStatusCode.OK_200) await waitJobs(servers) -- cgit v1.2.3