aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/fixtures
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /packages/tests/fixtures
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'packages/tests/fixtures')
-rw-r--r--packages/tests/fixtures/60fps_720p_small.mp4bin0 -> 276786 bytes
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json93
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json93
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/bad-public-key.json3
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json81
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/create.json81
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/http-signature.json93
-rw-r--r--packages/tests/fixtures/ap-json/mastodon/public-key.json3
-rw-r--r--packages/tests/fixtures/ap-json/peertube/announce-without-context.json13
-rw-r--r--packages/tests/fixtures/ap-json/peertube/invalid-keys.json6
-rw-r--r--packages/tests/fixtures/ap-json/peertube/keys.json4
-rw-r--r--packages/tests/fixtures/avatar-big.pngbin0 -> 146585 bytes
-rw-r--r--packages/tests/fixtures/avatar-resized-120x120.gifbin0 -> 88318 bytes
-rw-r--r--packages/tests/fixtures/avatar-resized-120x120.pngbin0 -> 1727 bytes
-rw-r--r--packages/tests/fixtures/avatar-resized-48x48.gifbin0 -> 20462 bytes
-rw-r--r--packages/tests/fixtures/avatar-resized-48x48.pngbin0 -> 727 bytes
-rw-r--r--packages/tests/fixtures/avatar.gifbin0 -> 46917 bytes
-rw-r--r--packages/tests/fixtures/avatar.pngbin0 -> 1674 bytes
-rw-r--r--packages/tests/fixtures/avatar2-resized-120x120.pngbin0 -> 1725 bytes
-rw-r--r--packages/tests/fixtures/avatar2-resized-48x48.pngbin0 -> 760 bytes
-rw-r--r--packages/tests/fixtures/avatar2.pngbin0 -> 4850 bytes
-rw-r--r--packages/tests/fixtures/banner-resized.jpgbin0 -> 59947 bytes
-rw-r--r--packages/tests/fixtures/banner.jpgbin0 -> 31648 bytes
-rw-r--r--packages/tests/fixtures/custom-preview-big.pngbin0 -> 536513 bytes
-rw-r--r--packages/tests/fixtures/custom-preview.jpgbin0 -> 14146 bytes
-rw-r--r--packages/tests/fixtures/custom-thumbnail-big.jpgbin0 -> 20379 bytes
-rw-r--r--packages/tests/fixtures/custom-thumbnail.jpgbin0 -> 6898 bytes
-rw-r--r--packages/tests/fixtures/custom-thumbnail.pngbin0 -> 18070 bytes
-rw-r--r--packages/tests/fixtures/exif.jpgbin0 -> 10877 bytes
-rw-r--r--packages/tests/fixtures/exif.pngbin0 -> 21059 bytes
-rw-r--r--packages/tests/fixtures/live/0-000067.tsbin0 -> 270532 bytes
-rw-r--r--packages/tests/fixtures/live/0-000068.tsbin0 -> 181420 bytes
-rw-r--r--packages/tests/fixtures/live/0-000069.tsbin0 -> 345732 bytes
-rw-r--r--packages/tests/fixtures/live/0-000070.tsbin0 -> 282376 bytes
-rw-r--r--packages/tests/fixtures/live/0.m3u814
-rw-r--r--packages/tests/fixtures/live/1-000067.tsbin0 -> 620024 bytes
-rw-r--r--packages/tests/fixtures/live/1-000068.tsbin0 -> 382392 bytes
-rw-r--r--packages/tests/fixtures/live/1-000069.tsbin0 -> 712332 bytes
-rw-r--r--packages/tests/fixtures/live/1-000070.tsbin0 -> 608556 bytes
-rw-r--r--packages/tests/fixtures/live/1.m3u814
-rw-r--r--packages/tests/fixtures/live/master.m3u88
-rw-r--r--packages/tests/fixtures/low-bitrate.mp4bin0 -> 43850 bytes
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-broken/main.js12
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-broken/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js85
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js53
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js95
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json3
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json3
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js21
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json23
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-five/main.js23
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-five/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-four/main.js201
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-four/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js69
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js106
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js65
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-native/main.js21
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-native/package.json23
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js82
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json19
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-six/main.js46
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-six/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js92
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js38
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-unloading/lib.js2
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-unloading/main.js14
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-unloading/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-video-constants/main.js46
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-video-constants/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-websocket/main.js36
-rw-r--r--packages/tests/fixtures/peertube-plugin-test-websocket/package.json20
-rw-r--r--packages/tests/fixtures/peertube-plugin-test/languages/fr.json3
-rw-r--r--packages/tests/fixtures/peertube-plugin-test/main.js477
-rw-r--r--packages/tests/fixtures/peertube-plugin-test/package.json22
-rw-r--r--packages/tests/fixtures/rtmps.cert21
-rw-r--r--packages/tests/fixtures/rtmps.key28
-rw-r--r--packages/tests/fixtures/sample.oggbin0 -> 105243 bytes
-rw-r--r--packages/tests/fixtures/subtitle-bad.txt11
-rw-r--r--packages/tests/fixtures/subtitle-good.srt11
-rw-r--r--packages/tests/fixtures/subtitle-good1.vtt8
-rw-r--r--packages/tests/fixtures/subtitle-good2.vtt8
-rw-r--r--packages/tests/fixtures/thumbnail-playlist.jpgbin0 -> 5040 bytes
-rw-r--r--packages/tests/fixtures/video-720p.torrentbin0 -> 2644 bytes
-rw-r--r--packages/tests/fixtures/video_import_preview.jpgbin0 -> 9551 bytes
-rw-r--r--packages/tests/fixtures/video_import_preview_yt_dlp.jpgbin0 -> 15844 bytes
-rw-r--r--packages/tests/fixtures/video_import_thumbnail.jpgbin0 -> 10980 bytes
-rw-r--r--packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpgbin0 -> 10676 bytes
-rw-r--r--packages/tests/fixtures/video_short.avibin0 -> 584656 bytes
-rw-r--r--packages/tests/fixtures/video_short.mkvbin0 -> 40642 bytes
-rw-r--r--packages/tests/fixtures/video_short.mp4bin0 -> 38783 bytes
-rw-r--r--packages/tests/fixtures/video_short.mp4.jpgbin0 -> 5028 bytes
-rw-r--r--packages/tests/fixtures/video_short.ogvbin0 -> 140849 bytes
-rw-r--r--packages/tests/fixtures/video_short.ogv.jpgbin0 -> 5023 bytes
-rw-r--r--packages/tests/fixtures/video_short.webmbin0 -> 218910 bytes
-rw-r--r--packages/tests/fixtures/video_short.webm.jpgbin0 -> 5028 bytes
-rw-r--r--packages/tests/fixtures/video_short1-preview.webm.jpgbin0 -> 31188 bytes
-rw-r--r--packages/tests/fixtures/video_short1.webmbin0 -> 572456 bytes
-rw-r--r--packages/tests/fixtures/video_short1.webm.jpgbin0 -> 6334 bytes
-rw-r--r--packages/tests/fixtures/video_short2.webmbin0 -> 942961 bytes
-rw-r--r--packages/tests/fixtures/video_short2.webm.jpgbin0 -> 6607 bytes
-rw-r--r--packages/tests/fixtures/video_short3.webmbin0 -> 292677 bytes
-rw-r--r--packages/tests/fixtures/video_short3.webm.jpgbin0 -> 5674 bytes
-rw-r--r--packages/tests/fixtures/video_short_0p.mp4bin0 -> 3051 bytes
-rw-r--r--packages/tests/fixtures/video_short_144p.m3u813
-rw-r--r--packages/tests/fixtures/video_short_144p.mp4bin0 -> 15634 bytes
-rw-r--r--packages/tests/fixtures/video_short_240p.m3u813
-rw-r--r--packages/tests/fixtures/video_short_240p.mp4bin0 -> 23084 bytes
-rw-r--r--packages/tests/fixtures/video_short_360p.m3u813
-rw-r--r--packages/tests/fixtures/video_short_360p.mp4bin0 -> 30620 bytes
-rw-r--r--packages/tests/fixtures/video_short_480.webmbin0 -> 69217 bytes
-rw-r--r--packages/tests/fixtures/video_short_480p.m3u813
-rw-r--r--packages/tests/fixtures/video_short_480p.mp4bin0 -> 39881 bytes
-rw-r--r--packages/tests/fixtures/video_short_4k.mp4bin0 -> 618949 bytes
-rw-r--r--packages/tests/fixtures/video_short_720p.m3u813
-rw-r--r--packages/tests/fixtures/video_short_720p.mp4bin0 -> 59109 bytes
-rw-r--r--packages/tests/fixtures/video_short_fake.webm1
-rw-r--r--packages/tests/fixtures/video_short_mp3_256k.mp4bin0 -> 194985 bytes
-rw-r--r--packages/tests/fixtures/video_short_no_audio.mp4bin0 -> 34259 bytes
-rw-r--r--packages/tests/fixtures/video_very_long_10p.mp4bin0 -> 185338 bytes
-rw-r--r--packages/tests/fixtures/video_very_short_240p.mp4bin0 -> 9352 bytes
130 files changed, 2639 insertions, 0 deletions
diff --git a/packages/tests/fixtures/60fps_720p_small.mp4 b/packages/tests/fixtures/60fps_720p_small.mp4
new file mode 100644
index 000000000..74bf968a4
--- /dev/null
+++ b/packages/tests/fixtures/60fps_720p_small.mp4
Binary files differ
diff --git a/packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json b/packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json
new file mode 100644
index 000000000..4e7bc3af5
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/bad-body-http-signature.json
@@ -0,0 +1,93 @@
1{
2 "headers": {
3 "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)",
4 "host": "localhost",
5 "date": "Mon, 22 Oct 2018 13:34:22 GMT",
6 "accept-encoding": "gzip",
7 "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=",
8 "content-type": "application/activity+json",
9 "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==\"",
10 "content-length": "2815"
11 },
12 "body": {
13 "@context": [
14 "https://www.w3.org/ns/activitystreams",
15 "https://w3id.org/security/v1",
16 {
17 "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
18 "sensitive": "as:sensitive",
19 "movedTo": {
20 "@id": "as:movedTo",
21 "@type": "@id"
22 },
23 "Hashtag": "as:Hashtag",
24 "ostatus": "http://ostatus.org#",
25 "atomUri": "ostatus:atomUri",
26 "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
27 "conversation": "ostatus:conversation",
28 "toot": "http://joinmastodon.org/ns#",
29 "Emoji": "toot:Emoji",
30 "focalPoint": {
31 "@container": "@list",
32 "@id": "toot:focalPoint"
33 },
34 "featured": {
35 "@id": "toot:featured",
36 "@type": "@id"
37 },
38 "schema": "http://schema.org#",
39 "PropertyValue": "schema:PropertyValue",
40 "value": "schema:value"
41 }
42 ],
43 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity",
44 "type": "Create",
45 "actor": "http://localhost:3000/users/ronan2",
46 "published": "2018-10-22T13:34:18Z",
47 "to": [
48 "https://www.w3.org/ns/activitystreams#Public"
49 ],
50 "cc": [
51 "http://localhost:3000/users/ronan2/followers",
52 "http://localhost:9000/accounts/ronan"
53 ],
54 "object": {
55 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
56 "type": "Note",
57 "summary": null,
58 "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
59 "published": "2018-10-22T13:34:18Z",
60 "url": "http://localhost:3000/@ronan2/100939547203370948",
61 "attributedTo": "http://localhost:3000/users/ronan2",
62 "to": [
63 "https://www.w3.org/ns/activitystreams#Public"
64 ],
65 "cc": [
66 "http://localhost:3000/users/ronan2/followers",
67 "http://localhost:9000/accounts/ronan"
68 ],
69 "sensitive": false,
70 "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
71 "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
72 "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation",
73 "content": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>",
74 "contentMap": {
75 "en": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>"
76 },
77 "attachment": [],
78 "tag": [
79 {
80 "type": "Mention",
81 "href": "http://localhost:9000/accounts/ronan",
82 "name": "@ronan@localhost:9000"
83 }
84 ]
85 },
86 "signature": {
87 "type": "RsaSignature2017",
88 "creator": "http://localhost:3000/users/ronan2#main-key",
89 "created": "2018-10-22T13:34:19Z",
90 "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q=="
91 }
92 }
93}
diff --git a/packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json b/packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json
new file mode 100644
index 000000000..098597db0
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/bad-http-signature.json
@@ -0,0 +1,93 @@
1{
2 "headers": {
3 "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)",
4 "host": "localhost",
5 "date": "Mon, 22 Oct 2018 13:34:22 GMT",
6 "accept-encoding": "gzip",
7 "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=",
8 "content-type": "application/activity+json",
9 "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==\"",
10 "content-length": "2815"
11 },
12 "body": {
13 "@context": [
14 "https://www.w3.org/ns/activitystreams",
15 "https://w3id.org/security/v1",
16 {
17 "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
18 "sensitive": "as:sensitive",
19 "movedTo": {
20 "@id": "as:movedTo",
21 "@type": "@id"
22 },
23 "Hashtag": "as:Hashtag",
24 "ostatus": "http://ostatus.org#",
25 "atomUri": "ostatus:atomUri",
26 "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
27 "conversation": "ostatus:conversation",
28 "toot": "http://joinmastodon.org/ns#",
29 "Emoji": "toot:Emoji",
30 "focalPoint": {
31 "@container": "@list",
32 "@id": "toot:focalPoint"
33 },
34 "featured": {
35 "@id": "toot:featured",
36 "@type": "@id"
37 },
38 "schema": "http://schema.org#",
39 "PropertyValue": "schema:PropertyValue",
40 "value": "schema:value"
41 }
42 ],
43 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity",
44 "type": "Create",
45 "actor": "http://localhost:3000/users/ronan2",
46 "published": "2018-10-22T13:34:18Z",
47 "to": [
48 "https://www.w3.org/ns/activitystreams#Public"
49 ],
50 "cc": [
51 "http://localhost:3000/users/ronan2/followers",
52 "http://localhost:9000/accounts/ronan"
53 ],
54 "object": {
55 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
56 "type": "Note",
57 "summary": null,
58 "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
59 "published": "2018-10-22T13:34:18Z",
60 "url": "http://localhost:3000/@ronan2/100939547203370948",
61 "attributedTo": "http://localhost:3000/users/ronan2",
62 "to": [
63 "https://www.w3.org/ns/activitystreams#Public"
64 ],
65 "cc": [
66 "http://localhost:3000/users/ronan2/followers",
67 "http://localhost:9000/accounts/ronan"
68 ],
69 "sensitive": false,
70 "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
71 "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
72 "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation",
73 "content": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>",
74 "contentMap": {
75 "en": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>"
76 },
77 "attachment": [],
78 "tag": [
79 {
80 "type": "Mention",
81 "href": "http://localhost:9000/accounts/ronan",
82 "name": "@ronan@localhost:9000"
83 }
84 ]
85 },
86 "signature": {
87 "type": "RsaSignature2017",
88 "creator": "http://localhost:3000/users/ronan2#main-key",
89 "created": "2018-10-22T13:34:19Z",
90 "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q=="
91 }
92 }
93}
diff --git a/packages/tests/fixtures/ap-json/mastodon/bad-public-key.json b/packages/tests/fixtures/ap-json/mastodon/bad-public-key.json
new file mode 100644
index 000000000..73d18b3ad
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/bad-public-key.json
@@ -0,0 +1,3 @@
1{
2 "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"
3}
diff --git a/packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json b/packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json
new file mode 100644
index 000000000..2cd037241
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/create-bad-signature.json
@@ -0,0 +1,81 @@
1{
2 "@context": [
3 "https://www.w3.org/ns/activitystreams",
4 "https://w3id.org/security/v1",
5 {
6 "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
7 "sensitive": "as:sensitive",
8 "movedTo": {
9 "@id": "as:movedTo",
10 "@type": "@id"
11 },
12 "Hashtag": "as:Hashtag",
13 "ostatus": "http://ostatus.org#",
14 "atomUri": "ostatus:atomUri",
15 "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
16 "conversation": "ostatus:conversation",
17 "toot": "http://joinmastodon.org/ns#",
18 "Emoji": "toot:Emoji",
19 "focalPoint": {
20 "@container": "@list",
21 "@id": "toot:focalPoint"
22 },
23 "featured": {
24 "@id": "toot:featured",
25 "@type": "@id"
26 },
27 "schema": "http://schema.org#",
28 "PropertyValue": "schema:PropertyValue",
29 "value": "schema:value"
30 }
31 ],
32 "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698/activity",
33 "type": "Create",
34 "actor": "http://localhost:3000/users/ronan2",
35 "published": "2018-10-22T12:43:07Z",
36 "to": [
37 "https://www.w3.org/ns/activitystreams#Public"
38 ],
39 "cc": [
40 "http://localhost:3000/users/ronan2/followers",
41 "http://localhost:9000/accounts/ronan"
42 ],
43 "object": {
44 "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698",
45 "type": "Note",
46 "summary": null,
47 "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
48 "published": "2018-10-22T12:43:07Z",
49 "url": "http://localhost:3000/@ronan2/100939345950887698",
50 "attributedTo": "http://localhost:3000/users/ronan2",
51 "to": [
52 "https://www.w3.org/ns/activitystreams#Public"
53 ],
54 "cc": [
55 "http://localhost:3000/users/ronan2/followers",
56 "http://localhost:9000/accounts/ronan"
57 ],
58 "sensitive": false,
59 "atomUri": "http://localhost:3000/users/ronan2/statuses/100939345950887698",
60 "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
61 "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation",
62 "content": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zerg</p>",
63 "contentMap": {
64 "en": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zerg</p>"
65 },
66 "attachment": [],
67 "tag": [
68 {
69 "type": "Mention",
70 "href": "http://localhost:9000/accounts/ronan",
71 "name": "@ronan@localhost:9000"
72 }
73 ]
74 },
75 "signature": {
76 "type": "RsaSignature2017",
77 "creator": "http://localhost:3000/users/ronan2#main-key",
78 "created": "2018-10-22T12:43:08Z",
79 "signatureValue": "Vgr8nA0agPr9TcA4BlX+MWhmuE+rBcoIJLpnPbm3E5SnOCXbgjEfEaTLqfuzzkKNsR3PBbkvi3YWK4/DxJ0zmpzSB7yy4NRzluQMVQHqJiFKXAX3Sr3fIrK24xkWW9/F207c1NpFajSGbgnFKBdtFE0e5VqwSrSoOJkZukZW/2ATSnsyzblieuUmvTWpD0PqpUOsynPjw+RqZnqPn0cjw1z2Dm7ZRt3trnyMTXFYZw5U/YuqMY2kpadD6vq780md8kXlJIylxG6ZrlO2jz9fJdnfuVq43d4QFNsBm1K1r2WtNqX+i+wiqh+u3PjF4pzXtl/a3hJOH18IfZnK7I21mQ=="
80 }
81}
diff --git a/packages/tests/fixtures/ap-json/mastodon/create.json b/packages/tests/fixtures/ap-json/mastodon/create.json
new file mode 100644
index 000000000..0be271bb8
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/create.json
@@ -0,0 +1,81 @@
1{
2 "@context": [
3 "https://www.w3.org/ns/activitystreams",
4 "https://w3id.org/security/v1",
5 {
6 "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
7 "sensitive": "as:sensitive",
8 "movedTo": {
9 "@id": "as:movedTo",
10 "@type": "@id"
11 },
12 "Hashtag": "as:Hashtag",
13 "ostatus": "http://ostatus.org#",
14 "atomUri": "ostatus:atomUri",
15 "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
16 "conversation": "ostatus:conversation",
17 "toot": "http://joinmastodon.org/ns#",
18 "Emoji": "toot:Emoji",
19 "focalPoint": {
20 "@container": "@list",
21 "@id": "toot:focalPoint"
22 },
23 "featured": {
24 "@id": "toot:featured",
25 "@type": "@id"
26 },
27 "schema": "http://schema.org#",
28 "PropertyValue": "schema:PropertyValue",
29 "value": "schema:value"
30 }
31 ],
32 "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698/activity",
33 "type": "Create",
34 "actor": "http://localhost:3000/users/ronan2",
35 "published": "2018-10-22T12:43:07Z",
36 "to": [
37 "https://www.w3.org/ns/activitystreams#Public"
38 ],
39 "cc": [
40 "http://localhost:3000/users/ronan2/followers",
41 "http://localhost:9000/accounts/ronan"
42 ],
43 "object": {
44 "id": "http://localhost:3000/users/ronan2/statuses/100939345950887698",
45 "type": "Note",
46 "summary": null,
47 "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
48 "published": "2018-10-22T12:43:07Z",
49 "url": "http://localhost:3000/@ronan2/100939345950887698",
50 "attributedTo": "http://localhost:3000/users/ronan2",
51 "to": [
52 "https://www.w3.org/ns/activitystreams#Public"
53 ],
54 "cc": [
55 "http://localhost:3000/users/ronan2/followers",
56 "http://localhost:9000/accounts/ronan"
57 ],
58 "sensitive": false,
59 "atomUri": "http://localhost:3000/users/ronan2/statuses/100939345950887698",
60 "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
61 "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation",
62 "content": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zerg</p>",
63 "contentMap": {
64 "en": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zerg</p>"
65 },
66 "attachment": [],
67 "tag": [
68 {
69 "type": "Mention",
70 "href": "http://localhost:9000/accounts/ronan",
71 "name": "@ronan@localhost:9000"
72 }
73 ]
74 },
75 "signature": {
76 "type": "RsaSignature2017",
77 "creator": "http://localhost:3000/users/ronan2#main-key",
78 "created": "2018-10-22T12:43:08Z",
79 "signatureValue": "VgR8nA0agPr9TcA4BlX+MWhmuE+rBcoIJLpnPbm3E5SnOCXbgjEfEaTLqfuzzkKNsR3PBbkvi3YWK4/DxJ0zmpzSB7yy4NRzluQMVQHqJiFKXAX3Sr3fIrK24xkWW9/F207c1NpFajSGbgnFKBdtFE0e5VqwSrSoOJkZukZW/2ATSnsyzblieuUmvTWpD0PqpUOsynPjw+RqZnqPn0cjw1z2Dm7ZRt3trnyMTXFYZw5U/YuqMY2kpadD6vq780md8kXlJIylxG6ZrlO2jz9fJdnfuVq43d4QFNsBm1K1r2WtNqX+i+wiqh+u3PjF4pzXtl/a3hJOH18IfZnK7I21mQ=="
80 }
81}
diff --git a/packages/tests/fixtures/ap-json/mastodon/http-signature.json b/packages/tests/fixtures/ap-json/mastodon/http-signature.json
new file mode 100644
index 000000000..4e7bc3af5
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/http-signature.json
@@ -0,0 +1,93 @@
1{
2 "headers": {
3 "user-agent": "http.rb/3.3.0 (Mastodon/2.5.0; +http://localhost:3000/)",
4 "host": "localhost",
5 "date": "Mon, 22 Oct 2018 13:34:22 GMT",
6 "accept-encoding": "gzip",
7 "digest": "SHA-256=FEr5j2WSSfdEMcG3NTOXuGU0lUchfTJx4+BtUlWOwDk=",
8 "content-type": "application/activity+json",
9 "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==\"",
10 "content-length": "2815"
11 },
12 "body": {
13 "@context": [
14 "https://www.w3.org/ns/activitystreams",
15 "https://w3id.org/security/v1",
16 {
17 "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
18 "sensitive": "as:sensitive",
19 "movedTo": {
20 "@id": "as:movedTo",
21 "@type": "@id"
22 },
23 "Hashtag": "as:Hashtag",
24 "ostatus": "http://ostatus.org#",
25 "atomUri": "ostatus:atomUri",
26 "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
27 "conversation": "ostatus:conversation",
28 "toot": "http://joinmastodon.org/ns#",
29 "Emoji": "toot:Emoji",
30 "focalPoint": {
31 "@container": "@list",
32 "@id": "toot:focalPoint"
33 },
34 "featured": {
35 "@id": "toot:featured",
36 "@type": "@id"
37 },
38 "schema": "http://schema.org#",
39 "PropertyValue": "schema:PropertyValue",
40 "value": "schema:value"
41 }
42 ],
43 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948/activity",
44 "type": "Create",
45 "actor": "http://localhost:3000/users/ronan2",
46 "published": "2018-10-22T13:34:18Z",
47 "to": [
48 "https://www.w3.org/ns/activitystreams#Public"
49 ],
50 "cc": [
51 "http://localhost:3000/users/ronan2/followers",
52 "http://localhost:9000/accounts/ronan"
53 ],
54 "object": {
55 "id": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
56 "type": "Note",
57 "summary": null,
58 "inReplyTo": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
59 "published": "2018-10-22T13:34:18Z",
60 "url": "http://localhost:3000/@ronan2/100939547203370948",
61 "attributedTo": "http://localhost:3000/users/ronan2",
62 "to": [
63 "https://www.w3.org/ns/activitystreams#Public"
64 ],
65 "cc": [
66 "http://localhost:3000/users/ronan2/followers",
67 "http://localhost:9000/accounts/ronan"
68 ],
69 "sensitive": false,
70 "atomUri": "http://localhost:3000/users/ronan2/statuses/100939547203370948",
71 "inReplyToAtomUri": "http://localhost:9000/videos/watch/90e6f8ed-b369-423c-b0c8-f44e5350c752",
72 "conversation": "tag:localhost:3000,2018-10-19:objectId=72:objectType=Conversation",
73 "content": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>",
74 "contentMap": {
75 "en": "<p><span class=\"h-card\"><a href=\"http://localhost:9000/accounts/ronan\" class=\"u-url mention\">@<span>ronan</span></a></span> zergzerg</p>"
76 },
77 "attachment": [],
78 "tag": [
79 {
80 "type": "Mention",
81 "href": "http://localhost:9000/accounts/ronan",
82 "name": "@ronan@localhost:9000"
83 }
84 ]
85 },
86 "signature": {
87 "type": "RsaSignature2017",
88 "creator": "http://localhost:3000/users/ronan2#main-key",
89 "created": "2018-10-22T13:34:19Z",
90 "signatureValue": "x+xL4l8ERziYVhwEafHJyBQOInvNZ0gV4ccYd9AtFYeGJagc8fY6jjjhbDRCD7yMhgTjBX69z20MXnDuwpmM6wej3dt1wLKdIyXVViO84nAlqFz7KmNxtk5lDnAVX/vttscT5YUFvw4dbPT2mQiEd1lKbaLftRiIPEomZpQ37+fUkQdcPrnhruPAISO/Sof1n1LFW4mYIffozteQSZBH6HaCVp+MRMIhdMi5e8w7PD48/cZz8D/EU8Vqi91FM76/3tMqg6nLqQ+8bq74Jvt2kzwZlIufe+I55QMpZOmF6hGIJEt+R0JXdjQbtgcELONmNj2dr8sAlzu7zKlAGuJ24Q=="
91 }
92 }
93}
diff --git a/packages/tests/fixtures/ap-json/mastodon/public-key.json b/packages/tests/fixtures/ap-json/mastodon/public-key.json
new file mode 100644
index 000000000..b7b9b8308
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/mastodon/public-key.json
@@ -0,0 +1,3 @@
1{
2 "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"
3}
diff --git a/packages/tests/fixtures/ap-json/peertube/announce-without-context.json b/packages/tests/fixtures/ap-json/peertube/announce-without-context.json
new file mode 100644
index 000000000..cda1c514c
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/peertube/announce-without-context.json
@@ -0,0 +1,13 @@
1{
2 "type": "Announce",
3 "id": "http://127.0.0.1:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05/announces/1",
4 "actor": "http://127.0.0.1:9002/accounts/peertube",
5 "object": "http://127.0.0.1:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05",
6 "to": [
7 "https://www.w3.org/ns/activitystreams#Public",
8 "http://127.0.0.1:9002/accounts/peertube/followers",
9 "http://127.0.0.1:9002/video-channels/root_channel/followers",
10 "http://127.0.0.1:9002/accounts/root/followers"
11 ],
12 "cc": []
13}
diff --git a/packages/tests/fixtures/ap-json/peertube/invalid-keys.json b/packages/tests/fixtures/ap-json/peertube/invalid-keys.json
new file mode 100644
index 000000000..0544e96b9
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/peertube/invalid-keys.json
@@ -0,0 +1,6 @@
1{
2 "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqjQGdH6D3naKmSbbr/Df\nEh1H42F3WlHYXuxKLkm5Bemjdde+GwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYO\nwAyc3Zoy7afPNa4bZXqhJ1Im41rMGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55s\nIkczDkseJuadTvG+A1e4uNY2lnRmVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/F\npP5S75TS5l1DfJQIq2lp8RwrH6FvGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM\n7mS7eP8zF8lKXYUu8cjIscKm+XqGmyRoPyw2Pp53tew29idRUocVQHGBnlNbpKdd\naQIDAQAB\n-----END PUBLIC KEY-----\n",
3 "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-----"
4}
5
6
diff --git a/packages/tests/fixtures/ap-json/peertube/keys.json b/packages/tests/fixtures/ap-json/peertube/keys.json
new file mode 100644
index 000000000..1a7700865
--- /dev/null
+++ b/packages/tests/fixtures/ap-json/peertube/keys.json
@@ -0,0 +1,4 @@
1{
2 "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqjQGdH6D3naKmSbbr/Df\nEh1H42F3WlHYXuxKLkm5Bemjdde+GwHYdz5m3fcIWw3HTzfA+y9Of8epGdfSrtYO\nwAyc3Zoy7afPNa4bZXqhJ1Im41rMGieiCuUn4uTPPucIjC0gCkVwvuQr3Elbk55s\nIkczDkseJuadTvG+A1e4uNY2lnRmVhf4g5B90u6CLe2KdbPpifRoKlw9zaUBj4/F\npP5S75TS5l1DfJQIq2lp8RwrH6FvGKLnWlbGeNYX96DDvlA5Sxoxz6a+bTV9OopM\n7mS7eP8zF8lKXYUu8cjIscKm+XqGmyRoPyw3Pp53tew29idRUocVQHGBnlNbpKdd\naQIDAQAB\n-----END PUBLIC KEY-----\n",
3 "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-----"
4}
diff --git a/packages/tests/fixtures/avatar-big.png b/packages/tests/fixtures/avatar-big.png
new file mode 100644
index 000000000..e593e40da
--- /dev/null
+++ b/packages/tests/fixtures/avatar-big.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar-resized-120x120.gif b/packages/tests/fixtures/avatar-resized-120x120.gif
new file mode 100644
index 000000000..81a82189e
--- /dev/null
+++ b/packages/tests/fixtures/avatar-resized-120x120.gif
Binary files differ
diff --git a/packages/tests/fixtures/avatar-resized-120x120.png b/packages/tests/fixtures/avatar-resized-120x120.png
new file mode 100644
index 000000000..9d84151f8
--- /dev/null
+++ b/packages/tests/fixtures/avatar-resized-120x120.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar-resized-48x48.gif b/packages/tests/fixtures/avatar-resized-48x48.gif
new file mode 100644
index 000000000..5900ff12e
--- /dev/null
+++ b/packages/tests/fixtures/avatar-resized-48x48.gif
Binary files differ
diff --git a/packages/tests/fixtures/avatar-resized-48x48.png b/packages/tests/fixtures/avatar-resized-48x48.png
new file mode 100644
index 000000000..9e5f3b490
--- /dev/null
+++ b/packages/tests/fixtures/avatar-resized-48x48.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar.gif b/packages/tests/fixtures/avatar.gif
new file mode 100644
index 000000000..f29707760
--- /dev/null
+++ b/packages/tests/fixtures/avatar.gif
Binary files differ
diff --git a/packages/tests/fixtures/avatar.png b/packages/tests/fixtures/avatar.png
new file mode 100644
index 000000000..4b7fd2c0a
--- /dev/null
+++ b/packages/tests/fixtures/avatar.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar2-resized-120x120.png b/packages/tests/fixtures/avatar2-resized-120x120.png
new file mode 100644
index 000000000..44149facb
--- /dev/null
+++ b/packages/tests/fixtures/avatar2-resized-120x120.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar2-resized-48x48.png b/packages/tests/fixtures/avatar2-resized-48x48.png
new file mode 100644
index 000000000..bb3939b1a
--- /dev/null
+++ b/packages/tests/fixtures/avatar2-resized-48x48.png
Binary files differ
diff --git a/packages/tests/fixtures/avatar2.png b/packages/tests/fixtures/avatar2.png
new file mode 100644
index 000000000..dae702190
--- /dev/null
+++ b/packages/tests/fixtures/avatar2.png
Binary files differ
diff --git a/packages/tests/fixtures/banner-resized.jpg b/packages/tests/fixtures/banner-resized.jpg
new file mode 100644
index 000000000..952732d61
--- /dev/null
+++ b/packages/tests/fixtures/banner-resized.jpg
Binary files differ
diff --git a/packages/tests/fixtures/banner.jpg b/packages/tests/fixtures/banner.jpg
new file mode 100644
index 000000000..e5f284f59
--- /dev/null
+++ b/packages/tests/fixtures/banner.jpg
Binary files differ
diff --git a/packages/tests/fixtures/custom-preview-big.png b/packages/tests/fixtures/custom-preview-big.png
new file mode 100644
index 000000000..03d171af3
--- /dev/null
+++ b/packages/tests/fixtures/custom-preview-big.png
Binary files differ
diff --git a/packages/tests/fixtures/custom-preview.jpg b/packages/tests/fixtures/custom-preview.jpg
new file mode 100644
index 000000000..5a039d830
--- /dev/null
+++ b/packages/tests/fixtures/custom-preview.jpg
Binary files differ
diff --git a/packages/tests/fixtures/custom-thumbnail-big.jpg b/packages/tests/fixtures/custom-thumbnail-big.jpg
new file mode 100644
index 000000000..08375e425
--- /dev/null
+++ b/packages/tests/fixtures/custom-thumbnail-big.jpg
Binary files differ
diff --git a/packages/tests/fixtures/custom-thumbnail.jpg b/packages/tests/fixtures/custom-thumbnail.jpg
new file mode 100644
index 000000000..ef818442d
--- /dev/null
+++ b/packages/tests/fixtures/custom-thumbnail.jpg
Binary files differ
diff --git a/packages/tests/fixtures/custom-thumbnail.png b/packages/tests/fixtures/custom-thumbnail.png
new file mode 100644
index 000000000..9f34daec1
--- /dev/null
+++ b/packages/tests/fixtures/custom-thumbnail.png
Binary files differ
diff --git a/packages/tests/fixtures/exif.jpg b/packages/tests/fixtures/exif.jpg
new file mode 100644
index 000000000..2997b38e9
--- /dev/null
+++ b/packages/tests/fixtures/exif.jpg
Binary files differ
diff --git a/packages/tests/fixtures/exif.png b/packages/tests/fixtures/exif.png
new file mode 100644
index 000000000..a1a0113f8
--- /dev/null
+++ b/packages/tests/fixtures/exif.png
Binary files differ
diff --git a/packages/tests/fixtures/live/0-000067.ts b/packages/tests/fixtures/live/0-000067.ts
new file mode 100644
index 000000000..a59f41a63
--- /dev/null
+++ b/packages/tests/fixtures/live/0-000067.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/0-000068.ts b/packages/tests/fixtures/live/0-000068.ts
new file mode 100644
index 000000000..83dcbbb4c
--- /dev/null
+++ b/packages/tests/fixtures/live/0-000068.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/0-000069.ts b/packages/tests/fixtures/live/0-000069.ts
new file mode 100644
index 000000000..cafd4e978
--- /dev/null
+++ b/packages/tests/fixtures/live/0-000069.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/0-000070.ts b/packages/tests/fixtures/live/0-000070.ts
new file mode 100644
index 000000000..0936199ea
--- /dev/null
+++ b/packages/tests/fixtures/live/0-000070.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/0.m3u8 b/packages/tests/fixtures/live/0.m3u8
new file mode 100644
index 000000000..c3be19d26
--- /dev/null
+++ b/packages/tests/fixtures/live/0.m3u8
@@ -0,0 +1,14 @@
1#EXTM3U
2#EXT-X-VERSION:6
3#EXT-X-TARGETDURATION:2
4#EXT-X-MEDIA-SEQUENCE:68
5#EXT-X-INDEPENDENT-SEGMENTS
6#EXTINF:2.000000,
7#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:39.019+0200
80-000068.ts
9#EXTINF:2.000000,
10#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:41.019+0200
110-000069.ts
12#EXTINF:2.000000,
13#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:43.019+0200
140-000070.
diff --git a/packages/tests/fixtures/live/1-000067.ts b/packages/tests/fixtures/live/1-000067.ts
new file mode 100644
index 000000000..17db8f81e
--- /dev/null
+++ b/packages/tests/fixtures/live/1-000067.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/1-000068.ts b/packages/tests/fixtures/live/1-000068.ts
new file mode 100644
index 000000000..f7bb97040
--- /dev/null
+++ b/packages/tests/fixtures/live/1-000068.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/1-000069.ts b/packages/tests/fixtures/live/1-000069.ts
new file mode 100644
index 000000000..64c791337
--- /dev/null
+++ b/packages/tests/fixtures/live/1-000069.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/1-000070.ts b/packages/tests/fixtures/live/1-000070.ts
new file mode 100644
index 000000000..a5f04f109
--- /dev/null
+++ b/packages/tests/fixtures/live/1-000070.ts
Binary files differ
diff --git a/packages/tests/fixtures/live/1.m3u8 b/packages/tests/fixtures/live/1.m3u8
new file mode 100644
index 000000000..26d7fa6b0
--- /dev/null
+++ b/packages/tests/fixtures/live/1.m3u8
@@ -0,0 +1,14 @@
1#EXTM3U
2#EXT-X-VERSION:6
3#EXT-X-TARGETDURATION:2
4#EXT-X-MEDIA-SEQUENCE:68
5#EXT-X-INDEPENDENT-SEGMENTS
6#EXTINF:2.000000,
7#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:39.019+0200
81-000068.ts
9#EXTINF:2.000000,
10#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:41.019+0200
111-000069.ts
12#EXTINF:2.000000,
13#EXT-X-PROGRAM-DATE-TIME:2023-04-18T13:38:43.019+0200
141-000070.ts
diff --git a/packages/tests/fixtures/live/master.m3u8 b/packages/tests/fixtures/live/master.m3u8
new file mode 100644
index 000000000..7e52f33cf
--- /dev/null
+++ b/packages/tests/fixtures/live/master.m3u8
@@ -0,0 +1,8 @@
1#EXTM3U
2#EXT-X-VERSION:6
3#EXT-X-STREAM-INF:BANDWIDTH=1287342,RESOLUTION=640x360,CODECS="avc1.64001f,mp4a.40.2"
40.m3u8
5
6#EXT-X-STREAM-INF:BANDWIDTH=3051742,RESOLUTION=1280x720,CODECS="avc1.64001f,mp4a.40.2"
71.m3u8
8
diff --git a/packages/tests/fixtures/low-bitrate.mp4 b/packages/tests/fixtures/low-bitrate.mp4
new file mode 100644
index 000000000..69004eccc
--- /dev/null
+++ b/packages/tests/fixtures/low-bitrate.mp4
Binary files differ
diff --git a/packages/tests/fixtures/peertube-plugin-test-broken/main.js b/packages/tests/fixtures/peertube-plugin-test-broken/main.js
new file mode 100644
index 000000000..afdb6f7a0
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-broken/main.js
@@ -0,0 +1,12 @@
1async function register (options) {
2 options.unknownFunction()
3}
4
5async function unregister () {
6 return
7}
8
9module.exports = {
10 register,
11 unregister
12}
diff --git a/packages/tests/fixtures/peertube-plugin-test-broken/package.json b/packages/tests/fixtures/peertube-plugin-test-broken/package.json
new file mode 100644
index 000000000..fd03df216
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-broken/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-broken",
3 "version": "0.0.1",
4 "description": "Plugin test broken",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js
new file mode 100644
index 000000000..58bc27661
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/main.js
@@ -0,0 +1,85 @@
1async function register ({
2 registerExternalAuth,
3 peertubeHelpers,
4 settingsManager,
5 unregisterExternalAuth
6}) {
7 {
8 const result = registerExternalAuth({
9 authName: 'external-auth-1',
10 authDisplayName: () => 'External Auth 1',
11 onLogout: user => peertubeHelpers.logger.info('On logout %s', user.username),
12 onAuthRequest: (req, res) => {
13 const username = req.query.username
14
15 result.userAuthenticated({
16 req,
17 res,
18 username,
19 email: username + '@example.com'
20 })
21 }
22 })
23 }
24
25 {
26 const result = registerExternalAuth({
27 authName: 'external-auth-2',
28 authDisplayName: () => 'External Auth 2',
29 onAuthRequest: (req, res) => {
30 result.userAuthenticated({
31 req,
32 res,
33 username: 'kefka',
34 email: 'kefka@example.com',
35 role: 0,
36 displayName: 'Kefka Palazzo',
37 adminFlags: 1,
38 videoQuota: 42000,
39 videoQuotaDaily: 42100,
40
41 // Always use new value except for videoQuotaDaily field
42 userUpdater: ({ fieldName, currentValue, newValue }) => {
43 if (fieldName === 'videoQuotaDaily') return currentValue
44
45 return newValue
46 }
47 })
48 },
49 hookTokenValidity: (options) => {
50 if (options.type === 'refresh') {
51 return { valid: false }
52 }
53
54 if (options.type === 'access') {
55 const token = options.token
56 const now = new Date()
57 now.setTime(now.getTime() - 5000)
58
59 const createdAt = new Date(token.createdAt)
60
61 return { valid: createdAt.getTime() >= now.getTime() }
62 }
63
64 return { valid: true }
65 }
66 })
67 }
68
69 settingsManager.onSettingsChange(settings => {
70 if (settings.disableKefka) {
71 unregisterExternalAuth('external-auth-2')
72 }
73 })
74}
75
76async function unregister () {
77 return
78}
79
80module.exports = {
81 register,
82 unregister
83}
84
85// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json
new file mode 100644
index 000000000..22814b047
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-one/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-external-auth-one",
3 "version": "0.0.1",
4 "description": "External auth one",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js
new file mode 100644
index 000000000..30cedccc6
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/main.js
@@ -0,0 +1,53 @@
1async function register ({
2 registerExternalAuth,
3 peertubeHelpers
4}) {
5 {
6 const result = registerExternalAuth({
7 authName: 'external-auth-7',
8 authDisplayName: () => 'External Auth 7',
9 onAuthRequest: (req, res) => {
10 result.userAuthenticated({
11 req,
12 res,
13 username: 'cid',
14 email: 'cid@example.com',
15 displayName: 'Cid Marquez'
16 })
17 },
18 onLogout: (user, req) => {
19 return 'https://example.com/redirectUrl'
20 }
21 })
22 }
23
24 {
25 const result = registerExternalAuth({
26 authName: 'external-auth-8',
27 authDisplayName: () => 'External Auth 8',
28 onAuthRequest: (req, res) => {
29 result.userAuthenticated({
30 req,
31 res,
32 username: 'cid',
33 email: 'cid@example.com',
34 displayName: 'Cid Marquez'
35 })
36 },
37 onLogout: (user, req) => {
38 return 'https://example.com/redirectUrl?access_token=' + req.headers['authorization'].split(' ')[1]
39 }
40 })
41 }
42}
43
44async function unregister () {
45
46}
47
48module.exports = {
49 register,
50 unregister
51}
52
53// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json
new file mode 100644
index 000000000..f323d189d
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-three/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-external-auth-three",
3 "version": "0.0.1",
4 "description": "External auth three",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js
new file mode 100644
index 000000000..755dbb62b
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/main.js
@@ -0,0 +1,95 @@
1async function register ({
2 registerExternalAuth,
3 peertubeHelpers
4}) {
5 {
6 const result = registerExternalAuth({
7 authName: 'external-auth-3',
8 authDisplayName: () => 'External Auth 3',
9 onAuthRequest: (req, res) => {
10 result.userAuthenticated({
11 req,
12 res,
13 username: 'cid',
14 email: 'cid@example.com',
15 displayName: 'Cid Marquez'
16 })
17 }
18 })
19 }
20
21 {
22 const result = registerExternalAuth({
23 authName: 'external-auth-4',
24 authDisplayName: () => 'External Auth 4',
25 onAuthRequest: (req, res) => {
26 result.userAuthenticated({
27 req,
28 res,
29 username: 'kefka2',
30 email: 'kefka@example.com',
31 displayName: 'Kefka duplication'
32 })
33 }
34 })
35 }
36
37 {
38 const result = registerExternalAuth({
39 authName: 'external-auth-5',
40 authDisplayName: () => 'External Auth 5',
41 onAuthRequest: (req, res) => {
42 result.userAuthenticated({
43 req,
44 res,
45 username: 'kefka',
46 email: 'kefka@example.com',
47 displayName: 'Kefka duplication'
48 })
49 }
50 })
51 }
52
53 {
54 const result = registerExternalAuth({
55 authName: 'external-auth-6',
56 authDisplayName: () => 'External Auth 6',
57 onAuthRequest: (req, res) => {
58 result.userAuthenticated({
59 req,
60 res,
61 username: 'existing_user',
62 email: 'existing_user@example.com',
63 displayName: 'Existing user'
64 })
65 }
66 })
67 }
68
69 {
70 const result = registerExternalAuth({
71 authName: 'external-auth-7',
72 authDisplayName: () => 'External Auth 7',
73 onAuthRequest: (req, res) => {
74 result.userAuthenticated({
75 req,
76 res,
77 username: 'existing_user2',
78 email: 'custom_email_existing_user2@example.com',
79 displayName: 'Existing user 2'
80 })
81 }
82 })
83 }
84}
85
86async function unregister () {
87 return
88}
89
90module.exports = {
91 register,
92 unregister
93}
94
95// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json
new file mode 100644
index 000000000..a5ca4d07a
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-external-auth-two/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-external-auth-two",
3 "version": "0.0.1",
4 "description": "External auth two",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json
new file mode 100644
index 000000000..52d8313df
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/fr.json
@@ -0,0 +1,3 @@
1{
2 "Hello world": "Bonjour le monde"
3}
diff --git a/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json
new file mode 100644
index 000000000..9e187d83b
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-filter-translations/languages/it.json
@@ -0,0 +1,3 @@
1{
2 "Hello world": "Ciao, mondo!"
3}
diff --git a/packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js b/packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js
new file mode 100644
index 000000000..71c11b2ba
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-filter-translations/main.js
@@ -0,0 +1,21 @@
1async function register ({ registerHook, registerSetting, settingsManager, storageManager, peertubeHelpers }) {
2 registerHook({
3 target: 'filter:api.videos.list.params',
4 handler: obj => addToCount(obj)
5 })
6}
7
8async function unregister () {
9 return
10}
11
12module.exports = {
13 register,
14 unregister
15}
16
17// ############################################################################
18
19function addToCount (obj) {
20 return Object.assign({}, obj, { count: obj.count + 1 })
21}
diff --git a/packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json b/packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json
new file mode 100644
index 000000000..2adce4743
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-filter-translations/package.json
@@ -0,0 +1,23 @@
1{
2 "name": "peertube-plugin-test-filter-translations",
3 "version": "0.0.1",
4 "description": "Plugin test filter and translations",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {
20 "fr-FR": "./languages/fr.json",
21 "it-IT": "./languages/it.json"
22 }
23}
diff --git a/packages/tests/fixtures/peertube-plugin-test-five/main.js b/packages/tests/fixtures/peertube-plugin-test-five/main.js
new file mode 100644
index 000000000..07dd18654
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-five/main.js
@@ -0,0 +1,23 @@
1async function register ({
2 getRouter
3}) {
4 const router = getRouter()
5 router.get('/ping', (req, res) => res.json({ message: 'pong' }))
6
7 router.get('/is-authenticated', (req, res) => res.json({ isAuthenticated: res.locals.authenticated }))
8
9 router.post('/form/post/mirror', (req, res) => {
10 res.json(req.body)
11 })
12}
13
14async function unregister () {
15 return
16}
17
18module.exports = {
19 register,
20 unregister
21}
22
23// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-five/package.json b/packages/tests/fixtures/peertube-plugin-test-five/package.json
new file mode 100644
index 000000000..1f5d65d9d
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-five/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-five",
3 "version": "0.0.1",
4 "description": "Plugin test 5",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-four/main.js b/packages/tests/fixtures/peertube-plugin-test-four/main.js
new file mode 100644
index 000000000..b10177b45
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-four/main.js
@@ -0,0 +1,201 @@
1async function register ({
2 peertubeHelpers,
3 registerHook,
4 getRouter
5}) {
6 const logger = peertubeHelpers.logger
7
8 logger.info('Hello world from plugin four')
9
10 {
11 const username = 'root'
12 const results = await peertubeHelpers.database.query(
13 'SELECT "email" from "user" WHERE "username" = $username',
14 {
15 type: 'SELECT',
16 bind: { username }
17 }
18 )
19
20 logger.info('root email is ' + results[0]['email'])
21 }
22
23 {
24 registerHook({
25 target: 'action:api.video.viewed',
26 handler: async ({ video }) => {
27 const videoFromDB1 = await peertubeHelpers.videos.loadByUrl(video.url)
28 const videoFromDB2 = await peertubeHelpers.videos.loadByIdOrUUID(video.id)
29 const videoFromDB3 = await peertubeHelpers.videos.loadByIdOrUUID(video.uuid)
30
31 if (videoFromDB1.uuid !== videoFromDB2.uuid || videoFromDB2.uuid !== videoFromDB3.uuid) return
32
33 logger.info('video from DB uuid is %s.', videoFromDB1.uuid)
34
35 await peertubeHelpers.videos.removeVideo(video.id)
36
37 logger.info('Video deleted by plugin four.')
38 }
39 })
40 }
41
42 {
43 const serverActor = await peertubeHelpers.server.getServerActor()
44 logger.info('server actor name is %s', serverActor.preferredUsername)
45 }
46
47 {
48 logger.info('server url is %s', peertubeHelpers.config.getWebserverUrl())
49 }
50
51 {
52 const actions = {
53 blockServer,
54 unblockServer,
55 blockAccount,
56 unblockAccount,
57 blacklist,
58 unblacklist
59 }
60
61 const router = getRouter()
62 router.post('/commander', async (req, res) => {
63 try {
64 await actions[req.body.command](peertubeHelpers, req.body)
65
66 res.sendStatus(204)
67 } catch (err) {
68 logger.error('Error in commander.', { err })
69 res.sendStatus(500)
70 }
71 })
72
73 router.get('/server-config', async (req, res) => {
74 const serverConfig = await peertubeHelpers.config.getServerConfig()
75
76 return res.json({ serverConfig })
77 })
78
79 router.get('/server-listening-config', async (req, res) => {
80 const config = await peertubeHelpers.config.getServerListeningConfig()
81
82 return res.json({ config })
83 })
84
85 router.get('/static-route', async (req, res) => {
86 const staticRoute = peertubeHelpers.plugin.getBaseStaticRoute()
87
88 return res.json({ staticRoute })
89 })
90
91 router.get('/router-route', async (req, res) => {
92 const routerRoute = peertubeHelpers.plugin.getBaseRouterRoute()
93
94 return res.json({ routerRoute })
95 })
96
97 router.get('/user/:id', async (req, res) => {
98 const user = await peertubeHelpers.user.loadById(req.params.id)
99 if (!user) return res.status(404).end()
100
101 return res.json({
102 username: user.username
103 })
104 })
105
106 router.get('/user', async (req, res) => {
107 const user = await peertubeHelpers.user.getAuthUser(res)
108 if (!user) return res.sendStatus(404)
109
110 const isAdmin = user.role === 0
111 const isModerator = user.role === 1
112 const isUser = user.role === 2
113
114 return res.json({
115 id: user.id,
116 username: user.username,
117 displayName: user.Account.name,
118 isAdmin,
119 isModerator,
120 isUser
121 })
122 })
123
124 router.get('/video-files/:id', async (req, res) => {
125 const details = await peertubeHelpers.videos.getFiles(req.params.id)
126 if (!details) return res.sendStatus(404)
127
128 return res.json(details)
129 })
130
131 router.get('/ffprobe', async (req, res) => {
132 const result = await peertubeHelpers.videos.ffprobe(req.query.path)
133 if (!result) return res.sendStatus(404)
134
135 return res.json(result)
136 })
137
138 router.post('/send-notification', async (req, res) => {
139 peertubeHelpers.socket.sendNotification(req.body.userId, {
140 type: 1,
141 userId: req.body.userId
142 })
143
144 return res.sendStatus(201)
145 })
146
147 router.post('/send-video-live-new-state/:uuid', async (req, res) => {
148 const video = await peertubeHelpers.videos.loadByIdOrUUID(req.params.uuid)
149 peertubeHelpers.socket.sendVideoLiveNewState(video)
150
151 return res.sendStatus(201)
152 })
153 }
154
155}
156
157async function unregister () {
158 return
159}
160
161module.exports = {
162 register,
163 unregister
164}
165
166// ###########################################################################
167
168async function blockServer (peertubeHelpers, body) {
169 const serverActor = await peertubeHelpers.server.getServerActor()
170
171 await peertubeHelpers.moderation.blockServer({ byAccountId: serverActor.Account.id, hostToBlock: body.hostToBlock })
172}
173
174async function unblockServer (peertubeHelpers, body) {
175 const serverActor = await peertubeHelpers.server.getServerActor()
176
177 await peertubeHelpers.moderation.unblockServer({ byAccountId: serverActor.Account.id, hostToUnblock: body.hostToUnblock })
178}
179
180async function blockAccount (peertubeHelpers, body) {
181 const serverActor = await peertubeHelpers.server.getServerActor()
182
183 await peertubeHelpers.moderation.blockAccount({ byAccountId: serverActor.Account.id, handleToBlock: body.handleToBlock })
184}
185
186async function unblockAccount (peertubeHelpers, body) {
187 const serverActor = await peertubeHelpers.server.getServerActor()
188
189 await peertubeHelpers.moderation.unblockAccount({ byAccountId: serverActor.Account.id, handleToUnblock: body.handleToUnblock })
190}
191
192async function blacklist (peertubeHelpers, body) {
193 await peertubeHelpers.moderation.blacklistVideo({
194 videoIdOrUUID: body.videoUUID,
195 createOptions: body
196 })
197}
198
199async function unblacklist (peertubeHelpers, body) {
200 await peertubeHelpers.moderation.unblacklistVideo({ videoIdOrUUID: body.videoUUID })
201}
diff --git a/packages/tests/fixtures/peertube-plugin-test-four/package.json b/packages/tests/fixtures/peertube-plugin-test-four/package.json
new file mode 100644
index 000000000..dda3c7f37
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-four/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-four",
3 "version": "0.0.1",
4 "description": "Plugin test 4",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js
new file mode 100644
index 000000000..f58faa847
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js
@@ -0,0 +1,69 @@
1async function register ({
2 registerIdAndPassAuth,
3 peertubeHelpers,
4 settingsManager,
5 unregisterIdAndPassAuth
6}) {
7 registerIdAndPassAuth({
8 authName: 'spyro-auth',
9
10 onLogout: () => {
11 peertubeHelpers.logger.info('On logout for auth 1 - 1')
12 },
13
14 getWeight: () => 15,
15
16 login (body) {
17 if (body.id === 'spyro' && body.password === 'spyro password') {
18 return Promise.resolve({
19 username: 'spyro',
20 email: 'spyro@example.com',
21 role: 2,
22 displayName: 'Spyro the Dragon'
23 })
24 }
25
26 return null
27 }
28 })
29
30 registerIdAndPassAuth({
31 authName: 'crash-auth',
32
33 onLogout: () => {
34 peertubeHelpers.logger.info('On logout for auth 1 - 2')
35 },
36
37 getWeight: () => 50,
38
39 login (body) {
40 if (body.id === 'crash' && body.password === 'crash password') {
41 return Promise.resolve({
42 username: 'crash',
43 email: 'crash@example.com',
44 role: 1,
45 displayName: 'Crash Bandicoot'
46 })
47 }
48
49 return null
50 }
51 })
52
53 settingsManager.onSettingsChange(settings => {
54 if (settings.disableSpyro) {
55 unregisterIdAndPassAuth('spyro-auth')
56 }
57 })
58}
59
60async function unregister () {
61 return
62}
63
64module.exports = {
65 register,
66 unregister
67}
68
69// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json
new file mode 100644
index 000000000..f8ad18a90
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-id-pass-auth-one",
3 "version": "0.0.1",
4 "description": "Id and pass auth one",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js
new file mode 100644
index 000000000..1200acfbd
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js
@@ -0,0 +1,106 @@
1async function register ({
2 registerIdAndPassAuth,
3 peertubeHelpers
4}) {
5 registerIdAndPassAuth({
6 authName: 'laguna-bad-auth',
7
8 onLogout: () => {
9 peertubeHelpers.logger.info('On logout for auth 3 - 1')
10 },
11
12 getWeight: () => 5,
13
14 login (body) {
15 if (body.id === 'laguna' && body.password === 'laguna password') {
16 return Promise.resolve({
17 username: 'laguna',
18 email: 'laguna@example.com',
19 displayName: 'Laguna Loire'
20 })
21 }
22
23 return null
24 }
25 })
26
27 registerIdAndPassAuth({
28 authName: 'ward-auth',
29
30 getWeight: () => 5,
31
32 login (body) {
33 if (body.id === 'ward') {
34 return Promise.resolve({
35 username: '-ward-42',
36 email: 'ward@example.com'
37 })
38 }
39
40 return null
41 }
42 })
43
44 registerIdAndPassAuth({
45 authName: 'kiros-auth',
46
47 getWeight: () => 5,
48
49 login (body) {
50 if (body.id === 'kiros') {
51 return Promise.resolve({
52 username: 'kiros',
53 email: 'kiros@example.com',
54 displayName: 'a'.repeat(5000)
55 })
56 }
57
58 return null
59 }
60 })
61
62 registerIdAndPassAuth({
63 authName: 'raine-auth',
64
65 getWeight: () => 5,
66
67 login (body) {
68 if (body.id === 'raine') {
69 return Promise.resolve({
70 username: 'raine',
71 email: 'raine@example.com',
72 role: 42
73 })
74 }
75
76 return null
77 }
78 })
79
80 registerIdAndPassAuth({
81 authName: 'ellone-auth',
82
83 getWeight: () => 5,
84
85 login (body) {
86 if (body.id === 'ellone') {
87 return Promise.resolve({
88 username: 'ellone'
89 })
90 }
91
92 return null
93 }
94 })
95}
96
97async function unregister () {
98 return
99}
100
101module.exports = {
102 register,
103 unregister
104}
105
106// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json
new file mode 100644
index 000000000..f9f107b1a
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-id-pass-auth-three",
3 "version": "0.0.1",
4 "description": "Id and pass auth three",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
new file mode 100644
index 000000000..fad5abf60
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
@@ -0,0 +1,65 @@
1async function register ({
2 registerIdAndPassAuth,
3 peertubeHelpers
4}) {
5 registerIdAndPassAuth({
6 authName: 'laguna-auth',
7
8 onLogout: () => {
9 peertubeHelpers.logger.info('On logout for auth 2 - 1')
10 },
11
12 getWeight: () => 30,
13
14 hookTokenValidity: (options) => {
15 if (options.type === 'refresh') {
16 return { valid: false }
17 }
18
19 if (options.type === 'access') {
20 const token = options.token
21 const now = new Date()
22 now.setTime(now.getTime() - 5000)
23
24 const createdAt = new Date(token.createdAt)
25
26 return { valid: createdAt.getTime() >= now.getTime() }
27 }
28
29 return { valid: true }
30 },
31
32 login (body) {
33 if (body.id === 'laguna' && body.password === 'laguna password') {
34 return Promise.resolve({
35 username: 'laguna',
36 email: 'laguna@example.com',
37 displayName: 'Laguna Loire',
38 adminFlags: 1,
39 videoQuota: 42000,
40 videoQuotaDaily: 42100,
41
42 // Always use new value except for videoQuotaDaily field
43 userUpdater: ({ fieldName, currentValue, newValue }) => {
44 if (fieldName === 'videoQuotaDaily') return currentValue
45
46 return newValue
47 }
48 })
49 }
50
51 return null
52 }
53 })
54}
55
56async function unregister () {
57 return
58}
59
60module.exports = {
61 register,
62 unregister
63}
64
65// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json
new file mode 100644
index 000000000..5df15fac1
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-id-pass-auth-two",
3 "version": "0.0.1",
4 "description": "Id and pass auth two",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-native/main.js b/packages/tests/fixtures/peertube-plugin-test-native/main.js
new file mode 100644
index 000000000..0390faea9
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-native/main.js
@@ -0,0 +1,21 @@
1const print = require('a-native-example')
2
3async function register ({ getRouter }) {
4 print('hello world')
5
6 const router = getRouter()
7
8 router.get('/', (req, res) => {
9 print('hello world')
10 res.sendStatus(204)
11 })
12}
13
14async function unregister () {
15 return
16}
17
18module.exports = {
19 register,
20 unregister
21}
diff --git a/packages/tests/fixtures/peertube-plugin-test-native/package.json b/packages/tests/fixtures/peertube-plugin-test-native/package.json
new file mode 100644
index 000000000..a6525720b
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-native/package.json
@@ -0,0 +1,23 @@
1{
2 "name": "peertube-plugin-test-native",
3 "version": "0.0.1",
4 "description": "Plugin test-native",
5 "engine": {
6 "peertube": ">=4.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {},
20 "dependencies": {
21 "a-native-example": "^1.0.0"
22 }
23}
diff --git a/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js
new file mode 100644
index 000000000..ada4a70fe
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/main.js
@@ -0,0 +1,82 @@
1async function register ({ registerHook, registerSetting, settingsManager, storageManager, peertubeHelpers }) {
2 registerHook({
3 target: 'filter:feed.podcast.rss.create-custom-xmlns.result',
4 handler: (result, params) => {
5 return result.concat([
6 {
7 name: "biz",
8 value: "https://example.com/biz-xmlns",
9 },
10 ])
11 }
12 })
13
14 registerHook({
15 target: 'filter:feed.podcast.channel.create-custom-tags.result',
16 handler: (result, params) => {
17 const { videoChannel } = params
18 return result.concat([
19 {
20 name: "fooTag",
21 attributes: { "bar": "baz" },
22 value: "42",
23 },
24 {
25 name: "biz:videoChannel",
26 attributes: { "name": videoChannel.name, "id": videoChannel.id },
27 },
28 {
29 name: "biz:buzzItem",
30 value: [
31 {
32 name: "nestedTag",
33 value: "example nested tag",
34 },
35 ],
36 },
37 ])
38 }
39 })
40
41 registerHook({
42 target: 'filter:feed.podcast.video.create-custom-tags.result',
43 handler: (result, params) => {
44 const { video, liveItem } = params
45 return result.concat([
46 {
47 name: "fizzTag",
48 attributes: { "bar": "baz" },
49 value: "21",
50 },
51 {
52 name: "biz:video",
53 attributes: { "name": video.name, "id": video.id, "isLive": liveItem },
54 },
55 {
56 name: "biz:buzz",
57 value: [
58 {
59 name: "nestedTag",
60 value: "example nested tag",
61 },
62 ],
63 }
64 ])
65 }
66 })
67}
68
69async function unregister () {
70 return
71}
72
73module.exports = {
74 register,
75 unregister
76}
77
78// ############################################################################
79
80function addToCount (obj) {
81 return Object.assign({}, obj, { count: obj.count + 1 })
82}
diff --git a/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json
new file mode 100644
index 000000000..0f5a05a79
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-podcast-custom-tags/package.json
@@ -0,0 +1,19 @@
1{
2 "name": "peertube-plugin-test-podcast-custom-tags",
3 "version": "0.0.1",
4 "description": "Plugin test custom tags in Podcast RSS feeds",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": []
19}
diff --git a/packages/tests/fixtures/peertube-plugin-test-six/main.js b/packages/tests/fixtures/peertube-plugin-test-six/main.js
new file mode 100644
index 000000000..243b041e7
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-six/main.js
@@ -0,0 +1,46 @@
1const fs = require('fs')
2const path = require('path')
3
4async function register ({
5 storageManager,
6 peertubeHelpers,
7 getRouter
8}) {
9 const { logger } = peertubeHelpers
10
11 {
12 await storageManager.storeData('superkey', { value: 'toto' })
13 await storageManager.storeData('anotherkey', { value: 'toto2' })
14 await storageManager.storeData('storedArrayKey', ['toto', 'toto2'])
15
16 const result = await storageManager.getData('superkey')
17 logger.info('superkey stored value is %s', result.value)
18
19 const storedArrayValue = await storageManager.getData('storedArrayKey')
20 logger.info('storedArrayKey isArray is %s', Array.isArray(storedArrayValue) ? 'true' : 'false')
21 logger.info('storedArrayKey stored value is %s', storedArrayValue.join(', '))
22 }
23
24 {
25 getRouter().get('/create-file', async (req, res) => {
26 const basePath = peertubeHelpers.plugin.getDataDirectoryPath()
27
28 fs.writeFile(path.join(basePath, 'Aladdin.txt'), 'Prince Ali', function (err) {
29 if (err) return res.sendStatus(500)
30
31 res.sendStatus(200)
32 })
33 })
34 }
35}
36
37async function unregister () {
38 return
39}
40
41module.exports = {
42 register,
43 unregister
44}
45
46// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-six/package.json b/packages/tests/fixtures/peertube-plugin-test-six/package.json
new file mode 100644
index 000000000..8c97826b0
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-six/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-six",
3 "version": "0.0.1",
4 "description": "Plugin test 6",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js
new file mode 100644
index 000000000..c4ae777f5
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/main.js
@@ -0,0 +1,92 @@
1async function register ({ transcodingManager }) {
2
3 // Output options
4 {
5 {
6 const builder = () => {
7 return {
8 outputOptions: [
9 '-r 10'
10 ]
11 }
12 }
13
14 transcodingManager.addVODProfile('libx264', 'low-vod', builder)
15 }
16
17 {
18 const builder = (options) => {
19 return {
20 outputOptions: [
21 '-r:' + options.streamNum + ' 50'
22 ]
23 }
24 }
25
26 transcodingManager.addLiveProfile('libx264', 'high-live', builder)
27 }
28 }
29
30 // Input options
31 {
32 {
33 const builder = () => {
34 return {
35 inputOptions: [
36 '-r 5'
37 ]
38 }
39 }
40
41 transcodingManager.addVODProfile('libx264', 'input-options-vod', builder)
42 }
43
44 {
45 const builder = () => {
46 return {
47 inputOptions: [
48 '-r 50'
49 ]
50 }
51 }
52
53 transcodingManager.addLiveProfile('libx264', 'input-options-live', builder)
54 }
55 }
56
57 // Scale filters
58 {
59 {
60 const builder = () => {
61 return {
62 scaleFilter: {
63 name: 'Glomgold'
64 }
65 }
66 }
67
68 transcodingManager.addVODProfile('libx264', 'bad-scale-vod', builder)
69 }
70
71 {
72 const builder = () => {
73 return {
74 scaleFilter: {
75 name: 'Flintheart'
76 }
77 }
78 }
79
80 transcodingManager.addLiveProfile('libx264', 'bad-scale-live', builder)
81 }
82 }
83}
84
85async function unregister () {
86 return
87}
88
89module.exports = {
90 register,
91 unregister
92}
diff --git a/packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json
new file mode 100644
index 000000000..bedbfa051
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-transcoding-one/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-transcoding-one",
3 "version": "0.0.1",
4 "description": "Plugin test transcoding 1",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js
new file mode 100644
index 000000000..a914bce49
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/main.js
@@ -0,0 +1,38 @@
1async function register ({ transcodingManager }) {
2
3 {
4 const builder = () => {
5 return {
6 outputOptions: []
7 }
8 }
9
10 transcodingManager.addVODProfile('libopus', 'test-vod-profile', builder)
11 transcodingManager.addVODProfile('libvpx-vp9', 'test-vod-profile', builder)
12
13 transcodingManager.addVODEncoderPriority('audio', 'libopus', 1000)
14 transcodingManager.addVODEncoderPriority('video', 'libvpx-vp9', 1000)
15 }
16
17 {
18 const builder = (options) => {
19 return {
20 outputOptions: [
21 '-b:' + options.streamNum + ' 10K'
22 ]
23 }
24 }
25
26 transcodingManager.addLiveProfile('libopus', 'test-live-profile', builder)
27 transcodingManager.addLiveEncoderPriority('audio', 'libopus', 1000)
28 }
29}
30
31async function unregister () {
32 return
33}
34
35module.exports = {
36 register,
37 unregister
38}
diff --git a/packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json
new file mode 100644
index 000000000..34be0454b
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-transcoding-two/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-transcoding-two",
3 "version": "0.0.1",
4 "description": "Plugin test transcoding 2",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-unloading/lib.js b/packages/tests/fixtures/peertube-plugin-test-unloading/lib.js
new file mode 100644
index 000000000..f57e7cb01
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-unloading/lib.js
@@ -0,0 +1,2 @@
1const d = new Date()
2exports.value = d.getTime()
diff --git a/packages/tests/fixtures/peertube-plugin-test-unloading/main.js b/packages/tests/fixtures/peertube-plugin-test-unloading/main.js
new file mode 100644
index 000000000..5c8457cef
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-unloading/main.js
@@ -0,0 +1,14 @@
1const lib = require('./lib')
2
3async function register ({ getRouter }) {
4 const router = getRouter()
5 router.get('/get', (req, res) => res.json({ message: lib.value }))
6}
7
8async function unregister () {
9}
10
11module.exports = {
12 register,
13 unregister
14}
diff --git a/packages/tests/fixtures/peertube-plugin-test-unloading/package.json b/packages/tests/fixtures/peertube-plugin-test-unloading/package.json
new file mode 100644
index 000000000..7076d4b6f
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-unloading/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-unloading",
3 "version": "0.0.1",
4 "description": "Plugin test (modules unloading)",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-video-constants/main.js b/packages/tests/fixtures/peertube-plugin-test-video-constants/main.js
new file mode 100644
index 000000000..06527bd35
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-video-constants/main.js
@@ -0,0 +1,46 @@
1async function register ({
2 videoCategoryManager,
3 videoLicenceManager,
4 videoLanguageManager,
5 videoPrivacyManager,
6 playlistPrivacyManager,
7 getRouter
8}) {
9 videoLanguageManager.addConstant('al_bhed', 'Al Bhed')
10 videoLanguageManager.addLanguage('al_bhed2', 'Al Bhed 2')
11 videoLanguageManager.addConstant('al_bhed3', 'Al Bhed 3')
12 videoLanguageManager.deleteConstant('en')
13 videoLanguageManager.deleteLanguage('fr')
14 videoLanguageManager.deleteConstant('al_bhed3')
15
16 videoCategoryManager.addCategory(42, 'Best category')
17 videoCategoryManager.addConstant(43, 'High best category')
18 videoCategoryManager.deleteConstant(1) // Music
19 videoCategoryManager.deleteCategory(2) // Films
20
21 videoLicenceManager.addLicence(42, 'Best licence')
22 videoLicenceManager.addConstant(43, 'High best licence')
23 videoLicenceManager.deleteConstant(1) // Attribution
24 videoLicenceManager.deleteConstant(7) // Public domain
25
26 videoPrivacyManager.deleteConstant(2)
27 videoPrivacyManager.deletePrivacy(2)
28 playlistPrivacyManager.deleteConstant(3)
29 playlistPrivacyManager.deletePlaylistPrivacy(3)
30
31 {
32 const router = getRouter()
33 router.get('/reset-categories', (req, res) => {
34 videoCategoryManager.resetConstants()
35
36 res.sendStatus(204)
37 })
38 }
39}
40
41async function unregister () {}
42
43module.exports = {
44 register,
45 unregister
46}
diff --git a/packages/tests/fixtures/peertube-plugin-test-video-constants/package.json b/packages/tests/fixtures/peertube-plugin-test-video-constants/package.json
new file mode 100644
index 000000000..0fcf39933
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-video-constants/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-video-constants",
3 "version": "0.0.1",
4 "description": "Plugin test video constants",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test-websocket/main.js b/packages/tests/fixtures/peertube-plugin-test-websocket/main.js
new file mode 100644
index 000000000..3fde76cfe
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-websocket/main.js
@@ -0,0 +1,36 @@
1const WebSocketServer = require('ws').WebSocketServer
2
3async function register ({
4 registerWebSocketRoute
5}) {
6 const wss = new WebSocketServer({ noServer: true })
7
8 wss.on('connection', function connection(ws) {
9 ws.on('message', function message(data) {
10 if (data.toString() === 'ping') {
11 ws.send('pong')
12 }
13 })
14 })
15
16 registerWebSocketRoute({
17 route: '/toto',
18
19 handler: (request, socket, head) => {
20 wss.handleUpgrade(request, socket, head, ws => {
21 wss.emit('connection', ws, request)
22 })
23 }
24 })
25}
26
27async function unregister () {
28 return
29}
30
31module.exports = {
32 register,
33 unregister
34}
35
36// ###########################################################################
diff --git a/packages/tests/fixtures/peertube-plugin-test-websocket/package.json b/packages/tests/fixtures/peertube-plugin-test-websocket/package.json
new file mode 100644
index 000000000..89c8baa04
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test-websocket/package.json
@@ -0,0 +1,20 @@
1{
2 "name": "peertube-plugin-test-websocket",
3 "version": "0.0.1",
4 "description": "Plugin test websocket",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {}
20}
diff --git a/packages/tests/fixtures/peertube-plugin-test/languages/fr.json b/packages/tests/fixtures/peertube-plugin-test/languages/fr.json
new file mode 100644
index 000000000..9e52f7065
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test/languages/fr.json
@@ -0,0 +1,3 @@
1{
2 "Hi": "Coucou"
3}
diff --git a/packages/tests/fixtures/peertube-plugin-test/main.js b/packages/tests/fixtures/peertube-plugin-test/main.js
new file mode 100644
index 000000000..e16bf0ca3
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test/main.js
@@ -0,0 +1,477 @@
1async function register ({ registerHook, registerSetting, settingsManager, storageManager, peertubeHelpers }) {
2 {
3 const actionHooks = [
4 'action:application.listening',
5 'action:notifier.notification.created',
6
7 'action:api.video.updated',
8 'action:api.video.deleted',
9 'action:api.video.uploaded',
10 'action:api.video.viewed',
11
12 'action:api.video.file-updated',
13
14 'action:api.video-channel.created',
15 'action:api.video-channel.updated',
16 'action:api.video-channel.deleted',
17
18 'action:api.live-video.created',
19 'action:live.video.state.updated',
20
21 'action:api.video-thread.created',
22 'action:api.video-comment-reply.created',
23 'action:api.video-comment.deleted',
24
25 'action:api.video-caption.created',
26 'action:api.video-caption.deleted',
27
28 'action:api.user.blocked',
29 'action:api.user.unblocked',
30 'action:api.user.registered',
31 'action:api.user.created',
32 'action:api.user.deleted',
33 'action:api.user.updated',
34 'action:api.user.oauth2-got-token',
35
36 'action:api.video-playlist-element.created'
37 ]
38
39 for (const h of actionHooks) {
40 registerHook({
41 target: h,
42 handler: () => peertubeHelpers.logger.debug('Run hook %s.', h)
43 })
44 }
45
46 for (const h of [ 'action:activity-pub.remote-video.created', 'action:activity-pub.remote-video.updated' ]) {
47 registerHook({
48 target: h,
49 handler: ({ video, videoAPObject }) => {
50 peertubeHelpers.logger.debug('Run hook %s - AP %s - video %s.', h, video.name, videoAPObject.name )
51 }
52 })
53 }
54 }
55
56 registerHook({
57 target: 'filter:api.videos.list.params',
58 handler: obj => addToCount(obj)
59 })
60
61 registerHook({
62 target: 'filter:api.videos.list.result',
63 handler: obj => addToTotal(obj)
64 })
65
66 registerHook({
67 target: 'filter:api.video-playlist.videos.list.params',
68 handler: obj => addToCount(obj)
69 })
70
71 registerHook({
72 target: 'filter:api.video-playlist.videos.list.result',
73 handler: obj => addToTotal(obj)
74 })
75
76 registerHook({
77 target: 'filter:api.accounts.videos.list.params',
78 handler: obj => addToCount(obj)
79 })
80
81 registerHook({
82 target: 'filter:api.accounts.videos.list.result',
83 handler: obj => addToTotal(obj, 2)
84 })
85
86 registerHook({
87 target: 'filter:api.video-channels.videos.list.params',
88 handler: obj => addToCount(obj, 3)
89 })
90
91 registerHook({
92 target: 'filter:api.video-channels.videos.list.result',
93 handler: obj => addToTotal(obj, 3)
94 })
95
96 registerHook({
97 target: 'filter:api.user.me.videos.list.params',
98 handler: obj => addToCount(obj, 4)
99 })
100
101 registerHook({
102 target: 'filter:api.user.me.videos.list.result',
103 handler: obj => addToTotal(obj, 4)
104 })
105
106 registerHook({
107 target: 'filter:api.user.me.subscription-videos.list.params',
108 handler: obj => addToCount(obj)
109 })
110
111 registerHook({
112 target: 'filter:api.user.me.subscription-videos.list.result',
113 handler: obj => addToTotal(obj, 4)
114 })
115
116 registerHook({
117 target: 'filter:api.video.get.result',
118 handler: video => {
119 video.name += ' <3'
120
121 return video
122 }
123 })
124
125 // ---------------------------------------------------------------------------
126
127 registerHook({
128 target: 'filter:api.video-channels.list.params',
129 handler: obj => addToCount(obj, 1)
130 })
131
132 registerHook({
133 target: 'filter:api.video-channels.list.result',
134 handler: obj => addToTotal(obj, 1)
135 })
136
137 registerHook({
138 target: 'filter:api.video-channel.get.result',
139 handler: channel => {
140 channel.name += ' <3'
141
142 return channel
143 }
144 })
145
146 // ---------------------------------------------------------------------------
147
148 for (const hook of [ 'filter:api.video.upload.accept.result', 'filter:api.live-video.create.accept.result' ]) {
149 registerHook({
150 target: hook,
151 handler: ({ accepted }, { videoBody, liveVideoBody }) => {
152 if (!accepted) return { accepted: false }
153
154 const name = videoBody
155 ? videoBody.name
156 : liveVideoBody.name
157
158 if (name.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word' }
159
160 return { accepted: true }
161 }
162 })
163 }
164
165 registerHook({
166 target: 'filter:api.video.update-file.accept.result',
167 handler: ({ accepted }, { videoFile }) => {
168 if (!accepted) return { accepted: false }
169 if (videoFile.filename.includes('webm')) return { accepted: false, errorMessage: 'no webm' }
170
171 return { accepted: true }
172 }
173 })
174
175 registerHook({
176 target: 'filter:api.video.pre-import-url.accept.result',
177 handler: ({ accepted }, { videoImportBody }) => {
178 if (!accepted) return { accepted: false }
179 if (videoImportBody.targetUrl.includes('bad')) return { accepted: false, errorMessage: 'bad target url' }
180
181 return { accepted: true }
182 }
183 })
184
185 registerHook({
186 target: 'filter:api.video.pre-import-torrent.accept.result',
187 handler: ({ accepted }, { videoImportBody }) => {
188 if (!accepted) return { accepted: false }
189 if (videoImportBody.name.includes('bad torrent')) return { accepted: false, errorMessage: 'bad torrent' }
190
191 return { accepted: true }
192 }
193 })
194
195 registerHook({
196 target: 'filter:api.video.post-import-url.accept.result',
197 handler: ({ accepted }, { video }) => {
198 if (!accepted) return { accepted: false }
199 if (video.name.includes('bad word')) return { accepted: false, errorMessage: 'bad word' }
200
201 return { accepted: true }
202 }
203 })
204
205 registerHook({
206 target: 'filter:api.video.post-import-torrent.accept.result',
207 handler: ({ accepted }, { video }) => {
208 if (!accepted) return { accepted: false }
209 if (video.name.includes('bad word')) return { accepted: false, errorMessage: 'bad word' }
210
211 return { accepted: true }
212 }
213 })
214
215 // ---------------------------------------------------------------------------
216
217 registerHook({
218 target: 'filter:api.video-thread.create.accept.result',
219 handler: ({ accepted }, { commentBody }) => checkCommentBadWord(accepted, commentBody)
220 })
221
222 registerHook({
223 target: 'filter:api.video-comment-reply.create.accept.result',
224 handler: ({ accepted }, { commentBody }) => checkCommentBadWord(accepted, commentBody)
225 })
226
227 registerHook({
228 target: 'filter:activity-pub.remote-video-comment.create.accept.result',
229 handler: ({ accepted }, { comment }) => checkCommentBadWord(accepted, comment)
230 })
231
232 // ---------------------------------------------------------------------------
233
234 registerHook({
235 target: 'filter:activity-pub.activity.context.build.result',
236 handler: context => context.concat([ { recordedAt: 'https://schema.org/recordedAt' } ])
237 })
238
239 registerHook({
240 target: 'filter:activity-pub.video.json-ld.build.result',
241 handler: (jsonld, { video }) => ({ ...jsonld, videoName: video.name })
242 })
243
244 // ---------------------------------------------------------------------------
245
246 registerHook({
247 target: 'filter:api.video-threads.list.params',
248 handler: obj => addToCount(obj)
249 })
250
251 registerHook({
252 target: 'filter:api.video-threads.list.result',
253 handler: obj => addToTotal(obj)
254 })
255
256 registerHook({
257 target: 'filter:api.video-thread-comments.list.result',
258 handler: obj => {
259 obj.data.forEach(c => c.text += ' <3')
260
261 return obj
262 }
263 })
264
265 registerHook({
266 target: 'filter:video.auto-blacklist.result',
267 handler: (blacklisted, { video }) => {
268 if (blacklisted) return true
269 if (video.name.includes('please blacklist me')) return true
270
271 return false
272 }
273 })
274
275 {
276 registerHook({
277 target: 'filter:api.user.signup.allowed.result',
278 handler: (result, params) => {
279 if (params && params.body && params.body.email && params.body.email.includes('jma 1')) {
280 return { allowed: false, errorMessage: 'No jma 1' }
281 }
282
283 return result
284 }
285 })
286
287 registerHook({
288 target: 'filter:api.user.request-signup.allowed.result',
289 handler: (result, params) => {
290 if (params && params.body && params.body.email && params.body.email.includes('jma 2')) {
291 return { allowed: false, errorMessage: 'No jma 2' }
292 }
293
294 return result
295 }
296 })
297 }
298
299 registerHook({
300 target: 'filter:api.download.torrent.allowed.result',
301 handler: (result, params) => {
302 if (params && params.downloadName.includes('bad torrent')) {
303 return { allowed: false, errorMessage: 'Liu Bei' }
304 }
305
306 return result
307 }
308 })
309
310 registerHook({
311 target: 'filter:api.download.video.allowed.result',
312 handler: async (result, params) => {
313 const loggedInUser = await peertubeHelpers.user.getAuthUser(params.res)
314 if (loggedInUser) return { allowed: true }
315
316 if (params && !params.streamingPlaylist && params.video.name.includes('bad file')) {
317 return { allowed: false, errorMessage: 'Cao Cao' }
318 }
319
320 if (params && params.streamingPlaylist && params.video.name.includes('bad playlist file')) {
321 return { allowed: false, errorMessage: 'Sun Jian' }
322 }
323
324 return result
325 }
326 })
327
328 // ---------------------------------------------------------------------------
329
330 registerHook({
331 target: 'filter:html.embed.video.allowed.result',
332 handler: (result, params) => {
333 return {
334 allowed: false,
335 html: 'Lu Bu'
336 }
337 }
338 })
339
340 registerHook({
341 target: 'filter:html.embed.video-playlist.allowed.result',
342 handler: (result, params) => {
343 return {
344 allowed: false,
345 html: 'Diao Chan'
346 }
347 }
348 })
349
350 // ---------------------------------------------------------------------------
351
352 registerHook({
353 target: 'filter:html.client.json-ld.result',
354 handler: (jsonld, context) => {
355 if (!context || !context.video) return jsonld
356
357 return Object.assign(jsonld, { recordedAt: 'http://example.com/recordedAt' })
358 }
359 })
360
361 // ---------------------------------------------------------------------------
362
363 registerHook({
364 target: 'filter:api.server.stats.get.result',
365 handler: (result) => {
366 return { ...result, customStats: 14 }
367 }
368 })
369
370 registerHook({
371 target: 'filter:job-queue.process.params',
372 handler: (object, context) => {
373 if (context.type !== 'video-studio-edition') return object
374
375 object.data.tasks = [
376 {
377 name: 'cut',
378 options: {
379 start: 0,
380 end: 1
381 }
382 }
383 ]
384
385 return object
386 }
387 })
388
389 registerHook({
390 target: 'filter:transcoding.auto.resolutions-to-transcode.result',
391 handler: (object, context) => {
392 if (context.video.name.includes('transcode-filter')) {
393 object = [ 100 ]
394 }
395
396 return object
397 }
398 })
399
400 // Upload/import/live attributes
401 for (const target of [
402 'filter:api.video.upload.video-attribute.result',
403 'filter:api.video.import-url.video-attribute.result',
404 'filter:api.video.import-torrent.video-attribute.result',
405 'filter:api.video.live.video-attribute.result'
406 ]) {
407 registerHook({
408 target,
409 handler: (result) => {
410 return { ...result, description: result.description + ' - ' + target }
411 }
412 })
413 }
414
415 {
416 const filterHooks = [
417 'filter:api.search.videos.local.list.params',
418 'filter:api.search.videos.local.list.result',
419 'filter:api.search.videos.index.list.params',
420 'filter:api.search.videos.index.list.result',
421 'filter:api.search.video-channels.local.list.params',
422 'filter:api.search.video-channels.local.list.result',
423 'filter:api.search.video-channels.index.list.params',
424 'filter:api.search.video-channels.index.list.result',
425 'filter:api.search.video-playlists.local.list.params',
426 'filter:api.search.video-playlists.local.list.result',
427 'filter:api.search.video-playlists.index.list.params',
428 'filter:api.search.video-playlists.index.list.result',
429
430 'filter:api.overviews.videos.list.params',
431 'filter:api.overviews.videos.list.result',
432
433 'filter:job-queue.process.params',
434 'filter:job-queue.process.result'
435 ]
436
437 for (const h of filterHooks) {
438 registerHook({
439 target: h,
440 handler: (obj) => {
441 peertubeHelpers.logger.debug('Run hook %s.', h)
442
443 return obj
444 }
445 })
446 }
447 }
448}
449
450async function unregister () {
451 return
452}
453
454module.exports = {
455 register,
456 unregister
457}
458
459// ############################################################################
460
461function addToCount (obj, amount = 1) {
462 return Object.assign({}, obj, { count: obj.count + amount })
463}
464
465function addToTotal (result, amount = 1) {
466 return {
467 data: result.data,
468 total: result.total + amount
469 }
470}
471
472function checkCommentBadWord (accepted, commentBody) {
473 if (!accepted) return { accepted: false }
474 if (commentBody.text.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word '}
475
476 return { accepted: true }
477}
diff --git a/packages/tests/fixtures/peertube-plugin-test/package.json b/packages/tests/fixtures/peertube-plugin-test/package.json
new file mode 100644
index 000000000..108f21fd6
--- /dev/null
+++ b/packages/tests/fixtures/peertube-plugin-test/package.json
@@ -0,0 +1,22 @@
1{
2 "name": "peertube-plugin-test",
3 "version": "0.0.1",
4 "description": "Plugin test",
5 "engine": {
6 "peertube": ">=1.3.0"
7 },
8 "keywords": [
9 "peertube",
10 "plugin"
11 ],
12 "homepage": "https://github.com/Chocobozzz/PeerTube",
13 "author": "Chocobozzz",
14 "bugs": "https://github.com/Chocobozzz/PeerTube/issues",
15 "library": "./main.js",
16 "staticDirs": {},
17 "css": [],
18 "clientScripts": [],
19 "translations": {
20 "fr-FR": "./languages/fr.json"
21 }
22}
diff --git a/packages/tests/fixtures/rtmps.cert b/packages/tests/fixtures/rtmps.cert
new file mode 100644
index 000000000..3ef606c52
--- /dev/null
+++ b/packages/tests/fixtures/rtmps.cert
@@ -0,0 +1,21 @@
1-----BEGIN CERTIFICATE-----
2MIIDazCCAlOgAwIBAgIUKNycLAZUs2jFsWUW+zZhBkpLB2wwDQYJKoZIhvcNAQEL
3BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
4GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMTExMDUxMDA4MzhaFw0yMTEy
5MDUxMDA4MzhaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
6HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB
7AQUAA4IBDwAwggEKAoIBAQDak20d81KG/9mVLU6Qw/uRniC935yf9Rlp8FVCDxUd
8zLbfHjrnIOv8kqinUI0nuEQC4DnF7Rbafe88WDU33Q8ixU/R0czUGq1AEwIjyN30
95NjokCb26xWIly7RCfc/Ot6tjguHwKvcxqJMNC0Lit9Go9MDVnGFLkgHia68P72T
10ZDVV44YpzwYDicwQs5C4nZ4yzAeclia07qfUY0VAEZlxJ/9zjwYHCT0AKaEPH35E
11dUvjuvJ1OSHSN1S4acR+TPR3FwKQh3H/M/GWIqoiIOpdjFUBLs80QOM2aNrLmlyP
12JtyFJLxCP7Ery9fGY/yzHeSxpgOKwZopD6uHZKi5yazNAgMBAAGjUzBRMB0GA1Ud
13DgQWBBSSjhRQdWsybNQMLMhkwV+xiP2uoDAfBgNVHSMEGDAWgBSSjhRQdWsybNQM
14LMhkwV+xiP2uoDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQC8
15rJu3J5sqVKNQaXOmLPd49RM7KG3Y1KPqbQi1lh+sW6aefZ9daeh3JDYGBZGPG/Fi
16IMMP+LhGG0WqDm4ClK00wyNhBuNPEyzvuN/WMRX5djPxO1IZi+KogFwXsn853Ov9
17oV3nxArNNjDu2n92FiB7RTlXRXPIoRo2zEBcLvveGySn9XUazRzlqx6FAxYe2xsw
18U3cZ6/wwU1YsEZa5bwIQk+gkFj3zDsTyEkn2ntcE2NlR+AhCHKa/yAxgPFycAVPX
192o+wNnc6H4syP98mMGj9hEE3RSJyCPgGBlgi7Swl64G3YygFPJzfLX9YTuxwr/eI
20oitEjF9ljtmdEnf0RdOj
21-----END CERTIFICATE-----
diff --git a/packages/tests/fixtures/rtmps.key b/packages/tests/fixtures/rtmps.key
new file mode 100644
index 000000000..14a85e70a
--- /dev/null
+++ b/packages/tests/fixtures/rtmps.key
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDak20d81KG/9mV
3LU6Qw/uRniC935yf9Rlp8FVCDxUdzLbfHjrnIOv8kqinUI0nuEQC4DnF7Rbafe88
4WDU33Q8ixU/R0czUGq1AEwIjyN305NjokCb26xWIly7RCfc/Ot6tjguHwKvcxqJM
5NC0Lit9Go9MDVnGFLkgHia68P72TZDVV44YpzwYDicwQs5C4nZ4yzAeclia07qfU
6Y0VAEZlxJ/9zjwYHCT0AKaEPH35EdUvjuvJ1OSHSN1S4acR+TPR3FwKQh3H/M/GW
7IqoiIOpdjFUBLs80QOM2aNrLmlyPJtyFJLxCP7Ery9fGY/yzHeSxpgOKwZopD6uH
8ZKi5yazNAgMBAAECggEAND7C+UK8+jnTl13CBsZhrnfemaQGexGJ5pGkv2p9gKb7
9Gy/Nooty/OdNWtjdNJ5N22YfSRkXulgZxBHNfrHfOU9yedOtIxHRUZx5iXYs36mH
1002cJeUHN3t1MOnkoWTvIGDH4vZUnP1lXV+Gs1rJ2Fht4h7a04cGjQ/H8C1EtDjqX
11kzH2T/gwo5hdGrxifRTs5wCVoP/iUwNtBI4WrY2rfC6sV+NOICgp0xX0NvGWZ8UT
12K1Ntpl8IxnxmeBd26d+Gbjc9d9fIRDtyXby4YOIlDZxnIiZEI0I452JqGl/jrXaP
13F3Troet4OBj5uH5s374d6ubKq66XogiLMIjEj2tYfQKBgQDtuaOu+y549bFJKVc9
14TCiWSOl/0j2kKKG8UG23zMC//AT13WqZDT5ObfOAuMhy70au/PD84D9RU/+gRVWb
15ptfybD9ugRNC8PkmdT82uYtZpS4+Xw4qyWVRgqQFmjSYz63cLcULVi8kiG8XmG5u
16QGgT/tNv5mxhOMUGSxhClOpLBwKBgQDrYO9UrLs+gDVKbHF4Dh+YJpaLnwwF+TFA
17j3ZbkE0XEeeXp/YDgyClmWwEkteJeNljtreCZ9gMkx3JdR9i8uecUQ2tFDBg3cN0
18BZAex2jFwSb0QbfzHNnE07I+aEIfHHjYXjzABl+1Yt95giKjce0Ke+8Zzahue0+9
19lYcAHemQiwKBgQCs9JAbIdJo3NBUW0iGZ19sH7YKciq4wXsSaC27OLPPugrd2m7Q
201arMIwCzWT01KdLyQ0MNqBVJFWT49RjYuuWIEauAuVYLMQkEKu+H4Cx7V0syw7Op
21+4bEa9jr3op/1zE17PLcUaLQ4JZ6w0Ms4Z0XVyH72thlT4lBD+ehoXhohwKBgEtJ
22LAPnY9Sv6Vuup/SAf/aIkSqDarMWa3x85pyO4Tl5zpuha3zgGjcdhYFI/ovIDbBp
23JvUdBeuvup1PSwS5MP+8pSUxCfBRvkyD4v8VRRvLlgwWYSHvnm/oTmDLtCqDTtvV
24+JRq9X3s7BHPYAjrTahGz8lvEGqWIoE/LHkLGEPVAoGAaF3VHuqDfmD9PJUAlsU1
25qxN7yfOd2ve0+66Ghus24DVqUFqwp5f2AxZXYUtSaNUp8fVbqIi+Yq3YDTU2KfId
265QNA/AiKi4VUNLElsG5DZlbszsE5KNp9fWQoggdQ5LND7AGEKeFERHOVQ7C5sc/C
27omIqK5/PsZmaf4OZLyecxJY=
28-----END PRIVATE KEY-----
diff --git a/packages/tests/fixtures/sample.ogg b/packages/tests/fixtures/sample.ogg
new file mode 100644
index 000000000..0d7f43eb7
--- /dev/null
+++ b/packages/tests/fixtures/sample.ogg
Binary files differ
diff --git a/packages/tests/fixtures/subtitle-bad.txt b/packages/tests/fixtures/subtitle-bad.txt
new file mode 100644
index 000000000..a2a30ae47
--- /dev/null
+++ b/packages/tests/fixtures/subtitle-bad.txt
@@ -0,0 +1,11 @@
11
200:00:01,600 --> 00:00:04,200
3English (US)
4
52
600:00:05,900 --> 00:00:07,999
7This is a subtitle in American English
8
93
1000:00:10,000 --> 00:00:14,000
11Adding subtitles is very easy to do \ No newline at end of file
diff --git a/packages/tests/fixtures/subtitle-good.srt b/packages/tests/fixtures/subtitle-good.srt
new file mode 100644
index 000000000..a2a30ae47
--- /dev/null
+++ b/packages/tests/fixtures/subtitle-good.srt
@@ -0,0 +1,11 @@
11
200:00:01,600 --> 00:00:04,200
3English (US)
4
52
600:00:05,900 --> 00:00:07,999
7This is a subtitle in American English
8
93
1000:00:10,000 --> 00:00:14,000
11Adding subtitles is very easy to do \ No newline at end of file
diff --git a/packages/tests/fixtures/subtitle-good1.vtt b/packages/tests/fixtures/subtitle-good1.vtt
new file mode 100644
index 000000000..04cd23946
--- /dev/null
+++ b/packages/tests/fixtures/subtitle-good1.vtt
@@ -0,0 +1,8 @@
1WEBVTT
2
300:01.000 --> 00:04.000
4Subtitle good 1.
5
600:05.000 --> 00:09.000
7- It will perforate your stomach.
8- You could die. \ No newline at end of file
diff --git a/packages/tests/fixtures/subtitle-good2.vtt b/packages/tests/fixtures/subtitle-good2.vtt
new file mode 100644
index 000000000..4d3256def
--- /dev/null
+++ b/packages/tests/fixtures/subtitle-good2.vtt
@@ -0,0 +1,8 @@
1WEBVTT
2
300:01.000 --> 00:04.000
4Subtitle good 2.
5
600:05.000 --> 00:09.000
7- It will perforate your stomach.
8- You could die. \ No newline at end of file
diff --git a/packages/tests/fixtures/thumbnail-playlist.jpg b/packages/tests/fixtures/thumbnail-playlist.jpg
new file mode 100644
index 000000000..12de5817b
--- /dev/null
+++ b/packages/tests/fixtures/thumbnail-playlist.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video-720p.torrent b/packages/tests/fixtures/video-720p.torrent
new file mode 100644
index 000000000..64bfd5220
--- /dev/null
+++ b/packages/tests/fixtures/video-720p.torrent
Binary files differ
diff --git a/packages/tests/fixtures/video_import_preview.jpg b/packages/tests/fixtures/video_import_preview.jpg
new file mode 100644
index 000000000..a98da178f
--- /dev/null
+++ b/packages/tests/fixtures/video_import_preview.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_import_preview_yt_dlp.jpg b/packages/tests/fixtures/video_import_preview_yt_dlp.jpg
new file mode 100644
index 000000000..9e8833bf9
--- /dev/null
+++ b/packages/tests/fixtures/video_import_preview_yt_dlp.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_import_thumbnail.jpg b/packages/tests/fixtures/video_import_thumbnail.jpg
new file mode 100644
index 000000000..9ee1bc382
--- /dev/null
+++ b/packages/tests/fixtures/video_import_thumbnail.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpg b/packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpg
new file mode 100644
index 000000000..a10e07207
--- /dev/null
+++ b/packages/tests/fixtures/video_import_thumbnail_yt_dlp.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short.avi b/packages/tests/fixtures/video_short.avi
new file mode 100644
index 000000000..88979cab2
--- /dev/null
+++ b/packages/tests/fixtures/video_short.avi
Binary files differ
diff --git a/packages/tests/fixtures/video_short.mkv b/packages/tests/fixtures/video_short.mkv
new file mode 100644
index 000000000..a67f4f806
--- /dev/null
+++ b/packages/tests/fixtures/video_short.mkv
Binary files differ
diff --git a/packages/tests/fixtures/video_short.mp4 b/packages/tests/fixtures/video_short.mp4
new file mode 100644
index 000000000..35678362b
--- /dev/null
+++ b/packages/tests/fixtures/video_short.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short.mp4.jpg b/packages/tests/fixtures/video_short.mp4.jpg
new file mode 100644
index 000000000..7ac29122c
--- /dev/null
+++ b/packages/tests/fixtures/video_short.mp4.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short.ogv b/packages/tests/fixtures/video_short.ogv
new file mode 100644
index 000000000..9e253da82
--- /dev/null
+++ b/packages/tests/fixtures/video_short.ogv
Binary files differ
diff --git a/packages/tests/fixtures/video_short.ogv.jpg b/packages/tests/fixtures/video_short.ogv.jpg
new file mode 100644
index 000000000..5bc63969b
--- /dev/null
+++ b/packages/tests/fixtures/video_short.ogv.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short.webm b/packages/tests/fixtures/video_short.webm
new file mode 100644
index 000000000..bf4b0ab6c
--- /dev/null
+++ b/packages/tests/fixtures/video_short.webm
Binary files differ
diff --git a/packages/tests/fixtures/video_short.webm.jpg b/packages/tests/fixtures/video_short.webm.jpg
new file mode 100644
index 000000000..7ac29122c
--- /dev/null
+++ b/packages/tests/fixtures/video_short.webm.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short1-preview.webm.jpg b/packages/tests/fixtures/video_short1-preview.webm.jpg
new file mode 100644
index 000000000..15454942d
--- /dev/null
+++ b/packages/tests/fixtures/video_short1-preview.webm.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short1.webm b/packages/tests/fixtures/video_short1.webm
new file mode 100644
index 000000000..70ac0c644
--- /dev/null
+++ b/packages/tests/fixtures/video_short1.webm
Binary files differ
diff --git a/packages/tests/fixtures/video_short1.webm.jpg b/packages/tests/fixtures/video_short1.webm.jpg
new file mode 100644
index 000000000..b2740d73d
--- /dev/null
+++ b/packages/tests/fixtures/video_short1.webm.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short2.webm b/packages/tests/fixtures/video_short2.webm
new file mode 100644
index 000000000..13d72dff7
--- /dev/null
+++ b/packages/tests/fixtures/video_short2.webm
Binary files differ
diff --git a/packages/tests/fixtures/video_short2.webm.jpg b/packages/tests/fixtures/video_short2.webm.jpg
new file mode 100644
index 000000000..afe476c7f
--- /dev/null
+++ b/packages/tests/fixtures/video_short2.webm.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short3.webm b/packages/tests/fixtures/video_short3.webm
new file mode 100644
index 000000000..cde5dcd58
--- /dev/null
+++ b/packages/tests/fixtures/video_short3.webm
Binary files differ
diff --git a/packages/tests/fixtures/video_short3.webm.jpg b/packages/tests/fixtures/video_short3.webm.jpg
new file mode 100644
index 000000000..b572f676e
--- /dev/null
+++ b/packages/tests/fixtures/video_short3.webm.jpg
Binary files differ
diff --git a/packages/tests/fixtures/video_short_0p.mp4 b/packages/tests/fixtures/video_short_0p.mp4
new file mode 100644
index 000000000..2069a49b8
--- /dev/null
+++ b/packages/tests/fixtures/video_short_0p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_144p.m3u8 b/packages/tests/fixtures/video_short_144p.m3u8
new file mode 100644
index 000000000..96568625b
--- /dev/null
+++ b/packages/tests/fixtures/video_short_144p.m3u8
@@ -0,0 +1,13 @@
1#EXTM3U
2#EXT-X-VERSION:7
3#EXT-X-TARGETDURATION:4
4#EXT-X-MEDIA-SEQUENCE:0
5#EXT-X-PLAYLIST-TYPE:VOD
6#EXT-X-MAP:URI="3dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4",BYTERANGE="1375@0"
7#EXTINF:4.000000,
8#EXT-X-BYTERANGE:10518@1375
93dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4
10#EXTINF:1.000000,
11#EXT-X-BYTERANGE:3741@11893
123dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4
13#EXT-X-ENDLIST
diff --git a/packages/tests/fixtures/video_short_144p.mp4 b/packages/tests/fixtures/video_short_144p.mp4
new file mode 100644
index 000000000..047d43c17
--- /dev/null
+++ b/packages/tests/fixtures/video_short_144p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_240p.m3u8 b/packages/tests/fixtures/video_short_240p.m3u8
new file mode 100644
index 000000000..96568625b
--- /dev/null
+++ b/packages/tests/fixtures/video_short_240p.m3u8
@@ -0,0 +1,13 @@
1#EXTM3U
2#EXT-X-VERSION:7
3#EXT-X-TARGETDURATION:4
4#EXT-X-MEDIA-SEQUENCE:0
5#EXT-X-PLAYLIST-TYPE:VOD
6#EXT-X-MAP:URI="3dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4",BYTERANGE="1375@0"
7#EXTINF:4.000000,
8#EXT-X-BYTERANGE:10518@1375
93dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4
10#EXTINF:1.000000,
11#EXT-X-BYTERANGE:3741@11893
123dd13e27-1ae1-441c-9b77-48c6b95603be-144-fragmented.mp4
13#EXT-X-ENDLIST
diff --git a/packages/tests/fixtures/video_short_240p.mp4 b/packages/tests/fixtures/video_short_240p.mp4
new file mode 100644
index 000000000..46609e81a
--- /dev/null
+++ b/packages/tests/fixtures/video_short_240p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_360p.m3u8 b/packages/tests/fixtures/video_short_360p.m3u8
new file mode 100644
index 000000000..f7072dc6d
--- /dev/null
+++ b/packages/tests/fixtures/video_short_360p.m3u8
@@ -0,0 +1,13 @@
1#EXTM3U
2#EXT-X-VERSION:7
3#EXT-X-TARGETDURATION:4
4#EXT-X-MEDIA-SEQUENCE:0
5#EXT-X-PLAYLIST-TYPE:VOD
6#EXT-X-MAP:URI="05c40acd-3e94-4d25-ade8-97f7ff2cf0ac-360-fragmented.mp4",BYTERANGE="1376@0"
7#EXTINF:4.000000,
8#EXT-X-BYTERANGE:19987@1376
905c40acd-3e94-4d25-ade8-97f7ff2cf0ac-360-fragmented.mp4
10#EXTINF:1.000000,
11#EXT-X-BYTERANGE:9147@21363
1205c40acd-3e94-4d25-ade8-97f7ff2cf0ac-360-fragmented.mp4
13#EXT-X-ENDLIST
diff --git a/packages/tests/fixtures/video_short_360p.mp4 b/packages/tests/fixtures/video_short_360p.mp4
new file mode 100644
index 000000000..7a8189bbc
--- /dev/null
+++ b/packages/tests/fixtures/video_short_360p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_480.webm b/packages/tests/fixtures/video_short_480.webm
new file mode 100644
index 000000000..3145105e1
--- /dev/null
+++ b/packages/tests/fixtures/video_short_480.webm
Binary files differ
diff --git a/packages/tests/fixtures/video_short_480p.m3u8 b/packages/tests/fixtures/video_short_480p.m3u8
new file mode 100644
index 000000000..5ff30dfa7
--- /dev/null
+++ b/packages/tests/fixtures/video_short_480p.m3u8
@@ -0,0 +1,13 @@
1#EXTM3U
2#EXT-X-VERSION:7
3#EXT-X-TARGETDURATION:4
4#EXT-X-MEDIA-SEQUENCE:0
5#EXT-X-PLAYLIST-TYPE:VOD
6#EXT-X-MAP:URI="f9377e69-d8f2-4de8-8087-ddbca6629829-480-fragmented.mp4",BYTERANGE="1376@0"
7#EXTINF:4.000000,
8#EXT-X-BYTERANGE:26042@1376
9f9377e69-d8f2-4de8-8087-ddbca6629829-480-fragmented.mp4
10#EXTINF:1.000000,
11#EXT-X-BYTERANGE:12353@27418
12f9377e69-d8f2-4de8-8087-ddbca6629829-480-fragmented.mp4
13#EXT-X-ENDLIST
diff --git a/packages/tests/fixtures/video_short_480p.mp4 b/packages/tests/fixtures/video_short_480p.mp4
new file mode 100644
index 000000000..e05b58b6b
--- /dev/null
+++ b/packages/tests/fixtures/video_short_480p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_4k.mp4 b/packages/tests/fixtures/video_short_4k.mp4
new file mode 100644
index 000000000..402479743
--- /dev/null
+++ b/packages/tests/fixtures/video_short_4k.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_720p.m3u8 b/packages/tests/fixtures/video_short_720p.m3u8
new file mode 100644
index 000000000..7cee94032
--- /dev/null
+++ b/packages/tests/fixtures/video_short_720p.m3u8
@@ -0,0 +1,13 @@
1#EXTM3U
2#EXT-X-VERSION:7
3#EXT-X-TARGETDURATION:4
4#EXT-X-MEDIA-SEQUENCE:0
5#EXT-X-PLAYLIST-TYPE:VOD
6#EXT-X-MAP:URI="c1014aa4-d1f4-4b66-927b-c23d283fcae0-720-fragmented.mp4",BYTERANGE="1356@0"
7#EXTINF:4.000000,
8#EXT-X-BYTERANGE:39260@1356
9c1014aa4-d1f4-4b66-927b-c23d283fcae0-720-fragmented.mp4
10#EXTINF:1.000000,
11#EXT-X-BYTERANGE:18493@40616
12c1014aa4-d1f4-4b66-927b-c23d283fcae0-720-fragmented.mp4
13#EXT-X-ENDLIST
diff --git a/packages/tests/fixtures/video_short_720p.mp4 b/packages/tests/fixtures/video_short_720p.mp4
new file mode 100644
index 000000000..35e8f69a7
--- /dev/null
+++ b/packages/tests/fixtures/video_short_720p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_fake.webm b/packages/tests/fixtures/video_short_fake.webm
new file mode 100644
index 000000000..d85290ae5
--- /dev/null
+++ b/packages/tests/fixtures/video_short_fake.webm
@@ -0,0 +1 @@
this is a fake video mouahahah
diff --git a/packages/tests/fixtures/video_short_mp3_256k.mp4 b/packages/tests/fixtures/video_short_mp3_256k.mp4
new file mode 100644
index 000000000..4c1c7b45e
--- /dev/null
+++ b/packages/tests/fixtures/video_short_mp3_256k.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_short_no_audio.mp4 b/packages/tests/fixtures/video_short_no_audio.mp4
new file mode 100644
index 000000000..329d20fba
--- /dev/null
+++ b/packages/tests/fixtures/video_short_no_audio.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_very_long_10p.mp4 b/packages/tests/fixtures/video_very_long_10p.mp4
new file mode 100644
index 000000000..852297933
--- /dev/null
+++ b/packages/tests/fixtures/video_very_long_10p.mp4
Binary files differ
diff --git a/packages/tests/fixtures/video_very_short_240p.mp4 b/packages/tests/fixtures/video_very_short_240p.mp4
new file mode 100644
index 000000000..95b6be92a
--- /dev/null
+++ b/packages/tests/fixtures/video_very_short_240p.mp4
Binary files differ