]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/misc-endpoints.ts
Introduce user command
[github/Chocobozzz/PeerTube.git] / server / tests / misc-endpoints.ts
index 698d833283caea5b5a03e0463ccc1f2231b91453..84bdcaabf7418f8ee788deb9026aa5d842e7b2ab 100644 (file)
@@ -2,10 +2,9 @@
 
 import 'mocha'
 import * as chai from 'chai'
+import { HttpStatusCode } from '@shared/core-utils'
 import {
-  addVideoChannel,
   cleanupTests,
-  createUser,
   flushAndRunServer,
   makeGetRequest,
   ServerInfo,
@@ -13,7 +12,6 @@ import {
   uploadVideo
 } from '../../shared/extra-utils'
 import { VideoPrivacy } from '../../shared/models/videos'
-import { HttpStatusCode } from '@shared/core-utils'
 
 const expect = chai.expect
 
@@ -80,6 +78,31 @@ describe('Test misc endpoints', function () {
 
       expect(res.header.location).to.equal('/my-account/settings')
     })
+
+    it('Should test webfinger', async function () {
+      const resource = 'acct:peertube@' + server.host
+      const accountUrl = server.url + '/accounts/peertube'
+
+      const res = await makeGetRequest({
+        url: server.url,
+        path: '/.well-known/webfinger?resource=' + resource,
+        statusCodeExpected: HttpStatusCode.OK_200
+      })
+
+      const data = res.body
+
+      expect(data.subject).to.equal(resource)
+      expect(data.aliases).to.contain(accountUrl)
+
+      const self = data.links.find(l => l.rel === 'self')
+      expect(self).to.exist
+      expect(self.type).to.equal('application/activity+json')
+      expect(self.href).to.equal(accountUrl)
+
+      const remoteInteract = data.links.find(l => l.rel === 'http://ostatus.org/schema/1.0/subscribe')
+      expect(remoteInteract).to.exist
+      expect(remoteInteract.template).to.equal(server.url + '/remote-interaction?uri={uri}')
+    })
   })
 
   describe('Test classic static endpoints', function () {
@@ -110,6 +133,8 @@ describe('Test misc endpoints', function () {
       })
 
       expect(res.body.software.name).to.equal('peertube')
+      expect(res.body.usage.users.activeMonth).to.equal(1)
+      expect(res.body.usage.users.activeHalfyear).to.equal(1)
     })
   })
 
@@ -144,11 +169,11 @@ describe('Test misc endpoints', function () {
       await uploadVideo(server.url, server.accessToken, { name: 'video 2', nsfw: false })
       await uploadVideo(server.url, server.accessToken, { name: 'video 3', privacy: VideoPrivacy.PRIVATE })
 
-      await addVideoChannel(server.url, server.accessToken, { name: 'channel1', displayName: 'channel 1' })
-      await addVideoChannel(server.url, server.accessToken, { name: 'channel2', displayName: 'channel 2' })
+      await server.channelsCommand.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
+      await server.channelsCommand.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
 
-      await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' })
-      await createUser({ url: server.url, accessToken: server.accessToken, username: 'user2', password: 'password' })
+      await server.usersCommand.create({ username: 'user1', password: 'password' })
+      await server.usersCommand.create({ username: 'user2', password: 'password' })
 
       const res = await makeGetRequest({
         url: server.url,