diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-11 16:27:07 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-13 14:05:49 +0200 |
commit | c48e82b5e0478434de30626d14594a97f2402e7c (patch) | |
tree | a78e5272bd0fe4f5b41831e571e02d05f1515b82 /server/tests/api/check-params | |
parent | a651038487faa838bda3ce04695b08bc65baff70 (diff) | |
download | PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.tar.gz PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.tar.zst PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.zip |
Basic video redundancy implementation
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 9 | ||||
-rw-r--r-- | server/tests/api/check-params/index.ts | 8 | ||||
-rw-r--r-- | server/tests/api/check-params/redundancy.ts | 103 |
3 files changed, 108 insertions, 12 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 2bc3b27d9..cdc95c81a 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -169,15 +169,6 @@ describe('Test server follows API validators', function () { | |||
169 | statusCodeExpected: 404 | 169 | statusCodeExpected: 404 |
170 | }) | 170 | }) |
171 | }) | 171 | }) |
172 | |||
173 | it('Should succeed with the correct parameters', async function () { | ||
174 | await makeDeleteRequest({ | ||
175 | url: server.url, | ||
176 | path: path + '/localhost:9002', | ||
177 | token: server.accessToken, | ||
178 | statusCodeExpected: 404 | ||
179 | }) | ||
180 | }) | ||
181 | }) | 172 | }) |
182 | }) | 173 | }) |
183 | 174 | ||
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 777acbb0f..44460a167 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -1,15 +1,17 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './accounts' | 2 | import './accounts' |
3 | import './config' | ||
3 | import './follows' | 4 | import './follows' |
4 | import './jobs' | 5 | import './jobs' |
6 | import './redundancy' | ||
7 | import './search' | ||
5 | import './services' | 8 | import './services' |
9 | import './user-subscriptions' | ||
6 | import './users' | 10 | import './users' |
7 | import './video-abuses' | 11 | import './video-abuses' |
8 | import './video-blacklist' | 12 | import './video-blacklist' |
9 | import './video-captions' | 13 | import './video-captions' |
10 | import './video-channels' | 14 | import './video-channels' |
11 | import './video-comments' | 15 | import './video-comments' |
12 | import './videos' | ||
13 | import './video-imports' | 16 | import './video-imports' |
14 | import './search' | 17 | import './videos' |
15 | import './user-subscriptions' | ||
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts new file mode 100644 index 000000000..aa588e3dd --- /dev/null +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -0,0 +1,103 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
4 | |||
5 | import { | ||
6 | createUser, | ||
7 | doubleFollow, | ||
8 | flushAndRunMultipleServers, | ||
9 | flushTests, | ||
10 | killallServers, | ||
11 | makePutBodyRequest, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | userLogin | ||
15 | } from '../../utils' | ||
16 | |||
17 | describe('Test server redundancy API validators', function () { | ||
18 | let servers: ServerInfo[] | ||
19 | let userAccessToken = null | ||
20 | |||
21 | // --------------------------------------------------------------- | ||
22 | |||
23 | before(async function () { | ||
24 | this.timeout(30000) | ||
25 | |||
26 | await flushTests() | ||
27 | servers = await flushAndRunMultipleServers(2) | ||
28 | |||
29 | await setAccessTokensToServers(servers) | ||
30 | await doubleFollow(servers[0], servers[1]) | ||
31 | |||
32 | const user = { | ||
33 | username: 'user1', | ||
34 | password: 'password' | ||
35 | } | ||
36 | |||
37 | await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) | ||
38 | userAccessToken = await userLogin(servers[0], user) | ||
39 | }) | ||
40 | |||
41 | describe('When updating redundancy', function () { | ||
42 | const path = '/api/v1/server/redundancy' | ||
43 | |||
44 | it('Should fail with an invalid token', async function () { | ||
45 | await makePutBodyRequest({ | ||
46 | url: servers[0].url, | ||
47 | path: path + '/localhost:9002', | ||
48 | fields: { redundancyAllowed: true }, | ||
49 | token: 'fake_token', | ||
50 | statusCodeExpected: 401 | ||
51 | }) | ||
52 | }) | ||
53 | |||
54 | it('Should fail if the user is not an administrator', async function () { | ||
55 | await makePutBodyRequest({ | ||
56 | url: servers[0].url, | ||
57 | path: path + '/localhost:9002', | ||
58 | fields: { redundancyAllowed: true }, | ||
59 | token: userAccessToken, | ||
60 | statusCodeExpected: 403 | ||
61 | }) | ||
62 | }) | ||
63 | |||
64 | it('Should fail if we do not follow this server', async function () { | ||
65 | await makePutBodyRequest({ | ||
66 | url: servers[0].url, | ||
67 | path: path + '/example.com', | ||
68 | fields: { redundancyAllowed: true }, | ||
69 | token: servers[0].accessToken, | ||
70 | statusCodeExpected: 404 | ||
71 | }) | ||
72 | }) | ||
73 | |||
74 | it('Should fail without de redundancyAllowed param', async function () { | ||
75 | await makePutBodyRequest({ | ||
76 | url: servers[0].url, | ||
77 | path: path + '/localhost:9002', | ||
78 | fields: { blabla: true }, | ||
79 | token: servers[0].accessToken, | ||
80 | statusCodeExpected: 400 | ||
81 | }) | ||
82 | }) | ||
83 | |||
84 | it('Should succeed with the correct parameters', async function () { | ||
85 | await makePutBodyRequest({ | ||
86 | url: servers[0].url, | ||
87 | path: path + '/localhost:9002', | ||
88 | fields: { redundancyAllowed: true }, | ||
89 | token: servers[0].accessToken, | ||
90 | statusCodeExpected: 204 | ||
91 | }) | ||
92 | }) | ||
93 | }) | ||
94 | |||
95 | after(async function () { | ||
96 | killallServers(servers) | ||
97 | |||
98 | // Keep the logs if the test failed | ||
99 | if (this['ok']) { | ||
100 | await flushTests() | ||
101 | } | ||
102 | }) | ||
103 | }) | ||