]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/reverse-proxy.ts
Support video views/viewers stats in server
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / reverse-proxy.ts
index c20b7a5f0fc40fb696f923e0bd7bb05e6c832a0c..fa2063536f4ce89ccd52b709016c12d23ba94686 100644 (file)
@@ -1,8 +1,9 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
-import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
 
 describe('Test application behind a reverse proxy', function () {
   let server: PeerTubeServer
@@ -40,8 +41,8 @@ describe('Test application behind a reverse proxy', function () {
   it('Should view a video only once with the same IP by default', async function () {
     this.timeout(20000)
 
-    await server.videos.view({ id: videoId })
-    await server.videos.view({ id: videoId })
+    await server.views.simulateView({ id: videoId })
+    await server.views.simulateView({ id: videoId })
 
     // Wait the repeatable job
     await wait(8000)
@@ -53,8 +54,8 @@ describe('Test application behind a reverse proxy', function () {
   it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
     this.timeout(20000)
 
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
 
     // Wait the repeatable job
     await wait(8000)
@@ -66,8 +67,8 @@ describe('Test application behind a reverse proxy', function () {
   it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () {
     this.timeout(20000)
 
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
 
     // Wait the repeatable job
     await wait(8000)
@@ -79,8 +80,8 @@ describe('Test application behind a reverse proxy', function () {
   it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
     this.timeout(20000)
 
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
-    await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
+    await server.views.simulateView({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
 
     // Wait the repeatable job
     await wait(8000)