From 757f0da370a992cf07afd20d3829b2748c76cc15 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Oct 2017 17:27:06 +0200 Subject: Add tests to user roles --- server/tests/utils/users.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'server/tests/utils') diff --git a/server/tests/utils/users.ts b/server/tests/utils/users.ts index e5f3eb1b3..12569dd42 100644 --- a/server/tests/utils/users.ts +++ b/server/tests/utils/users.ts @@ -1,10 +1,21 @@ import * as request from 'supertest' -function createUser (url: string, accessToken: string, username: string, password: string, videoQuota = 1000000, specialStatus = 204) { +import { UserRole } from '../../../shared' + +function createUser ( + url: string, + accessToken: string, + username: string, + password: string, + videoQuota = 1000000, + role: UserRole = UserRole.USER, + specialStatus = 204 +) { const path = '/api/v1/users' const body = { username, password, + role, email: username + '@example.com', videoQuota } @@ -114,12 +125,13 @@ function updateMyUser (url: string, accessToken: string, newPassword: string, di .expect(204) } -function updateUser (url: string, userId: number, accessToken: string, email: string, videoQuota: number) { +function updateUser (url: string, userId: number, accessToken: string, email: string, videoQuota: number, role: UserRole) { const path = '/api/v1/users/' + userId const toSend = {} if (email !== undefined && email !== null) toSend['email'] = email if (videoQuota !== undefined && videoQuota !== null) toSend['videoQuota'] = videoQuota + if (role !== undefined && role !== null) toSend['role'] = role return request(url) .put(path) -- cgit v1.2.3