diff options
Diffstat (limited to 'server/tests/api/check-params/follows.ts')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index dfe3f226d..2bc9f6b96 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -32,19 +32,13 @@ describe('Test server follows API validators', function () { | |||
32 | let userAccessToken = null | 32 | let userAccessToken = null |
33 | 33 | ||
34 | before(async function () { | 34 | before(async function () { |
35 | const user = { | 35 | userAccessToken = await server.users.generateUserAndToken('user1') |
36 | username: 'user1', | ||
37 | password: 'password' | ||
38 | } | ||
39 | |||
40 | await server.users.create({ username: user.username, password: user.password }) | ||
41 | userAccessToken = await server.login.getAccessToken(user) | ||
42 | }) | 36 | }) |
43 | 37 | ||
44 | describe('When adding follows', function () { | 38 | describe('When adding follows', function () { |
45 | const path = '/api/v1/server/following' | 39 | const path = '/api/v1/server/following' |
46 | 40 | ||
47 | it('Should fail without hosts', async function () { | 41 | it('Should fail with nothing', async function () { |
48 | await makePostBodyRequest({ | 42 | await makePostBodyRequest({ |
49 | url: server.url, | 43 | url: server.url, |
50 | path, | 44 | path, |
@@ -53,41 +47,51 @@ describe('Test server follows API validators', function () { | |||
53 | }) | 47 | }) |
54 | }) | 48 | }) |
55 | 49 | ||
56 | it('Should fail if hosts is not an array', async function () { | 50 | it('Should fail if hosts is not composed by hosts', async function () { |
57 | await makePostBodyRequest({ | 51 | await makePostBodyRequest({ |
58 | url: server.url, | 52 | url: server.url, |
59 | path, | 53 | path, |
54 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, | ||
60 | token: server.accessToken, | 55 | token: server.accessToken, |
61 | fields: { hosts: 'localhost:9002' }, | ||
62 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 56 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
63 | }) | 57 | }) |
64 | }) | 58 | }) |
65 | 59 | ||
66 | it('Should fail if the array is not composed by hosts', async function () { | 60 | it('Should fail if hosts is composed with http schemes', async function () { |
67 | await makePostBodyRequest({ | 61 | await makePostBodyRequest({ |
68 | url: server.url, | 62 | url: server.url, |
69 | path, | 63 | path, |
70 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, | 64 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, |
71 | token: server.accessToken, | 65 | token: server.accessToken, |
72 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 66 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
73 | }) | 67 | }) |
74 | }) | 68 | }) |
75 | 69 | ||
76 | it('Should fail if the array is composed with http schemes', async function () { | 70 | it('Should fail if hosts are not unique', async function () { |
77 | await makePostBodyRequest({ | 71 | await makePostBodyRequest({ |
78 | url: server.url, | 72 | url: server.url, |
79 | path, | 73 | path, |
80 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, | 74 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, |
81 | token: server.accessToken, | 75 | token: server.accessToken, |
82 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 76 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
83 | }) | 77 | }) |
84 | }) | 78 | }) |
85 | 79 | ||
86 | it('Should fail if hosts are not unique', async function () { | 80 | it('Should fail if handles is not composed by handles', async function () { |
87 | await makePostBodyRequest({ | 81 | await makePostBodyRequest({ |
88 | url: server.url, | 82 | url: server.url, |
89 | path, | 83 | path, |
90 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, | 84 | fields: { handles: [ 'hello@example.com', 'localhost:9001' ] }, |
85 | token: server.accessToken, | ||
86 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
87 | }) | ||
88 | }) | ||
89 | |||
90 | it('Should fail if handles are not unique', async function () { | ||
91 | await makePostBodyRequest({ | ||
92 | url: server.url, | ||
93 | path, | ||
94 | fields: { urls: [ 'hello@example.com', 'hello@example.com' ] }, | ||
91 | token: server.accessToken, | 95 | token: server.accessToken, |
92 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 96 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
93 | }) | 97 | }) |