2020-01-31 16:56:52 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-10-12 15:26:04 +02:00
|
|
|
|
|
|
|
import 'mocha'
|
|
|
|
|
|
|
|
import {
|
2019-04-24 11:54:23 +02:00
|
|
|
cleanupTests,
|
2018-10-12 15:26:04 +02:00
|
|
|
createUser,
|
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
|
|
|
makeDeleteRequest,
|
|
|
|
makeGetRequest,
|
|
|
|
makePostBodyRequest,
|
|
|
|
ServerInfo,
|
2019-04-24 11:54:23 +02:00
|
|
|
setAccessTokensToServers,
|
|
|
|
userLogin
|
2019-04-15 15:26:15 +02:00
|
|
|
} from '../../../../shared/extra-utils'
|
2018-10-29 17:48:31 +01:00
|
|
|
import {
|
|
|
|
checkBadCountPagination,
|
|
|
|
checkBadSortPagination,
|
|
|
|
checkBadStartPagination
|
2019-04-15 15:26:15 +02:00
|
|
|
} from '../../../../shared/extra-utils/requests/check-api-params'
|
2020-12-07 14:32:36 +01:00
|
|
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
2018-10-12 15:26:04 +02:00
|
|
|
|
|
|
|
describe('Test blocklist API validators', function () {
|
|
|
|
let servers: ServerInfo[]
|
|
|
|
let server: ServerInfo
|
2018-10-15 13:03:04 +02:00
|
|
|
let userAccessToken: string
|
2018-10-12 15:26:04 +02:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
|
|
|
servers = await flushAndRunMultipleServers(2)
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
server = servers[0]
|
|
|
|
|
|
|
|
const user = { username: 'user1', password: 'password' }
|
2019-04-15 10:49:46 +02:00
|
|
|
await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
|
2018-10-12 15:26:04 +02:00
|
|
|
|
2018-10-15 13:03:04 +02:00
|
|
|
userAccessToken = await userLogin(server, user)
|
|
|
|
|
2018-10-12 15:26:04 +02:00
|
|
|
await doubleFollow(servers[0], servers[1])
|
|
|
|
})
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
describe('When managing user blocklist', function () {
|
|
|
|
|
|
|
|
describe('When managing user accounts blocklist', function () {
|
2018-10-15 13:03:04 +02:00
|
|
|
const path = '/api/v1/users/me/blocklist/accounts'
|
2018-10-12 15:26:04 +02:00
|
|
|
|
|
|
|
describe('When listing blocked accounts', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad start pagination', async function () {
|
|
|
|
await checkBadStartPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad count pagination', async function () {
|
|
|
|
await checkBadCountPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an incorrect sort', async function () {
|
|
|
|
await checkBadSortPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When blocking an account', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user1' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown account', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user2' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-12 17:26:40 +02:00
|
|
|
it('Should fail to block ourselves', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'root' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.CONFLICT_409
|
2018-10-12 17:26:40 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-12 15:26:04 +02:00
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user1' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When unblocking an account', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user1',
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown account block', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user2',
|
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user1',
|
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When managing user servers blocklist', function () {
|
|
|
|
const path = '/api/v1/users/me/blocklist/servers'
|
|
|
|
|
|
|
|
describe('When listing blocked servers', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad start pagination', async function () {
|
|
|
|
await checkBadStartPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad count pagination', async function () {
|
|
|
|
await checkBadCountPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an incorrect sort', async function () {
|
|
|
|
await checkBadSortPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When blocking a server', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
|
|
|
fields: { host: 'localhost:9002' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-04-14 10:55:34 +02:00
|
|
|
it('Should succeed with an unknown server', async function () {
|
2018-10-12 15:26:04 +02:00
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { host: 'localhost:9003' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-12 17:26:40 +02:00
|
|
|
it('Should fail with our own server', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + server.port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.CONFLICT_409
|
2018-10-12 17:26:40 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-12 15:26:04 +02:00
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + servers[1].port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When unblocking a server', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2019-04-24 11:54:23 +02:00
|
|
|
path: path + '/localhost:' + servers[1].port,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown server block', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2020-04-14 10:55:34 +02:00
|
|
|
path: path + '/localhost:9004',
|
2018-10-12 15:26:04 +02:00
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2019-04-24 11:54:23 +02:00
|
|
|
path: path + '/localhost:' + servers[1].port,
|
2018-10-12 15:26:04 +02:00
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-15 13:03:04 +02:00
|
|
|
describe('When managing server blocklist', function () {
|
|
|
|
|
|
|
|
describe('When managing server accounts blocklist', function () {
|
|
|
|
const path = '/api/v1/server/blocklist/accounts'
|
|
|
|
|
|
|
|
describe('When listing blocked accounts', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: userAccessToken,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad start pagination', async function () {
|
|
|
|
await checkBadStartPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad count pagination', async function () {
|
|
|
|
await checkBadCountPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an incorrect sort', async function () {
|
|
|
|
await checkBadSortPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When blocking an account', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user1' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: userAccessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user1' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown account', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user2' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail to block ourselves', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'root' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.CONFLICT_409
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { accountName: 'user1' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When unblocking an account', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user1',
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user1',
|
|
|
|
token: userAccessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown account block', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user2',
|
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
|
|
|
path: path + '/user1',
|
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When managing server servers blocklist', function () {
|
|
|
|
const path = '/api/v1/server/blocklist/servers'
|
|
|
|
|
|
|
|
describe('When listing blocked servers', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makeGetRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: userAccessToken,
|
|
|
|
path,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad start pagination', async function () {
|
|
|
|
await checkBadStartPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a bad count pagination', async function () {
|
|
|
|
await checkBadCountPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an incorrect sort', async function () {
|
|
|
|
await checkBadSortPagination(server.url, path, server.accessToken)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When blocking a server', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + servers[1].port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: userAccessToken,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + servers[1].port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-04-14 10:55:34 +02:00
|
|
|
it('Should succeed with an unknown server', async function () {
|
2018-10-15 13:03:04 +02:00
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
|
|
|
fields: { host: 'localhost:9003' },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with our own server', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + server.port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.CONFLICT_409
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makePostBodyRequest({
|
|
|
|
url: server.url,
|
|
|
|
token: server.accessToken,
|
|
|
|
path,
|
2019-04-24 11:54:23 +02:00
|
|
|
fields: { host: 'localhost:' + servers[1].port },
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('When unblocking a server', function () {
|
|
|
|
it('Should fail with an unauthenticated user', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2019-04-24 11:54:23 +02:00
|
|
|
path: path + '/localhost:' + servers[1].port,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with a user without the appropriate rights', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2019-04-24 11:54:23 +02:00
|
|
|
path: path + '/localhost:' + servers[1].port,
|
2018-10-15 13:03:04 +02:00
|
|
|
token: userAccessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.FORBIDDEN_403
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should fail with an unknown server block', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2020-04-14 10:55:34 +02:00
|
|
|
path: path + '/localhost:9004',
|
2018-10-15 13:03:04 +02:00
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should succeed with the correct params', async function () {
|
|
|
|
await makeDeleteRequest({
|
|
|
|
url: server.url,
|
2019-04-24 11:54:23 +02:00
|
|
|
path: path + '/localhost:' + servers[1].port,
|
2018-10-15 13:03:04 +02:00
|
|
|
token: server.accessToken,
|
2020-12-07 14:32:36 +01:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-10-15 13:03:04 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-04-24 11:54:23 +02:00
|
|
|
after(async function () {
|
|
|
|
await cleanupTests(servers)
|
2018-10-12 15:26:04 +02:00
|
|
|
})
|
|
|
|
})
|