aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/peertube.ts
blob: e5038838efcd7fc9a711aa3700a6379bf1ec45e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'mocha'
import {
  expect
} from 'chai'
import {
  createUser,
  execCLI,
  flushTests,
  getEnvCli,
  killallServers,
  runServer,
  ServerInfo,
  setAccessTokensToServers
} from '../../../shared/utils'

describe('Test CLI wrapper', function () {
  let server: ServerInfo
  const cmd = 'node ./dist/server/tools/peertube.js'

  before(async function () {
    this.timeout(30000)

    await flushTests()
    server = await runServer(1)
    await setAccessTokensToServers([ server ])

    await createUser(server.url, server.accessToken, 'user_1', 'super password')
  })

  it('Should display no selected instance', async function () {
    this.timeout(60000)

    const env = getEnvCli(server)
    const stdout = await execCLI(`${env} ${cmd} --help`)

    expect(stdout).to.contain('selected')
  })

  it('Should remember the authentifying material of the user', async function () {
    this.timeout(60000)

    const env = getEnvCli(server)
    await execCLI(`${env} ` + cmd + ` auth add --url ${server.url} -U user_1 -p "super password"`)
  })

  after(async function () {
    await execCLI(cmd + ` auth del ${server.url}`)

    killallServers([ server ])
  })
})