/* 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,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
describe('Test blocklist API validators', function () {
let servers: PeerTubeServer[]
await makePostBodyRequest({
url: server.url,
path,
- fields: { host: 'localhost:9002' },
+ fields: { host: '127.0.0.1:9002' },
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:9003' },
+ fields: { host: '127.0.0.1:9003' },
expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:' + server.port },
+ fields: { host: server.host },
expectedStatus: HttpStatusCode.CONFLICT_409
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:' + servers[1].port },
+ fields: { host: servers[1].host },
expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
it('Should fail with an unauthenticated user', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:' + servers[1].port,
+ path: path + '/' + servers[1].host,
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
it('Should fail with an unknown server block', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:9004',
+ path: path + '/127.0.0.1:9004',
token: server.accessToken,
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
it('Should succeed with the correct params', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:' + servers[1].port,
+ path: path + '/' + servers[1].host,
token: server.accessToken,
expectedStatus: HttpStatusCode.NO_CONTENT_204
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { host: 'localhost:' + servers[1].port },
+ fields: { host: servers[1].host },
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
url: server.url,
token: userAccessToken,
path,
- fields: { host: 'localhost:' + servers[1].port },
+ fields: { host: servers[1].host },
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:9003' },
+ fields: { host: '127.0.0.1:9003' },
expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:' + server.port },
+ fields: { host: server.host },
expectedStatus: HttpStatusCode.CONFLICT_409
})
})
url: server.url,
token: server.accessToken,
path,
- fields: { host: 'localhost:' + servers[1].port },
+ fields: { host: servers[1].host },
expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
it('Should fail with an unauthenticated user', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:' + servers[1].port,
+ path: path + '/' + servers[1].host,
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
it('Should fail with a user without the appropriate rights', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:' + servers[1].port,
+ path: path + '/' + servers[1].host,
token: userAccessToken,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should fail with an unknown server block', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:9004',
+ path: path + '/127.0.0.1:9004',
token: server.accessToken,
expectedStatus: HttpStatusCode.NOT_FOUND_404
})
it('Should succeed with the correct params', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/localhost:' + servers[1].port,
+ path: path + '/' + servers[1].host,
token: server.accessToken,
expectedStatus: HttpStatusCode.NO_CONTENT_204
})