import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
ServerInfo,
setAccessTokensToServers,
userLogin
-} from '../../../../shared/utils'
+} from '../../../../shared/extra-utils'
describe('Test server redundancy API validators', function () {
let servers: ServerInfo[]
before(async function () {
this.timeout(30000)
- await flushTests()
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
password: 'password'
}
- await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
+ await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
userAccessToken = await userLogin(servers[0], user)
})
it('Should fail with an invalid token', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: 'fake_token',
statusCodeExpected: 401
it('Should fail if the user is not an administrator', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: userAccessToken,
statusCodeExpected: 403
it('Should fail without de redundancyAllowed param', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { blabla: true },
token: servers[0].accessToken,
statusCodeExpected: 400
it('Should succeed with the correct parameters', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: servers[0].accessToken,
statusCodeExpected: 204
})
after(async function () {
- killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ await cleanupTests(servers)
})
})