github-ldap 1.0.5 → 1.0.6
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.
- data/github-ldap.gemspec +1 -1
- data/lib/github/ldap.rb +16 -10
- data/test/ldap_test.rb +11 -0
- metadata +2 -2
data/github-ldap.gemspec
CHANGED
data/lib/github/ldap.rb
CHANGED
@@ -3,7 +3,21 @@ module GitHub
|
|
3
3
|
require 'net/ldap'
|
4
4
|
require 'github/ldap/domain'
|
5
5
|
|
6
|
-
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
# Utility method to perform searches against the ldap server.
|
9
|
+
#
|
10
|
+
# It takes the same arguments than Net:::LDAP#search.
|
11
|
+
# Returns an Array with the entries that match the search.
|
12
|
+
# Returns nil if there are no entries that match the search.
|
13
|
+
def_delegator :@connection, :search
|
14
|
+
|
15
|
+
# Utility method to get the last operation result with a human friendly message.
|
16
|
+
#
|
17
|
+
# Returns an OpenStruct with `code` and `message`.
|
18
|
+
# If `code` is 0, the operation succeeded and there is no message.
|
19
|
+
def_delegator :@connection, :get_operation_result, :last_operation_result
|
20
|
+
|
7
21
|
|
8
22
|
def initialize(options = {})
|
9
23
|
@uid = options[:uid] || "sAMAccountName"
|
@@ -40,15 +54,7 @@ module GitHub
|
|
40
54
|
# If `code` is 0, the operation succeeded and there is no message.
|
41
55
|
def test_connection
|
42
56
|
@connection.bind
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
# Utility method to get the last operation result with a human friendly message.
|
47
|
-
#
|
48
|
-
# Returns an OpenStruct with `code` and `message`.
|
49
|
-
# If `code` is 0, the operation succeeded and there is no message.
|
50
|
-
def get_last_operation_result
|
51
|
-
@connection.get_operation_result
|
57
|
+
last_operation_result
|
52
58
|
end
|
53
59
|
|
54
60
|
# Creates a new domain object to perform operations
|
data/test/ldap_test.rb
CHANGED
@@ -30,4 +30,15 @@ class GitHubLdapTest < Minitest::Test
|
|
30
30
|
assert_equal :start_tls, @ldap.check_encryption('TLS')
|
31
31
|
assert_equal :start_tls, @ldap.check_encryption(:start_tls)
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_search_delegator
|
35
|
+
user = @ldap.domain('dc=github,dc=com').valid_login? 'calavera', 'secret'
|
36
|
+
|
37
|
+
result = @ldap.search(
|
38
|
+
{:base => 'dc=github,dc=com',
|
39
|
+
:attributes => %w(uid),
|
40
|
+
:filter => Net::LDAP::Filter.eq('uid', 'calavera')})
|
41
|
+
|
42
|
+
assert_equal 'calavera', result.first[:uid].first
|
43
|
+
end
|
33
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ldap
|