diff options
Diffstat (limited to 'server/tests/external-plugins')
-rw-r--r-- | server/tests/external-plugins/akismet.ts | 160 | ||||
-rw-r--r-- | server/tests/external-plugins/auth-ldap.ts | 8 | ||||
-rw-r--r-- | server/tests/external-plugins/index.ts | 1 |
3 files changed, 169 insertions, 0 deletions
diff --git a/server/tests/external-plugins/akismet.ts b/server/tests/external-plugins/akismet.ts new file mode 100644 index 000000000..974bf0011 --- /dev/null +++ b/server/tests/external-plugins/akismet.ts | |||
@@ -0,0 +1,160 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { HttpStatusCode } from '@shared/models' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | waitJobs | ||
12 | } from '@shared/server-commands' | ||
13 | |||
14 | describe('Official plugin Akismet', function () { | ||
15 | let servers: PeerTubeServer[] | ||
16 | let videoUUID: string | ||
17 | |||
18 | before(async function () { | ||
19 | this.timeout(30000) | ||
20 | |||
21 | servers = await createMultipleServers(2) | ||
22 | await setAccessTokensToServers(servers) | ||
23 | |||
24 | await servers[0].plugins.install({ | ||
25 | npmName: 'peertube-plugin-akismet' | ||
26 | }) | ||
27 | |||
28 | if (!process.env.AKISMET_KEY) throw new Error('Missing AKISMET_KEY from env') | ||
29 | |||
30 | await servers[0].plugins.updateSettings({ | ||
31 | npmName: 'peertube-plugin-akismet', | ||
32 | settings: { | ||
33 | 'akismet-api-key': process.env.AKISMET_KEY | ||
34 | } | ||
35 | }) | ||
36 | |||
37 | await doubleFollow(servers[0], servers[1]) | ||
38 | }) | ||
39 | |||
40 | describe('Local threads/replies', function () { | ||
41 | |||
42 | before(async function () { | ||
43 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' }) | ||
44 | videoUUID = uuid | ||
45 | }) | ||
46 | |||
47 | it('Should not detect a thread as spam', async function () { | ||
48 | await servers[0].comments.createThread({ videoId: videoUUID, text: 'comment' }) | ||
49 | }) | ||
50 | |||
51 | it('Should not detect a reply as spam', async function () { | ||
52 | await servers[0].comments.addReplyToLastThread({ text: 'reply' }) | ||
53 | }) | ||
54 | |||
55 | it('Should detect a thread as spam', async function () { | ||
56 | await servers[0].comments.createThread({ | ||
57 | videoId: videoUUID, | ||
58 | text: 'akismet-guaranteed-spam', | ||
59 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | ||
60 | }) | ||
61 | }) | ||
62 | |||
63 | it('Should detect a thread as spam', async function () { | ||
64 | await servers[0].comments.createThread({ videoId: videoUUID, text: 'comment' }) | ||
65 | await servers[0].comments.addReplyToLastThread({ text: 'akismet-guaranteed-spam', expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | ||
66 | }) | ||
67 | }) | ||
68 | |||
69 | describe('Remote threads/replies', function () { | ||
70 | |||
71 | before(async function () { | ||
72 | this.timeout(60000) | ||
73 | |||
74 | const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' }) | ||
75 | videoUUID = uuid | ||
76 | |||
77 | await waitJobs(servers) | ||
78 | }) | ||
79 | |||
80 | it('Should not detect a thread as spam', async function () { | ||
81 | this.timeout(30000) | ||
82 | |||
83 | await servers[1].comments.createThread({ videoId: videoUUID, text: 'remote comment 1' }) | ||
84 | await waitJobs(servers) | ||
85 | |||
86 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) | ||
87 | expect(data).to.have.lengthOf(1) | ||
88 | }) | ||
89 | |||
90 | it('Should not detect a reply as spam', async function () { | ||
91 | this.timeout(30000) | ||
92 | |||
93 | await servers[1].comments.addReplyToLastThread({ text: 'I agree with you' }) | ||
94 | await waitJobs(servers) | ||
95 | |||
96 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) | ||
97 | expect(data).to.have.lengthOf(1) | ||
98 | |||
99 | const tree = await servers[0].comments.getThread({ videoId: videoUUID, threadId: data[0].id }) | ||
100 | expect(tree.children).to.have.lengthOf(1) | ||
101 | }) | ||
102 | |||
103 | it('Should detect a thread as spam', async function () { | ||
104 | this.timeout(30000) | ||
105 | |||
106 | await servers[1].comments.createThread({ videoId: videoUUID, text: 'akismet-guaranteed-spam' }) | ||
107 | await waitJobs(servers) | ||
108 | |||
109 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) | ||
110 | expect(data).to.have.lengthOf(1) | ||
111 | }) | ||
112 | |||
113 | it('Should detect a thread as spam', async function () { | ||
114 | this.timeout(30000) | ||
115 | |||
116 | await servers[1].comments.addReplyToLastThread({ text: 'akismet-guaranteed-spam' }) | ||
117 | await waitJobs(servers) | ||
118 | |||
119 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) | ||
120 | expect(data).to.have.lengthOf(1) | ||
121 | |||
122 | const thread = data[0] | ||
123 | const tree = await servers[0].comments.getThread({ videoId: videoUUID, threadId: thread.id }) | ||
124 | expect(tree.children).to.have.lengthOf(1) | ||
125 | }) | ||
126 | }) | ||
127 | |||
128 | describe('Signup', function () { | ||
129 | |||
130 | before(async function () { | ||
131 | await servers[0].config.updateExistingSubConfig({ | ||
132 | newConfig: { | ||
133 | signup: { | ||
134 | enabled: true | ||
135 | } | ||
136 | } | ||
137 | }) | ||
138 | }) | ||
139 | |||
140 | it('Should allow signup', async function () { | ||
141 | await servers[0].users.register({ | ||
142 | username: 'user1', | ||
143 | displayName: 'user 1' | ||
144 | }) | ||
145 | }) | ||
146 | |||
147 | it('Should detect a signup as SPAM', async function () { | ||
148 | await servers[0].users.register({ | ||
149 | username: 'user2', | ||
150 | displayName: 'user 2', | ||
151 | email: 'akismet-guaranteed-spam@example.com', | ||
152 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | ||
153 | }) | ||
154 | }) | ||
155 | }) | ||
156 | |||
157 | after(async function () { | ||
158 | await cleanupTests(servers) | ||
159 | }) | ||
160 | }) | ||
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index d7f155d2a..6f6a574a0 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts | |||
@@ -94,6 +94,14 @@ describe('Official plugin auth-ldap', function () { | |||
94 | await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) | 94 | await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) |
95 | }) | 95 | }) |
96 | 96 | ||
97 | it('Should not be able to ask password reset', async function () { | ||
98 | await server.users.askResetPassword({ email: 'fry@planetexpress.com', expectedStatus: HttpStatusCode.CONFLICT_409 }) | ||
99 | }) | ||
100 | |||
101 | it('Should not be able to ask email verification', async function () { | ||
102 | await server.users.askSendVerifyEmail({ email: 'fry@planetexpress.com', expectedStatus: HttpStatusCode.CONFLICT_409 }) | ||
103 | }) | ||
104 | |||
97 | it('Should not login if the plugin is uninstalled', async function () { | 105 | it('Should not login if the plugin is uninstalled', async function () { |
98 | await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) | 106 | await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) |
99 | 107 | ||
diff --git a/server/tests/external-plugins/index.ts b/server/tests/external-plugins/index.ts index 31d818b51..815bbf1da 100644 --- a/server/tests/external-plugins/index.ts +++ b/server/tests/external-plugins/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import './akismet' | ||
1 | import './auth-ldap' | 2 | import './auth-ldap' |
2 | import './auto-block-videos' | 3 | import './auto-block-videos' |
3 | import './auto-mute' | 4 | import './auto-mute' |