]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/videos-common-filters.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / videos-common-filters.ts
index afe42b0d5226143627a034b8ecd67eba28885fe4..6b3ec917ecdee6e761b0f86633f46b662f9a6bee 100644 (file)
@@ -8,8 +8,8 @@ import {
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel
-} from '@shared/extra-utils'
-import { HttpStatusCode, UserRole, VideoInclude } from '@shared/models'
+} from '@shared/server-commands'
+import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models'
 
 describe('Test video filters validators', function () {
   let server: PeerTubeServer
@@ -112,7 +112,7 @@ describe('Test video filters validators', function () {
 
     const validIncludes = [
       VideoInclude.NONE,
-      VideoInclude.HIDDEN_PRIVACY,
+      VideoInclude.BLOCKED_OWNER,
       VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.BLACKLISTED
     ]
 
@@ -120,6 +120,7 @@ describe('Test video filters validators', function () {
       token?: string
       isLocal?: boolean
       include?: VideoInclude
+      privacyOneOf?: VideoPrivacy[]
       expectedStatus: HttpStatusCode
     }) {
       const paths = [
@@ -136,6 +137,7 @@ describe('Test video filters validators', function () {
           token: options.token || server.accessToken,
           query: {
             isLocal: options.isLocal,
+            privacyOneOf: options.privacyOneOf,
             include: options.include
           },
           expectedStatus: options.expectedStatus
@@ -143,6 +145,22 @@ describe('Test video filters validators', function () {
       }
     }
 
+    it('Should fail with a bad privacyOneOf', async function () {
+      await testEndpoints({ privacyOneOf: [ 'toto' ] as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+    })
+
+    it('Should succeed with a good privacyOneOf', async function () {
+      await testEndpoints({ privacyOneOf: [ VideoPrivacy.INTERNAL ], expectedStatus: HttpStatusCode.OK_200 })
+    })
+
+    it('Should fail to use privacyOneOf with a simple user', async function () {
+      await testEndpoints({
+        privacyOneOf: [ VideoPrivacy.INTERNAL ],
+        token: userAccessToken,
+        expectedStatus: HttpStatusCode.UNAUTHORIZED_401
+      })
+    })
+
     it('Should fail with a bad include', async function () {
       await testEndpoints({ include: 'toto' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
     })