aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-27 11:41:38 +0100
committerChocobozzz <me@florianbigard.com>2020-11-27 11:41:38 +0100
commit353f8bc0c7a71ad490e4501b8c80e13e5cec1932 (patch)
treea3a6c637e2baf57597c733dbc166b1959754bf34
parente2c1f7795752caf8cde19fdee8b9ab7fb16b0395 (diff)
downloadPeerTube-353f8bc0c7a71ad490e4501b8c80e13e5cec1932.tar.gz
PeerTube-353f8bc0c7a71ad490e4501b8c80e13e5cec1932.tar.zst
PeerTube-353f8bc0c7a71ad490e4501b8c80e13e5cec1932.zip
Add registered setting CLI plugin install test
-rw-r--r--server/tests/api/server/plugins.ts16
-rw-r--r--server/tests/cli/peertube.ts5
-rw-r--r--shared/extra-utils/server/plugins.ts20
3 files changed, 27 insertions, 14 deletions
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index ecf7c0d3f..1c6eabe6d 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -10,7 +10,6 @@ import {
10 getMyUserInformation, 10 getMyUserInformation,
11 getPlugin, 11 getPlugin,
12 getPluginPackageJSON, 12 getPluginPackageJSON,
13 getPluginRegisteredSettings,
14 getPublicSettings, 13 getPublicSettings,
15 installPlugin, 14 installPlugin,
16 killallServers, 15 killallServers,
@@ -20,6 +19,7 @@ import {
20 ServerInfo, 19 ServerInfo,
21 setAccessTokensToServers, 20 setAccessTokensToServers,
22 setPluginVersion, 21 setPluginVersion,
22 testHelloWorldRegisteredSettings,
23 uninstallPlugin, 23 uninstallPlugin,
24 updateCustomSubConfig, 24 updateCustomSubConfig,
25 updateMyUser, 25 updateMyUser,
@@ -34,7 +34,6 @@ import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugi
34import { PluginPackageJson } from '../../../../shared/models/plugins/plugin-package-json.model' 34import { PluginPackageJson } from '../../../../shared/models/plugins/plugin-package-json.model'
35import { PluginType } from '../../../../shared/models/plugins/plugin.type' 35import { PluginType } from '../../../../shared/models/plugins/plugin.type'
36import { PublicServerSetting } from '../../../../shared/models/plugins/public-server.setting' 36import { PublicServerSetting } from '../../../../shared/models/plugins/public-server.setting'
37import { RegisteredServerSettings } from '../../../../shared/models/plugins/register-server-setting.model'
38import { ServerConfig } from '../../../../shared/models/server' 37import { ServerConfig } from '../../../../shared/models/server'
39import { User } from '../../../../shared/models/users' 38import { User } from '../../../../shared/models/users'
40 39
@@ -209,18 +208,7 @@ describe('Test plugins', function () {
209 }) 208 })
210 209
211 it('Should get registered settings', async function () { 210 it('Should get registered settings', async function () {
212 const res = await getPluginRegisteredSettings({ 211 await testHelloWorldRegisteredSettings(server)
213 url: server.url,
214 accessToken: server.accessToken,
215 npmName: 'peertube-plugin-hello-world'
216 })
217
218 const registeredSettings = (res.body as RegisteredServerSettings).registeredSettings
219
220 expect(registeredSettings).to.have.length.at.least(1)
221
222 const adminNameSettings = registeredSettings.find(s => s.name === 'admin-name')
223 expect(adminNameSettings).to.not.be.undefined
224 }) 212 })
225 213
226 it('Should get public settings', async function () { 214 it('Should get public settings', async function () {
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index e2861f46e..348438533 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -19,6 +19,7 @@ import {
19 removeVideo, 19 removeVideo,
20 ServerInfo, 20 ServerInfo,
21 setAccessTokensToServers, 21 setAccessTokensToServers,
22 testHelloWorldRegisteredSettings,
22 uploadVideoAndGetId, 23 uploadVideoAndGetId,
23 userLogin, 24 userLogin,
24 waitJobs 25 waitJobs
@@ -205,6 +206,10 @@ describe('Test CLI wrapper', function () {
205 await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`) 206 await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`)
206 }) 207 })
207 208
209 it('Should have registered settings', async function () {
210 await testHelloWorldRegisteredSettings(server)
211 })
212
208 it('Should list installed plugins', async function () { 213 it('Should list installed plugins', async function () {
209 const env = getEnvCli(server) 214 const env = getEnvCli(server)
210 const res = await execCLI(`${env} ${cmd} plugins list`) 215 const res = await execCLI(`${env} ${cmd} plugins list`)
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 8f370f655..83db2f6b8 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -1,5 +1,9 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
1import { readJSON, writeJSON } from 'fs-extra' 4import { readJSON, writeJSON } from 'fs-extra'
2import { join } from 'path' 5import { join } from 'path'
6import { RegisteredServerSettings } from '@shared/models'
3import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model' 7import { PeertubePluginIndexList } from '../../models/plugins/peertube-plugin-index-list.model'
4import { PluginType } from '../../models/plugins/plugin.type' 8import { PluginType } from '../../models/plugins/plugin.type'
5import { buildServerDirectory, root } from '../miscs/miscs' 9import { buildServerDirectory, root } from '../miscs/miscs'
@@ -119,6 +123,21 @@ function getPluginRegisteredSettings (parameters: {
119 }) 123 })
120} 124}
121 125
126async function testHelloWorldRegisteredSettings (server: ServerInfo) {
127 const res = await getPluginRegisteredSettings({
128 url: server.url,
129 accessToken: server.accessToken,
130 npmName: 'peertube-plugin-hello-world'
131 })
132
133 const registeredSettings = (res.body as RegisteredServerSettings).registeredSettings
134
135 expect(registeredSettings).to.have.length.at.least(1)
136
137 const adminNameSettings = registeredSettings.find(s => s.name === 'admin-name')
138 expect(adminNameSettings).to.not.be.undefined
139}
140
122function getPublicSettings (parameters: { 141function getPublicSettings (parameters: {
123 url: string 142 url: string
124 npmName: string 143 npmName: string
@@ -265,6 +284,7 @@ export {
265 updatePlugin, 284 updatePlugin,
266 getPlugin, 285 getPlugin,
267 uninstallPlugin, 286 uninstallPlugin,
287 testHelloWorldRegisteredSettings,
268 updatePluginSettings, 288 updatePluginSettings,
269 getPluginRegisteredSettings, 289 getPluginRegisteredSettings,
270 getPackageJSONPath, 290 getPackageJSONPath,