soar-registry-directory 6.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c32931eb5c662b57a167f89e9f37641f1069b9f2
4
- data.tar.gz: 1bd2a2a6fd37c124228ec8e2fa656324a78250fb
3
+ metadata.gz: 184dcc7503dc83106a910320501e0051fb27e815
4
+ data.tar.gz: 286fc633c8ff058630867e01d34fad23fafe9bcf
5
5
  SHA512:
6
- metadata.gz: 3f8c0d59dedfae89eed3d4fc0bfbb942c4cf583351761cfc1805fb28eb16537e0efb9197512c06cc163d24ce507292a2b94a98c2346a24d2c65941665e11fd0c
7
- data.tar.gz: b2cf12ef9732c39407ff2796daca5266c60bce849688119dd6b16e3a7acb7f7d833146a36bab77d11483767346825fe152df5307a188b8e05231a7c9a0000c62
6
+ metadata.gz: 44e58322123aa440c2f668d3efa2c9d2f69c69826a4dd4b093e867e8fe1b46b88419b5014b74c55d0b71910ceaf6155b0ccc66109ba57303360bdb5c227ecb88
7
+ data.tar.gz: 4715812e40e690ddf0cb151f9b98e062bfcdb82dcb2c22a5a814a8ac8028ca43ecd8fc0f53539c4724a89eefe3212ac45089afd485e65aaf673721c65382d149
@@ -19,7 +19,7 @@ module Soar
19
19
  end
20
20
 
21
21
  ##
22
- # @param [Hash] entity
22
+ # @param [Hash{String => }] entity
23
23
  # @return [Boolean]
24
24
  # @raise [Soar::Registry::Directory::Error::NetworkingError, Soar::Registry::Directory::Error::DuplicateEntryError]
25
25
  ##
@@ -29,7 +29,7 @@ module Soar
29
29
 
30
30
  ##
31
31
  # @param [String] primary_key
32
- # @return [Hash] entry
32
+ # @return [Hash{String => }] entry
33
33
  # @raise [Soar::Registry:::Directory::Error::NoEntriesFound] if primary key not found
34
34
  # @raise [Soar::Registry::Directory::Error::NetworkingError]
35
35
  ##
@@ -40,7 +40,7 @@ module Soar
40
40
  ##
41
41
  # @param [String] key
42
42
  # @param [String] value
43
- # @return [Array] list of entries
43
+ # @return [Array<Hash{String => }>] list of entries
44
44
  # @raise [ArgumentError, Soar::Registry::Directory::Error::NetworkingError]
45
45
  ##
46
46
  def search(key, value)
@@ -48,7 +48,7 @@ module Soar
48
48
  end
49
49
 
50
50
  ##
51
- # @return [Array] a list of provider specific indexes
51
+ # @return [Array<String>] a list of provider specific indexes
52
52
  # @raise [Soar::Registry::Directory::Error::NetworkingError]
53
53
  ##
54
54
  def index
@@ -1,5 +1,6 @@
1
1
  require 'soar/registry/directory/error'
2
2
  require 'net/ldap'
3
+ require 'hashie'
3
4
 
4
5
  module Soar
5
6
  module Registry
@@ -22,7 +23,7 @@ module Soar
22
23
  ##
23
24
  def initialize(config: , base: , attributes: , index: , credentials: )
24
25
  adapt_exceptions do
25
- @index = index.map { |x| x.to_sym }
26
+ @index = index
26
27
  @attributes = attributes
27
28
  @config = {
28
29
  host: config['host'],
@@ -42,7 +43,7 @@ module Soar
42
43
  end
43
44
 
44
45
  ##
45
- # @param [Hash{Symbol => }] entry
46
+ # @param [Hash{String => String, Number, Array}] entry
46
47
  # @return [Boolean]
47
48
  # @raise [Soar::Registry::Directory::Error::DuplicateEntryError]
48
49
  ##
@@ -50,15 +51,15 @@ module Soar
50
51
  adapt_exceptions do
51
52
 
52
53
  @index.each { |index|
53
- if (entry[:attributes].keys.include?(index))
54
- result = search(index, entry[:attributes][index])
54
+ if (entry['attributes'].keys.include?(index))
55
+ result = search(index, entry['attributes'][index])
55
56
  raise Soar::Registry::Directory::Error::DuplicateEntryError if result.length > 0
56
57
  end
57
58
  }
58
59
 
59
60
  @client.add({
60
- dn: entry[:dn],
61
- attributes: entry[:attributes]
61
+ dn: entry['dn'],
62
+ attributes: entry['attributes'].map { |k, v| [k.to_sym, v] }.to_h
62
63
  })
63
64
  return true
64
65
  end
@@ -66,7 +67,7 @@ module Soar
66
67
 
67
68
  ##
68
69
  # @param [String] primary key of the identity ie. the first index
69
- # @return [Hash{Symbol => String, Number, Array}] single matching entry
70
+ # @return [Hash{String => String, Number, Array}] single matching entry
70
71
  # @raise [Soar::Registry::Directory::Error::NoEntriesFoundError] if primary key not found
71
72
  # @raise [Soar::Registry::Directory::Error::MultipleEntriesFound] if multiple matches found
72
73
  ##
@@ -81,9 +82,9 @@ module Soar
81
82
  raise Soar::Registry::Directory::Error::MultipleEntriesFound if result.length > 1
82
83
  response = {}
83
84
  @attributes.each { |attribute|
84
- response[attribute.to_sym] = result[0][attribute.to_sym][0]
85
+ response[attribute] = result[0][attribute.to_sym][0]
85
86
  }
86
- response
87
+ return response
87
88
  end
88
89
  end
89
90
 
@@ -91,7 +92,7 @@ module Soar
91
92
  ##
92
93
  # @param [String] key
93
94
  # @param [String] value
94
- # @return [Array<Hash{Symbol => String, Array, Number}>] list of matching entries
95
+ # @return [Array<Hash{String => String, Array, Number}>] list of matching entries
95
96
  # @raise [ArgumentError] if value or named index is not specified
96
97
  ##
97
98
  def search(key, value)
@@ -106,7 +107,7 @@ module Soar
106
107
  entries.each { |entry|
107
108
  response = {}
108
109
  @attributes.each { |attribute|
109
- response[attribute.to_sym] = entry[attribute.to_sym][0]
110
+ response[attribute] = entry[attribute.to_sym][0]
110
111
  }
111
112
  result << response
112
113
  }
@@ -139,7 +140,7 @@ module Soar
139
140
  def adapt_exceptions
140
141
  begin
141
142
  yield
142
- rescue Net::LDAP::BindingInformationInvalidError, Net::LDAP::ConnectionRefusedError, Errno::ECONNREFUSED => e
143
+ rescue Net::LDAP::BindingInformationInvalidError, Net::LDAP::NoBindResultError, Net::LDAP::ConnectionRefusedError, Errno::ECONNREFUSED => e
143
144
  raise Soar::Registry::Directory::Error::NetworkingError, e.message
144
145
  end
145
146
  end
@@ -38,7 +38,7 @@ module Soar
38
38
  end
39
39
 
40
40
  ##
41
- # @param [Hash{Symbol => String, Number}] entry
41
+ # @param [Hash{String => String, Number}] entry
42
42
  # @return [Boolean]
43
43
  ##
44
44
  def put(entry)
@@ -51,7 +51,7 @@ module Soar
51
51
 
52
52
  ##
53
53
  # @param [String] primary key the first index
54
- # @return [Hash{Symbol => String, Number}] single matching entry
54
+ # @return [Hash{String => String, Number}] single matching entry
55
55
  # @raise [Soar::Registry::Directory::Error::NoEntriesFoundError] if primary key not found
56
56
  # @raise [Soar::Registry::Directory::Error::MultipleEntriesFound] if multiple matches found
57
57
  ##
@@ -66,16 +66,16 @@ module Soar
66
66
  field.name
67
67
  }
68
68
  result = mysql_statement.fetch
69
- result = Hash[result.map.with_index { |value, index|
69
+ return Hash[result.map.with_index { |value, index|
70
70
  [field_names[index.to_i], value]
71
- }].symbolize_keys
71
+ }]
72
72
  end
73
73
  end
74
74
 
75
75
  ##
76
76
  # @param [String] key should be in indexed in db schema
77
77
  # @param [String] value
78
- # @return [Array<Hash{Symbol => String, Number}>] list of matching entries
78
+ # @return [Array<Hash{String => String, Number}>] list of matching entries
79
79
  # @raise [ArgumentError] if value or named index is not specified
80
80
  ##
81
81
  def search(key, value)
@@ -91,9 +91,9 @@ module Soar
91
91
  mysql_statement.each { |entry|
92
92
  result << Hash[entry.map.with_index { |value, index|
93
93
  [field_names[index.to_i], value]
94
- }].symbolize_keys
94
+ }]
95
95
  }
96
- result
96
+ return result
97
97
  end
98
98
  end
99
99
 
@@ -104,7 +104,7 @@ module Soar
104
104
  adapt_exceptions do
105
105
  index = []
106
106
  @client.query("SHOW INDEX FROM Client").each_hash { |entry|
107
- index << entry['Column_name'].to_sym
107
+ index << entry['Column_name']
108
108
  }
109
109
  index
110
110
  end
@@ -11,22 +11,22 @@ module Soar
11
11
  def initialize
12
12
  @configuration = YAML.load_file("config/#{ENV['CONFIG_FILE']}")
13
13
  @base = @configuration['provider']['config']['base']
14
- @index = @configuration['provider']['config']['index'].map { |x| x.to_sym }
14
+ @index = @configuration['provider']['config']['index']
15
15
  @entries = [{
16
- dn: "cn=John Smith,#{@base}",
17
- attributes: {
18
- cn: "John Smith",
19
- mail: "test@example.com",
20
- objectclass: ["inetOrgPerson", "top"],
21
- sn: "Smith"
16
+ "dn" => "cn=John Smith,#{@base}",
17
+ "attributes" => {
18
+ "cn" => "John Smith",
19
+ "mail" => "test@example.com",
20
+ "objectclass" => ["inetOrgPerson", "top"],
21
+ "sn" => "Smith"
22
22
  }
23
23
  }, {
24
- dn: "cn=Sarel Cilliers,#{@base}",
25
- attributes: {
26
- cn: "Sarel Cilliers",
27
- mail: "sarel@example.com",
28
- objectclass: ["inetOrgPerson", "top"],
29
- sn: "Cilliers"
24
+ "dn" => "cn=Sarel Cilliers,#{@base}",
25
+ "attributes" => {
26
+ "cn" => "Sarel Cilliers",
27
+ "mail" => "sarel@example.com",
28
+ "objectclass" => ["inetOrgPerson", "top"],
29
+ "sn" => "Cilliers"
30
30
  }
31
31
  }]
32
32
  @connection_retries = 6
@@ -38,7 +38,7 @@ module Soar
38
38
  provider = provider_class.new(@configuration['provider']['config'].map { |k,v| [k.to_sym, v] }.to_h )
39
39
  @directory = Soar::Registry::Directory.new(provider)
40
40
  @entries.each { |entry|
41
- provider.delete(entry[:dn])
41
+ provider.delete(entry['dn'])
42
42
  }
43
43
  rescue Soar::Registry::Directory::Error::NetworkingError => e
44
44
  raise if @connection_retries == 0
@@ -55,8 +55,8 @@ module Soar
55
55
  def given_existing_data
56
56
  @entries.each{ |entry|
57
57
  @directory.put(entry)
58
- result = @directory.search("mail", entry[:attributes][:mail])
59
- entry[:attributes][:entryuuid] = result[0][@index[0]]
58
+ result = @directory.search("mail", entry['attributes']['mail'])
59
+ entry['attributes']['entryuuid'] = result[0][@index[0]]
60
60
  }
61
61
  end
62
62
 
@@ -70,7 +70,6 @@ module Soar
70
70
  password: @configuration['provider']['config']['credentials']['password']
71
71
  }
72
72
  })
73
-
74
73
  end
75
74
 
76
75
  def put_duplicate_entry
@@ -84,8 +83,8 @@ module Soar
84
83
  def put_entry
85
84
  begin
86
85
  @directory.put(@entries[0])
87
- result = @directory.search("mail", @entries[0][:attributes][:mail])
88
- @entries[0][:attributes][:entryuuid] = result[0][@index[0]]
86
+ result = @directory.search("mail", @entries[0]['attributes']['mail'])
87
+ @entries[0]['attributes']['entryuuid'] = result[0][@index[0]]
89
88
  rescue Soar::Registry::Directory::Error::NetworkingError => e
90
89
  @error = e
91
90
  end
@@ -93,7 +92,7 @@ module Soar
93
92
 
94
93
  def search_for_entry
95
94
  begin
96
- @result = @directory.search("mail", @entries[0][:attributes][:mail])
95
+ @result = @directory.search("mail", @entries[0]['attributes']['mail'])
97
96
  rescue Soar::Registry::Directory::Error::NetworkingError => e
98
97
  @error = e
99
98
  end
@@ -109,7 +108,7 @@ module Soar
109
108
 
110
109
  def fetch_entry
111
110
  begin
112
- @result = @directory.fetch(@entries[0][:attributes][:entryuuid])
111
+ @result = @directory.fetch(@entries[0]['attributes']['entryuuid'])
113
112
  rescue Soar::Registry::Directory::Error::NoEntriesFoundError, Soar::Registry::Directory::Error::NetworkingError => e
114
113
  @error = e
115
114
  end
@@ -120,15 +119,15 @@ module Soar
120
119
  end
121
120
 
122
121
  def persisted?
123
- result = @directory.fetch(@entries[0][:attributes][:entryuuid])
124
- entry = @entries[0][:attributes]
125
- entry.delete(:objectclass)
122
+ result = @directory.fetch(@entries[0]['attributes']['entryuuid'])
123
+ entry = @entries[0]['attributes']
124
+ entry.delete('objectclass')
126
125
  result == entry
127
126
  end
128
127
 
129
128
  def returned?
130
- entry = @entries[0][:attributes]
131
- entry.delete(:objectclass)
129
+ entry = @entries[0]['attributes']
130
+ entry.delete('objectclass')
132
131
  @result == [entry]
133
132
  end
134
133
 
@@ -137,8 +136,8 @@ module Soar
137
136
  end
138
137
 
139
138
  def single_entry?
140
- entry = @entries[0][:attributes]
141
- entry.delete(:objectclass)
139
+ entry = @entries[0]['attributes']
140
+ entry.delete('objectclass')
142
141
  @result == entry
143
142
  end
144
143
 
@@ -12,20 +12,20 @@ module Soar
12
12
 
13
13
  def initialize
14
14
  @configuration = YAML.load_file("config/#{ENV['CONFIG_FILE']}")
15
- @index = @configuration['provider']['config']['index'].map { |index| index.to_sym }
15
+ @index = @configuration['provider']['config']['index']
16
16
  @attributes = @configuration['provider']['config']['attributes']
17
17
  @entries = [{
18
- ID: 1,
19
- Client_Number: "C123456789",
20
- Notifyemail_Invoice: "johnconner@example.com",
21
- First_Name: 'John',
22
- Surname: 'Connor'
18
+ "ID" => 1,
19
+ "Client_Number" => "C123456789",
20
+ "Notifyemail_Invoice" => "johnconner@example.com",
21
+ "First_Name" => 'John',
22
+ "Surname" => 'Connor'
23
23
  }, {
24
- ID: 2,
25
- First_Name: 'Sarah',
26
- Surname: 'Connor',
27
- Client_Number: "C101112134",
28
- Notifyemail_Invoice: "sarahconnor@example.com"
24
+ "ID" => 2,
25
+ "First_Name" => 'Sarah',
26
+ "Surname" => 'Connor',
27
+ "Client_Number" => "C101112134",
28
+ "Notifyemail_Invoice" => "sarahconnor@example.com"
29
29
  }]
30
30
  @connection_retries = 6
31
31
  end
@@ -73,7 +73,7 @@ module Soar
73
73
 
74
74
  def search_for_entry
75
75
  begin
76
- @result = @directory.search("Notifyemail_Invoice", @entries[0][:Notifyemail_Invoice])
76
+ @result = @directory.search("Notifyemail_Invoice", @entries[0]['Notifyemail_Invoice'])
77
77
  rescue Soar::Registry::Directory::Error::NetworkingError => e
78
78
  @error = e.message
79
79
  end
@@ -89,14 +89,14 @@ module Soar
89
89
 
90
90
  def fetch_entry
91
91
  begin
92
- @result = @directory.fetch(@entries[0][:ID])
92
+ @result = @directory.fetch(@entries[0]['ID'])
93
93
  rescue Soar::Registry::Directory::Error::NoEntriesFoundError, Soar::Registry::Directory::Error::NetworkingError => e
94
94
  @error = e.message
95
95
  end
96
96
  end
97
97
 
98
98
  def persisted?
99
- @directory.fetch(@entries[0][:ID]) == @entries[0]
99
+ @directory.fetch(@entries[0]['ID']) == @entries[0]
100
100
  end
101
101
 
102
102
  def returned?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar-registry-directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Mulder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashy_db