diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-04-09 12:08:36 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-04-09 12:08:36 +0200 |
commit | 2c2e90921646d223060e98d517fc8ac61c90eb9e (patch) | |
tree | cc36bfa79f0809e8c9602492788ef95b3521e003 /server/tests/utils | |
parent | db216afd980846c418a4ebab8190c3ead561dfc1 (diff) | |
download | PeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.tar.gz PeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.tar.zst PeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.zip |
Server: add ability to register new user
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/users.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/tests/utils/users.js b/server/tests/utils/users.js index 8138074d0..310dc0c6b 100644 --- a/server/tests/utils/users.js +++ b/server/tests/utils/users.js | |||
@@ -4,6 +4,7 @@ const request = require('supertest') | |||
4 | 4 | ||
5 | const usersUtils = { | 5 | const usersUtils = { |
6 | createUser, | 6 | createUser, |
7 | registerUser, | ||
7 | getUserInformation, | 8 | getUserInformation, |
8 | getUserVideoRating, | 9 | getUserVideoRating, |
9 | getUsersList, | 10 | getUsersList, |
@@ -36,6 +37,27 @@ function createUser (url, accessToken, username, password, specialStatus, end) { | |||
36 | .end(end) | 37 | .end(end) |
37 | } | 38 | } |
38 | 39 | ||
40 | function registerUser (url, username, password, specialStatus, end) { | ||
41 | if (!end) { | ||
42 | end = specialStatus | ||
43 | specialStatus = 204 | ||
44 | } | ||
45 | |||
46 | const path = '/api/v1/users/register' | ||
47 | const body = { | ||
48 | username, | ||
49 | password, | ||
50 | email: username + '@example.com' | ||
51 | } | ||
52 | |||
53 | request(url) | ||
54 | .post(path) | ||
55 | .set('Accept', 'application/json') | ||
56 | .send(body) | ||
57 | .expect(specialStatus) | ||
58 | .end(end) | ||
59 | } | ||
60 | |||
39 | function getUserInformation (url, accessToken, end) { | 61 | function getUserInformation (url, accessToken, end) { |
40 | const path = '/api/v1/users/me' | 62 | const path = '/api/v1/users/me' |
41 | 63 | ||