samanage 1.7.9 → 1.8.0
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/groups.rb +0 -1
- data/lib/samanage/api/users.rb +2 -2
- data/samanage.gemspec +1 -1
- data/spec/api/samanage_group_spec.rb +5 -1
- data/spec/api/samanage_user_spec.rb +19 -0
- data/spec/samanage_api_spec.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d70a2a85e1f7606feeb1ba847efa75067eb79e8
|
4
|
+
data.tar.gz: 6d66b498fbbe47bcb48d2202718273a3bd462664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57efde3151897203323b7545db3892a0d0ccf733cadfda29b61c6bd9e9f596d284e1e4808319717ed4e731771b19c4d594d5e68f4bfcc11d134813e4fb47317d
|
7
|
+
data.tar.gz: 7db1d6ee21585b792de8584ca07260dc31d6c58cc73f9298e17801a53327d568c8821fb51b28508528af9456743c0f9f1c36e3dfa23aeffe93e169230884135c
|
data/changelog.md
CHANGED
data/lib/samanage/api/groups.rb
CHANGED
data/lib/samanage/api/users.rb
CHANGED
@@ -39,14 +39,14 @@ module Samanage
|
|
39
39
|
# Returns nil if no matching group_id
|
40
40
|
def find_user_group_id_by_email(email: )
|
41
41
|
user = self.check_user(value: email)
|
42
|
-
group_ids = user[:data].select{|u| u['email'].to_s.downcase == email.to_s.downcase}.first.to_h['group_ids']
|
42
|
+
group_ids = user[:data].select{|u| u['email'].to_s.downcase == email.to_s.downcase}.first.to_h['group_ids'].to_a
|
43
43
|
group_ids.each do |group_id|
|
44
44
|
group = self.find_group(id: group_id)
|
45
45
|
if group[:data]['is_user'] && email == group[:data]['email']
|
46
46
|
return group_id
|
47
47
|
end
|
48
48
|
end
|
49
|
-
return
|
49
|
+
return nil
|
50
50
|
end
|
51
51
|
|
52
52
|
# Check for user by field (ex: users.json?field=value)
|
data/samanage.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'samanage'
|
4
|
-
s.version = '1.
|
4
|
+
s.version = '1.8.0'
|
5
5
|
s.date = Date.today.strftime("%Y-%m-%d")
|
6
6
|
s.summary = "Samanage Ruby Gem"
|
7
7
|
s.description = "Connect to Samanage using Ruby!"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'samanage'
|
2
|
-
|
3
2
|
describe Samanage::Api do
|
4
3
|
context 'group' do
|
5
4
|
before(:each) do
|
@@ -50,6 +49,11 @@ describe Samanage::Api do
|
|
50
49
|
|
51
50
|
expect(group_id).to eq(found_group_id)
|
52
51
|
end
|
52
|
+
it 'returns nil for finding invalid group by name' do
|
53
|
+
group_name = "Invalid-#{rand(100)*100}"
|
54
|
+
found_group_id = @controller.find_group_id_by_name(group: group_name)
|
55
|
+
expect(found_group_id).to be(nil)
|
56
|
+
end
|
53
57
|
it 'adds member to group' do
|
54
58
|
random_group_id = @controller.collect_groups.sample['id']
|
55
59
|
random_user_email = @controller.collect_users.sample['email']
|
@@ -86,6 +86,25 @@ describe Samanage::Api do
|
|
86
86
|
|
87
87
|
expect(function_id).to eq(found_id)
|
88
88
|
end
|
89
|
+
|
90
|
+
|
91
|
+
it 'returns nil for invalid find_user_group_id_by_email' do
|
92
|
+
invalid_user_email = 'abc@123.gov'
|
93
|
+
function_id = @controller.find_user_group_id_by_email(email: invalid_user_email)
|
94
|
+
|
95
|
+
expect(function_id).to be(nil)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'returns nil for invalid find_user_id_by_email' do
|
99
|
+
invalid_user_email = 'abc@123.gov'
|
100
|
+
function_id = @controller.find_user_id_by_email(email: invalid_user_email)
|
101
|
+
|
102
|
+
expect(function_id).to be(nil)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
89
108
|
it 'update_user: update_user by id' do
|
90
109
|
users = @controller.collect_users
|
91
110
|
sample_id = users.sample['id']
|
data/spec/samanage_api_spec.rb
CHANGED
@@ -41,6 +41,16 @@ describe Samanage do
|
|
41
41
|
samanage_admin = api_controller.execute(path: "users.json?email=#{admin_email}")
|
42
42
|
expect(samanage_admin[:data].first['role']['name']).to eq('Administrator')
|
43
43
|
end
|
44
|
+
|
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://appeu.samanage.com')
|
48
|
+
end
|
49
|
+
|
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://app.samanage.com')
|
53
|
+
end
|
44
54
|
end
|
45
55
|
end
|
46
56
|
end
|