+ it('Should have an expired access token')
+
+ it('Should refresh the token')
+
+ it('Should be able to upload a video again')
+
+ it('Should be able to create a new user', function (done) {
+ usersUtils.createUser(server.url, accessToken, 'user_1', 'super password', done)
+ })
+
+ it('Should be able to login with this user', function (done) {
+ server.user = {
+ username: 'user_1',
+ password: 'super password'
+ }
+
+ loginUtils.loginAndGetAccessToken(server, function (err, token) {
+ if (err) throw err
+
+ accessTokenUser = token
+
+ done()
+ })
+ })
+
+ it('Should be able to get the user informations', function (done) {
+ usersUtils.getUserInformation(server.url, accessTokenUser, function (err, res) {
+ if (err) throw err
+
+ const user = res.body
+
+ expect(user.username).to.equal('user_1')
+ expect(user.id).to.exist
+
+ done()
+ })
+ })
+
+ it('Should be able to upload a video with this user', function (done) {
+ this.timeout(5000)
+
+ const name = 'my super name'
+ const description = 'my super description'
+ const tags = [ 'tag1', 'tag2', 'tag3' ]
+ const file = 'video_short.webm'
+ videosUtils.uploadVideo(server.url, accessTokenUser, name, description, tags, file, done)
+ })
+
+ it('Should list all the users', function (done) {
+ usersUtils.getUsersList(server.url, function (err, res) {
+ if (err) throw err
+
+ const result = res.body
+ const total = result.total
+ const users = result.data
+
+ expect(total).to.equal(2)
+ expect(users).to.be.an('array')
+ expect(users.length).to.equal(2)
+
+ const user = users[0]
+ expect(user.username).to.equal('user_1')
+
+ const rootUser = users[1]
+ expect(rootUser.username).to.equal('root')
+ userId = user.id
+
+ done()
+ })
+ })
+
+ it('Should list only the first user by username asc', function (done) {
+ usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, 'username', function (err, res) {
+ if (err) throw err
+
+ const result = res.body
+ const total = result.total
+ const users = result.data
+
+ expect(total).to.equal(2)
+ expect(users.length).to.equal(1)
+
+ const user = users[0]
+ expect(user.username).to.equal('root')
+
+ done()
+ })
+ })
+
+ it('Should list only the first user by username desc', function (done) {
+ usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-username', function (err, res) {
+ if (err) throw err
+
+ const result = res.body
+ const total = result.total
+ const users = result.data
+
+ expect(total).to.equal(2)
+ expect(users.length).to.equal(1)
+
+ const user = users[0]
+ expect(user.username).to.equal('user_1')
+
+ done()
+ })
+ })
+
+ it('Should list only the second user by createdAt desc', function (done) {
+ usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-createdAt', function (err, res) {
+ if (err) throw err
+
+ const result = res.body
+ const total = result.total
+ const users = result.data
+
+ expect(total).to.equal(2)
+ expect(users.length).to.equal(1)
+
+ const user = users[0]
+ expect(user.username).to.equal('user_1')
+
+ done()
+ })
+ })
+
+ it('Should list all the users by createdAt asc', function (done) {
+ usersUtils.getUsersListPaginationAndSort(server.url, 0, 2, 'createdAt', function (err, res) {
+ if (err) throw err
+
+ const result = res.body
+ const total = result.total
+ const users = result.data
+
+ expect(total).to.equal(2)
+ expect(users.length).to.equal(2)
+
+ expect(users[0].username).to.equal('root')
+ expect(users[1].username).to.equal('user_1')
+
+ done()
+ })
+ })
+
+ it('Should update the user password', function (done) {
+ usersUtils.updateUser(server.url, userId, accessTokenUser, 'new password', function (err, res) {
+ if (err) throw err
+
+ server.user.password = 'new password'
+ loginUtils.login(server.url, server.client, server.user, 200, done)
+ })
+ })
+
+ it('Should be able to remove this user', function (done) {
+ usersUtils.removeUser(server.url, userId, accessToken, done)
+ })
+
+ it('Should not be able to login with this user', function (done) {
+ // server.user is already set to user 1
+ loginUtils.login(server.url, server.client, server.user, 400, done)
+ })
+
+ it('Should not have videos of this user', function (done) {
+ videosUtils.getVideosList(server.url, function (err, res) {
+ if (err) throw err
+
+ expect(res.body.total).to.equal(1)
+ const video = res.body.data[0]
+ expect(video.author).to.equal('root')
+
+ done()
+ })
+ })
+