aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/plugins.ts32
-rw-r--r--server/tests/fixtures/peertube-plugin-test-broken/main.js12
-rw-r--r--server/tests/fixtures/peertube-plugin-test-broken/package.json20
3 files changed, 64 insertions, 0 deletions
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 6046ab97e..6b61c7c33 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -2,6 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { 6import {
6 cleanupTests, 7 cleanupTests,
7 closeAllSequelize, 8 closeAllSequelize,
@@ -10,6 +11,7 @@ import {
10 getMyUserInformation, 11 getMyUserInformation,
11 getPlugin, 12 getPlugin,
12 getPluginPackageJSON, 13 getPluginPackageJSON,
14 getPluginTestPath,
13 getPublicSettings, 15 getPublicSettings,
14 installPlugin, 16 installPlugin,
15 killallServers, 17 killallServers,
@@ -400,6 +402,36 @@ describe('Test plugins', function () {
400 expect((res.body as User).theme).to.equal('instance-default') 402 expect((res.body as User).theme).to.equal('instance-default')
401 }) 403 })
402 404
405 it('Should not install a broken plugin', async function () {
406 this.timeout(60000)
407
408 async function check () {
409 const res = await listPlugins({
410 url: server.url,
411 accessToken: server.accessToken,
412 pluginType: PluginType.PLUGIN
413 })
414
415 const plugins: PeerTubePlugin[] = res.body.data
416
417 expect(plugins.find(p => p.name === 'test-broken')).to.not.exist
418 }
419
420 await installPlugin({
421 url: server.url,
422 accessToken: server.accessToken,
423 path: getPluginTestPath('-broken'),
424 expectedStatus: HttpStatusCode.BAD_REQUEST_400
425 })
426
427 await check()
428
429 killallServers([ server ])
430 await reRunServer(server)
431
432 await check()
433 })
434
403 after(async function () { 435 after(async function () {
404 await closeAllSequelize([ server ]) 436 await closeAllSequelize([ server ])
405 await cleanupTests([ server ]) 437 await cleanupTests([ server ])
diff --git a/server/tests/fixtures/peertube-plugin-test-broken/main.js b/server/tests/fixtures/peertube-plugin-test-broken/main.js
new file mode 100644
index 000000000..afdb6f7a0
--- /dev/null
+++ b/server/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/server/tests/fixtures/peertube-plugin-test-broken/package.json b/server/tests/fixtures/peertube-plugin-test-broken/package.json
new file mode 100644
index 000000000..fd03df216
--- /dev/null
+++ b/server/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}