diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2022-06-21 15:31:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 15:31:25 +0200 |
commit | 2e401e8575decb1d491d0db48ca1ab1eba5b2a66 (patch) | |
tree | eee1e6213ca4d635837ca01c2bdc5c876b8d8b7d /server/tests/api | |
parent | dec49521556fc228c6e05b6199e9b07f619b38fb (diff) | |
download | PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.gz PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.zst PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.zip |
store uploaded video filename (#4885)
* store uploaded video filename
closes #4731
* dont crash if videos channel exist
* migration: use raw query
* video source: fixes after code review
* cleanup
* bump migration
* updates after code review
* refactor: use checkUserCanManageVideo
* videoSource: add openapi doc
* test(check-params/video-source): fix timeout
* Styling
* Correctly set original filename as source
Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/index.ts | 11 | ||||
-rw-r--r-- | server/tests/api/check-params/video-source.ts | 44 | ||||
-rw-r--r-- | server/tests/api/videos/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/videos/video-source.ts | 39 |
4 files changed, 90 insertions, 5 deletions
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 259d7e783..a27bc8509 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -3,14 +3,14 @@ import './accounts' | |||
3 | import './blocklist' | 3 | import './blocklist' |
4 | import './bulk' | 4 | import './bulk' |
5 | import './config' | 5 | import './config' |
6 | import './custom-pages' | ||
7 | import './contact-form' | 6 | import './contact-form' |
7 | import './custom-pages' | ||
8 | import './debug' | 8 | import './debug' |
9 | import './follows' | 9 | import './follows' |
10 | import './jobs' | 10 | import './jobs' |
11 | import './live' | ||
11 | import './logs' | 12 | import './logs' |
12 | import './my-user' | 13 | import './my-user' |
13 | import './live' | ||
14 | import './plugins' | 14 | import './plugins' |
15 | import './redundancy' | 15 | import './redundancy' |
16 | import './search' | 16 | import './search' |
@@ -25,12 +25,13 @@ import './video-blacklist' | |||
25 | import './video-captions' | 25 | import './video-captions' |
26 | import './video-channels' | 26 | import './video-channels' |
27 | import './video-comments' | 27 | import './video-comments' |
28 | import './video-studio' | 28 | import './video-files' |
29 | import './video-imports' | 29 | import './video-imports' |
30 | import './video-playlists' | 30 | import './video-playlists' |
31 | import './videos' | 31 | import './video-source' |
32 | import './video-studio' | ||
32 | import './videos-common-filters' | 33 | import './videos-common-filters' |
33 | import './video-files' | ||
34 | import './videos-history' | 34 | import './videos-history' |
35 | import './videos-overviews' | 35 | import './videos-overviews' |
36 | import './videos' | ||
36 | import './views' | 37 | import './views' |
diff --git a/server/tests/api/check-params/video-source.ts b/server/tests/api/check-params/video-source.ts new file mode 100644 index 000000000..ca324bb9d --- /dev/null +++ b/server/tests/api/check-params/video-source.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
3 | |||
4 | describe('Test video sources API validator', function () { | ||
5 | let server: PeerTubeServer = null | ||
6 | let uuid: string | ||
7 | let userToken: string | ||
8 | |||
9 | before(async function () { | ||
10 | this.timeout(30000) | ||
11 | |||
12 | server = await createSingleServer(1) | ||
13 | await setAccessTokensToServers([ server ]) | ||
14 | |||
15 | const created = await server.videos.quickUpload({ name: 'video' }) | ||
16 | uuid = created.uuid | ||
17 | |||
18 | userToken = await server.users.generateUserAndToken('user') | ||
19 | }) | ||
20 | |||
21 | it('Should fail without a valid uuid', async function () { | ||
22 | await server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df563d0b0', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | ||
23 | }) | ||
24 | |||
25 | it('Should receive 404 when passing a non existing video id', async function () { | ||
26 | await server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | ||
27 | }) | ||
28 | |||
29 | it('Should not get the source as unauthenticated', async function () { | ||
30 | await server.videos.getSource({ id: uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401, token: null }) | ||
31 | }) | ||
32 | |||
33 | it('Should not get the source with another user', async function () { | ||
34 | await server.videos.getSource({ id: uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403, token: userToken }) | ||
35 | }) | ||
36 | |||
37 | it('Should succeed with the correct parameters get the source as another user', async function () { | ||
38 | await server.videos.getSource({ id: uuid }) | ||
39 | }) | ||
40 | |||
41 | after(async function () { | ||
42 | await cleanupTests([ server ]) | ||
43 | }) | ||
44 | }) | ||
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 27b119f30..a0b6b01cf 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts | |||
@@ -16,3 +16,4 @@ import './video-schedule-update' | |||
16 | import './videos-common-filters' | 16 | import './videos-common-filters' |
17 | import './videos-history' | 17 | import './videos-history' |
18 | import './videos-overview' | 18 | import './videos-overview' |
19 | import './video-source' | ||
diff --git a/server/tests/api/videos/video-source.ts b/server/tests/api/videos/video-source.ts new file mode 100644 index 000000000..e34642300 --- /dev/null +++ b/server/tests/api/videos/video-source.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import 'mocha' | ||
2 | import * as chai from 'chai' | ||
3 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
4 | |||
5 | const expect = chai.expect | ||
6 | |||
7 | describe('Test video source', () => { | ||
8 | let server: PeerTubeServer = null | ||
9 | const fixture = 'video_short.webm' | ||
10 | |||
11 | before(async function () { | ||
12 | this.timeout(30000) | ||
13 | |||
14 | server = await createSingleServer(1) | ||
15 | await setAccessTokensToServers([ server ]) | ||
16 | }) | ||
17 | |||
18 | it('Should get the source filename with legacy upload', async function () { | ||
19 | this.timeout(30000) | ||
20 | |||
21 | const { uuid } = await server.videos.upload({ attributes: { name: 'my video', fixture }, mode: 'legacy' }) | ||
22 | |||
23 | const source = await server.videos.getSource({ id: uuid }) | ||
24 | expect(source.filename).to.equal(fixture) | ||
25 | }) | ||
26 | |||
27 | it('Should get the source filename with resumable upload', async function () { | ||
28 | this.timeout(30000) | ||
29 | |||
30 | const { uuid } = await server.videos.upload({ attributes: { name: 'my video', fixture }, mode: 'resumable' }) | ||
31 | |||
32 | const source = await server.videos.getSource({ id: uuid }) | ||
33 | expect(source.filename).to.equal(fixture) | ||
34 | }) | ||
35 | |||
36 | after(async function () { | ||
37 | await cleanupTests([ server ]) | ||
38 | }) | ||
39 | }) | ||