diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/misc-endpoints.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/misc-endpoints.ts')
-rw-r--r-- | server/tests/misc-endpoints.ts | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 09e5afcf9..4968eef08 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts | |||
@@ -2,28 +2,18 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
6 | addVideoChannel, | 6 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
7 | cleanupTests, | ||
8 | createUser, | ||
9 | flushAndRunServer, | ||
10 | makeGetRequest, | ||
11 | ServerInfo, | ||
12 | setAccessTokensToServers, | ||
13 | uploadVideo | ||
14 | } from '../../shared/extra-utils' | ||
15 | import { VideoPrivacy } from '../../shared/models/videos' | ||
16 | import { HttpStatusCode } from '@shared/core-utils' | ||
17 | 7 | ||
18 | const expect = chai.expect | 8 | const expect = chai.expect |
19 | 9 | ||
20 | describe('Test misc endpoints', function () { | 10 | describe('Test misc endpoints', function () { |
21 | let server: ServerInfo | 11 | let server: PeerTubeServer |
22 | 12 | ||
23 | before(async function () { | 13 | before(async function () { |
24 | this.timeout(120000) | 14 | this.timeout(120000) |
25 | 15 | ||
26 | server = await flushAndRunServer(1) | 16 | server = await createSingleServer(1) |
27 | await setAccessTokensToServers([ server ]) | 17 | await setAccessTokensToServers([ server ]) |
28 | }) | 18 | }) |
29 | 19 | ||
@@ -33,7 +23,7 @@ describe('Test misc endpoints', function () { | |||
33 | const res = await makeGetRequest({ | 23 | const res = await makeGetRequest({ |
34 | url: server.url, | 24 | url: server.url, |
35 | path: '/.well-known/security.txt', | 25 | path: '/.well-known/security.txt', |
36 | statusCodeExpected: HttpStatusCode.OK_200 | 26 | expectedStatus: HttpStatusCode.OK_200 |
37 | }) | 27 | }) |
38 | 28 | ||
39 | expect(res.text).to.contain('security issue') | 29 | expect(res.text).to.contain('security issue') |
@@ -43,7 +33,7 @@ describe('Test misc endpoints', function () { | |||
43 | const res = await makeGetRequest({ | 33 | const res = await makeGetRequest({ |
44 | url: server.url, | 34 | url: server.url, |
45 | path: '/.well-known/nodeinfo', | 35 | path: '/.well-known/nodeinfo', |
46 | statusCodeExpected: HttpStatusCode.OK_200 | 36 | expectedStatus: HttpStatusCode.OK_200 |
47 | }) | 37 | }) |
48 | 38 | ||
49 | expect(res.body.links).to.be.an('array') | 39 | expect(res.body.links).to.be.an('array') |
@@ -55,7 +45,7 @@ describe('Test misc endpoints', function () { | |||
55 | const res = await makeGetRequest({ | 45 | const res = await makeGetRequest({ |
56 | url: server.url, | 46 | url: server.url, |
57 | path: '/.well-known/dnt-policy.txt', | 47 | path: '/.well-known/dnt-policy.txt', |
58 | statusCodeExpected: HttpStatusCode.OK_200 | 48 | expectedStatus: HttpStatusCode.OK_200 |
59 | }) | 49 | }) |
60 | 50 | ||
61 | expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt') | 51 | expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt') |
@@ -65,7 +55,7 @@ describe('Test misc endpoints', function () { | |||
65 | const res = await makeGetRequest({ | 55 | const res = await makeGetRequest({ |
66 | url: server.url, | 56 | url: server.url, |
67 | path: '/.well-known/dnt', | 57 | path: '/.well-known/dnt', |
68 | statusCodeExpected: HttpStatusCode.OK_200 | 58 | expectedStatus: HttpStatusCode.OK_200 |
69 | }) | 59 | }) |
70 | 60 | ||
71 | expect(res.body.tracking).to.equal('N') | 61 | expect(res.body.tracking).to.equal('N') |
@@ -75,7 +65,7 @@ describe('Test misc endpoints', function () { | |||
75 | const res = await makeGetRequest({ | 65 | const res = await makeGetRequest({ |
76 | url: server.url, | 66 | url: server.url, |
77 | path: '/.well-known/change-password', | 67 | path: '/.well-known/change-password', |
78 | statusCodeExpected: HttpStatusCode.FOUND_302 | 68 | expectedStatus: HttpStatusCode.FOUND_302 |
79 | }) | 69 | }) |
80 | 70 | ||
81 | expect(res.header.location).to.equal('/my-account/settings') | 71 | expect(res.header.location).to.equal('/my-account/settings') |
@@ -88,7 +78,7 @@ describe('Test misc endpoints', function () { | |||
88 | const res = await makeGetRequest({ | 78 | const res = await makeGetRequest({ |
89 | url: server.url, | 79 | url: server.url, |
90 | path: '/.well-known/webfinger?resource=' + resource, | 80 | path: '/.well-known/webfinger?resource=' + resource, |
91 | statusCodeExpected: HttpStatusCode.OK_200 | 81 | expectedStatus: HttpStatusCode.OK_200 |
92 | }) | 82 | }) |
93 | 83 | ||
94 | const data = res.body | 84 | const data = res.body |
@@ -113,7 +103,7 @@ describe('Test misc endpoints', function () { | |||
113 | const res = await makeGetRequest({ | 103 | const res = await makeGetRequest({ |
114 | url: server.url, | 104 | url: server.url, |
115 | path: '/robots.txt', | 105 | path: '/robots.txt', |
116 | statusCodeExpected: HttpStatusCode.OK_200 | 106 | expectedStatus: HttpStatusCode.OK_200 |
117 | }) | 107 | }) |
118 | 108 | ||
119 | expect(res.text).to.contain('User-agent') | 109 | expect(res.text).to.contain('User-agent') |
@@ -123,7 +113,7 @@ describe('Test misc endpoints', function () { | |||
123 | await makeGetRequest({ | 113 | await makeGetRequest({ |
124 | url: server.url, | 114 | url: server.url, |
125 | path: '/security.txt', | 115 | path: '/security.txt', |
126 | statusCodeExpected: HttpStatusCode.MOVED_PERMANENTLY_301 | 116 | expectedStatus: HttpStatusCode.MOVED_PERMANENTLY_301 |
127 | }) | 117 | }) |
128 | }) | 118 | }) |
129 | 119 | ||
@@ -131,7 +121,7 @@ describe('Test misc endpoints', function () { | |||
131 | const res = await makeGetRequest({ | 121 | const res = await makeGetRequest({ |
132 | url: server.url, | 122 | url: server.url, |
133 | path: '/nodeinfo/2.0.json', | 123 | path: '/nodeinfo/2.0.json', |
134 | statusCodeExpected: HttpStatusCode.OK_200 | 124 | expectedStatus: HttpStatusCode.OK_200 |
135 | }) | 125 | }) |
136 | 126 | ||
137 | expect(res.body.software.name).to.equal('peertube') | 127 | expect(res.body.software.name).to.equal('peertube') |
@@ -146,7 +136,7 @@ describe('Test misc endpoints', function () { | |||
146 | const res = await makeGetRequest({ | 136 | const res = await makeGetRequest({ |
147 | url: server.url, | 137 | url: server.url, |
148 | path: '/sitemap.xml', | 138 | path: '/sitemap.xml', |
149 | statusCodeExpected: HttpStatusCode.OK_200 | 139 | expectedStatus: HttpStatusCode.OK_200 |
150 | }) | 140 | }) |
151 | 141 | ||
152 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 142 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |
@@ -157,7 +147,7 @@ describe('Test misc endpoints', function () { | |||
157 | const res = await makeGetRequest({ | 147 | const res = await makeGetRequest({ |
158 | url: server.url, | 148 | url: server.url, |
159 | path: '/sitemap.xml', | 149 | path: '/sitemap.xml', |
160 | statusCodeExpected: HttpStatusCode.OK_200 | 150 | expectedStatus: HttpStatusCode.OK_200 |
161 | }) | 151 | }) |
162 | 152 | ||
163 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 153 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |
@@ -167,20 +157,20 @@ describe('Test misc endpoints', function () { | |||
167 | it('Should add videos, channel and accounts and get sitemap', async function () { | 157 | it('Should add videos, channel and accounts and get sitemap', async function () { |
168 | this.timeout(35000) | 158 | this.timeout(35000) |
169 | 159 | ||
170 | await uploadVideo(server.url, server.accessToken, { name: 'video 1', nsfw: false }) | 160 | await server.videos.upload({ attributes: { name: 'video 1', nsfw: false } }) |
171 | await uploadVideo(server.url, server.accessToken, { name: 'video 2', nsfw: false }) | 161 | await server.videos.upload({ attributes: { name: 'video 2', nsfw: false } }) |
172 | await uploadVideo(server.url, server.accessToken, { name: 'video 3', privacy: VideoPrivacy.PRIVATE }) | 162 | await server.videos.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } }) |
173 | 163 | ||
174 | await addVideoChannel(server.url, server.accessToken, { name: 'channel1', displayName: 'channel 1' }) | 164 | await server.channels.create({ attributes: { name: 'channel1', displayName: 'channel 1' } }) |
175 | await addVideoChannel(server.url, server.accessToken, { name: 'channel2', displayName: 'channel 2' }) | 165 | await server.channels.create({ attributes: { name: 'channel2', displayName: 'channel 2' } }) |
176 | 166 | ||
177 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' }) | 167 | await server.users.create({ username: 'user1', password: 'password' }) |
178 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user2', password: 'password' }) | 168 | await server.users.create({ username: 'user2', password: 'password' }) |
179 | 169 | ||
180 | const res = await makeGetRequest({ | 170 | const res = await makeGetRequest({ |
181 | url: server.url, | 171 | url: server.url, |
182 | path: '/sitemap.xml?t=1', // avoid using cache | 172 | path: '/sitemap.xml?t=1', // avoid using cache |
183 | statusCodeExpected: HttpStatusCode.OK_200 | 173 | expectedStatus: HttpStatusCode.OK_200 |
184 | }) | 174 | }) |
185 | 175 | ||
186 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 176 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |