/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeDeleteRequest,
makePostBodyRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '@shared/extra-utils'
-import { HttpStatusCode } from '@shared/models'
+} from '@shared/server-commands'
describe('Test server follows API validators', function () {
let server: PeerTubeServer
await makePostBodyRequest({
url: server.url,
path,
- fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] },
+ fields: { hosts: [ '127.0.0.1:9002', '127.0.0.1:coucou' ] },
token: server.accessToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] },
+ fields: { hosts: [ '127.0.0.1:9002', 'http://127.0.0.1:9003' ] },
token: server.accessToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { urls: [ 'localhost:9002', 'localhost:9002' ] },
+ fields: { urls: [ '127.0.0.1:9002', '127.0.0.1:9002' ] },
token: server.accessToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { handles: [ 'hello@example.com', 'localhost:9001' ] },
+ fields: { handles: [ 'hello@example.com', '127.0.0.1:9001' ] },
token: server.accessToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { hosts: [ 'localhost:9002' ] },
+ fields: { hosts: [ '127.0.0.1:9002' ] },
token: 'fake_token',
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { hosts: [ 'localhost:9002' ] },
+ fields: { hosts: [ '127.0.0.1:9002' ] },
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should fail with an invalid token', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/toto@localhost:9002',
+ path: path + '/toto@127.0.0.1:9002',
token: 'fake_token',
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
it('Should fail if the user is not an administrator', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/toto@localhost:9002',
+ path: path + '/toto@127.0.0.1:9002',
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should fail with an unknown follower', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/toto@localhost:9003',
+ path: path + '/toto@127.0.0.1:9003',
token: server.accessToken,
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
it('Should fail with an invalid token', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9002/accept',
+ path: path + '/toto@127.0.0.1:9002/accept',
token: 'fake_token',
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
it('Should fail if the user is not an administrator', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9002/accept',
+ path: path + '/toto@127.0.0.1:9002/accept',
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should fail with an unknown follower', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9003/accept',
+ path: path + '/toto@127.0.0.1:9003/accept',
token: server.accessToken,
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
it('Should fail with an invalid token', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9002/reject',
+ path: path + '/toto@127.0.0.1:9002/reject',
token: 'fake_token',
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
it('Should fail if the user is not an administrator', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9002/reject',
+ path: path + '/toto@127.0.0.1:9002/reject',
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should fail with an unknown follower', async function () {
await makePostBodyRequest({
url: server.url,
- path: path + '/toto@localhost:9003/reject',
+ path: path + '/toto@127.0.0.1:9003/reject',
token: server.accessToken,
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
it('Should fail with an invalid token', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:9002',
+ path: path + '/127.0.0.1:9002',
token: 'fake_token',
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
it('Should fail if the user is not an administrator', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:9002',
+ path: path + '/127.0.0.1:9002',
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})