aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/users.ts8
-rw-r--r--server/tests/api/users/users.ts17
-rw-r--r--server/tests/utils/users/users.ts11
3 files changed, 34 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 62faabc54..60165ae22 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -8,7 +8,7 @@ import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
8import { 8import {
9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, 9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers, 10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
11 updateUser, uploadVideo, userLogin 11 updateUser, uploadVideo, userLogin, deleteMe
12} from '../../utils' 12} from '../../utils'
13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
14import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports' 14import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports'
@@ -469,6 +469,12 @@ describe('Test users API validators', function () {
469 }) 469 })
470 }) 470 })
471 471
472 describe('When deleting our account', function () {
473 it('Should fail with with the root account', async function () {
474 await deleteMe(server.url, server.accessToken, 400)
475 })
476 })
477
472 describe('When register a new user', function () { 478 describe('When register a new user', function () {
473 const registrationPath = path + '/register' 479 const registrationPath = path + '/register'
474 const baseCorrectParams = { 480 const baseCorrectParams = {
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 1ea599859..c9e8eb6f9 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -6,7 +6,8 @@ import { UserRole } from '../../../../shared/index'
6import { 6import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating,
8 getUserInformation, getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, 8 getUserInformation, getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo,
9 registerUser, removeUser, removeVideo, runServer, ServerInfo, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo, userLogin 9 registerUser, removeUser, removeVideo, runServer, ServerInfo, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo, userLogin,
10 deleteMe
10} from '../../utils/index' 11} from '../../utils/index'
11import { follow } from '../../utils/server/follows' 12import { follow } from '../../utils/server/follows'
12import { setAccessTokensToServers } from '../../utils/users/login' 13import { setAccessTokensToServers } from '../../utils/users/login'
@@ -478,6 +479,20 @@ describe('Test users', function () {
478 expect(user.videoQuota).to.equal(5 * 1024 * 1024) 479 expect(user.videoQuota).to.equal(5 * 1024 * 1024)
479 }) 480 })
480 481
482 it('Should remove me', async function () {
483 {
484 const res = await getUsersList(server.url, server.accessToken)
485 expect(res.body.data.find(u => u.username === 'user_15')).to.not.be.undefined
486 }
487
488 await deleteMe(server.url, accessToken)
489
490 {
491 const res = await getUsersList(server.url, server.accessToken)
492 expect(res.body.data.find(u => u.username === 'user_15')).to.be.undefined
493 }
494 })
495
481 after(async function () { 496 after(async function () {
482 killallServers([ server ]) 497 killallServers([ server ])
483 498
diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts
index 37b15f64a..e24e721bd 100644
--- a/server/tests/utils/users/users.ts
+++ b/server/tests/utils/users/users.ts
@@ -56,6 +56,16 @@ function getMyUserInformation (url: string, accessToken: string, specialStatus =
56 .expect('Content-Type', /json/) 56 .expect('Content-Type', /json/)
57} 57}
58 58
59function deleteMe (url: string, accessToken: string, specialStatus = 204) {
60 const path = '/api/v1/users/me'
61
62 return request(url)
63 .delete(path)
64 .set('Accept', 'application/json')
65 .set('Authorization', 'Bearer ' + accessToken)
66 .expect(specialStatus)
67}
68
59function getMyUserVideoQuotaUsed (url: string, accessToken: string, specialStatus = 200) { 69function getMyUserVideoQuotaUsed (url: string, accessToken: string, specialStatus = 200) {
60 const path = '/api/v1/users/me/video-quota-used' 70 const path = '/api/v1/users/me/video-quota-used'
61 71
@@ -216,6 +226,7 @@ export {
216 registerUser, 226 registerUser,
217 getMyUserInformation, 227 getMyUserInformation,
218 getMyUserVideoRating, 228 getMyUserVideoRating,
229 deleteMe,
219 getMyUserVideoQuotaUsed, 230 getMyUserVideoQuotaUsed,
220 getUsersList, 231 getUsersList,
221 getUsersListPaginationAndSort, 232 getUsersListPaginationAndSort,