soar-registry-directory 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/soar/registry/directory/provider/ldap.rb +1 -0
- data/lib/soar/registry/directory/test/provider/ldap.rb +7 -25
- 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: f8fc37329cb604910b73547c7fca3ad7fe6f39ff
|
4
|
+
data.tar.gz: de37ddcb439fe8fbafb8a9395eb5bc32b69507d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: [
|
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,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
|
-
@
|
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
|
-
|
43
|
-
|
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][
|
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][
|
58
|
+
@entries[0][:attributes][:entryuuid] = result[0][@index[0]]
|
77
59
|
end
|
78
60
|
|
79
61
|
def search_for_entry
|