2016-12-01 19:07:11 +01:00
|
|
|
describe '/user/ban' do
|
|
|
|
|
2021-11-05 21:06:08 +01:00
|
|
|
Scripts.logout()
|
2016-12-01 19:07:11 +01:00
|
|
|
result = request('/user/login', {
|
2021-11-11 21:17:39 +01:00
|
|
|
email: $staff[:email],
|
|
|
|
password: $staff[:password],
|
2016-12-01 19:07:11 +01:00
|
|
|
staff: true
|
|
|
|
})
|
2020-08-20 04:33:40 +02:00
|
|
|
(result['status']).should.equal('success')
|
2016-12-01 19:07:11 +01:00
|
|
|
|
|
|
|
$csrf_userid = result['data']['userId']
|
|
|
|
$csrf_token = result['data']['token']
|
|
|
|
|
|
|
|
it 'should ban user' do
|
|
|
|
result = request('/user/ban', {
|
|
|
|
email: 'nothing@hotmail.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
user = $database.getRow('ban', 1 , 'id')
|
|
|
|
(user['email']).should.equal('nothing@hotmail.com')
|
|
|
|
|
2016-12-29 21:25:45 +01:00
|
|
|
lastLog = $database.getLastRow('log')
|
|
|
|
(lastLog['type']).should.equal('BAN_USER')
|
2016-12-01 19:07:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should get ban list' do
|
|
|
|
result = request('/user/list-ban', {
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['data'][0]).should.equal('nothing@hotmail.com')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not ban user if it is already banned' do
|
|
|
|
result = request('/user/ban', {
|
|
|
|
email: 'nothing@hotmail.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('fail')
|
|
|
|
(result['message']).should.equal('ALREADY_BANNED')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should un-ban user if it is already banned' do
|
|
|
|
result = request('/user/un-ban', {
|
|
|
|
email: 'nothing@hotmail.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('success')
|
|
|
|
|
|
|
|
user = $database.getRow('ban', 1 , 'id')
|
|
|
|
(user).should.equal(nil)
|
|
|
|
|
2016-12-29 21:25:45 +01:00
|
|
|
lastLog = $database.getLastRow('log')
|
|
|
|
(lastLog['type']).should.equal('UN_BAN_USER')
|
2016-12-01 19:07:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not un-ban user if it is not banned' do
|
|
|
|
result = request('/user/un-ban', {
|
|
|
|
email: 'nothing@hotmail.com',
|
|
|
|
csrf_userid: $csrf_userid,
|
|
|
|
csrf_token: $csrf_token
|
|
|
|
})
|
|
|
|
|
|
|
|
(result['status']).should.equal('fail')
|
|
|
|
(result['message']).should.equal('INVALID_EMAIL')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-12-29 21:25:45 +01:00
|
|
|
end
|