makePutBodyRequest,
setAccessTokensToServers,
killallServers,
- makePostUploadRequest
+ makePostUploadRequest,
+ getMyUserInformation,
+ createUser,
+ getUserAccessToken
} from '../../utils'
describe('Test videos API validator', function () {
const path = '/api/v1/videos/'
let server: ServerInfo
+ let channelId: number
// ---------------------------------------------------------------
server = await runServer(1)
await setAccessTokensToServers([ server ])
+
+ const res = await getMyUserInformation(server.url, server.accessToken)
+ channelId = res.body.videoChannels[0].id
})
describe('When listing a video', function () {
it('Should fail with nothing', async function () {
const fields = {}
const attaches = {}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without name', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a long name', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without a category', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a bad category', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without a licence', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a bad licence', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a bad language', async function () {
language: 563,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without nsfw attribute', async function () {
licence: 4,
language: 6,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
- it('Should fail with a bad nsfw attribue', async function () {
+ it('Should fail with a bad nsfw attribute', async function () {
const fields = {
name: 'my super name',
category: 5,
language: 6,
nsfw: 2,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without description', async function () {
licence: 1,
language: 6,
nsfw: false,
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a long description', async function () {
description: 'my super description which is very very very very very very very very very very very very very very' +
'very very very very very very very very very very very very very very very very very very very very very' +
'very very very very very very very very very very very very very very very long',
+ tags: [ 'tag1', 'tag2' ],
+ channelId
+ }
+ const attaches = {
+ 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ })
+
+ it('Should fail without a channel', async function () {
+ const fields = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ })
+
+ it('Should fail with a bad channel', async function () {
+ const fields = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'tag1', 'tag2' ],
+ channelId: 545454
+ }
+ const attaches = {
+ 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
+ })
+
+ it('Should fail with another user channel', async function () {
+ const user = {
+ username: 'fake',
+ password: 'fake_password'
+ }
+ await createUser(server.url, server.accessToken, user.username, user.password)
+
+ const accessTokenUser = await getUserAccessToken(server, user)
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const channelId = res.body.videoChannels[0].id
+
+ const fields = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'tag1', 'tag2' ],
+ channelId
+ }
+ const attaches = {
+ 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with too many tags', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
+ tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a tag length too low', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 't' ]
+ tags: [ 'tag1', 't' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a tag length too big', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'my_super_tag_too_long', 'tag1' ]
+ tags: [ 'my_super_tag_too_long', 'tag1' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without an input file', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail without an incorrect input file', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with a too big duration', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+ await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should succeed with the correct parameters', async function () {
language: 6,
nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2' ]
+ tags: [ 'tag1', 'tag2' ],
+ channelId
}
const attaches = {
'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
}
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+ await makePostUploadRequest({
+ url: server.url,
+ path: path + '/upload',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: 204
+ })
attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4')
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+ await makePostUploadRequest({
+ url: server.url,
+ path: path + '/upload',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: 204
+ })
attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv')
- await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+ await makePostUploadRequest({
+ url: server.url,
+ path: path + '/upload',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: 204
+ })
})
})