aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-09-23 16:23:06 +0200
committerChocobozzz <me@florianbigard.com>2022-09-26 16:27:06 +0200
commit84e7ff2757b6736df4277fb2c1d48d3ca0a760ae (patch)
treedf30213d777327d9513782ee5d4894473109ff93 /server
parent4f3814808791d8f380e75d152e0e14a01b758b9a (diff)
downloadPeerTube-84e7ff2757b6736df4277fb2c1d48d3ca0a760ae.tar.gz
PeerTube-84e7ff2757b6736df4277fb2c1d48d3ca0a760ae.tar.zst
PeerTube-84e7ff2757b6736df4277fb2c1d48d3ca0a760ae.zip
Test akismet plugin signup
Diffstat (limited to 'server')
-rw-r--r--server/tests/external-plugins/akismet.ts45
1 files changed, 37 insertions, 8 deletions
diff --git a/server/tests/external-plugins/akismet.ts b/server/tests/external-plugins/akismet.ts
index 557fc3daf..974bf0011 100644
--- a/server/tests/external-plugins/akismet.ts
+++ b/server/tests/external-plugins/akismet.ts
@@ -21,7 +21,9 @@ describe('Official plugin Akismet', function () {
21 servers = await createMultipleServers(2) 21 servers = await createMultipleServers(2)
22 await setAccessTokensToServers(servers) 22 await setAccessTokensToServers(servers)
23 23
24 await servers[0].plugins.install({ npmName: 'peertube-plugin-akismet' }) 24 await servers[0].plugins.install({
25 npmName: 'peertube-plugin-akismet'
26 })
25 27
26 if (!process.env.AKISMET_KEY) throw new Error('Missing AKISMET_KEY from env') 28 if (!process.env.AKISMET_KEY) throw new Error('Missing AKISMET_KEY from env')
27 29
@@ -71,6 +73,8 @@ describe('Official plugin Akismet', function () {
71 73
72 const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' }) 74 const { uuid } = await servers[0].videos.quickUpload({ name: 'video 1' })
73 videoUUID = uuid 75 videoUUID = uuid
76
77 await waitJobs(servers)
74 }) 78 })
75 79
76 it('Should not detect a thread as spam', async function () { 80 it('Should not detect a thread as spam', async function () {
@@ -109,19 +113,44 @@ describe('Official plugin Akismet', function () {
109 it('Should detect a thread as spam', async function () { 113 it('Should detect a thread as spam', async function () {
110 this.timeout(30000) 114 this.timeout(30000)
111 115
112 await servers[1].comments.createThread({ videoId: videoUUID, text: 'remote comment 2' })
113 await servers[1].comments.addReplyToLastThread({ text: 'akismet-guaranteed-spam' }) 116 await servers[1].comments.addReplyToLastThread({ text: 'akismet-guaranteed-spam' })
114 await waitJobs(servers) 117 await waitJobs(servers)
115 118
116 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) 119 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
117 expect(data).to.have.lengthOf(2) 120 expect(data).to.have.lengthOf(1)
118 121
119 for (const thread of data) { 122 const thread = data[0]
120 const tree = await servers[0].comments.getThread({ videoId: videoUUID, threadId: thread.id }) 123 const tree = await servers[0].comments.getThread({ videoId: videoUUID, threadId: thread.id })
121 if (tree.comment.text === 'remote comment 1') continue 124 expect(tree.children).to.have.lengthOf(1)
125 })
126 })
122 127
123 expect(tree.children).to.have.lengthOf(0) 128 describe('Signup', function () {
124 } 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 })
125 }) 154 })
126 }) 155 })
127 156