]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable no-unused-expressions */ | |
2 | ||
3 | 'use strict' | |
4 | ||
5 | const chai = require('chai') | |
6 | const expect = chai.expect | |
7 | const series = require('async/series') | |
8 | ||
9 | const serversUtils = require('../utils/servers') | |
10 | const configUtils = require('../utils/config') | |
11 | const usersUtils = require('../utils/users') | |
12 | ||
13 | describe('Test config', function () { | |
14 | let server = null | |
15 | ||
16 | before(function (done) { | |
17 | this.timeout(120000) | |
18 | ||
19 | series([ | |
20 | function (next) { | |
21 | serversUtils.flushTests(next) | |
22 | }, | |
23 | function (next) { | |
24 | serversUtils.runServer(1, function (server1) { | |
25 | server = server1 | |
26 | next() | |
27 | }) | |
28 | } | |
29 | ], done) | |
30 | }) | |
31 | ||
32 | it('Should have a correct config on a server with registration enabled', function (done) { | |
33 | configUtils.getConfig(server.url, function (err, res) { | |
34 | if (err) throw err | |
35 | ||
36 | const data = res.body | |
37 | ||
38 | expect(data.signup.allowed).to.be.true | |
39 | ||
40 | done() | |
41 | }) | |
42 | }) | |
43 | ||
44 | it('Should have a correct config on a server with registration enabled and a users limit', function (done) { | |
45 | series([ | |
46 | function (next) { | |
47 | usersUtils.registerUser(server.url, 'user1', 'super password', next) | |
48 | }, | |
49 | ||
50 | function (next) { | |
51 | usersUtils.registerUser(server.url, 'user2', 'super password', next) | |
52 | }, | |
53 | ||
54 | function (next) { | |
55 | usersUtils.registerUser(server.url, 'user3', 'super password', next) | |
56 | } | |
57 | ||
58 | ], function (err) { | |
59 | if (err) throw err | |
60 | ||
61 | configUtils.getConfig(server.url, function (err, res) { | |
62 | if (err) throw err | |
63 | ||
64 | const data = res.body | |
65 | ||
66 | expect(data.signup.allowed).to.be.false | |
67 | ||
68 | done() | |
69 | }) | |
70 | }) | |
71 | }) | |
72 | ||
73 | after(function (done) { | |
74 | process.kill(-server.app.pid) | |
75 | ||
76 | // Keep the logs if the test failed | |
77 | if (this.ok) { | |
78 | serversUtils.flushTests(done) | |
79 | } else { | |
80 | done() | |
81 | } | |
82 | }) | |
83 | }) |