1 /* tslint:disable:no-unused-expression */
9 flushAndRunMultipleServers,
14 setAccessTokensToServers,
16 } from '../../../../shared/extra-utils'
18 describe('Test server redundancy API validators', function () {
19 let servers: ServerInfo[]
20 let userAccessToken = null
22 // ---------------------------------------------------------------
24 before(async function () {
27 servers = await flushAndRunMultipleServers(2)
29 await setAccessTokensToServers(servers)
30 await doubleFollow(servers[0], servers[1])
37 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
38 userAccessToken = await userLogin(servers[0], user)
41 describe('When updating redundancy', function () {
42 const path = '/api/v1/server/redundancy'
44 it('Should fail with an invalid token', async function () {
45 await makePutBodyRequest({
47 path: path + '/localhost:' + servers[1].port,
48 fields: { redundancyAllowed: true },
50 statusCodeExpected: 401
54 it('Should fail if the user is not an administrator', async function () {
55 await makePutBodyRequest({
57 path: path + '/localhost:' + servers[1].port,
58 fields: { redundancyAllowed: true },
59 token: userAccessToken,
60 statusCodeExpected: 403
64 it('Should fail if we do not follow this server', async function () {
65 await makePutBodyRequest({
67 path: path + '/example.com',
68 fields: { redundancyAllowed: true },
69 token: servers[0].accessToken,
70 statusCodeExpected: 404
74 it('Should fail without de redundancyAllowed param', async function () {
75 await makePutBodyRequest({
77 path: path + '/localhost:' + servers[1].port,
78 fields: { blabla: true },
79 token: servers[0].accessToken,
80 statusCodeExpected: 400
84 it('Should succeed with the correct parameters', async function () {
85 await makePutBodyRequest({
87 path: path + '/localhost:' + servers[1].port,
88 fields: { redundancyAllowed: true },
89 token: servers[0].accessToken,
90 statusCodeExpected: 204
95 after(async function () {
96 await cleanupTests(servers)