soar-registry-directory 2.0.0 → 2.0.1

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: 70a565fb09b0f4af26cfb869c32c41aa5809b27e
4
- data.tar.gz: 2fb0d1201fce3c266bf570315b2524005a61776b
3
+ metadata.gz: f8fc37329cb604910b73547c7fca3ad7fe6f39ff
4
+ data.tar.gz: de37ddcb439fe8fbafb8a9395eb5bc32b69507d4
5
5
  SHA512:
6
- metadata.gz: cfbebba8afea49661752f2fe56a23f57c3874c3595af6b23f90fee6a30697258733b83836254df42e9552f1d841de4c8025ee7b7359f7be5871bd428cb72a049
7
- data.tar.gz: 12784a7f75d25c92dabdcd1f3fa88ec779bac1dfd5173507f0a29767ffc8ac60ef3e5816e52ac9ddb05b57f92bb92a32e69320dee5a1c0616f4b191c97b66181
6
+ metadata.gz: 77ddb080426ce0d95c55c489668303108ff57e872982cba993b2702b48a6ecb71d0778c608f89ca2cfbf41cbb607e7cd54e1cf7c261156cfc90c674b23907908
7
+ data.tar.gz: e047c942762f85c70aacb7d4702fe89a2f631f406fc326e2c618bbd6db12ee80b152e6bd3fd6b383570fb66c4f9d05af96079c4dfff8fa688c35ebf1367ea12b
data/README.md CHANGED
@@ -47,7 +47,7 @@ Create an instance of the stub provider by passing in the name, primary key and
47
47
  ```ruby
48
48
  > provider = Soar::Registry::Directory::Provider::Ldap.new({
49
49
  base: 'dc=hetzner,dc=co,dc=za',
50
- index: ['entryuuid', 'mail'],
50
+ index: [:entryuuid, :mail],
51
51
  config: {
52
52
  host: 'localhost',
53
53
  port: 389
@@ -59,6 +59,7 @@ Create an instance of the stub provider by passing in the name, primary key and
59
59
  }
60
60
  })
61
61
  ```
62
+ Please note: Primary key is assumed to be the first element of index array. Index array elements need to be symbols for Ldap.
62
63
 
63
64
  ### The Model
64
65
  ```ruby
@@ -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
@@ -1,4 +1,5 @@
1
1
  require 'soar/registry/directory'
2
+ require 'hashie'
2
3
 
3
4
  module Soar
4
5
  module Registry
@@ -9,16 +10,8 @@ module Soar
9
10
 
10
11
  def initialize
11
12
  @configuration = YAML.load_file("config/#{ENV['CONFIG_FILE']}")
12
- @base = @configuration['provider']['base']
13
- @config = {
14
- host: @configuration['provider']['config']['host'],
15
- port: @configuration['provider']['config']['port']
16
- }
17
- @credentials = {
18
- username: @configuration['provider']['credentials']['username'],
19
- password: @configuration['provider']['credentials']['password']
20
- }
21
- @index = @configuration['provider']['index']
13
+ @base = @configuration['provider']['config']['base']
14
+ @index = @configuration['provider']['config']['index']
22
15
  @entries = [{
23
16
  dn: "cn=John Smith,#{@base}",
24
17
  attributes: {
@@ -39,19 +32,8 @@ module Soar
39
32
  end
40
33
 
41
34
  def given_configured_directory
42
- provider = Soar::Registry::Directory::Provider::Ldap.new({
43
- base: @base,
44
- index: @index,
45
- config: {
46
- host: @config[:host],
47
- port: @config[:port]
48
- },
49
- attributes: ['entryuuid', 'cn', 'mail', 'sn'],
50
- credentials: {
51
- username: @credentials[:username],
52
- password: @credentials[:password]
53
- }
54
- })
35
+ provider_class = Object.const_get(@configuration['provider']['class'])
36
+ provider = provider_class.new(Hashie.symbolize_keys(@configuration['provider']['config']))
55
37
  @directory = Soar::Registry::Directory.new(provider)
56
38
  @entries.each { |entry|
57
39
  provider.delete(entry[:dn])
@@ -66,14 +48,14 @@ module Soar
66
48
  @entries.each{ |entry|
67
49
  @directory.put(entry)
68
50
  result = @directory.search("mail", entry[:attributes][:mail])
69
- entry[:attributes][:entryuuid] = result[0][:entryuuid]
51
+ entry[:attributes][:entryuuid] = result[0][@index[0]]
70
52
  }
71
53
  end
72
54
 
73
55
  def put_entry
74
56
  @directory.put(@entries[0])
75
57
  result = @directory.search("mail", @entries[0][:attributes][:mail])
76
- @entries[0][:attributes][:entryuuid] = result[0][:entryuuid]
58
+ @entries[0][:attributes][:entryuuid] = result[0][@index[0]]
77
59
  end
78
60
 
79
61
  def search_for_entry
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar-registry-directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Mulder