samanage 1.9.33 → 2.0.03
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +24 -26
- data/changelog.md +13 -0
- data/lib/samanage.rb +2 -1
- data/lib/samanage/api.rb +140 -144
- data/lib/samanage/api/attachments.rb +21 -0
- data/lib/samanage/api/category.rb +24 -19
- data/lib/samanage/api/changes.rb +59 -0
- data/lib/samanage/api/comments.rb +13 -13
- data/lib/samanage/api/contracts.rb +51 -47
- data/lib/samanage/api/custom_fields.rb +23 -19
- data/lib/samanage/api/custom_forms.rb +42 -38
- data/lib/samanage/api/departments.rb +25 -22
- data/lib/samanage/api/groups.rb +43 -39
- data/lib/samanage/api/hardwares.rb +57 -53
- data/lib/samanage/api/incidents.rb +60 -51
- data/lib/samanage/api/mobiles.rb +50 -46
- data/lib/samanage/api/other_assets.rb +47 -43
- data/lib/samanage/api/requester.rb +7 -7
- data/lib/samanage/api/sites.rb +27 -23
- data/lib/samanage/api/users.rb +58 -54
- data/lib/samanage/api/utils.rb +0 -19
- data/lib/samanage/error.rb +20 -20
- data/lib/samanage/url_builder.rb +53 -53
- data/lib/samanage/version.rb +2 -2
- data/samanage.gemspec +2 -2
- data/sample_file.txt +1 -0
- data/spec/api/samanage_attachment_spec.rb +14 -0
- data/spec/api/samanage_category_spec.rb +24 -24
- data/spec/api/samanage_change_spec.rb +98 -0
- data/spec/api/samanage_comments_spec.rb +25 -32
- data/spec/api/samanage_contract_spec.rb +62 -68
- data/spec/api/samanage_custom_field_spec.rb +12 -12
- data/spec/api/samanage_custom_form_spec.rb +24 -24
- data/spec/api/samanage_department_spec.rb +35 -36
- data/spec/api/samanage_group_spec.rb +59 -59
- data/spec/api/samanage_hardware_spec.rb +80 -85
- data/spec/api/samanage_incident_spec.rb +99 -103
- data/spec/api/samanage_mobile_spec.rb +70 -74
- data/spec/api/samanage_other_asset_spec.rb +72 -76
- data/spec/api/samanage_site_spec.rb +45 -45
- data/spec/api/samanage_user_spec.rb +117 -100
- data/spec/api/samanage_util_spec.rb +4 -9
- data/spec/samanage_api_spec.rb +48 -48
- data/spec/samanage_category_spec.rb +21 -28
- data/spec/samanage_url_builder_spec.rb +15 -15
- metadata +15 -11
- data/lib/data/gd-class2-root.crt +0 -24
@@ -1,27 +1,22 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
|
-
|
3
|
+
context 'Utils' 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
8
|
@users = @samanage.get_users[:data]
|
9
|
+
@incidents = @samanage.incidents
|
9
10
|
end
|
10
11
|
it 'sends an activation email' do
|
11
12
|
valid_email = @users.sample['email']
|
12
13
|
send_email = @samanage.send_activation_email(email: valid_email)
|
13
|
-
expect(send_email[:code]).to
|
14
|
+
expect(send_email[:code]).to eq(200)
|
14
15
|
end
|
15
16
|
it 'fails for invalid email' do
|
16
17
|
invalid_email = @samanage.users.sample['email'].gsub!('@','$')
|
17
18
|
expect{@samanage.send_activation_email(email: invalid_email)}.to raise_error(Samanage::Error)
|
18
19
|
end
|
19
|
-
it 'downloads an attachment' do
|
20
|
-
# attachable_incident_id = 22215549 # Need filter for has attachment?
|
21
|
-
# incident = @samanage.find_incident(id: attachable_incident_id, options: {layout: 'long'})
|
22
|
-
# attachment = @samanage.download_attachment(attachment: incident[:data]['attachments'].first)
|
23
|
-
# expect(attachment.class).to be(File)
|
24
|
-
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
data/spec/samanage_api_spec.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Samanage do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
describe 'API Controller' do
|
4
|
+
before(:each) do
|
5
|
+
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
+
end
|
7
|
+
context 'on instantiation' do
|
8
|
+
it 'Requires Valid Token' do
|
9
|
+
expect{
|
10
|
+
api_controller = Samanage::Api.new(token: "invalid token")
|
11
|
+
api_controller.authorize
|
12
|
+
}.to raise_error(Samanage::AuthorizationError)
|
13
|
+
expect{ Samanage::Api.new(token: TOKEN) }.to_not raise_error
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
it 'Validates Credentials on Creation' do
|
17
|
+
# Valid Credentials
|
18
|
+
expect(Samanage::Api.new(token: TOKEN)).to be_an_instance_of(Samanage::Api)
|
19
|
+
# Invalid / Reversed Credentials
|
20
|
+
expect{
|
21
|
+
api_controller = Samanage::Api.new(token: 'invalid')
|
22
|
+
api_controller.authorize
|
23
|
+
}.to raise_error(Samanage::AuthorizationError)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
it 'Finds all custom forms in development mode' do
|
27
|
+
api_controller = Samanage::Api.new(token: TOKEN, development_mode: true)
|
28
|
+
expect(api_controller).to be_an_instance_of(Samanage::Api)
|
29
|
+
expect(api_controller.custom_forms).not_to be(nil)
|
30
|
+
expect(api_controller.custom_forms).to be_a(Hash)
|
31
|
+
end
|
32
|
+
it 'Fails with invalid token in development mode' do
|
33
|
+
expect{ Samanage::Api.new(token: 'Invalid Token', development_mode: true)}.to raise_error(Samanage::AuthorizationError)
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
# Search random Samanage::Api.list_admins user and verifiy role is admin
|
37
|
+
it 'Finds Admins' do
|
38
|
+
api_controller = Samanage::Api.new(token: TOKEN, development_mode: true)
|
39
|
+
admins = api_controller.list_admins
|
40
|
+
admin_email = admins.sample.gsub('+',"%2B")
|
41
|
+
samanage_admin = api_controller.execute(path: "users.json?email=#{admin_email}")
|
42
|
+
expect(samanage_admin[:data].first['role']['name']).to eq('Administrator')
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
it 'sets eu datacenter' do
|
46
|
+
api_controller = Samanage::Api.new(token: 'token', datacenter: 'eu')
|
47
|
+
expect(api_controller.base_url).to eq('https://apieu.samanage.com/')
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
it 'does not set non/eu datacenter' do
|
51
|
+
api_controller = Samanage::Api.new(token: 'token', datacenter: 'invalid')
|
52
|
+
expect(api_controller.base_url).to eq('https://api.samanage.com/')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
56
|
end
|
@@ -1,31 +1,24 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::Api do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
category_create = @samanage.create_category(payload: payload)
|
25
|
-
|
26
|
-
expect(category_create[:data]['id']).to be_an(Integer)
|
27
|
-
expect(category_create[:data]['name']).to eq(category_name)
|
28
|
-
expect(category_create[:code]).to eq(200).or(201)
|
29
|
-
end
|
30
|
-
end
|
3
|
+
context 'category' do
|
4
|
+
before(:all) do
|
5
|
+
TOKEN ||= ENV['SAMANAGE_TEST_API_TOKEN']
|
6
|
+
@samanage = Samanage::Api.new(token: TOKEN)
|
7
|
+
@categories = @samanage.collect_categories
|
8
|
+
end
|
9
|
+
it 'creates a category' do
|
10
|
+
category_name = "category ##{(rand*10**4).ceil}"
|
11
|
+
category_description = "Location #{(rand*10**4).ceil}"
|
12
|
+
payload = {
|
13
|
+
category: {
|
14
|
+
name: category_name,
|
15
|
+
description: category_description
|
16
|
+
}
|
17
|
+
}
|
18
|
+
category_create = @samanage.create_category(payload: payload)
|
19
|
+
expect(category_create[:data]['id']).to be_an(Integer)
|
20
|
+
expect(category_create[:data]['name']).to eq(category_name)
|
21
|
+
expect(category_create[:code]).to eq(200).or(201)
|
22
|
+
end
|
23
|
+
end
|
31
24
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'samanage'
|
2
2
|
describe Samanage::UrlBuilder do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
context 'Url Builder' do
|
4
|
+
it 'Strips down to id' do
|
5
|
+
path = ['users.json','hardwares/1234']
|
6
|
+
options = [
|
7
|
+
{:id => '1234'},
|
8
|
+
{:id => 12345, :email => 'abc@company.com'},
|
9
|
+
{:email => 'abc', :name => 'Joe Doe'},
|
10
|
+
{:site => 0001, :id => 1234}
|
11
|
+
]
|
12
|
+
5.times {
|
13
|
+
url = Samanage::UrlBuilder.new(path: path.sample, options: options.sample).url
|
14
|
+
expect(url).to be_a(String)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
18
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samanage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.03
|
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-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.15.7
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.15.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.15.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.15.7
|
41
41
|
description: Connect to Samanage using Ruby!
|
42
42
|
email: cwalls2908@gmail.com
|
43
43
|
executables: []
|
@@ -51,10 +51,11 @@ files:
|
|
51
51
|
- LICENSE
|
52
52
|
- README.md
|
53
53
|
- changelog.md
|
54
|
-
- lib/data/gd-class2-root.crt
|
55
54
|
- lib/samanage.rb
|
56
55
|
- lib/samanage/api.rb
|
56
|
+
- lib/samanage/api/attachments.rb
|
57
57
|
- lib/samanage/api/category.rb
|
58
|
+
- lib/samanage/api/changes.rb
|
58
59
|
- lib/samanage/api/comments.rb
|
59
60
|
- lib/samanage/api/contracts.rb
|
60
61
|
- lib/samanage/api/custom_fields.rb
|
@@ -74,7 +75,10 @@ files:
|
|
74
75
|
- lib/samanage/url_builder.rb
|
75
76
|
- lib/samanage/version.rb
|
76
77
|
- samanage.gemspec
|
78
|
+
- sample_file.txt
|
79
|
+
- spec/api/samanage_attachment_spec.rb
|
77
80
|
- spec/api/samanage_category_spec.rb
|
81
|
+
- spec/api/samanage_change_spec.rb
|
78
82
|
- spec/api/samanage_comments_spec.rb
|
79
83
|
- spec/api/samanage_contract_spec.rb
|
80
84
|
- spec/api/samanage_custom_field_spec.rb
|
data/lib/data/gd-class2-root.crt
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
|
3
|
-
MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE
|
4
|
-
YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3
|
5
|
-
MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo
|
6
|
-
ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg
|
7
|
-
MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN
|
8
|
-
ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA
|
9
|
-
PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w
|
10
|
-
wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi
|
11
|
-
EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY
|
12
|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