]>
Commit | Line | Data |
---|---|---|
e22528ac C |
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') | |
291e8d3e | 11 | const usersUtils = require('../utils/users') |
e22528ac C |
12 | |
13 | describe('Test config', function () { | |
14 | let server = null | |
15 | ||
16 | before(function (done) { | |
5fe7e898 | 17 | this.timeout(120000) |
e22528ac C |
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 | ||
291e8d3e | 32 | it('Should have a correct config on a server with registration enabled', function (done) { |
e22528ac C |
33 | configUtils.getConfig(server.url, function (err, res) { |
34 | if (err) throw err | |
35 | ||
36 | const data = res.body | |
37 | ||
291e8d3e | 38 | expect(data.signup.allowed).to.be.truthy |
e22528ac C |
39 | |
40 | done() | |
41 | }) | |
42 | }) | |
43 | ||
291e8d3e C |
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', done) | |
48 | }, | |
49 | ||
50 | function (next) { | |
51 | usersUtils.registerUser(server.url, 'user2', 'super password', done) | |
52 | }, | |
53 | ||
54 | function (next) { | |
55 | usersUtils.registerUser(server.url, 'user3', 'super password', done) | |
56 | }, | |
57 | ||
58 | function (next) { | |
59 | usersUtils.registerUser(server.url, 'user4', 'super password', done) | |
60 | } | |
61 | ||
62 | ], function (err) { | |
63 | if (err) throw err | |
64 | ||
65 | configUtils.getConfig(server.url, function (err, res) { | |
66 | if (err) throw err | |
67 | ||
68 | const data = res.body | |
69 | ||
70 | expect(data.signup.allowed).to.be.truthy | |
71 | ||
72 | done() | |
73 | }) | |
74 | }) | |
75 | }) | |
76 | ||
e22528ac C |
77 | after(function (done) { |
78 | process.kill(-server.app.pid) | |
79 | ||
80 | // Keep the logs if the test failed | |
81 | if (this.ok) { | |
82 | serversUtils.flushTests(done) | |
83 | } else { | |
84 | done() | |
85 | } | |
86 | }) | |
87 | }) |