From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/activitypub/cleaner.ts | 52 +++++++++++++++---------------- server/tests/api/activitypub/client.ts | 6 ++-- server/tests/api/activitypub/fetch.ts | 18 +++++------ server/tests/api/activitypub/refresher.ts | 52 +++++++++++++++---------------- server/tests/api/activitypub/security.ts | 8 ++--- 5 files changed, 68 insertions(+), 68 deletions(-) (limited to 'server/tests/api/activitypub') diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index dcf758711..1421824da 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts @@ -46,9 +46,9 @@ describe('Test AP cleaner', function () { // Create 1 comment per video // Update 1 remote URL and 1 local URL on - videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'server 1' })).uuid - videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid - videoUUID3 = (await servers[2].videosCommand.quickUpload({ name: 'server 3' })).uuid + videoUUID1 = (await servers[0].videos.quickUpload({ name: 'server 1' })).uuid + videoUUID2 = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid + videoUUID3 = (await servers[2].videos.quickUpload({ name: 'server 3' })).uuid videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ] @@ -56,8 +56,8 @@ describe('Test AP cleaner', function () { for (const server of servers) { for (const uuid of videoUUIDs) { - await server.videosCommand.rate({ id: uuid, rating: 'like' }) - await server.commentsCommand.createThread({ videoId: uuid, text: 'comment' }) + await server.videos.rate({ id: uuid, rating: 'like' }) + await server.comments.createThread({ videoId: uuid, text: 'comment' }) } } @@ -67,7 +67,7 @@ describe('Test AP cleaner', function () { it('Should have the correct likes', async function () { for (const server of servers) { for (const uuid of videoUUIDs) { - const video = await server.videosCommand.get({ id: uuid }) + const video = await server.videos.get({ id: uuid }) expect(video.likes).to.equal(3) expect(video.dislikes).to.equal(0) @@ -78,9 +78,9 @@ describe('Test AP cleaner', function () { it('Should destroy server 3 internal likes and correctly clean them', async function () { this.timeout(20000) - await servers[2].sqlCommand.deleteAll('accountVideoRate') + await servers[2].sql.deleteAll('accountVideoRate') for (const uuid of videoUUIDs) { - await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0') + await servers[2].sql.setVideoField(uuid, 'likes', '0') } await wait(5000) @@ -88,14 +88,14 @@ describe('Test AP cleaner', function () { // Updated rates of my video { - const video = await servers[0].videosCommand.get({ id: videoUUID1 }) + const video = await servers[0].videos.get({ id: videoUUID1 }) expect(video.likes).to.equal(2) expect(video.dislikes).to.equal(0) } // Did not update rates of a remote video { - const video = await servers[0].videosCommand.get({ id: videoUUID2 }) + const video = await servers[0].videos.get({ id: videoUUID2 }) expect(video.likes).to.equal(3) expect(video.dislikes).to.equal(0) } @@ -106,7 +106,7 @@ describe('Test AP cleaner', function () { for (const server of servers) { for (const uuid of videoUUIDs) { - await server.videosCommand.rate({ id: uuid, rating: 'dislike' }) + await server.videos.rate({ id: uuid, rating: 'dislike' }) } } @@ -114,7 +114,7 @@ describe('Test AP cleaner', function () { for (const server of servers) { for (const uuid of videoUUIDs) { - const video = await server.videosCommand.get({ id: uuid }) + const video = await server.videos.get({ id: uuid }) expect(video.likes).to.equal(0) expect(video.dislikes).to.equal(3) } @@ -124,10 +124,10 @@ describe('Test AP cleaner', function () { it('Should destroy server 3 internal dislikes and correctly clean them', async function () { this.timeout(20000) - await servers[2].sqlCommand.deleteAll('accountVideoRate') + await servers[2].sql.deleteAll('accountVideoRate') for (const uuid of videoUUIDs) { - await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0') + await servers[2].sql.setVideoField(uuid, 'dislikes', '0') } await wait(5000) @@ -135,14 +135,14 @@ describe('Test AP cleaner', function () { // Updated rates of my video { - const video = await servers[0].videosCommand.get({ id: videoUUID1 }) + const video = await servers[0].videos.get({ id: videoUUID1 }) expect(video.likes).to.equal(0) expect(video.dislikes).to.equal(2) } // Did not update rates of a remote video { - const video = await servers[0].videosCommand.get({ id: videoUUID2 }) + const video = await servers[0].videos.get({ id: videoUUID2 }) expect(video.likes).to.equal(0) expect(video.dislikes).to.equal(3) } @@ -151,15 +151,15 @@ describe('Test AP cleaner', function () { it('Should destroy server 3 internal shares and correctly clean them', async function () { this.timeout(20000) - const preCount = await servers[0].sqlCommand.getCount('videoShare') + const preCount = await servers[0].sql.getCount('videoShare') expect(preCount).to.equal(6) - await servers[2].sqlCommand.deleteAll('videoShare') + await servers[2].sql.deleteAll('videoShare') await wait(5000) await waitJobs(servers) // Still 6 because we don't have remote shares on local videos - const postCount = await servers[0].sqlCommand.getCount('videoShare') + const postCount = await servers[0].sql.getCount('videoShare') expect(postCount).to.equal(6) }) @@ -167,17 +167,17 @@ describe('Test AP cleaner', function () { this.timeout(20000) { - const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) + const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 }) expect(total).to.equal(3) } - await servers[2].sqlCommand.deleteAll('videoComment') + await servers[2].sql.deleteAll('videoComment') await wait(5000) await waitJobs(servers) { - const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) + const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 }) expect(total).to.equal(2) } }) @@ -188,7 +188,7 @@ describe('Test AP cleaner', function () { async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` - const res = await servers[0].sqlCommand.selectQuery(query) + const res = await servers[0].sql.selectQuery(query) for (const rate of res) { const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) @@ -217,7 +217,7 @@ describe('Test AP cleaner', function () { { const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` - await servers[1].sqlCommand.updateQuery(query) + await servers[1].sql.updateQuery(query) await wait(5000) await waitJobs(servers) @@ -234,7 +234,7 @@ describe('Test AP cleaner', function () { const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` - const res = await servers[0].sqlCommand.selectQuery(query) + const res = await servers[0].sql.selectQuery(query) for (const comment of res) { const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) @@ -260,7 +260,7 @@ describe('Test AP cleaner', function () { { const query = `UPDATE "videoComment" SET url = url || 'kyle'` - await servers[1].sqlCommand.updateQuery(query) + await servers[1].sql.updateQuery(query) await wait(5000) await waitJobs(servers) diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index 0190df04c..5845045a3 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts @@ -68,12 +68,12 @@ describe('Test activitypub', function () { await setDefaultVideoChannel(servers) { - video = await await servers[0].videosCommand.quickUpload({ name: 'video' }) + video = await await servers[0].videos.quickUpload({ name: 'video' }) } { - const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id } - playlist = await servers[0].playlistsCommand.create({ attributes }) + const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].store.channel.id } + playlist = await servers[0].playlists.create({ attributes }) } await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index 5ab4a85d7..34694a773 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts @@ -21,24 +21,24 @@ describe('Test ActivityPub fetcher', function () { const user = { username: 'user1', password: 'password' } for (const server of servers) { - await server.usersCommand.create({ username: user.username, password: user.password }) + await server.users.create({ username: user.username, password: user.password }) } - const userAccessToken = await servers[0].loginCommand.getAccessToken(user) + const userAccessToken = await servers[0].login.getAccessToken(user) - await servers[0].videosCommand.upload({ attributes: { name: 'video root' } }) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'bad video root' } }) - await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'video user' } }) + await servers[0].videos.upload({ attributes: { name: 'video root' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } }) + await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } }) { const to = 'http://localhost:' + servers[0].port + '/accounts/user1' const value = 'http://localhost:' + servers[1].port + '/accounts/user1' - await servers[0].sqlCommand.setActorField(to, 'url', value) + await servers[0].sql.setActorField(to, 'url', value) } { const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid - await servers[0].sqlCommand.setVideoField(uuid, 'url', value) + await servers[0].sql.setVideoField(uuid, 'url', value) } }) @@ -49,7 +49,7 @@ describe('Test ActivityPub fetcher', function () { await waitJobs(servers) { - const { total, data } = await servers[0].videosCommand.list({ sort: 'createdAt' }) + const { total, data } = await servers[0].videos.list({ sort: 'createdAt' }) expect(total).to.equal(3) expect(data[0].name).to.equal('video root') @@ -58,7 +58,7 @@ describe('Test ActivityPub fetcher', function () { } { - const { total, data } = await servers[1].videosCommand.list({ sort: 'createdAt' }) + const { total, data } = await servers[1].videos.list({ sort: 'createdAt' }) expect(total).to.equal(1) expect(data[0].name).to.equal('video root') diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 5af4b1edb..d2f71e857 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts @@ -34,28 +34,28 @@ describe('Test AP refresher', function () { await setDefaultVideoChannel(servers) { - videoUUID1 = (await servers[1].videosCommand.quickUpload({ name: 'video1' })).uuid - videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'video2' })).uuid - videoUUID3 = (await servers[1].videosCommand.quickUpload({ name: 'video3' })).uuid + videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid + videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid + videoUUID3 = (await servers[1].videos.quickUpload({ name: 'video3' })).uuid } { - const token1 = await servers[1].usersCommand.generateUserAndToken('user1') - await servers[1].videosCommand.upload({ token: token1, attributes: { name: 'video4' } }) + const token1 = await servers[1].users.generateUserAndToken('user1') + await servers[1].videos.upload({ token: token1, attributes: { name: 'video4' } }) - const token2 = await servers[1].usersCommand.generateUserAndToken('user2') - await servers[1].videosCommand.upload({ token: token2, attributes: { name: 'video5' } }) + const token2 = await servers[1].users.generateUserAndToken('user2') + await servers[1].videos.upload({ token: token2, attributes: { name: 'video5' } }) } { - const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } - const created = await servers[1].playlistsCommand.create({ attributes }) + const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id } + const created = await servers[1].playlists.create({ attributes }) playlistUUID1 = created.uuid } { - const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } - const created = await servers[1].playlistsCommand.create({ attributes }) + const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id } + const created = await servers[1].playlists.create({ attributes }) playlistUUID2 = created.uuid } @@ -70,15 +70,15 @@ describe('Test AP refresher', function () { await wait(10000) // Change UUID so the remote server returns a 404 - await servers[1].sqlCommand.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') + await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') - await servers[0].videosCommand.get({ id: videoUUID1 }) - await servers[0].videosCommand.get({ id: videoUUID2 }) + await servers[0].videos.get({ id: videoUUID1 }) + await servers[0].videos.get({ id: videoUUID2 }) await waitJobs(servers) - await servers[0].videosCommand.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) - await servers[0].videosCommand.get({ id: videoUUID2 }) + await servers[0].videos.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[0].videos.get({ id: videoUUID2 }) }) it('Should not update a remote video if the remote instance is down', async function () { @@ -86,18 +86,18 @@ describe('Test AP refresher', function () { await killallServers([ servers[1] ]) - await servers[1].sqlCommand.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') + await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') // Video will need a refresh await wait(10000) - await servers[0].videosCommand.get({ id: videoUUID3 }) + await servers[0].videos.get({ id: videoUUID3 }) // The refresh should fail await waitJobs([ servers[0] ]) await reRunServer(servers[1]) - await servers[0].videosCommand.get({ id: videoUUID3 }) + await servers[0].videos.get({ id: videoUUID3 }) }) }) @@ -106,13 +106,13 @@ describe('Test AP refresher', function () { it('Should remove a deleted actor', async function () { this.timeout(60000) - const command = servers[0].accountsCommand + const command = servers[0].accounts await wait(10000) // Change actor name so the remote server returns a 404 const to = 'http://localhost:' + servers[1].port + '/accounts/user2' - await servers[1].sqlCommand.setActorField(to, 'preferredUsername', 'toto') + await servers[1].sql.setActorField(to, 'preferredUsername', 'toto') await command.get({ accountName: 'user1@localhost:' + servers[1].port }) await command.get({ accountName: 'user2@localhost:' + servers[1].port }) @@ -132,15 +132,15 @@ describe('Test AP refresher', function () { await wait(10000) // Change UUID so the remote server returns a 404 - await servers[1].sqlCommand.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') + await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') - await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 }) - await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 }) + await servers[0].playlists.get({ playlistId: playlistUUID1 }) + await servers[0].playlists.get({ playlistId: playlistUUID2 }) await waitJobs(servers) - await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 }) - await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 }) + await servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) }) diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index c32940070..ab0eb256e 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts @@ -24,8 +24,8 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' return Promise.all([ - onServer.sqlCommand.setActorField(url, 'publicKey', publicKey), - onServer.sqlCommand.setActorField(url, 'privateKey', privateKey) + onServer.sql.setActorField(url, 'publicKey', publicKey), + onServer.sql.setActorField(url, 'privateKey', privateKey) ]) } @@ -33,8 +33,8 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' return Promise.all([ - onServer.sqlCommand.setActorField(url, 'createdAt', updatedAt), - onServer.sqlCommand.setActorField(url, 'updatedAt', updatedAt) + onServer.sql.setActorField(url, 'createdAt', updatedAt), + onServer.sql.setActorField(url, 'updatedAt', updatedAt) ]) } -- cgit v1.2.3