1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
13 } from '../../../../shared/extra-utils'
15 describe('Test services API validators', function () {
16 let server: ServerInfo
18 // ---------------------------------------------------------------
20 before(async function () {
23 server = await flushAndRunServer(1)
24 await setAccessTokensToServers([ server ])
26 const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })
27 server.video = res.body.video
30 describe('Test oEmbed API validators', function () {
32 it('Should fail with an invalid url', async function () {
33 const embedUrl = 'hello.com'
34 await checkParamEmbed(server, embedUrl)
37 it('Should fail with an invalid host', async function () {
38 const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid
39 await checkParamEmbed(server, embedUrl)
42 it('Should fail with an invalid video id', async function () {
43 const embedUrl = 'http://localhost:9001/videos/watch/blabla'
44 await checkParamEmbed(server, embedUrl)
47 it('Should fail with an unknown video', async function () {
48 const embedUrl = 'http://localhost:9001/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c'
49 await checkParamEmbed(server, embedUrl, 404)
52 it('Should fail with an invalid path', async function () {
53 const embedUrl = 'http://localhost:9001/videos/watchs/' + server.video.uuid
55 await checkParamEmbed(server, embedUrl)
58 it('Should fail with an invalid max height', async function () {
59 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
61 await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' })
64 it('Should fail with an invalid max width', async function () {
65 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
67 await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' })
70 it('Should fail with an invalid format', async function () {
71 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
73 await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' })
76 it('Should fail with a non supported format', async function () {
77 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
79 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
82 it('Should succeed with the correct params', async function () {
83 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
90 await checkParamEmbed(server, embedUrl, 200, query)
95 killallServers([ server ])
99 function checkParamEmbed (server: ServerInfo, embedUrl: string, statusCodeExpected = 400, query = {}) {
100 const path = '/services/oembed'
102 return makeGetRequest({
105 query: Object.assign(query, { url: embedUrl }),