+ it('Should succeed with the correct params', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/user1',
+ token: server.accessToken,
+ statusCodeExpected: 204
+ })
+ })
+ })
+ })
+
+ 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,
+ statusCodeExpected: 401
+ })
+ })
+
+ it('Should fail with a user without the appropriate rights', async function () {
+ await makeGetRequest({
+ url: server.url,
+ token: userAccessToken,
+ path,
+ statusCodeExpected: 403
+ })
+ })
+
+ 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:' + servers[1].port },
+ statusCodeExpected: 401
+ })
+ })
+
+ it('Should fail with a user without the appropriate rights', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ token: userAccessToken,
+ path,
+ fields: { host: 'localhost:' + servers[1].port },
+ statusCodeExpected: 403
+ })
+ })
+
+ it('Should fail with an unknown server', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ token: server.accessToken,
+ path,
+ fields: { host: 'localhost:9003' },
+ statusCodeExpected: 404
+ })
+ })
+
+ it('Should fail with our own server', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ token: server.accessToken,
+ path,
+ fields: { host: 'localhost:' + server.port },
+ statusCodeExpected: 409
+ })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ token: server.accessToken,
+ path,
+ fields: { host: 'localhost:' + servers[1].port },
+ statusCodeExpected: 204
+ })
+ })
+ })
+
+ describe('When unblocking a server', function () {
+ it('Should fail with an unauthenticated user', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/localhost:' + servers[1].port,
+ statusCodeExpected: 401
+ })
+ })
+
+ it('Should fail with a user without the appropriate rights', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/localhost:' + servers[1].port,
+ token: userAccessToken,
+ statusCodeExpected: 403
+ })
+ })
+
+ it('Should fail with an unknown server block', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/localhost:9003',
+ token: server.accessToken,
+ statusCodeExpected: 404
+ })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/localhost:' + servers[1].port,
+ token: server.accessToken,
+ statusCodeExpected: 204
+ })
+ })
+ })
+ })
+ })
+
+ after(async function () {
+ await cleanupTests(servers)