diff options
Diffstat (limited to 'server/tests/api/users')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 57 | ||||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 10 | ||||
-rw-r--r-- | server/tests/api/users/users-verification.ts | 3 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 30 |
4 files changed, 79 insertions, 21 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index d1d192238..57cca6ad4 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
@@ -10,7 +11,7 @@ import { | |||
10 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
11 | SubscriptionsCommand, | 12 | SubscriptionsCommand, |
12 | waitJobs | 13 | waitJobs |
13 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
14 | 15 | ||
15 | const expect = chai.expect | 16 | const expect = chai.expect |
16 | 17 | ||
@@ -32,20 +33,18 @@ describe('Test users subscriptions', function () { | |||
32 | // Server 1 and server 2 follow each other | 33 | // Server 1 and server 2 follow each other |
33 | await doubleFollow(servers[0], servers[1]) | 34 | await doubleFollow(servers[0], servers[1]) |
34 | 35 | ||
35 | { | 36 | for (const server of servers) { |
36 | for (const server of servers) { | 37 | const user = { username: 'user' + server.serverNumber, password: 'password' } |
37 | const user = { username: 'user' + server.serverNumber, password: 'password' } | 38 | await server.users.create({ username: user.username, password: user.password }) |
38 | await server.users.create({ username: user.username, password: user.password }) | ||
39 | 39 | ||
40 | const accessToken = await server.login.getAccessToken(user) | 40 | const accessToken = await server.login.getAccessToken(user) |
41 | users.push({ accessToken }) | 41 | users.push({ accessToken }) |
42 | 42 | ||
43 | const videoName1 = 'video 1-' + server.serverNumber | 43 | const videoName1 = 'video 1-' + server.serverNumber |
44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) | 44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) |
45 | 45 | ||
46 | const videoName2 = 'video 2-' + server.serverNumber | 46 | const videoName2 = 'video 2-' + server.serverNumber |
47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) | 47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) |
48 | } | ||
49 | } | 48 | } |
50 | 49 | ||
51 | await waitJobs(servers) | 50 | await waitJobs(servers) |
@@ -540,6 +539,40 @@ describe('Test users subscriptions', function () { | |||
540 | } | 539 | } |
541 | }) | 540 | }) |
542 | 541 | ||
542 | it('Should update video as internal and not see from remote server', async function () { | ||
543 | this.timeout(30000) | ||
544 | |||
545 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) | ||
546 | await waitJobs(servers) | ||
547 | |||
548 | { | ||
549 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
550 | expect(data.find(v => v.name === 'internal')).to.not.exist | ||
551 | } | ||
552 | }) | ||
553 | |||
554 | it('Should see internal from local user', async function () { | ||
555 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
556 | expect(data.find(v => v.name === 'internal')).to.exist | ||
557 | }) | ||
558 | |||
559 | it('Should update video as private and not see from anyone server', async function () { | ||
560 | this.timeout(30000) | ||
561 | |||
562 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | ||
563 | await waitJobs(servers) | ||
564 | |||
565 | { | ||
566 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
567 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
568 | } | ||
569 | |||
570 | { | ||
571 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
572 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
573 | } | ||
574 | }) | ||
575 | |||
543 | after(async function () { | 576 | after(async function () { |
544 | await cleanupTests(servers) | 577 | await cleanupTests(servers) |
545 | }) | 578 | }) |
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index d0ca82b07..5b2bbc520 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -6,16 +6,18 @@ import { | |||
6 | checkActorFilesWereRemoved, | 6 | checkActorFilesWereRemoved, |
7 | checkTmpIsEmpty, | 7 | checkTmpIsEmpty, |
8 | checkVideoFilesWereRemoved, | 8 | checkVideoFilesWereRemoved, |
9 | saveVideoInServers, | ||
10 | testImage | ||
11 | } from '@server/tests/shared' | ||
12 | import { MyUser } from '@shared/models' | ||
13 | import { | ||
9 | cleanupTests, | 14 | cleanupTests, |
10 | createMultipleServers, | 15 | createMultipleServers, |
11 | doubleFollow, | 16 | doubleFollow, |
12 | PeerTubeServer, | 17 | PeerTubeServer, |
13 | saveVideoInServers, | ||
14 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
15 | testImage, | ||
16 | waitJobs | 19 | waitJobs |
17 | } from '@shared/extra-utils' | 20 | } from '@shared/server-commands' |
18 | import { MyUser } from '@shared/models' | ||
19 | 21 | ||
20 | const expect = chai.expect | 22 | const expect = chai.expect |
21 | 23 | ||
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index f54463359..0f3cc401a 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { MockSmtpServer } from '@server/tests/shared' |
6 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' | ||
7 | 8 | ||
8 | const expect = chai.expect | 9 | const expect = chai.expect |
9 | 10 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 6c41e7d56..7023b3f08 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { testImage } from '@server/tests/shared' | ||
6 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
@@ -9,10 +11,8 @@ import { | |||
9 | makePutBodyRequest, | 11 | makePutBodyRequest, |
10 | PeerTubeServer, | 12 | PeerTubeServer, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
12 | testImage, | ||
13 | waitJobs | 14 | waitJobs |
14 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
15 | import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | ||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
@@ -230,7 +230,7 @@ describe('Test users', function () { | |||
230 | }) | 230 | }) |
231 | 231 | ||
232 | it('Should have an expired access token', async function () { | 232 | it('Should have an expired access token', async function () { |
233 | this.timeout(15000) | 233 | this.timeout(60000) |
234 | 234 | ||
235 | await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()) | 235 | await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()) |
236 | await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()) | 236 | await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()) |
@@ -559,6 +559,28 @@ describe('Test users', function () { | |||
559 | expect(user.autoPlayNextVideo).to.be.true | 559 | expect(user.autoPlayNextVideo).to.be.true |
560 | }) | 560 | }) |
561 | 561 | ||
562 | it('Should be able to change the p2p attribute', async function () { | ||
563 | { | ||
564 | await server.users.updateMe({ | ||
565 | token: userToken, | ||
566 | webTorrentEnabled: false | ||
567 | }) | ||
568 | |||
569 | const user = await server.users.getMyInfo({ token: userToken }) | ||
570 | expect(user.p2pEnabled).to.be.false | ||
571 | } | ||
572 | |||
573 | { | ||
574 | await server.users.updateMe({ | ||
575 | token: userToken, | ||
576 | p2pEnabled: true | ||
577 | }) | ||
578 | |||
579 | const user = await server.users.getMyInfo({ token: userToken }) | ||
580 | expect(user.p2pEnabled).to.be.true | ||
581 | } | ||
582 | }) | ||
583 | |||
562 | it('Should be able to change the email attribute', async function () { | 584 | it('Should be able to change the email attribute', async function () { |
563 | await server.users.updateMe({ | 585 | await server.users.updateMe({ |
564 | token: userToken, | 586 | token: userToken, |