+ await servers[0].servers.waitUntilLog('server actor name is peertube')
+ })
+ })
+
+ describe('Plugin', function () {
+
+ it('Should get the base static route', async function () {
+ const res = await makeGetRequest({
+ url: servers[0].url,
+ path: '/plugins/test-four/router/static-route',
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/')
+ })
+
+ it('Should get the base static route', async function () {
+ const baseRouter = '/plugins/test-four/0.0.1/router/'
+
+ const res = await makeGetRequest({
+ url: servers[0].url,
+ path: baseRouter + 'router-route',
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ expect(res.body.routerRoute).to.equal(baseRouter)
+ })
+ })
+
+ describe('User', function () {
+ let rootId: number
+
+ it('Should not get a user if not authenticated', async function () {
+ await makeGetRequest({
+ url: servers[0].url,
+ path: '/plugins/test-four/router/user',
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
+ })
+ })
+
+ it('Should get a user if authenticated', async function () {
+ const res = await makeGetRequest({
+ url: servers[0].url,
+ token: servers[0].accessToken,
+ path: '/plugins/test-four/router/user',
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ expect(res.body.username).to.equal('root')
+ expect(res.body.displayName).to.equal('root')
+ expect(res.body.isAdmin).to.be.true
+ expect(res.body.isModerator).to.be.false
+ expect(res.body.isUser).to.be.false
+
+ rootId = res.body.id
+ })
+
+ it('Should load a user by id', async function () {
+ {
+ const res = await makeGetRequest({
+ url: servers[0].url,
+ path: '/plugins/test-four/router/user/' + rootId,
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ expect(res.body.username).to.equal('root')
+ }
+
+ {
+ await makeGetRequest({
+ url: servers[0].url,
+ path: '/plugins/test-four/router/user/42',
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
+ })
+ }