X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Factivitypub%2Fclient.ts;h=d16f0510803773f6aa51f1ba6b046b5fe01ff906;hb=2ad9dcda240ee843c5e4a5b98cc94f7b2aab2c89;hp=d45232c8d0617cc84d8ead43b66078a8e17f6ee0;hpb=b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index d45232c8d..d16f05108 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts @@ -1,43 +1,64 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import * as chai from 'chai' import 'mocha' import { - flushTests, - killallServers, + cleanupTests, + doubleFollow, + flushAndRunMultipleServers, makeActivityPubGetRequest, - runServer, ServerInfo, - setAccessTokensToServers -} from '../../../../shared/utils' - + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/extra-utils' const expect = chai.expect describe('Test activitypub', function () { - let server: ServerInfo = null + let servers: ServerInfo[] = [] + let videoUUID: string before(async function () { this.timeout(30000) - await flushTests() + servers = await flushAndRunMultipleServers(2) + + await setAccessTokensToServers(servers) - server = await runServer(1) + { + const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) + videoUUID = res.body.video.uuid + } - await setAccessTokensToServers([ server ]) + await doubleFollow(servers[0], servers[1]) }) it('Should return the account object', async function () { - const res = await makeActivityPubGetRequest(server.url, '/accounts/root') + const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root') const object = res.body expect(object.type).to.equal('Person') - expect(object.id).to.equal('http://localhost:9001/accounts/root') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') expect(object.name).to.equal('root') expect(object.preferredUsername).to.equal('root') }) + it('Should return the video object', async function () { + const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID) + const object = res.body + + expect(object.type).to.equal('Video') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) + expect(object.name).to.equal('video') + }) + + it('Should redirect to the origin video object', async function () { + const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) + + expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) + }) + after(async function () { - killallServers([ server ]) + await cleanupTests(servers) }) })