-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import {
+ cleanupTests,
createUser,
- flushTests,
- killallServers,
+ flushAndRunServer,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
- runServer,
ServerInfo,
setAccessTokensToServers,
userLogin
-} from '../../../../shared/utils'
+} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
-} from '../../../../shared/utils/requests/check-api-params'
-import { waitJobs } from '../../../../shared/utils/server/jobs'
+} from '../../../../shared/extra-utils/requests/check-api-params'
+import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
describe('Test user subscriptions API validators', function () {
const path = '/api/v1/users/me/subscriptions'
before(async function () {
this.timeout(30000)
- await flushTests()
-
- server = await runServer(1)
+ server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
username: 'user1',
password: 'my super password'
}
- await createUser(server.url, server.accessToken, user.username, user.password)
+ await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
userAccessToken = await userLogin(server, user)
})
await makePostBodyRequest({
url: server.url,
path,
- fields: { uri: 'user1_channel@localhost:9001' },
+ fields: { uri: 'user1_channel@localhost:' + server.port },
statusCodeExpected: 401
})
})
url: server.url,
path,
token: server.accessToken,
- fields: { uri: 'user1_channel@localhost:9001' },
+ fields: { uri: 'user1_channel@localhost:' + server.port },
statusCodeExpected: 204
})
it('Should fail with a non authenticated user', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
statusCodeExpected: 401
})
})
it('Should fail with an unknown subscription', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/root1@localhost:9001',
+ path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 404
})
it('Should succeed with the correct parameters', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 200
})
await makeGetRequest({
url: server.url,
path: existPath,
- query: { 'uris[]': 'coucou@localhost:9001' },
+ query: { 'uris[]': 'coucou@localhost:' + server.port },
token: server.accessToken,
statusCodeExpected: 200
})
it('Should fail with a non authenticated user', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
statusCodeExpected: 401
})
})
it('Should fail with an unknown subscription', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/root1@localhost:9001',
+ path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 404
})
it('Should succeed with the correct parameters', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 204
})
})
after(async function () {
- killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ await cleanupTests([ server ])
})
})