2018-06-23 09:18:31 +02:00
|
|
|
import {API_ERROR, HTTP_STATUS} from "../../../src/lib/constants";
|
2018-06-21 08:10:33 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
export default function(server) {
|
|
|
|
describe('npm adduser', () => {
|
2017-04-19 21:15:28 +02:00
|
|
|
const user = String(Math.random());
|
|
|
|
const pass = String(Math.random());
|
2018-01-28 02:40:07 +01:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
beforeAll(function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.auth(user, pass)
|
2018-06-21 08:10:33 +02:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_ok(/user .* created/);
|
|
|
|
});
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
test('should create new user', () => {});
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
test('should log in', () => {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.auth(user, pass)
|
2018-06-21 08:10:33 +02:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_ok(/you are authenticated as/);
|
|
|
|
});
|
2014-07-22 23:45:28 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
test('should not register more users', () => {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.auth(String(Math.random()), String(Math.random()))
|
2018-06-21 08:10:33 +02:00
|
|
|
.status(HTTP_STATUS.CONFLICT)
|
2018-06-23 09:18:31 +02:00
|
|
|
.body_error(API_ERROR.MAX_USERS_REACHED);
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
|
|
|
});
|
2017-12-02 11:19:08 +01:00
|
|
|
}
|