]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/reverse-proxy.ts
Stop testing broken youtube-dl
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / reverse-proxy.ts
index fa2063536f4ce89ccd52b709016c12d23ba94686..11c96c4b524c755ce0d841a11b2f1f304d794782 100644 (file)
@@ -7,10 +7,11 @@ import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServ
 
 describe('Test application behind a reverse proxy', function () {
   let server: PeerTubeServer
+  let userAccessToken: string
   let videoId: string
 
   before(async function () {
-    this.timeout(30000)
+    this.timeout(60000)
 
     const config = {
       rates_limit: {
@@ -34,12 +35,14 @@ describe('Test application behind a reverse proxy', function () {
     server = await createSingleServer(1, config)
     await setAccessTokensToServers([ server ])
 
+    userAccessToken = await server.users.generateUserAndToken('user')
+
     const { uuid } = await server.videos.upload()
     videoId = uuid
   })
 
   it('Should view a video only once with the same IP by default', async function () {
-    this.timeout(20000)
+    this.timeout(40000)
 
     await server.views.simulateView({ id: videoId })
     await server.views.simulateView({ id: videoId })
@@ -93,7 +96,7 @@ describe('Test application behind a reverse proxy', function () {
   it('Should rate limit logins', async function () {
     const user = { username: 'root', password: 'fail' }
 
-    for (let i = 0; i < 19; i++) {
+    for (let i = 0; i < 18; i++) {
       await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
     }
 
@@ -103,13 +106,13 @@ describe('Test application behind a reverse proxy', function () {
   it('Should rate limit signup', async function () {
     for (let i = 0; i < 10; i++) {
       try {
-        await server.users.register({ username: 'test' + i })
+        await server.registrations.register({ username: 'test' + i })
       } catch {
         // empty
       }
     }
 
-    await server.users.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+    await server.registrations.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
   })
 
   it('Should not rate limit failed signup', async function () {
@@ -118,10 +121,10 @@ describe('Test application behind a reverse proxy', function () {
     await wait(7000)
 
     for (let i = 0; i < 3; i++) {
-      await server.users.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
+      await server.registrations.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
     }
 
-    await server.users.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+    await server.registrations.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
 
   })
 
@@ -141,6 +144,12 @@ describe('Test application behind a reverse proxy', function () {
     await server.videos.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
   })
 
+  it('Should rate limit API calls with a user but not with an admin', async function () {
+    await server.videos.get({ id: videoId, token: userAccessToken, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+
+    await server.videos.get({ id: videoId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
+  })
+
   after(async function () {
     await cleanupTests([ server ])
   })