aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-files.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/video-files.ts')
-rw-r--r--server/tests/api/check-params/video-files.ts80
1 files changed, 60 insertions, 20 deletions
diff --git a/server/tests/api/check-params/video-files.ts b/server/tests/api/check-params/video-files.ts
index 8c0795092..c698bea82 100644
--- a/server/tests/api/check-params/video-files.ts
+++ b/server/tests/api/check-params/video-files.ts
@@ -24,6 +24,12 @@ describe('Test videos files', function () {
24 let validId1: string 24 let validId1: string
25 let validId2: string 25 let validId2: string
26 26
27 let hlsFileId: number
28 let webtorrentFileId: number
29
30 let remoteHLSFileId: number
31 let remoteWebtorrentFileId: number
32
27 // --------------------------------------------------------------- 33 // ---------------------------------------------------------------
28 34
29 before(async function () { 35 before(async function () {
@@ -39,7 +45,12 @@ describe('Test videos files', function () {
39 45
40 { 46 {
41 const { uuid } = await servers[1].videos.quickUpload({ name: 'remote video' }) 47 const { uuid } = await servers[1].videos.quickUpload({ name: 'remote video' })
42 remoteId = uuid 48 await waitJobs(servers)
49
50 const video = await servers[1].videos.get({ id: uuid })
51 remoteId = video.uuid
52 remoteHLSFileId = video.streamingPlaylists[0].files[0].id
53 remoteWebtorrentFileId = video.files[0].id
43 } 54 }
44 55
45 { 56 {
@@ -47,7 +58,12 @@ describe('Test videos files', function () {
47 58
48 { 59 {
49 const { uuid } = await servers[0].videos.quickUpload({ name: 'both 1' }) 60 const { uuid } = await servers[0].videos.quickUpload({ name: 'both 1' })
50 validId1 = uuid 61 await waitJobs(servers)
62
63 const video = await servers[0].videos.get({ id: uuid })
64 validId1 = video.uuid
65 hlsFileId = video.streamingPlaylists[0].files[0].id
66 webtorrentFileId = video.files[0].id
51 } 67 }
52 68
53 { 69 {
@@ -76,43 +92,67 @@ describe('Test videos files', function () {
76 }) 92 })
77 93
78 it('Should not delete files of a unknown video', async function () { 94 it('Should not delete files of a unknown video', async function () {
79 await servers[0].videos.removeHLSFiles({ videoId: 404, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 95 const expectedStatus = HttpStatusCode.NOT_FOUND_404
80 await servers[0].videos.removeWebTorrentFiles({ videoId: 404, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 96
97 await servers[0].videos.removeHLSPlaylist({ videoId: 404, expectedStatus })
98 await servers[0].videos.removeAllWebTorrentFiles({ videoId: 404, expectedStatus })
99
100 await servers[0].videos.removeHLSFile({ videoId: 404, fileId: hlsFileId, expectedStatus })
101 await servers[0].videos.removeWebTorrentFile({ videoId: 404, fileId: webtorrentFileId, expectedStatus })
102 })
103
104 it('Should not delete unknown files', async function () {
105 const expectedStatus = HttpStatusCode.NOT_FOUND_404
106
107 await servers[0].videos.removeHLSFile({ videoId: validId1, fileId: webtorrentFileId, expectedStatus })
108 await servers[0].videos.removeWebTorrentFile({ videoId: validId1, fileId: hlsFileId, expectedStatus })
81 }) 109 })
82 110
83 it('Should not delete files of a remote video', async function () { 111 it('Should not delete files of a remote video', async function () {
84 await servers[0].videos.removeHLSFiles({ videoId: remoteId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 112 const expectedStatus = HttpStatusCode.BAD_REQUEST_400
85 await servers[0].videos.removeWebTorrentFiles({ videoId: remoteId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 113
114 await servers[0].videos.removeHLSPlaylist({ videoId: remoteId, expectedStatus })
115 await servers[0].videos.removeAllWebTorrentFiles({ videoId: remoteId, expectedStatus })
116
117 await servers[0].videos.removeHLSFile({ videoId: remoteId, fileId: remoteHLSFileId, expectedStatus })
118 await servers[0].videos.removeWebTorrentFile({ videoId: remoteId, fileId: remoteWebtorrentFileId, expectedStatus })
86 }) 119 })
87 120
88 it('Should not delete files by a non admin user', async function () { 121 it('Should not delete files by a non admin user', async function () {
89 const expectedStatus = HttpStatusCode.FORBIDDEN_403 122 const expectedStatus = HttpStatusCode.FORBIDDEN_403
90 123
91 await servers[0].videos.removeHLSFiles({ videoId: validId1, token: userToken, expectedStatus }) 124 await servers[0].videos.removeHLSPlaylist({ videoId: validId1, token: userToken, expectedStatus })
92 await servers[0].videos.removeHLSFiles({ videoId: validId1, token: moderatorToken, expectedStatus }) 125 await servers[0].videos.removeHLSPlaylist({ videoId: validId1, token: moderatorToken, expectedStatus })
126
127 await servers[0].videos.removeAllWebTorrentFiles({ videoId: validId1, token: userToken, expectedStatus })
128 await servers[0].videos.removeAllWebTorrentFiles({ videoId: validId1, token: moderatorToken, expectedStatus })
93 129
94 await servers[0].videos.removeWebTorrentFiles({ videoId: validId1, token: userToken, expectedStatus }) 130 await servers[0].videos.removeHLSFile({ videoId: validId1, fileId: hlsFileId, token: userToken, expectedStatus })
95 await servers[0].videos.removeWebTorrentFiles({ videoId: validId1, token: moderatorToken, expectedStatus }) 131 await servers[0].videos.removeHLSFile({ videoId: validId1, fileId: hlsFileId, token: moderatorToken, expectedStatus })
132
133 await servers[0].videos.removeWebTorrentFile({ videoId: validId1, fileId: webtorrentFileId, token: userToken, expectedStatus })
134 await servers[0].videos.removeWebTorrentFile({ videoId: validId1, fileId: webtorrentFileId, token: moderatorToken, expectedStatus })
96 }) 135 })
97 136
98 it('Should not delete files if the files are not available', async function () { 137 it('Should not delete files if the files are not available', async function () {
99 await servers[0].videos.removeHLSFiles({ videoId: hlsId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 138 await servers[0].videos.removeHLSPlaylist({ videoId: hlsId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
100 await servers[0].videos.removeWebTorrentFiles({ videoId: webtorrentId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 139 await servers[0].videos.removeAllWebTorrentFiles({ videoId: webtorrentId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
101 })
102 140
103 it('Should not delete files if no both versions are available', async function () { 141 await servers[0].videos.removeHLSFile({ videoId: hlsId, fileId: 404, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
104 await servers[0].videos.removeHLSFiles({ videoId: hlsId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 142 await servers[0].videos.removeWebTorrentFile({ videoId: webtorrentId, fileId: 404, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
105 await servers[0].videos.removeWebTorrentFiles({ videoId: webtorrentId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
106 }) 143 })
107 144
108 it('Should not delete files if no both versions are available', async function () { 145 it('Should not delete files if no both versions are available', async function () {
109 await servers[0].videos.removeHLSFiles({ videoId: hlsId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 146 await servers[0].videos.removeHLSPlaylist({ videoId: hlsId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
110 await servers[0].videos.removeWebTorrentFiles({ videoId: webtorrentId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 147 await servers[0].videos.removeAllWebTorrentFiles({ videoId: webtorrentId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
111 }) 148 })
112 149
113 it('Should delete files if both versions are available', async function () { 150 it('Should delete files if both versions are available', async function () {
114 await servers[0].videos.removeHLSFiles({ videoId: validId1 }) 151 await servers[0].videos.removeHLSFile({ videoId: validId1, fileId: hlsFileId })
115 await servers[0].videos.removeWebTorrentFiles({ videoId: validId2 }) 152 await servers[0].videos.removeWebTorrentFile({ videoId: validId1, fileId: webtorrentFileId })
153
154 await servers[0].videos.removeHLSPlaylist({ videoId: validId1 })
155 await servers[0].videos.removeAllWebTorrentFiles({ videoId: validId2 })
116 }) 156 })
117 157
118 after(async function () { 158 after(async function () {