From 41d1d075011174e73dccb74006181a92a618d7b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:05:15 +0200 Subject: Introduce login command --- server/tests/api/check-params/debug.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/api/check-params/debug.ts') diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 37bf0f99b..dc033a441 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts @@ -7,8 +7,7 @@ import { createUser, flushAndRunServer, ServerInfo, - setAccessTokensToServers, - userLogin + setAccessTokensToServers } from '../../../../shared/extra-utils' import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' @@ -32,7 +31,7 @@ describe('Test debug API validators', function () { password: 'my super password' } await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) - userAccessToken = await userLogin(server, user) + userAccessToken = await server.loginCommand.getAccessToken(user) }) describe('When getting debug endpoint', function () { -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/tests/api/check-params/debug.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/api/check-params/debug.ts') diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index dc033a441..2a7485cf3 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts @@ -4,7 +4,6 @@ import 'mocha' import { cleanupTests, - createUser, flushAndRunServer, ServerInfo, setAccessTokensToServers @@ -30,7 +29,7 @@ describe('Test debug API validators', function () { username: 'user1', password: 'my super password' } - await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) + await server.usersCommand.create({ username: user.username, password: user.password }) userAccessToken = await server.loginCommand.getAccessToken(user) }) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/check-params/debug.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/check-params/debug.ts') diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 2a7485cf3..609f9566e 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts @@ -29,8 +29,8 @@ describe('Test debug API validators', function () { username: 'user1', password: 'my super password' } - await server.usersCommand.create({ username: user.username, password: user.password }) - userAccessToken = await server.loginCommand.getAccessToken(user) + await server.users.create({ username: user.username, password: user.password }) + userAccessToken = await server.login.getAccessToken(user) }) describe('When getting debug endpoint', function () { -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/check-params/debug.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/check-params/debug.ts') diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 609f9566e..9c13e9daf 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts @@ -4,8 +4,8 @@ import 'mocha' import { cleanupTests, - flushAndRunServer, - ServerInfo, + createSingleServer, + PeerTubeServer, setAccessTokensToServers } from '../../../../shared/extra-utils' import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' @@ -13,7 +13,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c describe('Test debug API validators', function () { const path = '/api/v1/server/debug' - let server: ServerInfo + let server: PeerTubeServer let userAccessToken = '' // --------------------------------------------------------------- @@ -21,7 +21,7 @@ describe('Test debug API validators', function () { before(async function () { this.timeout(120000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/api/check-params/debug.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'server/tests/api/check-params/debug.ts') diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 9c13e9daf..a55786359 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts @@ -1,15 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' - -import { - cleanupTests, - createSingleServer, - PeerTubeServer, - setAccessTokensToServers -} from '../../../../shared/extra-utils' -import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' +import { HttpStatusCode } from '@shared/models' describe('Test debug API validators', function () { const path = '/api/v1/server/debug' @@ -39,7 +32,7 @@ describe('Test debug API validators', function () { await makeGetRequest({ url: server.url, path, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -48,7 +41,7 @@ describe('Test debug API validators', function () { url: server.url, path, token: userAccessToken, - statusCodeExpected: HttpStatusCode.FORBIDDEN_403 + expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) @@ -58,7 +51,7 @@ describe('Test debug API validators', function () { path, token: server.accessToken, query: { startDate: new Date().toISOString() }, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) }) -- cgit v1.2.3