samanage 1.8.8 → 1.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +3 -0
- data/lib/samanage/api/custom_fields.rb +3 -3
- data/lib/samanage/api/custom_forms.rb +3 -3
- data/lib/samanage/api/departments.rb +3 -2
- data/lib/samanage/api/groups.rb +3 -3
- data/lib/samanage/api/hardwares.rb +3 -3
- data/lib/samanage/api/incidents.rb +2 -0
- data/lib/samanage/api/mobiles.rb +3 -3
- data/lib/samanage/api/other_assets.rb +3 -3
- data/lib/samanage/api/sites.rb +3 -3
- data/lib/samanage/api/users.rb +3 -3
- data/lib/samanage/version.rb +1 -1
- data/spec/api/samanage_category_spec.rb +5 -5
- data/spec/api/samanage_comments_spec.rb +9 -9
- data/spec/api/samanage_custom_field_spec.rb +4 -4
- data/spec/api/samanage_custom_form_spec.rb +3 -3
- data/spec/api/samanage_department_spec.rb +9 -9
- data/spec/api/samanage_group_spec.rb +17 -17
- data/spec/api/samanage_hardware_spec.rb +17 -19
- data/spec/api/samanage_incident_spec.rb +24 -23
- data/spec/api/samanage_mobile_spec.rb +14 -16
- data/spec/api/samanage_other_asset_spec.rb +12 -14
- data/spec/api/samanage_site_spec.rb +7 -6
- data/spec/api/samanage_user_spec.rb +21 -25
- data/spec/api/samanage_util_spec.rb +6 -5
- data/spec/samanage_api_spec.rb +3 -3
- data/spec/samanage_category_spec.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12aaeb776e072d9ce54b43f057110c940aa12be8
|
4
|
+
data.tar.gz: 6e825ba3089895f5552dc4fd5146d58fc8060602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf644e3b6496ff4a6b4eee7c75c189098f2d6f7bd673d49053f98f151e93d2a649abc70102380ce056de34b1866bd963f3136b168df78106771c417ee3c9323
|
7
|
+
data.tar.gz: 416eeccd82d3ba033211114872d5110fa74b72688b83aa93ba4e87eeb8b7d121082dc48e22499650b24700cfce0b28ac488d42e2afd7aee0fa80801395cc17a6
|
data/changelog.md
CHANGED
@@ -8,13 +8,13 @@ module Samanage
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Gets all custom fields
|
11
|
-
def collect_custom_fields
|
11
|
+
def collect_custom_fields(options: {})
|
12
12
|
page = 1
|
13
13
|
custom_fields = Array.new
|
14
14
|
total_pages = self.get_custom_fields[:total_pages] ||= 2
|
15
|
-
|
15
|
+
1.upto(total_pages) do |page|
|
16
|
+
puts "Collecting Custom Fields page: #{page}/#{total_pages}" if options[:verbose]
|
16
17
|
custom_fields += self.execute(path: "custom_fields.json")[:data]
|
17
|
-
page += 1
|
18
18
|
end
|
19
19
|
custom_fields
|
20
20
|
end
|
@@ -7,13 +7,13 @@ module Samanage
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# Get all custom forms
|
10
|
-
def collect_custom_forms
|
10
|
+
def collect_custom_forms(options: {})
|
11
11
|
page = 1
|
12
12
|
custom_forms = Array.new
|
13
13
|
total_pages = self.get_custom_forms[:total_pages]
|
14
|
-
|
14
|
+
1.upto(total_pages) do |page|
|
15
|
+
puts "Collecting Custom Forms page: #{page}/#{total_pages}" if options[:verbose]
|
15
16
|
custom_forms += self.execute(http_method: 'get', path: "custom_forms.json?page=#{page}")[:data]
|
16
|
-
page += 1
|
17
17
|
end
|
18
18
|
custom_forms
|
19
19
|
end
|
@@ -5,11 +5,12 @@ module Samanage
|
|
5
5
|
self.execute(path: url)
|
6
6
|
end
|
7
7
|
|
8
|
-
def collect_departments
|
8
|
+
def collect_departments(options: {})
|
9
9
|
page = 1
|
10
10
|
departments = Array.new
|
11
11
|
total_pages = self.get_departments[:total_pages]
|
12
|
-
|
12
|
+
1.upto(total_pages) do |page|
|
13
|
+
puts "Collecting Groups page: #{page}/#{total_pages}" if options[:verbose]
|
13
14
|
departments += self.execute(http_method: 'get', path: "departments.json?page=#{page}")[:data]
|
14
15
|
page += 1
|
15
16
|
end
|
data/lib/samanage/api/groups.rb
CHANGED
@@ -5,13 +5,13 @@ module Samanage
|
|
5
5
|
self.execute(path: url)
|
6
6
|
end
|
7
7
|
|
8
|
-
def collect_groups
|
8
|
+
def collect_groups(options: {})
|
9
9
|
page = 1
|
10
10
|
groups = Array.new
|
11
11
|
total_pages = self.get_groups[:total_pages]
|
12
|
-
|
12
|
+
1.upto(total_pages) do |page|
|
13
|
+
puts "Collecting Groups page: #{page}/#{total_pages}" if options[:verbose]
|
13
14
|
groups += self.execute(http_method: 'get', path: "groups.json?page=#{page}")[:data]
|
14
|
-
page += 1
|
15
15
|
end
|
16
16
|
groups
|
17
17
|
end
|
@@ -8,13 +8,13 @@ module Samanage
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Get all hardwares
|
11
|
-
def collect_hardwares
|
11
|
+
def collect_hardwares(options: {})
|
12
12
|
page = 1
|
13
13
|
hardwares = Array.new
|
14
14
|
total_pages = self.get_hardwares[:total_pages]
|
15
|
-
|
15
|
+
1.upto(total_pages) do |page|
|
16
|
+
puts "Collecting Hardwares page: #{page}/#{total_pages}" if options[:verbose]
|
16
17
|
hardwares += self.execute(http_method: 'get', path: "hardwares.json?page=#{page}")[:data]
|
17
|
-
page += 1
|
18
18
|
end
|
19
19
|
hardwares
|
20
20
|
end
|
@@ -15,7 +15,9 @@ module Samanage
|
|
15
15
|
def collect_incidents(options: {})
|
16
16
|
incidents = Array.new
|
17
17
|
total_pages = self.get_incidents[:total_pages]
|
18
|
+
puts "Pulling Incidents with Audit Archives (this may take a while)" if options[:audit_archives] && options[:verbose]
|
18
19
|
1.upto(total_pages) do |page|
|
20
|
+
puts "Collecting Incidents page: #{page}/#{total_pages}" if options[:verbose]
|
19
21
|
if options[:audit_archives]
|
20
22
|
archives = 'layout=long&audit_archive=true'
|
21
23
|
paginated_incidents = self.execute(path: "incidents.json?page=#{page}")[:data]
|
data/lib/samanage/api/mobiles.rb
CHANGED
@@ -8,13 +8,13 @@ module Samanage
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Get all mobiles
|
11
|
-
def collect_mobiles
|
11
|
+
def collect_mobiles(options: {})
|
12
12
|
page = 1
|
13
13
|
mobiles = Array.new
|
14
14
|
total_pages = self.get_mobiles[:total_pages]
|
15
|
-
|
15
|
+
1.upto(total_pages) do |page|
|
16
|
+
puts "Collecting Mobiles page: #{page}/#{total_pages}" if options[:verbose]
|
16
17
|
mobiles += self.execute(http_method: 'get', path: "mobiles.json?page=#{page}")[:data]
|
17
|
-
page += 1
|
18
18
|
end
|
19
19
|
mobiles
|
20
20
|
end
|
@@ -8,14 +8,14 @@ module Samanage
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Returns all other assets
|
11
|
-
def collect_other_assets
|
11
|
+
def collect_other_assets(options: {})
|
12
12
|
page = 1
|
13
13
|
other_assets = Array.new
|
14
14
|
total_pages = self.get_other_assets[:total_pages]
|
15
15
|
other_assets = []
|
16
|
-
|
16
|
+
1.upto(total_pages) do |page|
|
17
|
+
puts "Collecting Other Assets page: #{page}/#{total_pages}" if options[:verbose]
|
17
18
|
other_assets += self.execute(http_method: 'get', path: "other_assets.json?page=#{page}")[:data]
|
18
|
-
page += 1
|
19
19
|
end
|
20
20
|
other_assets.uniq
|
21
21
|
end
|
data/lib/samanage/api/sites.rb
CHANGED
@@ -5,13 +5,13 @@ module Samanage
|
|
5
5
|
self.execute(path: url)
|
6
6
|
end
|
7
7
|
|
8
|
-
def collect_sites
|
8
|
+
def collect_sites(options: {})
|
9
9
|
page = 1
|
10
10
|
sites = Array.new
|
11
11
|
total_pages = self.get_sites[:total_pages]
|
12
|
-
|
12
|
+
1.upto(total_pages) do |page|
|
13
|
+
puts "Collecting Sites page: #{page}/#{total_pages}" if options[:verbose]
|
13
14
|
sites += self.execute(http_method: 'get', path: "sites.json?page=#{page}")[:data]
|
14
|
-
page += 1
|
15
15
|
end
|
16
16
|
sites
|
17
17
|
end
|
data/lib/samanage/api/users.rb
CHANGED
@@ -8,13 +8,13 @@ module Samanage
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Returns all users in the account
|
11
|
-
def collect_users
|
11
|
+
def collect_users(options: {})
|
12
12
|
page = 1
|
13
13
|
users = Array.new
|
14
14
|
total_pages = self.get_users[:total_pages]
|
15
|
-
|
15
|
+
1.upto(total_pages) do |page|
|
16
|
+
puts "Collecting Users page: #{page}/#{total_pages}" if options[:verbose]
|
16
17
|
users += self.execute(http_method: 'get', path: "users.json?page=#{page}")[:data]
|
17
|
-
page += 1
|
18
18
|
end
|
19
19
|
users
|
20
20
|
end
|
data/lib/samanage/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'category' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@categories = @samanage.categories
|
7
8
|
end
|
8
9
|
it 'collects all categories' do
|
9
|
-
categories
|
10
|
-
expect(categories).to be_an(Array)
|
10
|
+
expect(@categories).to be_an(Array)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'creates a category' do
|
@@ -19,7 +19,7 @@ describe Samanage::Api do
|
|
19
19
|
description: category_description
|
20
20
|
}
|
21
21
|
}
|
22
|
-
category_create = @
|
22
|
+
category_create = @samanage.create_category(payload: payload)
|
23
23
|
|
24
24
|
expect(category_create[:data]['id']).to be_an(Integer)
|
25
25
|
expect(category_create[:data]['name']).to eq(category_name)
|
@@ -1,35 +1,35 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'Comments' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
7
|
end
|
8
8
|
describe 'API Functions' do
|
9
9
|
it 'gets comments' do
|
10
|
-
incident_id = @
|
11
|
-
comments = @
|
10
|
+
incident_id = @samanage.get_incidents()[:data].sample.dig('id')
|
11
|
+
comments = @samanage.get_comments(incident_id: incident_id)
|
12
12
|
expect(comments).to be_a(Hash)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'creates a comment' do
|
16
|
-
incident_id = @
|
16
|
+
incident_id = @samanage.get_incidents()[:data].sample.dig('id')
|
17
17
|
rand_text = ('a'..'z').to_a.shuffle[0,8].join
|
18
18
|
comment = {
|
19
19
|
comment: {
|
20
20
|
body: rand_text,
|
21
21
|
}
|
22
22
|
}
|
23
|
-
api_call = @
|
23
|
+
api_call = @samanage.create_comment(incident_id: incident_id, comment: comment)
|
24
24
|
|
25
25
|
expect(api_call.dig(:data,'body')).to eq(rand_text)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'collects all comments' do
|
29
|
-
## incident_id = @
|
29
|
+
## incident_id = @samanage.get_incidents()[:data].sample.dig('id')
|
30
30
|
# incident_id = 19394209
|
31
|
-
# comments_api = @
|
32
|
-
# comments_found = @
|
31
|
+
# comments_api = @samanage.get_comments(incident_id: incident_id)
|
32
|
+
# comments_found = @samanage.collect_comments(incident_id: incident_id)
|
33
33
|
|
34
34
|
# Total count bug
|
35
35
|
# expect(comments_api[:total_count]).to eq(comments_found.size)
|
@@ -3,13 +3,13 @@ require 'samanage'
|
|
3
3
|
describe Samanage::Api do
|
4
4
|
context 'Custom Field' do
|
5
5
|
describe 'API Functions' do
|
6
|
-
before(:
|
6
|
+
before(:all) do
|
7
7
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
8
|
-
@
|
8
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
9
|
+
@custom_fields = @samanage.custom_fields
|
9
10
|
end
|
10
11
|
it 'collects all custom fields' do
|
11
|
-
|
12
|
-
expect(api_call).to be_a(Array)
|
12
|
+
expect(@custom_fields).to be_a(Array)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,13 +3,13 @@ require 'samanage'
|
|
3
3
|
describe Samanage::Api do
|
4
4
|
context 'Custom Form' do
|
5
5
|
describe 'API Functions' do
|
6
|
-
before(:
|
6
|
+
before(:all) do
|
7
7
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
8
8
|
@controller = Samanage::Api.new(token: TOKEN, development_mode: true)
|
9
|
+
@custom_forms = @controller.collect_custom_forms
|
9
10
|
end
|
10
11
|
it 'collects all custom forms' do
|
11
|
-
|
12
|
-
expect(api_call).to be_a(Array)
|
12
|
+
expect(@custom_forms).to be_a(Array)
|
13
13
|
end
|
14
14
|
it 'Organizes custom forms by module' do
|
15
15
|
api_call = @controller.organize_forms
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'department' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@departments = @samanage.departments
|
7
8
|
end
|
8
|
-
it 'get_users: it returns API call of
|
9
|
-
api_call = @
|
9
|
+
it 'get_users: it returns API call of departments' do
|
10
|
+
api_call = @samanage.get_departments
|
10
11
|
expect(api_call).to be_a(Hash)
|
11
12
|
expect(api_call[:total_count]).to be_an(Integer)
|
12
13
|
expect(api_call).to have_key(:response)
|
13
14
|
expect(api_call).to have_key(:code)
|
14
15
|
end
|
15
16
|
it 'collects all departments' do
|
16
|
-
|
17
|
-
|
18
|
-
expect(departments).to
|
19
|
-
expect(departments.size).to eq(department_count)
|
17
|
+
department_count = @samanage.get_departments[:total_count]
|
18
|
+
expect(@departments).to be_an(Array)
|
19
|
+
expect(@departments.size).to eq(department_count)
|
20
20
|
end
|
21
21
|
it 'creates a department' do
|
22
22
|
department_name = "department ##{(rand*10**4).ceil}"
|
@@ -28,7 +28,7 @@ describe Samanage::Api do
|
|
28
28
|
description: department_description
|
29
29
|
}
|
30
30
|
}
|
31
|
-
department_create = @
|
31
|
+
department_create = @samanage.create_department(payload: payload)
|
32
32
|
|
33
33
|
expect(department_create[:data]['id']).to be_an(Integer)
|
34
34
|
expect(department_create[:data]['name']).to eq(department_name)
|
@@ -1,27 +1,27 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'group' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@groups = @samanage.groups
|
8
|
+
@users = @samanage.users
|
7
9
|
end
|
8
10
|
it 'get_users: it returns API call of users' do
|
9
|
-
api_call = @
|
11
|
+
api_call = @samanage.get_groups
|
10
12
|
expect(api_call).to be_a(Hash)
|
11
13
|
expect(api_call[:total_count]).to be_an(Integer)
|
12
14
|
expect(api_call).to have_key(:response)
|
13
15
|
expect(api_call).to have_key(:code)
|
14
16
|
end
|
15
17
|
it 'collects all groups' do
|
16
|
-
|
17
|
-
|
18
|
-
expect(groups).to
|
19
|
-
expect(groups.size).to eq(group_count)
|
18
|
+
group_count = @samanage.get_groups[:total_count]
|
19
|
+
expect(@groups).to be_an(Array)
|
20
|
+
expect(@groups.size).to eq(group_count)
|
20
21
|
end
|
21
22
|
it 'find_group: returns a group card by known id' do
|
22
|
-
|
23
|
-
|
24
|
-
group = @controller.find_group(id: sample_id)
|
23
|
+
sample_id = @groups.sample['id']
|
24
|
+
group = @samanage.find_group(id: sample_id)
|
25
25
|
expect(group[:data]['id']).to eq(sample_id) # id should match found group
|
26
26
|
expect(group[:data]).to have_key('name')
|
27
27
|
end
|
@@ -34,7 +34,7 @@ describe Samanage::Api do
|
|
34
34
|
description: group_description
|
35
35
|
}
|
36
36
|
}
|
37
|
-
group_create = @
|
37
|
+
group_create = @samanage.create_group(payload: payload)
|
38
38
|
|
39
39
|
expect(group_create[:data]['id']).to be_an(Integer)
|
40
40
|
expect(group_create[:data]['name']).to eq(group_name)
|
@@ -42,23 +42,23 @@ describe Samanage::Api do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'finds a group by name' do
|
45
|
-
group = @
|
45
|
+
group = @groups.sample
|
46
46
|
group_name = group['name']
|
47
47
|
group_id = group['id']
|
48
|
-
found_group_id = @
|
48
|
+
found_group_id = @samanage.find_group_id_by_name(group: group_name)
|
49
49
|
|
50
50
|
expect(group_id).to eq(found_group_id)
|
51
51
|
end
|
52
52
|
it 'returns nil for finding invalid group by name' do
|
53
53
|
group_name = "Invalid-#{rand(100)*100}"
|
54
|
-
found_group_id = @
|
54
|
+
found_group_id = @samanage.find_group_id_by_name(group: group_name)
|
55
55
|
expect(found_group_id).to be(nil)
|
56
56
|
end
|
57
57
|
it 'adds member to group' do
|
58
|
-
random_group_id = @
|
59
|
-
random_user_email = @
|
58
|
+
random_group_id = @groups.sample['id']
|
59
|
+
random_user_email = @users.sample['email']
|
60
60
|
|
61
|
-
add_user_to_group = @
|
61
|
+
add_user_to_group = @samanage.add_member_to_group(email: random_user_email, group_id: random_group_id)
|
62
62
|
expect(add_user_to_group[:code]).to eq(200).or(201)
|
63
63
|
end
|
64
64
|
end
|
@@ -2,22 +2,23 @@ require 'samanage'
|
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'Hardware' do
|
4
4
|
describe 'API Functions' do
|
5
|
-
before(:
|
5
|
+
before(:all) do
|
6
6
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
7
|
-
@
|
7
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
8
|
+
@hardwares = @samanage.hardwares
|
8
9
|
end
|
9
10
|
it 'get_hardwares: it returns API call of hardwares' do
|
10
|
-
api_call = @
|
11
|
+
api_call = @samanage.get_hardwares
|
11
12
|
expect(api_call).to be_a(Hash)
|
12
13
|
expect(api_call[:total_count]).to be_an(Integer)
|
13
14
|
expect(api_call).to have_key(:response)
|
14
15
|
expect(api_call).to have_key(:code)
|
15
16
|
end
|
16
17
|
it 'collect_hardwares: collects array of hardwares' do
|
17
|
-
|
18
|
-
|
19
|
-
expect(hardwares).to be_an(Array)
|
20
|
-
expect(hardwares.size).to eq(hardware_count)
|
18
|
+
hardware_count = @samanage.get_hardwares[:total_count]
|
19
|
+
@hardwares = @samanage.hardwares
|
20
|
+
expect(@hardwares).to be_an(Array)
|
21
|
+
expect(@hardwares.size).to eq(hardware_count)
|
21
22
|
end
|
22
23
|
it 'create_hardware(payload: payload): creates a hardware' do
|
23
24
|
hardware_name = "samanage-ruby-#{(rand*10**10).ceil}"
|
@@ -28,7 +29,7 @@ describe Samanage::Api do
|
|
28
29
|
:bio => {:ssn => serial_number},
|
29
30
|
}
|
30
31
|
}
|
31
|
-
hardware_create = @
|
32
|
+
hardware_create = @samanage.create_hardware(payload: payload)
|
32
33
|
|
33
34
|
expect(hardware_create[:data]['id']).to be_an(Integer)
|
34
35
|
expect(hardware_create[:data]['name']).to eq(hardware_name)
|
@@ -41,12 +42,11 @@ describe Samanage::Api do
|
|
41
42
|
:name => hardware_name,
|
42
43
|
}
|
43
44
|
}
|
44
|
-
expect{@
|
45
|
+
expect{@samanage.create_hardware(payload: payload)}.to raise_error(Samanage::InvalidRequest)
|
45
46
|
end
|
46
47
|
it 'find_hardware: returns a hardware card by known id' do
|
47
|
-
|
48
|
-
|
49
|
-
hardware = @controller.find_hardware(id: sample_id)
|
48
|
+
sample_id = @hardwares.sample['id']
|
49
|
+
hardware = @samanage.find_hardware(id: sample_id)
|
50
50
|
|
51
51
|
expect(hardware[:data]['id']).to eq(sample_id) # id should match found hardware
|
52
52
|
expect(hardware[:data]).to have_key('name')
|
@@ -55,15 +55,14 @@ describe Samanage::Api do
|
|
55
55
|
end
|
56
56
|
it 'find_hardware: returns nothing for an invalid id' do
|
57
57
|
sample_id = (0..10).entries.sample
|
58
|
-
expect{@
|
58
|
+
expect{@samanage.find_hardware(id: sample_id)}.to raise_error(Samanage::NotFound) # id should match found hardware
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'finds_hardwares_by_serial' do
|
62
|
-
|
63
|
-
sample_hardware = hardwares.sample
|
62
|
+
sample_hardware = @hardwares.sample
|
64
63
|
sample_serial_number = sample_hardware['serial_number']
|
65
64
|
sample_id = sample_hardware['id']
|
66
|
-
found_assets = @
|
65
|
+
found_assets = @samanage.find_hardwares_by_serial(serial_number: sample_serial_number)
|
67
66
|
found_sample = found_assets[:data].sample
|
68
67
|
expect(sample_serial_number).not_to be(nil)
|
69
68
|
expect(found_sample['serial_number']).not_to be(nil)
|
@@ -71,15 +70,14 @@ describe Samanage::Api do
|
|
71
70
|
# expect(sample_id).to eq(found_assets[:data].first.dig('id'))
|
72
71
|
end
|
73
72
|
it 'update_hardware: update_hardware by id' do
|
74
|
-
|
75
|
-
sample_id = hardwares.sample['id']
|
73
|
+
sample_id = @hardwares.sample['id']
|
76
74
|
new_name = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
77
75
|
payload = {
|
78
76
|
:hardware => {
|
79
77
|
:name => new_name
|
80
78
|
}
|
81
79
|
}
|
82
|
-
hardware_update = @
|
80
|
+
hardware_update = @samanage.update_hardware(payload: payload, id: sample_id)
|
83
81
|
expect(hardware_update[:data]["name"]).to eq(new_name)
|
84
82
|
expect(hardware_update[:code]).to eq(200).or(201)
|
85
83
|
end
|
@@ -2,25 +2,28 @@ require 'samanage'
|
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'Incidents' do
|
4
4
|
describe 'API Functions' do
|
5
|
-
before(:
|
5
|
+
before(:all) do
|
6
6
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
7
|
-
@
|
7
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
8
|
+
@incidents = @samanage.incidents
|
9
|
+
@users = @samanage.users
|
10
|
+
@incidents_with_archives = @samanage.incidents(options: {audit_archives: true})
|
8
11
|
end
|
9
12
|
it 'get_incidents: it returns API call of incidents' do
|
10
|
-
api_call = @
|
13
|
+
api_call = @samanage.get_incidents
|
11
14
|
expect(api_call).to be_a(Hash)
|
12
15
|
expect(api_call[:total_count]).to be_an(Integer)
|
13
16
|
expect(api_call).to have_key(:response)
|
14
17
|
expect(api_call).to have_key(:code)
|
15
18
|
end
|
16
19
|
it 'collect_incidents: collects array of incidents' do
|
17
|
-
|
18
|
-
|
19
|
-
expect(incidents).to be_an(Array)
|
20
|
-
expect(incidents.size).to eq(incident_count)
|
20
|
+
incident_count = @samanage.get_incidents[:total_count]
|
21
|
+
@incidents = @samanage.incidents
|
22
|
+
expect(@incidents).to be_an(Array)
|
23
|
+
expect(@incidents.size).to eq(incident_count)
|
21
24
|
end
|
22
25
|
it 'create_incident(payload: json): creates a incident' do
|
23
|
-
users_email = @
|
26
|
+
users_email = @samanage.collect_users.sample['email']
|
24
27
|
incident_name = "Samanage Ruby Incident"
|
25
28
|
json = {
|
26
29
|
:incident => {
|
@@ -29,26 +32,25 @@ describe Samanage::Api do
|
|
29
32
|
:description => "Description"
|
30
33
|
}
|
31
34
|
}
|
32
|
-
incident_create = @
|
35
|
+
incident_create = @samanage.create_incident(payload: json)
|
33
36
|
|
34
37
|
expect(incident_create[:data]['id']).to be_an(Integer)
|
35
38
|
expect(incident_create[:data]['name']).to eq(incident_name)
|
36
39
|
expect(incident_create[:code]).to eq(200).or(201)
|
37
40
|
end
|
38
41
|
it 'create_incident: fails if no name/title' do
|
39
|
-
users_email = @
|
42
|
+
users_email = @users.sample['email']
|
40
43
|
json = {
|
41
44
|
:incident => {
|
42
45
|
:requester => {:email => users_email},
|
43
46
|
:description => "Description"
|
44
47
|
}
|
45
48
|
}
|
46
|
-
expect{@
|
49
|
+
expect{@samanage.create_incident(payload: json)}.to raise_error(Samanage::InvalidRequest)
|
47
50
|
end
|
48
51
|
it 'find_incident: returns a incident card by known id' do
|
49
|
-
|
50
|
-
|
51
|
-
incident = @controller.find_incident(id: sample_id)
|
52
|
+
sample_id = @incidents.sample['id']
|
53
|
+
incident = @samanage.find_incident(id: sample_id)
|
52
54
|
|
53
55
|
expect(incident[:data]['id']).to eq(sample_id) # id should match found incident
|
54
56
|
expect(incident[:data]).to have_key('name')
|
@@ -57,11 +59,10 @@ describe Samanage::Api do
|
|
57
59
|
end
|
58
60
|
it 'find_incident: returns nothing for an invalid id' do
|
59
61
|
sample_id = (0..10).entries.sample
|
60
|
-
expect{@
|
62
|
+
expect{@samanage.find_incident(id: sample_id)}.to raise_error(Samanage::NotFound) # id should match found incident
|
61
63
|
end
|
62
64
|
it 'update_incident: update_incident by id' do
|
63
|
-
|
64
|
-
sample_incident = incidents.reject{|i| ['Closed','Resolved'].include? i['state']}.sample
|
65
|
+
sample_incident = @incidents.reject{|i| ['Closed','Resolved'].include? i['state']}.sample
|
65
66
|
sample_id = sample_incident['id']
|
66
67
|
description = (0...500).map { ('a'..'z').to_a[rand(26)] }.join
|
67
68
|
incident_json = {
|
@@ -69,22 +70,22 @@ describe Samanage::Api do
|
|
69
70
|
:description => description
|
70
71
|
}
|
71
72
|
}
|
72
|
-
incident_update = @
|
73
|
+
incident_update = @samanage.update_incident(payload: incident_json, id: sample_id)
|
73
74
|
expect(incident_update[:data]['description']).to eq(description)
|
74
75
|
expect(incident_update[:code]).to eq(200).or(201)
|
75
76
|
end
|
76
77
|
it 'finds more data for option[:layout] = "long"' do
|
77
|
-
full_layout_incident_keys = @
|
78
|
-
basic_incident_keys = @
|
78
|
+
full_layout_incident_keys = @samanage.incidents(options: {layout: 'long'}).first.keys
|
79
|
+
basic_incident_keys = @samanage.incidents.sample.keys
|
79
80
|
expect(basic_incident_keys.size).to be < full_layout_incident_keys.size
|
80
81
|
end
|
81
82
|
it 'finds more audit archives for option[:audit_archives] = true' do
|
82
|
-
incident_keys = @
|
83
|
+
incident_keys = @incidents_with_archives.sample.keys
|
83
84
|
expect(incident_keys).to include('audits')
|
84
85
|
end
|
85
86
|
it 'finds audit archives for options: {audit_archives: true, layout: "long"}' do
|
86
|
-
full_incident_keys = @
|
87
|
-
basic_incident_keys = @
|
87
|
+
full_incident_keys = @incidents_with_archives.sample.keys
|
88
|
+
basic_incident_keys = @incidents.sample.keys
|
88
89
|
expect(basic_incident_keys.size).to be < full_incident_keys.size
|
89
90
|
expect(full_incident_keys).to include('audits')
|
90
91
|
end
|
@@ -3,22 +3,22 @@ require 'samanage'
|
|
3
3
|
describe Samanage::Api do
|
4
4
|
context 'Mobile' do
|
5
5
|
describe 'API Functions' do
|
6
|
-
before(:
|
6
|
+
before(:all) do
|
7
7
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
8
|
-
@
|
8
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
9
|
+
@mobiles = @samanage.mobiles
|
9
10
|
end
|
10
11
|
it 'get_mobiles: it returns API call of mobiles' do
|
11
|
-
api_call = @
|
12
|
+
api_call = @samanage.get_mobiles
|
12
13
|
expect(api_call).to be_a(Hash)
|
13
14
|
expect(api_call[:total_count]).to be_an(Integer)
|
14
15
|
expect(api_call).to have_key(:response)
|
15
16
|
expect(api_call).to have_key(:code)
|
16
17
|
end
|
17
18
|
it 'collect_mobiles: collects array of mobiles' do
|
18
|
-
|
19
|
-
|
20
|
-
expect(mobiles).to
|
21
|
-
expect(mobiles.size).to eq(mobile_count)
|
19
|
+
mobile_count = @samanage.get_mobiles[:total_count]
|
20
|
+
expect(@mobiles).to be_an(Array)
|
21
|
+
expect(@mobiles.size).to eq(mobile_count)
|
22
22
|
end
|
23
23
|
it 'create_mobile(payload: json): creates a mobile' do
|
24
24
|
mobile_name = "samanage-ruby-#{(rand*10**10).ceil}"
|
@@ -30,7 +30,7 @@ describe Samanage::Api do
|
|
30
30
|
serial_number: serial_number,
|
31
31
|
}
|
32
32
|
}
|
33
|
-
mobile_create = @
|
33
|
+
mobile_create = @samanage.create_mobile(payload: json)
|
34
34
|
|
35
35
|
expect(mobile_create[:data]['id']).to be_an(Integer)
|
36
36
|
expect(mobile_create[:data]['manufacturer']).to eq(mobile_name)
|
@@ -43,12 +43,11 @@ describe Samanage::Api do
|
|
43
43
|
manufacturer: mobile_name,
|
44
44
|
}
|
45
45
|
}
|
46
|
-
expect{@
|
46
|
+
expect{@samanage.create_mobile(payload: json)}.to raise_error(Samanage::InvalidRequest)
|
47
47
|
end
|
48
48
|
it 'find_mobile: returns a mobile card by known id' do
|
49
|
-
|
50
|
-
|
51
|
-
mobile = @controller.find_mobile(id: sample_id)
|
49
|
+
sample_id = @mobiles.sample['id']
|
50
|
+
mobile = @samanage.find_mobile(id: sample_id)
|
52
51
|
|
53
52
|
expect(mobile[:data]['id']).to eq(sample_id) # id should match found mobile
|
54
53
|
expect(mobile[:data]).to have_key('manufacturer')
|
@@ -57,18 +56,17 @@ describe Samanage::Api do
|
|
57
56
|
end
|
58
57
|
it 'find_mobile: returns nothing for an invalid id' do
|
59
58
|
sample_id = (0..10).entries.sample
|
60
|
-
expect{@
|
59
|
+
expect{@samanage.find_mobile(id: sample_id)}.to raise_error(Samanage::NotFound) # id should match found mobile
|
61
60
|
end
|
62
61
|
it 'update_mobile: update_mobile by id' do
|
63
|
-
|
64
|
-
sample_id = mobiles.sample['id']
|
62
|
+
sample_id = @mobiles.sample['id']
|
65
63
|
new_name = (0...50).map {('a'..'z').to_a[rand(26)] }.join
|
66
64
|
json = {
|
67
65
|
:mobile => {
|
68
66
|
:manufacturer => new_name
|
69
67
|
}
|
70
68
|
}
|
71
|
-
mobile_update = @
|
69
|
+
mobile_update = @samanage.update_mobile(payload: json, id: sample_id)
|
72
70
|
expect(mobile_update[:data]["manufacturer"]).to eq(new_name)
|
73
71
|
expect(mobile_update[:code]).to eq(200).or(201)
|
74
72
|
end
|
@@ -3,20 +3,20 @@ require 'samanage'
|
|
3
3
|
describe Samanage::Api do
|
4
4
|
context 'Other Assets' do
|
5
5
|
describe 'API Functions' do
|
6
|
-
before(:
|
6
|
+
before(:all) do
|
7
7
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
8
|
-
@
|
8
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
9
|
+
@other_assets = @samanage.other_assets
|
9
10
|
end
|
10
11
|
it 'get_other_assets: it returns API call of other_assets' do
|
11
|
-
api_call = @
|
12
|
+
api_call = @samanage.get_other_assets
|
12
13
|
expect(api_call).to be_a(Hash)
|
13
14
|
expect(api_call[:total_count]).to be_an(Integer)
|
14
15
|
expect(api_call).to have_key(:response)
|
15
16
|
expect(api_call).to have_key(:code)
|
16
17
|
end
|
17
18
|
it 'collect_other_assets: collects array of other_assets' do
|
18
|
-
other_assets
|
19
|
-
expect(other_assets).to be_an(Array)
|
19
|
+
expect(@other_assets).to be_an(Array)
|
20
20
|
end
|
21
21
|
it 'create_other_asset(payload: json): creates a other_asset' do
|
22
22
|
other_asset_name = "samanage-ruby-#{(rand*10**10).ceil}"
|
@@ -29,7 +29,7 @@ describe Samanage::Api do
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
|
32
|
-
other_asset_create = @
|
32
|
+
other_asset_create = @samanage.create_other_asset(payload: json)
|
33
33
|
expect(other_asset_create[:data]['id']).to be_an(Integer)
|
34
34
|
expect(other_asset_create[:data]['name']).to eq(other_asset_name)
|
35
35
|
expect(other_asset_create[:code]).to eq(200).or(201)
|
@@ -45,14 +45,13 @@ describe Samanage::Api do
|
|
45
45
|
}
|
46
46
|
}
|
47
47
|
json[:other_asset].delete(json[:other_asset].keys.sample) # Delete random sample from the examples above
|
48
|
-
expect{@
|
48
|
+
expect{@samanage.create_other_asset(payload: json)}.to raise_error(Samanage::InvalidRequest)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'find_other_asset: returns an other_asset card by known id' do
|
52
|
-
|
53
|
-
sample_id = other_assets.sample['id']
|
52
|
+
sample_id = @other_assets.sample['id']
|
54
53
|
|
55
|
-
other_asset = @
|
54
|
+
other_asset = @samanage.find_other_asset(id: sample_id)
|
56
55
|
|
57
56
|
expect(other_asset[:data]['id']).to eq(sample_id) # id should match found other_asset
|
58
57
|
expect(other_asset[:data]).to have_key('name')
|
@@ -61,18 +60,17 @@ describe Samanage::Api do
|
|
61
60
|
end
|
62
61
|
it 'find_other_asset: returns nothing for an invalid id' do
|
63
62
|
sample_id = (0..10).entries.sample
|
64
|
-
expect{@
|
63
|
+
expect{@samanage.find_other_asset(id: sample_id)}.to raise_error(Samanage::NotFound) # id should match found other_asset
|
65
64
|
end
|
66
65
|
it 'update_other_asset: update_other_asset by id' do
|
67
|
-
|
68
|
-
sample_id = other_assets.sample['id']
|
66
|
+
sample_id = @other_assets.sample['id']
|
69
67
|
new_name = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
70
68
|
json = {
|
71
69
|
:other_asset => {
|
72
70
|
:name => new_name
|
73
71
|
}
|
74
72
|
}
|
75
|
-
other_asset_update = @
|
73
|
+
other_asset_update = @samanage.update_other_asset(payload: json, id: sample_id)
|
76
74
|
expect(other_asset_update[:data]["name"]).to eq(new_name)
|
77
75
|
expect(other_asset_update[:code]).to eq(200).or(201)
|
78
76
|
end
|
@@ -1,20 +1,21 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'Site' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@sites = @samanage.sites
|
7
8
|
end
|
8
9
|
it 'get_users: it returns API call of users' do
|
9
|
-
api_call = @
|
10
|
+
api_call = @samanage.get_sites
|
10
11
|
expect(api_call).to be_a(Hash)
|
11
12
|
expect(api_call[:total_count]).to be_an(Integer)
|
12
13
|
expect(api_call).to have_key(:response)
|
13
14
|
expect(api_call).to have_key(:code)
|
14
15
|
end
|
15
16
|
it 'collects all sites' do
|
16
|
-
sites = @
|
17
|
-
site_count = @
|
17
|
+
sites = @sites
|
18
|
+
site_count = @samanage.get_sites[:total_count]
|
18
19
|
expect(sites).to be_an(Array)
|
19
20
|
expect(sites.size).to eq(site_count)
|
20
21
|
end
|
@@ -29,7 +30,7 @@ describe Samanage::Api do
|
|
29
30
|
description: site_description
|
30
31
|
}
|
31
32
|
}
|
32
|
-
site_create = @
|
33
|
+
site_create = @samanage.create_site(payload: payload)
|
33
34
|
|
34
35
|
expect(site_create[:data]['id']).to be_an(Integer)
|
35
36
|
expect(site_create[:data]['name']).to eq(site_name)
|
@@ -2,23 +2,23 @@ require 'samanage'
|
|
2
2
|
|
3
3
|
describe Samanage::Api do
|
4
4
|
context 'Users' do
|
5
|
-
before(:
|
5
|
+
before(:all) do
|
6
6
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
7
|
-
@
|
7
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
8
|
+
@users = @samanage.users
|
8
9
|
end
|
9
10
|
describe 'API Functions' do
|
10
11
|
it 'get_users: it returns API call of users' do
|
11
|
-
api_call = @
|
12
|
+
api_call = @samanage.get_users
|
12
13
|
expect(api_call).to be_a(Hash)
|
13
14
|
expect(api_call[:total_count]).to be_an(Integer)
|
14
15
|
expect(api_call).to have_key(:response)
|
15
16
|
expect(api_call).to have_key(:code)
|
16
17
|
end
|
17
18
|
it 'collect_users: collects array of users' do
|
18
|
-
|
19
|
-
|
20
|
-
expect(users).to
|
21
|
-
expect(users.size).to eq(user_count)
|
19
|
+
user_count = @samanage.get_users[:total_count]
|
20
|
+
expect(@users).to be_an(Array)
|
21
|
+
expect(@users.size).to eq(user_count)
|
22
22
|
end
|
23
23
|
it 'create_user(payload: json): creates a user' do
|
24
24
|
user_name = "samanage-ruby-#{(rand*10**10).ceil}"
|
@@ -29,7 +29,7 @@ describe Samanage::Api do
|
|
29
29
|
:email => email,
|
30
30
|
}
|
31
31
|
}
|
32
|
-
user_create = @
|
32
|
+
user_create = @samanage.create_user(payload: json)
|
33
33
|
expect(user_create[:data]['email']).to eq(email)
|
34
34
|
expect(user_create[:data]['id']).to be_an(Integer)
|
35
35
|
expect(user_create[:data]['name']).to eq(user_name)
|
@@ -42,12 +42,11 @@ describe Samanage::Api do
|
|
42
42
|
:name => user_name,
|
43
43
|
}
|
44
44
|
}
|
45
|
-
expect{@
|
45
|
+
expect{@samanage.create_user(payload: json)}.to raise_error(Samanage::InvalidRequest)
|
46
46
|
end
|
47
47
|
it 'find_user: returns a user card by known id' do
|
48
|
-
|
49
|
-
|
50
|
-
user = @controller.find_user(id: sample_id)
|
48
|
+
sample_id = @users.sample['id']
|
49
|
+
user = @samanage.find_user(id: sample_id)
|
51
50
|
expect(user[:data]['id']).to eq(sample_id) # id should match found user
|
52
51
|
expect(user[:data]).to have_key('email')
|
53
52
|
expect(user[:data]).to have_key('name')
|
@@ -56,33 +55,31 @@ describe Samanage::Api do
|
|
56
55
|
|
57
56
|
it 'find_user: returns nothing for an invalid id' do
|
58
57
|
sample_id = (0..10).entries.sample
|
59
|
-
expect{@
|
58
|
+
expect{@samanage.find_user(id: sample_id)}.to raise_error(Samanage::NotFound) # id should match found user
|
60
59
|
end
|
61
60
|
|
62
61
|
it 'finds_user_id_by_email' do
|
63
|
-
|
64
|
-
sample_user = users.sample
|
62
|
+
sample_user = @users.sample
|
65
63
|
sample_email = sample_user['email']
|
66
64
|
sample_id = sample_user['id']
|
67
|
-
found_id = @
|
65
|
+
found_id = @samanage.find_user_id_by_email(email: sample_email)
|
68
66
|
expect(sample_email).not_to be(nil)
|
69
67
|
expect(sample_id).to eq(found_id)
|
70
68
|
end
|
71
69
|
|
72
70
|
it 'finds group_id for user' do
|
73
|
-
|
74
|
-
sample_user = users.select{|u| u['role']['name'] == 'Administrator'}.sample
|
71
|
+
sample_user = @users.select{|u| u['role']['name'] == 'Administrator'}.sample
|
75
72
|
sample_user_email = sample_user['email']
|
76
73
|
group_ids = sample_user['group_ids']
|
77
74
|
found_id = nil
|
78
75
|
|
79
76
|
group_ids.each do |group_id|
|
80
|
-
group = @
|
77
|
+
group = @samanage.find_group(id: group_id)
|
81
78
|
if group[:data]['is_user'] && sample_user_email == group[:data]['email']
|
82
79
|
found_id ||= group_id
|
83
80
|
end
|
84
81
|
end
|
85
|
-
function_id = @
|
82
|
+
function_id = @samanage.find_user_group_id_by_email(email: sample_user_email)
|
86
83
|
|
87
84
|
expect(function_id).to eq(found_id)
|
88
85
|
end
|
@@ -90,14 +87,14 @@ describe Samanage::Api do
|
|
90
87
|
|
91
88
|
it 'returns nil for invalid find_user_group_id_by_email' do
|
92
89
|
invalid_user_email = 'abc@123.gov'
|
93
|
-
function_id = @
|
90
|
+
function_id = @samanage.find_user_group_id_by_email(email: invalid_user_email)
|
94
91
|
|
95
92
|
expect(function_id).to be(nil)
|
96
93
|
end
|
97
94
|
|
98
95
|
it 'returns nil for invalid find_user_id_by_email' do
|
99
96
|
invalid_user_email = 'abc@123.gov'
|
100
|
-
function_id = @
|
97
|
+
function_id = @samanage.find_user_id_by_email(email: invalid_user_email)
|
101
98
|
|
102
99
|
expect(function_id).to be(nil)
|
103
100
|
end
|
@@ -105,15 +102,14 @@ describe Samanage::Api do
|
|
105
102
|
|
106
103
|
|
107
104
|
it 'update_user: update_user by id' do
|
108
|
-
|
109
|
-
sample_id = users.sample['id']
|
105
|
+
sample_id = @users.sample['id']
|
110
106
|
new_name = (0...25).map { ('a'..'z').to_a[rand(26)] }.join
|
111
107
|
json = {
|
112
108
|
:user => {
|
113
109
|
:name => new_name
|
114
110
|
}
|
115
111
|
}
|
116
|
-
user_update = @
|
112
|
+
user_update = @samanage.update_user(payload: json, id: sample_id)
|
117
113
|
expect(user_update[:data]["name"]).to eq(new_name)
|
118
114
|
expect(user_update[:code]).to eq(200).or(201)
|
119
115
|
end
|
@@ -4,16 +4,17 @@ describe Samanage::Api do
|
|
4
4
|
describe 'API Functions' do
|
5
5
|
before(:each) do
|
6
6
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
7
|
-
@
|
7
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
8
|
+
@users = @samanage.users
|
8
9
|
end
|
9
10
|
it 'sends an activation email' do
|
10
|
-
valid_email = @
|
11
|
-
send_email = @
|
11
|
+
valid_email = @users.sample['email']
|
12
|
+
send_email = @samanage.send_activation_email(email: valid_email)
|
12
13
|
expect(send_email[:code]).to be(200)
|
13
14
|
end
|
14
15
|
it 'fails for invalid email' do
|
15
|
-
invalid_email = @
|
16
|
-
expect{@
|
16
|
+
invalid_email = @samanage.users.sample['email'].gsub!('@','$')
|
17
|
+
expect{@samanage.send_activation_email(email: invalid_email)}.to raise_error(Samanage::Error)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/spec/samanage_api_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Samanage do
|
3
3
|
describe 'API Controller' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
6
|
end
|
7
|
-
context 'on
|
8
|
-
it 'Requires
|
7
|
+
context 'on instantiation' do
|
8
|
+
it 'Requires Valid Token' do
|
9
9
|
expect{
|
10
10
|
api_controller = Samanage::Api.new(token: "invalid token")
|
11
11
|
api_controller.authorize
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
3
|
context 'category' do
|
4
|
-
before(:
|
4
|
+
before(:all) do
|
5
5
|
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
-
@
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@categories = @samanage.collect_categories
|
7
8
|
end
|
8
9
|
it 'collects all categories' do
|
9
|
-
|
10
|
-
|
11
|
-
expect(categories).to be_an(Array)
|
10
|
+
category_count = @samanage.execute(path: 'categories.json')
|
11
|
+
expect(@categories).to be_an(Array)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'creates a category' do
|
@@ -21,7 +21,7 @@ describe Samanage::Api do
|
|
21
21
|
description: category_description
|
22
22
|
}
|
23
23
|
}
|
24
|
-
category_create = @
|
24
|
+
category_create = @samanage.create_category(payload: payload)
|
25
25
|
|
26
26
|
expect(category_create[:data]['id']).to be_an(Integer)
|
27
27
|
expect(category_create[:data]['name']).to eq(category_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samanage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Walls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|