]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/videos-common-filters.ts
Add ability to disable http duration OTEL metrics
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / videos-common-filters.ts
index afe42b0d5226143627a034b8ecd67eba28885fe4..95523ce3d08b951c75a8976259b4722882172382 100644 (file)
@@ -1,6 +1,6 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
+import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models'
 import {
   cleanupTests,
   createSingleServer,
@@ -8,8 +8,7 @@ import {
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel
-} from '@shared/extra-utils'
-import { HttpStatusCode, UserRole, VideoInclude } from '@shared/models'
+} from '@shared/server-commands'
 
 describe('Test video filters validators', function () {
   let server: PeerTubeServer
@@ -112,7 +111,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 +119,7 @@ describe('Test video filters validators', function () {
       token?: string
       isLocal?: boolean
       include?: VideoInclude
+      privacyOneOf?: VideoPrivacy[]
       expectedStatus: HttpStatusCode
     }) {
       const paths = [
@@ -136,6 +136,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 +144,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 })
     })