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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c33712f14d8e3954583638e677767e18d8994685
4
- data.tar.gz: 2eb7879f1973dd1700aaa60ea7650550d8fd4e9e
3
+ metadata.gz: 9d70a2a85e1f7606feeb1ba847efa75067eb79e8
4
+ data.tar.gz: 6d66b498fbbe47bcb48d2202718273a3bd462664
5
5
  SHA512:
6
- metadata.gz: 8895ef4b07eaf76bdd3df1b91ec9b2d94daaa3b75683e0b9c1a48321aec85dd6000d7f79b7ebf8e3a892cc84c6f16350432d1036e31f8b9e0b6cbf1ebb1c55df
7
- data.tar.gz: 7c085ca06d726b5e6c36afcd8da1565a30f9af3cc79f7368fad9fa36a7930c93a33fc66b425c214afbb86103474681685169142e6858e08f610561bcce6f4c4e
6
+ metadata.gz: 57efde3151897203323b7545db3892a0d0ccf733cadfda29b61c6bd9e9f596d284e1e4808319717ed4e731771b19c4d594d5e68f4bfcc11d134813e4fb47317d
7
+ data.tar.gz: 7db1d6ee21585b792de8584ca07260dc31d6c58cc73f9298e17801a53327d568c8821fb51b28508528af9456743c0f9f1c36e3dfa23aeffe93e169230884135c
data/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ #1.8.0
2
+ - Adding coverage for invalid api requests
3
+
1
4
  #1.7.9
2
5
  - Solving eu datacenter support against base_url
3
6
  #1.7.8
@@ -1,6 +1,5 @@
1
1
  module Samanage
2
2
  class Api
3
-
4
3
  def get_groups(path: PATHS[:group], options: {})
5
4
  url = Samanage::UrlBuilder.new(path: path, options: options).url
6
5
  self.execute(path: url)
@@ -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.7.9'
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']
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samanage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.9
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Walls