aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-07 15:27:35 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-07 15:54:34 +0200
commitfdbda9e3d6564ec908733c7019305f6a3c363a9f (patch)
treec596034156f167e7cfafe41c4a3fc6adda488a0d /server/tests/cli
parent04de542abd940f9d2ca213fba3c68580c6c9b78a (diff)
downloadPeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.gz
PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.zst
PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.zip
Add tests for npm run scripts
Diffstat (limited to 'server/tests/cli')
-rw-r--r--server/tests/cli/index.ts2
-rw-r--r--server/tests/cli/reset-password.ts45
-rw-r--r--server/tests/cli/update-host.ts71
3 files changed, 118 insertions, 0 deletions
diff --git a/server/tests/cli/index.ts b/server/tests/cli/index.ts
new file mode 100644
index 000000000..e5a19ff10
--- /dev/null
+++ b/server/tests/cli/index.ts
@@ -0,0 +1,2 @@
1// Order of the tests we want to execute
2import './reset-password'
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
new file mode 100644
index 000000000..bbf0b3d11
--- /dev/null
+++ b/server/tests/cli/reset-password.ts
@@ -0,0 +1,45 @@
1import 'mocha'
2
3import {
4 createUser,
5 execCLI,
6 flushTests,
7 getEnvCli,
8 killallServers,
9 login,
10 runServer,
11 ServerInfo,
12 setAccessTokensToServers
13} from '../utils'
14
15describe('Test reset password scripts', function () {
16 let server: ServerInfo
17
18 before(async function () {
19 this.timeout(30000)
20
21 await flushTests()
22 server = await runServer(1)
23 await setAccessTokensToServers([ server ])
24
25 await createUser(server.url, server.accessToken, 'user_1', 'super password')
26 })
27
28 it('Should change the user password from CLI', async function () {
29 this.timeout(20000)
30
31 const env = getEnvCli(server)
32 await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`)
33
34 await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, 200)
35 })
36
37 after(async function () {
38 killallServers([ server ])
39
40 // Keep the logs if the test failed
41 if (this['ok']) {
42 await flushTests()
43 }
44 })
45})
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
new file mode 100644
index 000000000..af9703b32
--- /dev/null
+++ b/server/tests/cli/update-host.ts
@@ -0,0 +1,71 @@
1import 'mocha'
2import * as chai from 'chai'
3const expect = chai.expect
4
5import {
6 execCLI,
7 flushTests,
8 getEnvCli,
9 getVideosList,
10 killallServers,
11 parseTorrentVideo,
12 runServer,
13 ServerInfo,
14 setAccessTokensToServers,
15 uploadVideo
16} from '../utils'
17
18describe('Test update host scripts', function () {
19 let server: ServerInfo
20
21 before(async function () {
22 this.timeout(30000)
23
24 await flushTests()
25
26 const overrideConfig = {
27 webserver: {
28 port: 9256
29 }
30 }
31 server = await runServer(1, overrideConfig)
32 await setAccessTokensToServers([ server ])
33
34 // Upload two videos for our needs
35 const videoAttributes = {}
36 await uploadVideo(server.url, server.accessToken, videoAttributes)
37 await uploadVideo(server.url, server.accessToken, videoAttributes)
38 })
39
40 it('Should update torrent hosts', async function () {
41 this.timeout(20000)
42
43 killallServers([ server ])
44 server = await runServer(1)
45
46 const env = getEnvCli(server)
47 await execCLI(`${env} npm run update-host`)
48
49 const res = await getVideosList(server.url)
50 const videos = res.body.data
51
52 expect(videos[0].files[0].magnetUri).to.contain('localhost%3A9001%2Ftracker%2Fsocket')
53 expect(videos[0].files[0].magnetUri).to.contain('localhost%3A9001%2Fstatic%2Fwebseed%2F')
54
55 expect(videos[1].files[0].magnetUri).to.contain('localhost%3A9001%2Ftracker%2Fsocket')
56 expect(videos[1].files[0].magnetUri).to.contain('localhost%3A9001%2Fstatic%2Fwebseed%2F')
57
58 const torrent = await parseTorrentVideo(server, videos[0].uuid)
59 expect(torrent.announce[0]).to.equal('ws://localhost:9001/tracker/socket')
60 expect(torrent.urlList[0]).to.contain('http://localhost:9001/static/webseed')
61 })
62
63 after(async function () {
64 killallServers([ server ])
65
66 // Keep the logs if the test failed
67 if (this['ok']) {
68 await flushTests()
69 }
70 })
71})