]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/config.js
Add ability to limit user registrations
[github/Chocobozzz/PeerTube.git] / server / tests / api / config.js
index e79e12823b3b6fdca9259b7fe0fb9eb574f8f704..f2c00f85a94254f223a56ef3ab5807eb9a5a6fdd 100644 (file)
@@ -8,6 +8,7 @@ const series = require('async/series')
 
 const serversUtils = require('../utils/servers')
 const configUtils = require('../utils/config')
+const usersUtils = require('../utils/users')
 
 describe('Test config', function () {
   let server = null
@@ -28,18 +29,51 @@ describe('Test config', function () {
     ], done)
   })
 
-  it('Should have a correct config', function (done) {
+  it('Should have a correct config on a server with registration enabled', function (done) {
     configUtils.getConfig(server.url, function (err, res) {
       if (err) throw err
 
       const data = res.body
 
-      expect(data.signup.enabled).to.be.truthy
+      expect(data.signup.allowed).to.be.truthy
 
       done()
     })
   })
 
+  it('Should have a correct config on a server with registration enabled and a users limit', function (done) {
+    series([
+      function (next) {
+        usersUtils.registerUser(server.url, 'user1', 'super password', done)
+      },
+
+      function (next) {
+        usersUtils.registerUser(server.url, 'user2', 'super password', done)
+      },
+
+      function (next) {
+        usersUtils.registerUser(server.url, 'user3', 'super password', done)
+      },
+
+      function (next) {
+        usersUtils.registerUser(server.url, 'user4', 'super password', done)
+      }
+
+    ], function (err) {
+      if (err) throw err
+
+      configUtils.getConfig(server.url, function (err, res) {
+        if (err) throw err
+
+        const data = res.body
+
+        expect(data.signup.allowed).to.be.truthy
+
+        done()
+      })
+    })
+  })
+
   after(function (done) {
     process.kill(-server.app.pid)