2014-07-22 23:45:28 +02:00
|
|
|
var assert = require('assert')
|
|
|
|
var Server = require('./lib/server')
|
|
|
|
|
|
|
|
module.exports = function() {
|
2014-11-12 12:14:37 +01:00
|
|
|
var server = new Server('http://localhost:55551/')
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('adduser', function() {
|
|
|
|
var user = String(Math.random())
|
|
|
|
var pass = String(Math.random())
|
|
|
|
before(function(cb) {
|
|
|
|
server.auth(user, pass, function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 201)
|
|
|
|
assert(body.ok.match(/user .* created/))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('creating new user', function(){})
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('should log in', function(cb) {
|
|
|
|
server.auth(user, pass, function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 201)
|
|
|
|
assert(body.ok.match(/you are authenticated as/))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('should not register more users', function(cb) {
|
|
|
|
server.auth(String(Math.random()), String(Math.random()), function(res, body) {
|
2015-02-12 12:28:19 +01:00
|
|
|
assert.equal(res.statusCode, 409)
|
2014-11-12 12:14:37 +01:00
|
|
|
assert(body.error.match(/maximum amount of users reached/))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2014-07-22 23:45:28 +02:00
|
|
|
}
|