aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-08 16:26:38 +0200
committerChocobozzz <me@florianbigard.com>2022-04-08 16:28:14 +0200
commitc6d20c84a75c77f50e19afa93aa318ad92edba90 (patch)
tree9a1115277389af26f19e25223eb18346595b5aa9 /server/tests
parent1575be682587149993f80af9d6b26f2d4db454c8 (diff)
downloadPeerTube-c6d20c84a75c77f50e19afa93aa318ad92edba90.tar.gz
PeerTube-c6d20c84a75c77f50e19afa93aa318ad92edba90.tar.zst
PeerTube-c6d20c84a75c77f50e19afa93aa318ad92edba90.zip
Disallow unlisted video indexation
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/client.ts61
1 files changed, 59 insertions, 2 deletions
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 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' 6import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
7import { 7import {
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/', '/@' ]