opensupports/tests/scripts.rb

56 lines
1.5 KiB
Ruby
Raw Normal View History

class Scripts
def self.createUser(email = 'steve@jobs.com', password = 'custompassword', name = 'steve jobs')
response = request('/user/signup', {
:name => name,
:email => email,
:password => password
})
if response['status'] === 'fail'
raise response['message']
2016-05-15 01:22:46 +02:00
end
userRow = $database.getRow('user', email, 'email')
2017-02-25 07:42:10 +01:00
request('/user/verify', {
:email => email,
:token => userRow['verification_token']
})
end
def self.login(email = 'steve@jobs.com', password = 'custompassword', staff = false)
request('/user/logout')
response = request('/user/login', {
:email => email,
:password => password,
:staff => staff
})
if response['data'].any?
$csrf_userid = response['data']['userId']
$csrf_token = response['data']['token']
end
response['data']
end
2017-02-25 07:42:10 +01:00
def self.createTicket(title = 'Winter is coming')
result = request('/ticket/create', {
2017-02-25 07:42:10 +01:00
title: title,
content: 'The north remembers',
departmentId: 1,
language: 'en',
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
result['data']
end
def self.createAPIKey(name)
2017-02-25 07:42:10 +01:00
request('/system/add-api-key', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
name: name
})
end
end