2017-12-02 11:19:08 +01:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
2017-04-19 21:15:28 +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());
|
2017-12-02 11:19:08 +01:00
|
|
|
beforeAll(function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.auth(user, pass)
|
|
|
|
.status(201)
|
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)
|
|
|
|
.status(201)
|
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()))
|
|
|
|
.status(409)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_error(/maximum amount of users reached/);
|
|
|
|
});
|
|
|
|
});
|
2017-01-19 16:14:39 +01:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
describe('should adduser created with htpasswd', () => {
|
2017-08-06 21:54:15 +02:00
|
|
|
const user = 'preexisting';
|
|
|
|
const pass = 'preexisting';
|
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
beforeAll(function() {
|
2017-01-19 16:14:39 +01:00
|
|
|
return fs.appendFileSync(
|
2017-08-06 21:54:15 +02:00
|
|
|
path.join(__dirname, '../store/test-storage', '.htpasswd'),
|
2017-01-19 16:14:39 +01:00
|
|
|
'preexisting:$apr1$4YSboUa9$yVKjE7.PxIOuK3M4D7VjX.'
|
2017-04-19 21:15:28 +02:00
|
|
|
);
|
|
|
|
});
|
2017-08-06 21:54:15 +02:00
|
|
|
|
2017-12-02 11:19:08 +01:00
|
|
|
test('should log in', () => {
|
2017-01-19 16:14:39 +01:00
|
|
|
return server.auth(user, pass)
|
|
|
|
.status(201)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_ok(/you are authenticated as/);
|
|
|
|
});
|
|
|
|
});
|
2017-12-02 11:19:08 +01:00
|
|
|
}
|