diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/activitypub/helpers.ts | 13 | ||||
-rw-r--r-- | server/tests/api/check-params/config.ts | 35 | ||||
-rw-r--r-- | server/tests/api/check-params/user-notifications.ts | 3 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 20 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 73 | ||||
-rw-r--r-- | server/tests/api/search/search-videos.ts | 8 | ||||
-rw-r--r-- | server/tests/api/server/auto-follows.ts | 211 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 66 | ||||
-rw-r--r-- | server/tests/api/server/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 21 | ||||
-rw-r--r-- | server/tests/api/videos/video-abuse.ts | 77 | ||||
-rw-r--r-- | server/tests/api/videos/video-change-ownership.ts | 2 |
12 files changed, 500 insertions, 30 deletions
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 365d0e1ae..0d1f154fe 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts | |||
@@ -53,19 +53,6 @@ describe('Test activity pub helpers', function () { | |||
53 | expect(result).to.be.false | 53 | expect(result).to.be.false |
54 | }) | 54 | }) |
55 | 55 | ||
56 | it('Should fail with an invalid PeerTube URL', async function () { | ||
57 | const keys = require('./json/peertube/keys.json') | ||
58 | const body = require('./json/peertube/announce-without-context.json') | ||
59 | |||
60 | const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } | ||
61 | const signedBody = await buildSignedActivity(actorSignature as any, body) | ||
62 | |||
63 | const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9003/accounts/peertube' } | ||
64 | const result = await isJsonLDSignatureVerified(fromActor as any, signedBody) | ||
65 | |||
66 | expect(result).to.be.false | ||
67 | }) | ||
68 | |||
69 | it('Should succeed with a valid PeerTube signature', async function () { | 56 | it('Should succeed with a valid PeerTube signature', async function () { |
70 | const keys = require('./json/peertube/keys.json') | 57 | const keys = require('./json/peertube/keys.json') |
71 | const body = require('./json/peertube/announce-without-context.json') | 58 | const body = require('./json/peertube/announce-without-context.json') |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 7773ae1e7..9435bb1e8 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -5,8 +5,16 @@ import 'mocha' | |||
5 | import { CustomConfig } from '../../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../../shared/models/server/custom-config.model' |
6 | 6 | ||
7 | import { | 7 | import { |
8 | createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, flushAndRunServer, ServerInfo, | 8 | cleanupTests, |
9 | setAccessTokensToServers, userLogin, immutableAssign, cleanupTests | 9 | createUser, |
10 | flushAndRunServer, | ||
11 | immutableAssign, | ||
12 | makeDeleteRequest, | ||
13 | makeGetRequest, | ||
14 | makePutBodyRequest, | ||
15 | ServerInfo, | ||
16 | setAccessTokensToServers, | ||
17 | userLogin | ||
10 | } from '../../../../shared/extra-utils' | 18 | } from '../../../../shared/extra-utils' |
11 | 19 | ||
12 | describe('Test config API validators', function () { | 20 | describe('Test config API validators', function () { |
@@ -19,6 +27,18 @@ describe('Test config API validators', function () { | |||
19 | shortDescription: 'my short description', | 27 | shortDescription: 'my short description', |
20 | description: 'my super description', | 28 | description: 'my super description', |
21 | terms: 'my super terms', | 29 | terms: 'my super terms', |
30 | codeOfConduct: 'my super coc', | ||
31 | |||
32 | creationReason: 'my super reason', | ||
33 | moderationInformation: 'my super moderation information', | ||
34 | administrator: 'Kuja', | ||
35 | maintenanceLifetime: 'forever', | ||
36 | businessModel: 'my super business model', | ||
37 | hardwareInformation: '2vCore 3GB RAM', | ||
38 | |||
39 | languages: [ 'en', 'es' ], | ||
40 | categories: [ 1, 2 ], | ||
41 | |||
22 | isNSFW: true, | 42 | isNSFW: true, |
23 | defaultClientRoute: '/videos/recently-added', | 43 | defaultClientRoute: '/videos/recently-added', |
24 | defaultNSFWPolicy: 'blur', | 44 | defaultNSFWPolicy: 'blur', |
@@ -98,6 +118,17 @@ describe('Test config API validators', function () { | |||
98 | enabled: false, | 118 | enabled: false, |
99 | manualApproval: true | 119 | manualApproval: true |
100 | } | 120 | } |
121 | }, | ||
122 | followings: { | ||
123 | instance: { | ||
124 | autoFollowBack: { | ||
125 | enabled: true | ||
126 | }, | ||
127 | autoFollowIndex: { | ||
128 | enabled: true, | ||
129 | indexUrl: 'https://index.example.com' | ||
130 | } | ||
131 | } | ||
101 | } | 132 | } |
102 | } | 133 | } |
103 | 134 | ||
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 14ee20d45..3b06be7ef 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -172,7 +172,8 @@ describe('Test user notifications API validators', function () { | |||
172 | commentMention: UserNotificationSettingValue.WEB, | 172 | commentMention: UserNotificationSettingValue.WEB, |
173 | newFollow: UserNotificationSettingValue.WEB, | 173 | newFollow: UserNotificationSettingValue.WEB, |
174 | newUserRegistration: UserNotificationSettingValue.WEB, | 174 | newUserRegistration: UserNotificationSettingValue.WEB, |
175 | newInstanceFollower: UserNotificationSettingValue.WEB | 175 | newInstanceFollower: UserNotificationSettingValue.WEB, |
176 | autoInstanceFollowing: UserNotificationSettingValue.WEB | ||
176 | } | 177 | } |
177 | 178 | ||
178 | it('Should fail with missing fields', async function () { | 179 | it('Should fail with missing fields', async function () { |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 939b919ed..55094795c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -476,6 +476,22 @@ describe('Test users API validators', function () { | |||
476 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | 476 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) |
477 | }) | 477 | }) |
478 | 478 | ||
479 | it('Should fail with an invalid noInstanceConfigWarningModal attribute', async function () { | ||
480 | const fields = { | ||
481 | noInstanceConfigWarningModal: -1 | ||
482 | } | ||
483 | |||
484 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | ||
485 | }) | ||
486 | |||
487 | it('Should fail with an invalid noWelcomeModal attribute', async function () { | ||
488 | const fields = { | ||
489 | noWelcomeModal: -1 | ||
490 | } | ||
491 | |||
492 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | ||
493 | }) | ||
494 | |||
479 | it('Should succeed to change password with the correct params', async function () { | 495 | it('Should succeed to change password with the correct params', async function () { |
480 | const fields = { | 496 | const fields = { |
481 | currentPassword: 'my super password', | 497 | currentPassword: 'my super password', |
@@ -483,7 +499,9 @@ describe('Test users API validators', function () { | |||
483 | nsfwPolicy: 'blur', | 499 | nsfwPolicy: 'blur', |
484 | autoPlayVideo: false, | 500 | autoPlayVideo: false, |
485 | email: 'super_email@example.com', | 501 | email: 'super_email@example.com', |
486 | theme: 'default' | 502 | theme: 'default', |
503 | noInstanceConfigWarningModal: true, | ||
504 | noWelcomeModal: true | ||
487 | } | 505 | } |
488 | 506 | ||
489 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) | 507 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 6fa630562..15a34f5aa 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -14,10 +14,13 @@ import { | |||
14 | getVideoCommentThreads, | 14 | getVideoCommentThreads, |
15 | getVideoThreadComments, | 15 | getVideoThreadComments, |
16 | immutableAssign, | 16 | immutableAssign, |
17 | MockInstancesIndex, | ||
17 | registerUser, | 18 | registerUser, |
18 | removeVideoFromBlacklist, | 19 | removeVideoFromBlacklist, |
19 | reportVideoAbuse, | 20 | reportVideoAbuse, |
21 | unfollow, | ||
20 | updateCustomConfig, | 22 | updateCustomConfig, |
23 | updateCustomSubConfig, | ||
21 | updateMyUser, | 24 | updateMyUser, |
22 | updateVideo, | 25 | updateVideo, |
23 | updateVideoChannel, | 26 | updateVideoChannel, |
@@ -29,6 +32,7 @@ import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/l | |||
29 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 32 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
30 | import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' | 33 | import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' |
31 | import { | 34 | import { |
35 | checkAutoInstanceFollowing, | ||
32 | checkCommentMention, | 36 | checkCommentMention, |
33 | CheckerBaseParams, | 37 | CheckerBaseParams, |
34 | checkMyVideoImportIsFinished, | 38 | checkMyVideoImportIsFinished, |
@@ -108,7 +112,8 @@ describe('Test users notifications', function () { | |||
108 | commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 112 | commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
109 | newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 113 | newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
110 | newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 114 | newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
111 | newInstanceFollower: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL | 115 | newInstanceFollower: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
116 | autoInstanceFollowing: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL | ||
112 | } | 117 | } |
113 | 118 | ||
114 | before(async function () { | 119 | before(async function () { |
@@ -873,7 +878,18 @@ describe('Test users notifications', function () { | |||
873 | }) | 878 | }) |
874 | }) | 879 | }) |
875 | 880 | ||
876 | describe('New instance follower', function () { | 881 | describe('New instance follows', function () { |
882 | const instanceIndexServer = new MockInstancesIndex() | ||
883 | const config = { | ||
884 | followings: { | ||
885 | instance: { | ||
886 | autoFollowIndex: { | ||
887 | indexUrl: 'http://localhost:42100', | ||
888 | enabled: true | ||
889 | } | ||
890 | } | ||
891 | } | ||
892 | } | ||
877 | let baseParams: CheckerBaseParams | 893 | let baseParams: CheckerBaseParams |
878 | 894 | ||
879 | before(async () => { | 895 | before(async () => { |
@@ -883,6 +899,9 @@ describe('Test users notifications', function () { | |||
883 | socketNotifications: adminNotifications, | 899 | socketNotifications: adminNotifications, |
884 | token: servers[0].accessToken | 900 | token: servers[0].accessToken |
885 | } | 901 | } |
902 | |||
903 | await instanceIndexServer.initialize() | ||
904 | instanceIndexServer.addInstance(servers[1].host) | ||
886 | }) | 905 | }) |
887 | 906 | ||
888 | it('Should send a notification only to admin when there is a new instance follower', async function () { | 907 | it('Should send a notification only to admin when there is a new instance follower', async function () { |
@@ -897,6 +916,56 @@ describe('Test users notifications', function () { | |||
897 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 916 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } |
898 | await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence') | 917 | await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence') |
899 | }) | 918 | }) |
919 | |||
920 | it('Should send a notification on auto follow back', async function () { | ||
921 | this.timeout(40000) | ||
922 | |||
923 | await unfollow(servers[2].url, servers[2].accessToken, servers[0]) | ||
924 | await waitJobs(servers) | ||
925 | |||
926 | const config = { | ||
927 | followings: { | ||
928 | instance: { | ||
929 | autoFollowBack: { enabled: true } | ||
930 | } | ||
931 | } | ||
932 | } | ||
933 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
934 | |||
935 | await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) | ||
936 | |||
937 | await waitJobs(servers) | ||
938 | |||
939 | const followerHost = servers[0].host | ||
940 | const followingHost = servers[2].host | ||
941 | await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') | ||
942 | |||
943 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | ||
944 | await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence') | ||
945 | |||
946 | config.followings.instance.autoFollowBack.enabled = false | ||
947 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
948 | await unfollow(servers[0].url, servers[0].accessToken, servers[2]) | ||
949 | await unfollow(servers[2].url, servers[2].accessToken, servers[0]) | ||
950 | }) | ||
951 | |||
952 | it('Should send a notification on auto instances index follow', async function () { | ||
953 | this.timeout(30000) | ||
954 | await unfollow(servers[0].url, servers[0].accessToken, servers[1]) | ||
955 | |||
956 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
957 | |||
958 | await wait(5000) | ||
959 | await waitJobs(servers) | ||
960 | |||
961 | const followerHost = servers[0].host | ||
962 | const followingHost = servers[1].host | ||
963 | await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') | ||
964 | |||
965 | config.followings.instance.autoFollowIndex.enabled = false | ||
966 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
967 | await unfollow(servers[0].url, servers[0].accessToken, servers[1]) | ||
968 | }) | ||
900 | }) | 969 | }) |
901 | 970 | ||
902 | describe('New actor follow', function () { | 971 | describe('New actor follow', function () { |
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index c06200ffe..a3e05156b 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts | |||
@@ -206,7 +206,7 @@ describe('Test videos search', function () { | |||
206 | const query = { | 206 | const query = { |
207 | search: '9999', | 207 | search: '9999', |
208 | categoryOneOf: [ 1 ], | 208 | categoryOneOf: [ 1 ], |
209 | tagsOneOf: [ 'aaaa', 'ffff' ] | 209 | tagsOneOf: [ 'aAaa', 'ffff' ] |
210 | } | 210 | } |
211 | const res1 = await advancedVideosSearch(server.url, query) | 211 | const res1 = await advancedVideosSearch(server.url, query) |
212 | expect(res1.body.total).to.equal(2) | 212 | expect(res1.body.total).to.equal(2) |
@@ -219,15 +219,15 @@ describe('Test videos search', function () { | |||
219 | const query = { | 219 | const query = { |
220 | search: '9999', | 220 | search: '9999', |
221 | categoryOneOf: [ 1 ], | 221 | categoryOneOf: [ 1 ], |
222 | tagsAllOf: [ 'cccc' ] | 222 | tagsAllOf: [ 'CCcc' ] |
223 | } | 223 | } |
224 | const res1 = await advancedVideosSearch(server.url, query) | 224 | const res1 = await advancedVideosSearch(server.url, query) |
225 | expect(res1.body.total).to.equal(2) | 225 | expect(res1.body.total).to.equal(2) |
226 | 226 | ||
227 | const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blabla' ] })) | 227 | const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blAbla' ] })) |
228 | expect(res2.body.total).to.equal(0) | 228 | expect(res2.body.total).to.equal(0) |
229 | 229 | ||
230 | const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'cccc' ] })) | 230 | const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'CCCC' ] })) |
231 | expect(res3.body.total).to.equal(1) | 231 | expect(res3.body.total).to.equal(1) |
232 | }) | 232 | }) |
233 | 233 | ||
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts new file mode 100644 index 000000000..df468034c --- /dev/null +++ b/server/tests/api/server/auto-follows.ts | |||
@@ -0,0 +1,211 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | acceptFollower, | ||
7 | cleanupTests, | ||
8 | flushAndRunMultipleServers, | ||
9 | MockInstancesIndex, | ||
10 | ServerInfo, | ||
11 | setAccessTokensToServers, | ||
12 | unfollow, | ||
13 | updateCustomSubConfig, | ||
14 | wait | ||
15 | } from '../../../../shared/extra-utils/index' | ||
16 | import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort } from '../../../../shared/extra-utils/server/follows' | ||
17 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
18 | import { ActorFollow } from '../../../../shared/models/actors' | ||
19 | |||
20 | const expect = chai.expect | ||
21 | |||
22 | async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) { | ||
23 | { | ||
24 | const res = await getFollowersListPaginationAndSort(following.url, 0, 5, '-createdAt') | ||
25 | const follows = res.body.data as ActorFollow[] | ||
26 | |||
27 | const follow = follows.find(f => { | ||
28 | return f.follower.host === follower.host && f.state === 'accepted' | ||
29 | }) | ||
30 | |||
31 | if (exists === true) { | ||
32 | expect(follow).to.exist | ||
33 | } else { | ||
34 | expect(follow).to.be.undefined | ||
35 | } | ||
36 | } | ||
37 | |||
38 | { | ||
39 | const res = await getFollowingListPaginationAndSort(follower.url, 0, 5, '-createdAt') | ||
40 | const follows = res.body.data as ActorFollow[] | ||
41 | |||
42 | const follow = follows.find(f => { | ||
43 | return f.following.host === following.host && f.state === 'accepted' | ||
44 | }) | ||
45 | |||
46 | if (exists === true) { | ||
47 | expect(follow).to.exist | ||
48 | } else { | ||
49 | expect(follow).to.be.undefined | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | async function server1Follows2 (servers: ServerInfo[]) { | ||
55 | await follow(servers[0].url, [ servers[1].host ], servers[0].accessToken) | ||
56 | |||
57 | await waitJobs(servers) | ||
58 | } | ||
59 | |||
60 | async function resetFollows (servers: ServerInfo[]) { | ||
61 | try { | ||
62 | await unfollow(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ]) | ||
63 | await unfollow(servers[ 1 ].url, servers[ 1 ].accessToken, servers[ 0 ]) | ||
64 | } catch { /* empty */ } | ||
65 | |||
66 | await waitJobs(servers) | ||
67 | |||
68 | await checkFollow(servers[0], servers[1], false) | ||
69 | await checkFollow(servers[1], servers[0], false) | ||
70 | } | ||
71 | |||
72 | describe('Test auto follows', function () { | ||
73 | let servers: ServerInfo[] = [] | ||
74 | |||
75 | before(async function () { | ||
76 | this.timeout(30000) | ||
77 | |||
78 | servers = await flushAndRunMultipleServers(3) | ||
79 | |||
80 | // Get the access tokens | ||
81 | await setAccessTokensToServers(servers) | ||
82 | }) | ||
83 | |||
84 | describe('Auto follow back', function () { | ||
85 | |||
86 | it('Should not auto follow back if the option is not enabled', async function () { | ||
87 | this.timeout(15000) | ||
88 | |||
89 | await server1Follows2(servers) | ||
90 | |||
91 | await checkFollow(servers[0], servers[1], true) | ||
92 | await checkFollow(servers[1], servers[0], false) | ||
93 | |||
94 | await resetFollows(servers) | ||
95 | }) | ||
96 | |||
97 | it('Should auto follow back on auto accept if the option is enabled', async function () { | ||
98 | this.timeout(15000) | ||
99 | |||
100 | const config = { | ||
101 | followings: { | ||
102 | instance: { | ||
103 | autoFollowBack: { enabled: true } | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config) | ||
108 | |||
109 | await server1Follows2(servers) | ||
110 | |||
111 | await checkFollow(servers[0], servers[1], true) | ||
112 | await checkFollow(servers[1], servers[0], true) | ||
113 | |||
114 | await resetFollows(servers) | ||
115 | }) | ||
116 | |||
117 | it('Should wait the acceptation before auto follow back', async function () { | ||
118 | this.timeout(30000) | ||
119 | |||
120 | const config = { | ||
121 | followings: { | ||
122 | instance: { | ||
123 | autoFollowBack: { enabled: true } | ||
124 | } | ||
125 | }, | ||
126 | followers: { | ||
127 | instance: { | ||
128 | manualApproval: true | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config) | ||
133 | |||
134 | await server1Follows2(servers) | ||
135 | |||
136 | await checkFollow(servers[0], servers[1], false) | ||
137 | await checkFollow(servers[1], servers[0], false) | ||
138 | |||
139 | await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@' + servers[0].host) | ||
140 | await waitJobs(servers) | ||
141 | |||
142 | await checkFollow(servers[0], servers[1], true) | ||
143 | await checkFollow(servers[1], servers[0], true) | ||
144 | |||
145 | await resetFollows(servers) | ||
146 | |||
147 | config.followings.instance.autoFollowBack.enabled = false | ||
148 | config.followers.instance.manualApproval = false | ||
149 | await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config) | ||
150 | }) | ||
151 | }) | ||
152 | |||
153 | describe('Auto follow index', function () { | ||
154 | const instanceIndexServer = new MockInstancesIndex() | ||
155 | |||
156 | before(async () => { | ||
157 | await instanceIndexServer.initialize() | ||
158 | }) | ||
159 | |||
160 | it('Should not auto follow index if the option is not enabled', async function () { | ||
161 | this.timeout(30000) | ||
162 | |||
163 | await wait(5000) | ||
164 | await waitJobs(servers) | ||
165 | |||
166 | await checkFollow(servers[ 0 ], servers[ 1 ], false) | ||
167 | await checkFollow(servers[ 1 ], servers[ 0 ], false) | ||
168 | }) | ||
169 | |||
170 | it('Should auto follow the index', async function () { | ||
171 | this.timeout(30000) | ||
172 | |||
173 | instanceIndexServer.addInstance(servers[1].host) | ||
174 | |||
175 | const config = { | ||
176 | followings: { | ||
177 | instance: { | ||
178 | autoFollowIndex: { | ||
179 | indexUrl: 'http://localhost:42100', | ||
180 | enabled: true | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) | ||
186 | |||
187 | await wait(5000) | ||
188 | await waitJobs(servers) | ||
189 | |||
190 | await checkFollow(servers[ 0 ], servers[ 1 ], true) | ||
191 | |||
192 | await resetFollows(servers) | ||
193 | }) | ||
194 | |||
195 | it('Should follow new added instances in the index but not old ones', async function () { | ||
196 | this.timeout(30000) | ||
197 | |||
198 | instanceIndexServer.addInstance(servers[2].host) | ||
199 | |||
200 | await wait(5000) | ||
201 | await waitJobs(servers) | ||
202 | |||
203 | await checkFollow(servers[ 0 ], servers[ 1 ], false) | ||
204 | await checkFollow(servers[ 0 ], servers[ 2 ], true) | ||
205 | }) | ||
206 | }) | ||
207 | |||
208 | after(async function () { | ||
209 | await cleanupTests(servers) | ||
210 | }) | ||
211 | }) | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 78fdc9cc0..97cc99eea 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -28,7 +28,19 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { | |||
28 | 'with WebTorrent and Angular.' | 28 | 'with WebTorrent and Angular.' |
29 | ) | 29 | ) |
30 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') | 30 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') |
31 | |||
31 | expect(data.instance.terms).to.equal('No terms for now.') | 32 | expect(data.instance.terms).to.equal('No terms for now.') |
33 | expect(data.instance.creationReason).to.be.empty | ||
34 | expect(data.instance.codeOfConduct).to.be.empty | ||
35 | expect(data.instance.moderationInformation).to.be.empty | ||
36 | expect(data.instance.administrator).to.be.empty | ||
37 | expect(data.instance.maintenanceLifetime).to.be.empty | ||
38 | expect(data.instance.businessModel).to.be.empty | ||
39 | expect(data.instance.hardwareInformation).to.be.empty | ||
40 | |||
41 | expect(data.instance.languages).to.have.lengthOf(0) | ||
42 | expect(data.instance.categories).to.have.lengthOf(0) | ||
43 | |||
32 | expect(data.instance.defaultClientRoute).to.equal('/videos/trending') | 44 | expect(data.instance.defaultClientRoute).to.equal('/videos/trending') |
33 | expect(data.instance.isNSFW).to.be.false | 45 | expect(data.instance.isNSFW).to.be.false |
34 | expect(data.instance.defaultNSFWPolicy).to.equal('display') | 46 | expect(data.instance.defaultNSFWPolicy).to.equal('display') |
@@ -68,13 +80,29 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { | |||
68 | 80 | ||
69 | expect(data.followers.instance.enabled).to.be.true | 81 | expect(data.followers.instance.enabled).to.be.true |
70 | expect(data.followers.instance.manualApproval).to.be.false | 82 | expect(data.followers.instance.manualApproval).to.be.false |
83 | |||
84 | expect(data.followings.instance.autoFollowBack.enabled).to.be.false | ||
85 | expect(data.followings.instance.autoFollowIndex.enabled).to.be.false | ||
86 | expect(data.followings.instance.autoFollowIndex.indexUrl).to.equal('https://instances.joinpeertube.org') | ||
71 | } | 87 | } |
72 | 88 | ||
73 | function checkUpdatedConfig (data: CustomConfig) { | 89 | function checkUpdatedConfig (data: CustomConfig) { |
74 | expect(data.instance.name).to.equal('PeerTube updated') | 90 | expect(data.instance.name).to.equal('PeerTube updated') |
75 | expect(data.instance.shortDescription).to.equal('my short description') | 91 | expect(data.instance.shortDescription).to.equal('my short description') |
76 | expect(data.instance.description).to.equal('my super description') | 92 | expect(data.instance.description).to.equal('my super description') |
93 | |||
77 | expect(data.instance.terms).to.equal('my super terms') | 94 | expect(data.instance.terms).to.equal('my super terms') |
95 | expect(data.instance.creationReason).to.equal('my super creation reason') | ||
96 | expect(data.instance.codeOfConduct).to.equal('my super coc') | ||
97 | expect(data.instance.moderationInformation).to.equal('my super moderation information') | ||
98 | expect(data.instance.administrator).to.equal('Kuja') | ||
99 | expect(data.instance.maintenanceLifetime).to.equal('forever') | ||
100 | expect(data.instance.businessModel).to.equal('my super business model') | ||
101 | expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') | ||
102 | |||
103 | expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) | ||
104 | expect(data.instance.categories).to.deep.equal([ 1, 2 ]) | ||
105 | |||
78 | expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added') | 106 | expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added') |
79 | expect(data.instance.isNSFW).to.be.true | 107 | expect(data.instance.isNSFW).to.be.true |
80 | expect(data.instance.defaultNSFWPolicy).to.equal('blur') | 108 | expect(data.instance.defaultNSFWPolicy).to.equal('blur') |
@@ -119,6 +147,10 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
119 | 147 | ||
120 | expect(data.followers.instance.enabled).to.be.false | 148 | expect(data.followers.instance.enabled).to.be.false |
121 | expect(data.followers.instance.manualApproval).to.be.true | 149 | expect(data.followers.instance.manualApproval).to.be.true |
150 | |||
151 | expect(data.followings.instance.autoFollowBack.enabled).to.be.true | ||
152 | expect(data.followings.instance.autoFollowIndex.enabled).to.be.true | ||
153 | expect(data.followings.instance.autoFollowIndex.indexUrl).to.equal('https://updated.example.com') | ||
122 | } | 154 | } |
123 | 155 | ||
124 | describe('Test config', function () { | 156 | describe('Test config', function () { |
@@ -182,6 +214,18 @@ describe('Test config', function () { | |||
182 | shortDescription: 'my short description', | 214 | shortDescription: 'my short description', |
183 | description: 'my super description', | 215 | description: 'my super description', |
184 | terms: 'my super terms', | 216 | terms: 'my super terms', |
217 | codeOfConduct: 'my super coc', | ||
218 | |||
219 | creationReason: 'my super creation reason', | ||
220 | moderationInformation: 'my super moderation information', | ||
221 | administrator: 'Kuja', | ||
222 | maintenanceLifetime: 'forever', | ||
223 | businessModel: 'my super business model', | ||
224 | hardwareInformation: '2vCore 3GB RAM', | ||
225 | |||
226 | languages: [ 'en', 'es' ], | ||
227 | categories: [ 1, 2 ], | ||
228 | |||
185 | defaultClientRoute: '/videos/recently-added', | 229 | defaultClientRoute: '/videos/recently-added', |
186 | isNSFW: true, | 230 | isNSFW: true, |
187 | defaultNSFWPolicy: 'blur' as 'blur', | 231 | defaultNSFWPolicy: 'blur' as 'blur', |
@@ -261,6 +305,17 @@ describe('Test config', function () { | |||
261 | enabled: false, | 305 | enabled: false, |
262 | manualApproval: true | 306 | manualApproval: true |
263 | } | 307 | } |
308 | }, | ||
309 | followings: { | ||
310 | instance: { | ||
311 | autoFollowBack: { | ||
312 | enabled: true | ||
313 | }, | ||
314 | autoFollowIndex: { | ||
315 | enabled: true, | ||
316 | indexUrl: 'https://updated.example.com' | ||
317 | } | ||
318 | } | ||
264 | } | 319 | } |
265 | } | 320 | } |
266 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) | 321 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) |
@@ -310,6 +365,17 @@ describe('Test config', function () { | |||
310 | expect(data.instance.shortDescription).to.equal('my short description') | 365 | expect(data.instance.shortDescription).to.equal('my short description') |
311 | expect(data.instance.description).to.equal('my super description') | 366 | expect(data.instance.description).to.equal('my super description') |
312 | expect(data.instance.terms).to.equal('my super terms') | 367 | expect(data.instance.terms).to.equal('my super terms') |
368 | expect(data.instance.codeOfConduct).to.equal('my super coc') | ||
369 | |||
370 | expect(data.instance.creationReason).to.equal('my super creation reason') | ||
371 | expect(data.instance.moderationInformation).to.equal('my super moderation information') | ||
372 | expect(data.instance.administrator).to.equal('Kuja') | ||
373 | expect(data.instance.maintenanceLifetime).to.equal('forever') | ||
374 | expect(data.instance.businessModel).to.equal('my super business model') | ||
375 | expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') | ||
376 | |||
377 | expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) | ||
378 | expect(data.instance.categories).to.deep.equal([ 1, 2 ]) | ||
313 | }) | 379 | }) |
314 | 380 | ||
315 | it('Should remove the custom configuration', async function () { | 381 | it('Should remove the custom configuration', async function () { |
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts index 3daeeb49a..08205b2c8 100644 --- a/server/tests/api/server/index.ts +++ b/server/tests/api/server/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import './auto-follows' | ||
1 | import './config' | 2 | import './config' |
2 | import './contact-form' | 3 | import './contact-form' |
3 | import './email' | 4 | import './email' |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 3a3fabb4c..95b1bb626 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -442,7 +442,7 @@ describe('Test users', function () { | |||
442 | url: server.url, | 442 | url: server.url, |
443 | accessToken: accessTokenUser, | 443 | accessToken: accessTokenUser, |
444 | currentPassword: 'super password', | 444 | currentPassword: 'super password', |
445 | newPassword: 'new password' | 445 | password: 'new password' |
446 | }) | 446 | }) |
447 | user.password = 'new password' | 447 | user.password = 'new password' |
448 | 448 | ||
@@ -543,7 +543,7 @@ describe('Test users', function () { | |||
543 | }) | 543 | }) |
544 | 544 | ||
545 | const res = await getMyUserInformation(server.url, accessTokenUser) | 545 | const res = await getMyUserInformation(server.url, accessTokenUser) |
546 | const user = res.body | 546 | const user: User = res.body |
547 | 547 | ||
548 | expect(user.username).to.equal('user_1') | 548 | expect(user.username).to.equal('user_1') |
549 | expect(user.email).to.equal('updated@example.com') | 549 | expect(user.email).to.equal('updated@example.com') |
@@ -552,6 +552,8 @@ describe('Test users', function () { | |||
552 | expect(user.id).to.be.a('number') | 552 | expect(user.id).to.be.a('number') |
553 | expect(user.account.displayName).to.equal('new display name') | 553 | expect(user.account.displayName).to.equal('new display name') |
554 | expect(user.account.description).to.equal('my super description updated') | 554 | expect(user.account.description).to.equal('my super description updated') |
555 | expect(user.noWelcomeModal).to.be.false | ||
556 | expect(user.noInstanceConfigWarningModal).to.be.false | ||
555 | }) | 557 | }) |
556 | 558 | ||
557 | it('Should be able to update my theme', async function () { | 559 | it('Should be able to update my theme', async function () { |
@@ -568,6 +570,21 @@ describe('Test users', function () { | |||
568 | expect(body.theme).to.equal(theme) | 570 | expect(body.theme).to.equal(theme) |
569 | } | 571 | } |
570 | }) | 572 | }) |
573 | |||
574 | it('Should be able to update my modal preferences', async function () { | ||
575 | await updateMyUser({ | ||
576 | url: server.url, | ||
577 | accessToken: accessTokenUser, | ||
578 | noInstanceConfigWarningModal: true, | ||
579 | noWelcomeModal: true | ||
580 | }) | ||
581 | |||
582 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
583 | const user: User = res.body | ||
584 | |||
585 | expect(user.noWelcomeModal).to.be.true | ||
586 | expect(user.noInstanceConfigWarningModal).to.be.true | ||
587 | }) | ||
571 | }) | 588 | }) |
572 | 589 | ||
573 | describe('Updating another user', function () { | 590 | describe('Updating another user', function () { |
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index a2f3ee161..0cd6f22c7 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts | |||
@@ -17,6 +17,12 @@ import { | |||
17 | } from '../../../../shared/extra-utils/index' | 17 | } from '../../../../shared/extra-utils/index' |
18 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 18 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
20 | import { | ||
21 | addAccountToServerBlocklist, | ||
22 | addServerToServerBlocklist, | ||
23 | removeAccountFromServerBlocklist, | ||
24 | removeServerFromServerBlocklist | ||
25 | } from '../../../../shared/extra-utils/users/blocklist' | ||
20 | 26 | ||
21 | const expect = chai.expect | 27 | const expect = chai.expect |
22 | 28 | ||
@@ -163,13 +169,76 @@ describe('Test video abuses', function () { | |||
163 | expect(res.body.data[0].moderationComment).to.equal('It is valid') | 169 | expect(res.body.data[0].moderationComment).to.equal('It is valid') |
164 | }) | 170 | }) |
165 | 171 | ||
172 | it('Should hide video abuses from blocked accounts', async function () { | ||
173 | this.timeout(10000) | ||
174 | |||
175 | { | ||
176 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') | ||
177 | await waitJobs(servers) | ||
178 | |||
179 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | ||
180 | expect(res.body.total).to.equal(3) | ||
181 | } | ||
182 | |||
183 | const accountToBlock = 'root@localhost:' + servers[1].port | ||
184 | |||
185 | { | ||
186 | await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | ||
187 | |||
188 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
189 | expect(res.body.total).to.equal(2) | ||
190 | |||
191 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | ||
192 | expect(abuse).to.be.undefined | ||
193 | } | ||
194 | |||
195 | { | ||
196 | await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock) | ||
197 | |||
198 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
199 | expect(res.body.total).to.equal(3) | ||
200 | } | ||
201 | }) | ||
202 | |||
203 | it('Should hide video abuses from blocked servers', async function () { | ||
204 | const serverToBlock = servers[1].host | ||
205 | |||
206 | { | ||
207 | await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host) | ||
208 | |||
209 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
210 | expect(res.body.total).to.equal(2) | ||
211 | |||
212 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | ||
213 | expect(abuse).to.be.undefined | ||
214 | } | ||
215 | |||
216 | { | ||
217 | await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock) | ||
218 | |||
219 | const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken) | ||
220 | expect(res.body.total).to.equal(3) | ||
221 | } | ||
222 | }) | ||
223 | |||
166 | it('Should delete the video abuse', async function () { | 224 | it('Should delete the video abuse', async function () { |
225 | this.timeout(10000) | ||
226 | |||
167 | await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) | 227 | await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) |
168 | 228 | ||
169 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 229 | await waitJobs(servers) |
170 | expect(res.body.total).to.equal(0) | 230 | |
171 | expect(res.body.data).to.be.an('array') | 231 | { |
172 | expect(res.body.data.length).to.equal(0) | 232 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
233 | expect(res.body.total).to.equal(1) | ||
234 | expect(res.body.data.length).to.equal(1) | ||
235 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) | ||
236 | } | ||
237 | |||
238 | { | ||
239 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | ||
240 | expect(res.body.total).to.equal(3) | ||
241 | } | ||
173 | }) | 242 | }) |
174 | 243 | ||
175 | after(async function () { | 244 | after(async function () { |
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 3a3add71b..64ee2355a 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -191,7 +191,7 @@ describe('Test video change ownership - nominal', function () { | |||
191 | await waitJobs(servers) | 191 | await waitJobs(servers) |
192 | }) | 192 | }) |
193 | 193 | ||
194 | it('Should have video channel updated', async function () { | 194 | it('Should have the channel of the video updated', async function () { |
195 | for (const server of servers) { | 195 | for (const server of servers) { |
196 | const res = await getVideo(server.url, servers[0].video.uuid) | 196 | const res = await getVideo(server.url, servers[0].video.uuid) |
197 | 197 | ||