1 /* tslint:disable:no-unused-expression */
3 import * as request from 'supertest'
9 setAccessTokensToServers,
12 import { getVideosList, uploadVideo } from '../../utils/videos'
14 describe('Test services API validators', function () {
17 // ---------------------------------------------------------------
19 before(async function () {
24 server = await runServer(1)
25 await setAccessTokensToServers([ server ])
27 const videoAttributes = {
30 await uploadVideo(server.url, server.accessToken, videoAttributes)
32 const res = await getVideosList(server.url)
33 server.video = res.body.data[0]
36 describe('Test oEmbed API validators', function () {
37 const path = '/services/oembed'
39 it('Should fail with an invalid url', async function () {
40 const embedUrl = 'hello.com'
42 await request(server.url)
44 .query({ url: embedUrl })
45 .set('Accept', 'application/json')
46 .set('Authorization', 'Bearer ' + server.accessToken)
50 it('Should fail with an invalid host', async function () {
51 const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid
53 await request(server.url)
55 .query({ url: embedUrl })
56 .set('Accept', 'application/json')
57 .set('Authorization', 'Bearer ' + server.accessToken)
61 it('Should fail with an invalid video id', async function () {
62 const embedUrl = 'http://localhost:9001/videos/watch/blabla'
64 await request(server.url)
66 .query({ url: embedUrl })
67 .set('Accept', 'application/json')
68 .set('Authorization', 'Bearer ' + server.accessToken)
72 it('Should fail with an unknown video', async function () {
73 const embedUrl = 'http://localhost:9001/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c'
75 await request(server.url)
77 .query({ url: embedUrl })
78 .set('Accept', 'application/json')
79 .set('Authorization', 'Bearer ' + server.accessToken)
83 it('Should fail with an invalid path', async function () {
84 const embedUrl = 'http://localhost:9001/videos/watchs/' + server.video.uuid
86 await request(server.url)
88 .query({ url: embedUrl })
89 .set('Accept', 'application/json')
90 .set('Authorization', 'Bearer ' + server.accessToken)
94 it('Should fail with an invalid max height', async function () {
95 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
97 await request(server.url)
103 .set('Accept', 'application/json')
104 .set('Authorization', 'Bearer ' + server.accessToken)
108 it('Should fail with an invalid max width', async function () {
109 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
111 await request(server.url)
117 .set('Accept', 'application/json')
118 .set('Authorization', 'Bearer ' + server.accessToken)
122 it('Should fail with an invalid format', async function () {
123 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
125 await request(server.url)
131 .set('Accept', 'application/json')
132 .set('Authorization', 'Bearer ' + server.accessToken)
136 it('Should fail with a non supported format', async function () {
137 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
139 await request(server.url)
145 .set('Accept', 'application/json')
146 .set('Authorization', 'Bearer ' + server.accessToken)
151 after(async function () {
152 killallServers([ server ])
154 // Keep the logs if the test failed