diff options
-rw-r--r-- | server/lib/client-html.ts | 2 | ||||
-rw-r--r-- | server/tests/client.ts | 61 |
2 files changed, 61 insertions, 2 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 38697401a..a9c835fbf 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -134,6 +134,7 @@ class ClientHtml { | |||
134 | escapedSiteName: escapeHTML(siteName), | 134 | escapedSiteName: escapeHTML(siteName), |
135 | escapedTitle: escapeHTML(title), | 135 | escapedTitle: escapeHTML(title), |
136 | escapedDescription: escapeHTML(description), | 136 | escapedDescription: escapeHTML(description), |
137 | disallowIndexation: video.privacy !== VideoPrivacy.PUBLIC, | ||
137 | image, | 138 | image, |
138 | embed, | 139 | embed, |
139 | ogType, | 140 | ogType, |
@@ -197,6 +198,7 @@ class ClientHtml { | |||
197 | escapedSiteName: escapeHTML(siteName), | 198 | escapedSiteName: escapeHTML(siteName), |
198 | escapedTitle: escapeHTML(title), | 199 | escapedTitle: escapeHTML(title), |
199 | escapedDescription: escapeHTML(description), | 200 | escapedDescription: escapeHTML(description), |
201 | disallowIndexation: videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC, | ||
200 | embed, | 202 | embed, |
201 | image, | 203 | image, |
202 | list, | 204 | list, |
diff --git a/server/tests/client.ts b/server/tests/client.ts index fe048d7ff..f41129895 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' | 6 | import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createMultipleServers, | 9 | createMultipleServers, |
@@ -48,6 +48,10 @@ describe('Test a client controllers', function () { | |||
48 | const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ] | 48 | const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ] |
49 | 49 | ||
50 | let videoIds: (string | number)[] = [] | 50 | let videoIds: (string | number)[] = [] |
51 | let privateVideoId: string | ||
52 | let internalVideoId: string | ||
53 | let unlistedVideoId: string | ||
54 | |||
51 | let playlistIds: (string | number)[] = [] | 55 | let playlistIds: (string | number)[] = [] |
52 | 56 | ||
53 | before(async function () { | 57 | before(async function () { |
@@ -66,7 +70,7 @@ describe('Test a client controllers', function () { | |||
66 | attributes: { description: channelDescription } | 70 | attributes: { description: channelDescription } |
67 | }) | 71 | }) |
68 | 72 | ||
69 | // Video | 73 | // Public video |
70 | 74 | ||
71 | { | 75 | { |
72 | const attributes = { name: videoName, description: videoDescription } | 76 | const attributes = { name: videoName, description: videoDescription } |
@@ -80,6 +84,12 @@ describe('Test a client controllers', function () { | |||
80 | videoIds = [ video.id, video.uuid, video.shortUUID ] | 84 | videoIds = [ video.id, video.uuid, video.shortUUID ] |
81 | } | 85 | } |
82 | 86 | ||
87 | { | ||
88 | ({ uuid: privateVideoId } = await servers[0].videos.quickUpload({ name: 'private', privacy: VideoPrivacy.PRIVATE })); | ||
89 | ({ uuid: unlistedVideoId } = await servers[0].videos.quickUpload({ name: 'unlisted', privacy: VideoPrivacy.UNLISTED })); | ||
90 | ({ uuid: internalVideoId } = await servers[0].videos.quickUpload({ name: 'internal', privacy: VideoPrivacy.INTERNAL })) | ||
91 | } | ||
92 | |||
83 | // Playlist | 93 | // Playlist |
84 | 94 | ||
85 | { | 95 | { |
@@ -466,6 +476,53 @@ describe('Test a client controllers', function () { | |||
466 | } | 476 | } |
467 | }) | 477 | }) |
468 | 478 | ||
479 | it('Should add noindex meta tag for remote channels', async function () { | ||
480 | const handle = 'root_channel@' + servers[0].host | ||
481 | const paths = [ '/video-channels/', '/c/', '/@' ] | ||
482 | |||
483 | for (const path of paths) { | ||
484 | { | ||
485 | const { text } = await makeHTMLRequest(servers[1].url, path + handle) | ||
486 | expect(text).to.contain('<meta name="robots" content="noindex" />') | ||
487 | } | ||
488 | |||
489 | { | ||
490 | const { text } = await makeHTMLRequest(servers[0].url, path + handle) | ||
491 | expect(text).to.not.contain('<meta name="robots" content="noindex" />') | ||
492 | } | ||
493 | } | ||
494 | }) | ||
495 | |||
496 | it('Should not display internal/private video', async function () { | ||
497 | for (const basePath of watchVideoBasePaths) { | ||
498 | for (const id of [ privateVideoId, internalVideoId ]) { | ||
499 | const res = await makeGetRequest({ | ||
500 | url: servers[0].url, | ||
501 | path: basePath + id, | ||
502 | accept: 'text/html', | ||
503 | expectedStatus: HttpStatusCode.NOT_FOUND_404 | ||
504 | }) | ||
505 | |||
506 | expect(res.text).to.not.contain('internal') | ||
507 | expect(res.text).to.not.contain('private') | ||
508 | } | ||
509 | } | ||
510 | }) | ||
511 | |||
512 | it('Should add noindex meta tag for unlisted video', async function () { | ||
513 | for (const basePath of watchVideoBasePaths) { | ||
514 | const res = await makeGetRequest({ | ||
515 | url: servers[0].url, | ||
516 | path: basePath + unlistedVideoId, | ||
517 | accept: 'text/html', | ||
518 | expectedStatus: HttpStatusCode.OK_200 | ||
519 | }) | ||
520 | |||
521 | expect(res.text).to.contain('unlisted') | ||
522 | expect(res.text).to.contain('<meta name="robots" content="noindex" />') | ||
523 | } | ||
524 | }) | ||
525 | |||
469 | it('Should add noindex meta tag for remote accounts', async function () { | 526 | it('Should add noindex meta tag for remote accounts', async function () { |
470 | const handle = 'root_channel@' + servers[0].host | 527 | const handle = 'root_channel@' + servers[0].host |
471 | const paths = [ '/video-channels/', '/c/', '/@' ] | 528 | const paths = [ '/video-channels/', '/c/', '/@' ] |