diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/well-known.ts | 7 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 2 | ||||
-rw-r--r-- | server/initializers/config.ts | 3 | ||||
-rw-r--r-- | server/initializers/constants.ts | 3 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 8 | ||||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 2 | ||||
-rw-r--r-- | server/tests/misc-endpoints.ts | 30 | ||||
-rw-r--r-- | server/tests/shared/actors.ts | 8 | ||||
-rw-r--r-- | server/tests/shared/directories.ts | 8 | ||||
-rw-r--r-- | server/tests/shared/playlists.ts | 9 |
11 files changed, 54 insertions, 28 deletions
diff --git a/server/controllers/well-known.ts b/server/controllers/well-known.ts index f467bd629..ce5883571 100644 --- a/server/controllers/well-known.ts +++ b/server/controllers/well-known.ts | |||
@@ -5,6 +5,7 @@ import { root } from '@shared/core-utils' | |||
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 6 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
7 | import { cacheRoute } from '../middlewares/cache/cache' | 7 | import { cacheRoute } from '../middlewares/cache/cache' |
8 | import { handleStaticError } from '@server/middlewares' | ||
8 | 9 | ||
9 | const wellKnownRouter = express.Router() | 10 | const wellKnownRouter = express.Router() |
10 | 11 | ||
@@ -69,6 +70,12 @@ wellKnownRouter.use('/.well-known/host-meta', | |||
69 | } | 70 | } |
70 | ) | 71 | ) |
71 | 72 | ||
73 | wellKnownRouter.use('/.well-known/', | ||
74 | cacheRoute(ROUTE_CACHE_LIFETIME.WELL_KNOWN), | ||
75 | express.static(CONFIG.STORAGE.WELL_KNOWN_DIR, { fallthrough: false }), | ||
76 | handleStaticError | ||
77 | ) | ||
78 | |||
72 | // --------------------------------------------------------------------------- | 79 | // --------------------------------------------------------------------------- |
73 | 80 | ||
74 | export { | 81 | export { |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 3188903be..1fd4ba248 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -16,7 +16,7 @@ function checkMissedConfig () { | |||
16 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', | 16 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', |
17 | 'email.body.signature', 'email.subject.prefix', | 17 | 'email.body.signature', 'email.subject.prefix', |
18 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', | 18 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', |
19 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', | 19 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known', |
20 | 'log.level', | 20 | 'log.level', |
21 | 'user.video_quota', 'user.video_quota_daily', | 21 | 'user.video_quota', 'user.video_quota_daily', |
22 | 'video_channels.max_per_user', | 22 | 'video_channels.max_per_user', |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 2c92bea22..287bf6f6d 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -107,7 +107,8 @@ const CONFIG = { | |||
107 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), | 107 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), |
108 | CACHE_DIR: buildPath(config.get<string>('storage.cache')), | 108 | CACHE_DIR: buildPath(config.get<string>('storage.cache')), |
109 | PLUGINS_DIR: buildPath(config.get<string>('storage.plugins')), | 109 | PLUGINS_DIR: buildPath(config.get<string>('storage.plugins')), |
110 | CLIENT_OVERRIDES_DIR: buildPath(config.get<string>('storage.client_overrides')) | 110 | CLIENT_OVERRIDES_DIR: buildPath(config.get<string>('storage.client_overrides')), |
111 | WELL_KNOWN_DIR: buildPath(config.get<string>('storage.well_known')) | ||
111 | }, | 112 | }, |
112 | OBJECT_STORAGE: { | 113 | OBJECT_STORAGE: { |
113 | ENABLED: config.get<boolean>('object_storage.enabled'), | 114 | ENABLED: config.get<boolean>('object_storage.enabled'), |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 7039ab457..9257ebf93 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -116,7 +116,8 @@ const ROUTE_CACHE_LIFETIME = { | |||
116 | ACTIVITY_PUB: { | 116 | ACTIVITY_PUB: { |
117 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example | 117 | VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example |
118 | }, | 118 | }, |
119 | STATS: '4 hours' | 119 | STATS: '4 hours', |
120 | WELL_KNOWN: '1 day' | ||
120 | } | 121 | } |
121 | 122 | ||
122 | // --------------------------------------------------------------------------- | 123 | // --------------------------------------------------------------------------- |
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 5abed358f..0f4973184 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -159,8 +159,8 @@ async function check2Webseeds (videoUUID?: string) { | |||
159 | const { webtorrentFilenames } = await ensureSameFilenames(videoUUID) | 159 | const { webtorrentFilenames } = await ensureSameFilenames(videoUUID) |
160 | 160 | ||
161 | const directories = [ | 161 | const directories = [ |
162 | 'test' + servers[0].internalServerNumber + '/redundancy', | 162 | servers[0].getDirectoryPath('redundancy'), |
163 | 'test' + servers[1].internalServerNumber + '/videos' | 163 | servers[1].getDirectoryPath('videos') |
164 | ] | 164 | ] |
165 | 165 | ||
166 | for (const directory of directories) { | 166 | for (const directory of directories) { |
@@ -214,8 +214,8 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
214 | const { hlsFilenames } = await ensureSameFilenames(videoUUID) | 214 | const { hlsFilenames } = await ensureSameFilenames(videoUUID) |
215 | 215 | ||
216 | const directories = [ | 216 | const directories = [ |
217 | 'test' + servers[0].internalServerNumber + '/redundancy/hls', | 217 | servers[0].getDirectoryPath('redundancy/hls'), |
218 | 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls' | 218 | servers[1].getDirectoryPath('streaming-playlists/hls') |
219 | ] | 219 | ] |
220 | 220 | ||
221 | for (const directory of directories) { | 221 | for (const directory of directories) { |
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 62d668d1e..188e6f137 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -197,7 +197,7 @@ describe('Test users with multiple servers', function () { | |||
197 | it('Should not have actor files', async () => { | 197 | it('Should not have actor files', async () => { |
198 | for (const server of servers) { | 198 | for (const server of servers) { |
199 | for (const userAvatarFilename of userAvatarFilenames) { | 199 | for (const userAvatarFilename of userAvatarFilenames) { |
200 | await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber) | 200 | await checkActorFilesWereRemoved(userAvatarFilename, server) |
201 | } | 201 | } |
202 | } | 202 | } |
203 | }) | 203 | }) |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index a0c743170..9d223de48 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -1049,7 +1049,7 @@ describe('Test video playlists', function () { | |||
1049 | this.timeout(30000) | 1049 | this.timeout(30000) |
1050 | 1050 | ||
1051 | for (const server of servers) { | 1051 | for (const server of servers) { |
1052 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber) | 1052 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server) |
1053 | } | 1053 | } |
1054 | }) | 1054 | }) |
1055 | 1055 | ||
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 663ac044a..d2072342e 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts | |||
@@ -1,18 +1,24 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 4 | import { writeJson } from 'fs-extra' |
5 | import { join } from 'path' | ||
5 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' | 6 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | ||
6 | import { expectLogDoesNotContain } from './shared' | 8 | import { expectLogDoesNotContain } from './shared' |
7 | 9 | ||
8 | describe('Test misc endpoints', function () { | 10 | describe('Test misc endpoints', function () { |
9 | let server: PeerTubeServer | 11 | let server: PeerTubeServer |
12 | let wellKnownPath: string | ||
10 | 13 | ||
11 | before(async function () { | 14 | before(async function () { |
12 | this.timeout(120000) | 15 | this.timeout(120000) |
13 | 16 | ||
14 | server = await createSingleServer(1) | 17 | server = await createSingleServer(1) |
18 | |||
15 | await setAccessTokensToServers([ server ]) | 19 | await setAccessTokensToServers([ server ]) |
20 | |||
21 | wellKnownPath = server.getDirectoryPath('well-known') | ||
16 | }) | 22 | }) |
17 | 23 | ||
18 | describe('Test a well known endpoints', function () { | 24 | describe('Test a well known endpoints', function () { |
@@ -93,6 +99,28 @@ describe('Test misc endpoints', function () { | |||
93 | expect(remoteInteract).to.exist | 99 | expect(remoteInteract).to.exist |
94 | expect(remoteInteract.template).to.equal(server.url + '/remote-interaction?uri={uri}') | 100 | expect(remoteInteract.template).to.equal(server.url + '/remote-interaction?uri={uri}') |
95 | }) | 101 | }) |
102 | |||
103 | it('Should return 404 for non-existing files in /.well-known', async function () { | ||
104 | await makeGetRequest({ | ||
105 | url: server.url, | ||
106 | path: '/.well-known/non-existing-file', | ||
107 | expectedStatus: HttpStatusCode.NOT_FOUND_404 | ||
108 | }) | ||
109 | }) | ||
110 | |||
111 | it('Should return custom file from /.well-known', async function () { | ||
112 | const filename = 'existing-file.json' | ||
113 | |||
114 | await writeJson(join(wellKnownPath, filename), { iThink: 'therefore I am' }) | ||
115 | |||
116 | const { body } = await makeGetRequest({ | ||
117 | url: server.url, | ||
118 | path: '/.well-known/' + filename, | ||
119 | expectedStatus: HttpStatusCode.OK_200 | ||
120 | }) | ||
121 | |||
122 | expect(body.iThink).to.equal('therefore I am') | ||
123 | }) | ||
96 | }) | 124 | }) |
97 | 125 | ||
98 | describe('Test classic static endpoints', function () { | 126 | describe('Test classic static endpoints', function () { |
diff --git a/server/tests/shared/actors.ts b/server/tests/shared/actors.ts index f8f4a5137..41fd72e89 100644 --- a/server/tests/shared/actors.ts +++ b/server/tests/shared/actors.ts | |||
@@ -2,8 +2,6 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | ||
6 | import { root } from '@shared/core-utils' | ||
7 | import { Account, VideoChannel } from '@shared/models' | 5 | import { Account, VideoChannel } from '@shared/models' |
8 | import { PeerTubeServer } from '@shared/server-commands' | 6 | import { PeerTubeServer } from '@shared/server-commands' |
9 | 7 | ||
@@ -31,11 +29,9 @@ async function expectAccountFollows (options: { | |||
31 | return expectActorFollow({ ...options, data }) | 29 | return expectActorFollow({ ...options, data }) |
32 | } | 30 | } |
33 | 31 | ||
34 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { | 32 | async function checkActorFilesWereRemoved (filename: string, server: PeerTubeServer) { |
35 | const testDirectory = 'test' + serverNumber | ||
36 | |||
37 | for (const directory of [ 'avatars' ]) { | 33 | for (const directory of [ 'avatars' ]) { |
38 | const directoryPath = join(root(), testDirectory, directory) | 34 | const directoryPath = server.getDirectoryPath(directory) |
39 | 35 | ||
40 | const directoryExists = await pathExists(directoryPath) | 36 | const directoryExists = await pathExists(directoryPath) |
41 | expect(directoryExists).to.be.true | 37 | expect(directoryExists).to.be.true |
diff --git a/server/tests/shared/directories.ts b/server/tests/shared/directories.ts index c7065a767..90d534a06 100644 --- a/server/tests/shared/directories.ts +++ b/server/tests/shared/directories.ts | |||
@@ -2,22 +2,18 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | ||
6 | import { root } from '@shared/core-utils' | ||
7 | import { PeerTubeServer } from '@shared/server-commands' | 5 | import { PeerTubeServer } from '@shared/server-commands' |
8 | 6 | ||
9 | async function checkTmpIsEmpty (server: PeerTubeServer) { | 7 | async function checkTmpIsEmpty (server: PeerTubeServer) { |
10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) | 8 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
11 | 9 | ||
12 | if (await pathExists(join('test' + server.internalServerNumber, 'tmp', 'hls'))) { | 10 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { |
13 | await checkDirectoryIsEmpty(server, 'tmp/hls') | 11 | await checkDirectoryIsEmpty(server, 'tmp/hls') |
14 | } | 12 | } |
15 | } | 13 | } |
16 | 14 | ||
17 | async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { | 15 | async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { |
18 | const testDirectory = 'test' + server.internalServerNumber | 16 | const directoryPath = server.getDirectoryPath(directory) |
19 | |||
20 | const directoryPath = join(root(), testDirectory, directory) | ||
21 | 17 | ||
22 | const directoryExists = await pathExists(directoryPath) | 18 | const directoryExists = await pathExists(directoryPath) |
23 | expect(directoryExists).to.be.true | 19 | expect(directoryExists).to.be.true |
diff --git a/server/tests/shared/playlists.ts b/server/tests/shared/playlists.ts index fdd541d20..8db303fd8 100644 --- a/server/tests/shared/playlists.ts +++ b/server/tests/shared/playlists.ts | |||
@@ -1,17 +1,14 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { readdir } from 'fs-extra' | 2 | import { readdir } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { PeerTubeServer } from '@shared/server-commands' |
4 | import { root } from '@shared/core-utils' | ||
5 | 4 | ||
6 | async function checkPlaylistFilesWereRemoved ( | 5 | async function checkPlaylistFilesWereRemoved ( |
7 | playlistUUID: string, | 6 | playlistUUID: string, |
8 | internalServerNumber: number, | 7 | server: PeerTubeServer, |
9 | directories = [ 'thumbnails' ] | 8 | directories = [ 'thumbnails' ] |
10 | ) { | 9 | ) { |
11 | const testDirectory = 'test' + internalServerNumber | ||
12 | |||
13 | for (const directory of directories) { | 10 | for (const directory of directories) { |
14 | const directoryPath = join(root(), testDirectory, directory) | 11 | const directoryPath = server.getDirectoryPath(directory) |
15 | 12 | ||
16 | const files = await readdir(directoryPath) | 13 | const files = await readdir(directoryPath) |
17 | for (const file of files) { | 14 | for (const file of files) { |