+ await checkBadSortPagination(server.url, path)
+ })
+
+ it('Should fail with an incorrect actor type', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path,
+ query: {
+ actorType: 'blabla'
+ }
+ })
+ })
+
+ it('Should fail with an incorrect state', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path,
+ query: {
+ state: 'blabla',
+ actorType: 'Application'
+ }
+ })
+ })
+
+ it('Should fail succeed with the correct params', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path,
+ statusCodeExpected: HttpStatusCode.OK_200,
+ query: {
+ state: 'accepted'
+ }
+ })
+ })
+ })
+
+ describe('When removing a follower', function () {
+ const path = '/api/v1/server/followers'
+
+ it('Should fail with an invalid token', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002',
+ token: 'fake_token',
+ statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail if the user is not an administrator', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002',
+ token: userAccessToken,
+ statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail with an invalid follower', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/toto',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should fail with an unknown follower', async function () {
+ await makeDeleteRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9003',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ })
+ })
+ })
+
+ describe('When accepting a follower', function () {
+ const path = '/api/v1/server/followers'
+
+ it('Should fail with an invalid token', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002/accept',
+ token: 'fake_token',
+ statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail if the user is not an administrator', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002/accept',
+ token: userAccessToken,
+ statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail with an invalid follower', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto/accept',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should fail with an unknown follower', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9003/accept',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ })
+ })
+ })
+
+ describe('When rejecting a follower', function () {
+ const path = '/api/v1/server/followers'
+
+ it('Should fail with an invalid token', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002/reject',
+ token: 'fake_token',
+ statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail if the user is not an administrator', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9002/reject',
+ token: userAccessToken,
+ statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail with an invalid follower', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto/reject',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should fail with an unknown follower', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path: path + '/toto@localhost:9003/reject',
+ token: server.accessToken,
+ statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ })