aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-28 16:28:16 +0200
committerChocobozzz <me@florianbigard.com>2023-07-28 16:33:12 +0200
commit982edf32ae436424e9b1ebf7f13696e4871ce202 (patch)
treeb8ca5ae0c1fb27c014d22d4c5d0df63afbb5443a /server/tests/api
parentce8d0b5aaeb968d774ab2390461eec687d4730f4 (diff)
downloadPeerTube-982edf32ae436424e9b1ebf7f13696e4871ce202.tar.gz
PeerTube-982edf32ae436424e9b1ebf7f13696e4871ce202.tar.zst
PeerTube-982edf32ae436424e9b1ebf7f13696e4871ce202.zip
Remove deprecated video query filter
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/videos-common-filters.ts73
-rw-r--r--server/tests/api/videos/videos-common-filters.ts74
2 files changed, 0 insertions, 147 deletions
diff --git a/server/tests/api/check-params/videos-common-filters.ts b/server/tests/api/check-params/videos-common-filters.ts
index 3e44e2f67..603f7f777 100644
--- a/server/tests/api/check-params/videos-common-filters.ts
+++ b/server/tests/api/check-params/videos-common-filters.ts
@@ -35,79 +35,6 @@ describe('Test video filters validators', function () {
35 moderatorAccessToken = await server.login.getAccessToken(moderator) 35 moderatorAccessToken = await server.login.getAccessToken(moderator)
36 }) 36 })
37 37
38 describe('When setting a deprecated video filter', function () {
39
40 async function testEndpoints (token: string, filter: string, expectedStatus: HttpStatusCode) {
41 const paths = [
42 '/api/v1/video-channels/root_channel/videos',
43 '/api/v1/accounts/root/videos',
44 '/api/v1/videos',
45 '/api/v1/search/videos',
46 '/api/v1/users/me/subscriptions/videos'
47 ]
48
49 for (const path of paths) {
50 await makeGetRequest({
51 url: server.url,
52 path,
53 token,
54 query: {
55 filter
56 },
57 expectedStatus
58 })
59 }
60 }
61
62 it('Should fail with a bad filter', async function () {
63 await testEndpoints(server.accessToken, 'bad-filter', HttpStatusCode.BAD_REQUEST_400)
64 })
65
66 it('Should succeed with a good filter', async function () {
67 await testEndpoints(server.accessToken, 'local', HttpStatusCode.OK_200)
68 })
69
70 it('Should fail to list all-local/all with a simple user', async function () {
71 await testEndpoints(userAccessToken, 'all-local', HttpStatusCode.UNAUTHORIZED_401)
72 await testEndpoints(userAccessToken, 'all', HttpStatusCode.UNAUTHORIZED_401)
73 })
74
75 it('Should succeed to list all-local/all with a moderator', async function () {
76 await testEndpoints(moderatorAccessToken, 'all-local', HttpStatusCode.OK_200)
77 await testEndpoints(moderatorAccessToken, 'all', HttpStatusCode.OK_200)
78 })
79
80 it('Should succeed to list all-local/all with an admin', async function () {
81 await testEndpoints(server.accessToken, 'all-local', HttpStatusCode.OK_200)
82 await testEndpoints(server.accessToken, 'all', HttpStatusCode.OK_200)
83 })
84
85 // Because we cannot authenticate the user on the RSS endpoint
86 it('Should fail on the feeds endpoint with the all-local/all filter', async function () {
87 for (const filter of [ 'all', 'all-local' ]) {
88 await makeGetRequest({
89 url: server.url,
90 path: '/feeds/videos.json',
91 expectedStatus: HttpStatusCode.UNAUTHORIZED_401,
92 query: {
93 filter
94 }
95 })
96 }
97 })
98
99 it('Should succeed on the feeds endpoint with the local filter', async function () {
100 await makeGetRequest({
101 url: server.url,
102 path: '/feeds/videos.json',
103 expectedStatus: HttpStatusCode.OK_200,
104 query: {
105 filter: 'local'
106 }
107 })
108 })
109 })
110
111 describe('When setting video filters', function () { 38 describe('When setting video filters', function () {
112 39
113 const validIncludes = [ 40 const validIncludes = [
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts
index fac0f5dc5..48de7c537 100644
--- a/server/tests/api/videos/videos-common-filters.ts
+++ b/server/tests/api/videos/videos-common-filters.ts
@@ -74,80 +74,6 @@ describe('Test videos filter', function () {
74 ] 74 ]
75 }) 75 })
76 76
77 describe('Check deprecated videos filter', function () {
78
79 async function getVideosNames (options: {
80 server: PeerTubeServer
81 token: string
82 filter: string
83 skipSubscription?: boolean
84 expectedStatus?: HttpStatusCode
85 }) {
86 const { server, token, filter, skipSubscription = false, expectedStatus = HttpStatusCode.OK_200 } = options
87
88 const videosResults: Video[][] = []
89
90 for (const path of paths) {
91 if (skipSubscription && path === subscriptionVideosPath) continue
92
93 const res = await makeGetRequest({
94 url: server.url,
95 path,
96 token,
97 query: {
98 sort: 'createdAt',
99 filter
100 },
101 expectedStatus
102 })
103
104 videosResults.push(res.body.data.map(v => v.name))
105 }
106
107 return videosResults
108 }
109
110 it('Should display local videos', async function () {
111 for (const server of servers) {
112 const namesResults = await getVideosNames({ server, token: server.accessToken, filter: 'local' })
113 for (const names of namesResults) {
114 expect(names).to.have.lengthOf(1)
115 expect(names[0]).to.equal('public ' + server.serverNumber)
116 }
117 }
118 })
119
120 it('Should display all local videos by the admin or the moderator', async function () {
121 for (const server of servers) {
122 for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
123
124 const namesResults = await getVideosNames({ server, token, filter: 'all-local', skipSubscription: true })
125 for (const names of namesResults) {
126 expect(names).to.have.lengthOf(3)
127
128 expect(names[0]).to.equal('public ' + server.serverNumber)
129 expect(names[1]).to.equal('unlisted ' + server.serverNumber)
130 expect(names[2]).to.equal('private ' + server.serverNumber)
131 }
132 }
133 }
134 })
135
136 it('Should display all videos by the admin or the moderator', async function () {
137 for (const server of servers) {
138 for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
139
140 const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({ server, token, filter: 'all' })
141 expect(channelVideos).to.have.lengthOf(3)
142 expect(accountVideos).to.have.lengthOf(3)
143
144 expect(videos).to.have.lengthOf(5)
145 expect(searchVideos).to.have.lengthOf(5)
146 }
147 }
148 })
149 })
150
151 describe('Check videos filters', function () { 77 describe('Check videos filters', function () {
152 78
153 async function listVideos (options: { 79 async function listVideos (options: {