github-ldap 1.2.0 → 1.2.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: 64ef77cae7b6d41804fd11a87a169001313320ec
4
- data.tar.gz: 0d9fc6ed121d40dfcead6c8cd1c29cedc7598672
3
+ metadata.gz: a23a62005338f49107b2e82997fbdb9c02d4004c
4
+ data.tar.gz: bb3a1b3bed1dfb66a1b110bf2e7b31e5a74d7378
5
5
  SHA512:
6
- metadata.gz: 55c95dda73fffdce9e46a9718a8d1d58f32c9e47fc367b73c835a0f2e17b161a764c46cdeac24fc67331978764289696a99ea5586fc6c0382bf7d77ece583ad0
7
- data.tar.gz: 8cb01bc061b35bf11f00b34c4340fe08ebe826f419f142c4e3949c720d0e54857ac15066d0c49ef29f26d60f8b85402718fabd13c0e2c648f4b04017ce7bbd7b
6
+ metadata.gz: 24548e4cf5b738fb303b635297fd12c634d5a85d42076e367763e833fd0f59e107e398a3f9ff00ce8a69bb4a5d119bf91f5180661d5274e7c6f79e3445ed2bb3
7
+ data.tar.gz: 56669b0b27287bdd8cdf3b7820690e2b2832ac9adf12eacb5b882c6d71e687b05c1aa0f4459231738e0001dda538fed02817b13496bbf7e8c4366cc52dacc5c6
data/github-ldap.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "github-ldap"
5
- spec.version = "1.2.0"
5
+ spec.version = "1.2.1"
6
6
  spec.authors = ["David Calavera"]
7
7
  spec.email = ["david.calavera@gmail.com"]
8
8
  spec.description = %q{Ldap authentication for humans}
data/lib/github/ldap.rb CHANGED
@@ -95,14 +95,15 @@ module GitHub
95
95
  # Public - Search entries in the ldap server.
96
96
  #
97
97
  # options: is a hash with the same options that Net::LDAP::Connection#search supports.
98
+ # block: is an optional block to pass to the search.
98
99
  #
99
100
  # Returns an Array of Net::LDAP::Entry.
100
- def search(options)
101
+ def search(options, &block)
101
102
  result = if options[:base]
102
- @connection.search(options)
103
+ @connection.search(options, &block)
103
104
  else
104
105
  search_domains.each_with_object([]) do |base, result|
105
- rs = @connection.search(options.merge(:base => base))
106
+ rs = @connection.search(options.merge(:base => base), &block)
106
107
  result.concat Array(rs) unless rs == false
107
108
  end
108
109
  end
@@ -27,9 +27,13 @@ module GitHub
27
27
 
28
28
  # List all groups under this tree that match the query.
29
29
  #
30
+ # query: is the partial name to filter for.
31
+ # opts: additional options to filter with. It's specially recommended to restrict this search by size.
32
+ # block: is an optional block to pass to the search.
33
+ #
30
34
  # Returns a list of ldap entries.
31
- def filter_groups(query)
32
- search(filter: group_contains_filter(query))
35
+ def filter_groups(query, opts = {}, &block)
36
+ search(opts.merge(filter: group_contains_filter(query)), &block)
33
37
  end
34
38
 
35
39
  # List the groups in the ldap server that match the configured ones.
@@ -97,7 +101,7 @@ module GitHub
97
101
  # Returns the user if the login matches any `uid`.
98
102
  # Returns nil if there are no matches.
99
103
  def user?(login)
100
- search(filter: login_filter(@uid, login), limit: 1).first
104
+ search(filter: login_filter(@uid, login), size: 1).first
101
105
  end
102
106
 
103
107
  # Check if a user can be bound with a password.
@@ -127,16 +131,16 @@ module GitHub
127
131
 
128
132
  # Search entries using this domain as base.
129
133
  #
130
- # options: is a Hash with the options for the search.
131
- # The base option is always overriden.
134
+ # options: is a Hash with the options for the search. The base option is always overriden.
135
+ # block: is an optional block to pass to the search.
132
136
  #
133
137
  # Returns an array with the entries found.
134
- def search(options)
138
+ def search(options, &block)
135
139
  options[:base] = @base_name
136
140
  options[:attributes] ||= []
137
141
  options[:paged_searches_supported] = true
138
142
 
139
- @ldap.search(options)
143
+ @ldap.search(options, &block)
140
144
  end
141
145
 
142
146
  # Provide a meaningful result after a protocol operation (for example,
@@ -153,7 +157,7 @@ module GitHub
153
157
  #
154
158
  # Returns a Net::LDAP::Entry
155
159
  def bind
156
- search({}).first
160
+ search(size: 1, scope: Net::LDAP::SearchScope_BaseObject).first
157
161
  end
158
162
  end
159
163
  end
data/test/group_test.rb CHANGED
@@ -32,6 +32,19 @@ class GitHubLdapGroupTest < GitHub::Ldap::Test
32
32
  assert_equal 1, groups.size
33
33
  end
34
34
 
35
+ def test_filter_domain_groups_limited
36
+ groups = []
37
+ groups_domain.filter_groups('enter', size: 1) do |entry|
38
+ groups << entry
39
+ end
40
+ assert_equal 1, groups.size
41
+ end
42
+
43
+ def test_filter_domain_groups_unlimited
44
+ groups = groups_domain.filter_groups('ent')
45
+ assert_equal 3, groups.size
46
+ end
47
+
35
48
  def test_unknown_group
36
49
  refute @ldap.group("cn=foobar,ou=groups,dc=github,dc=com"),
37
50
  "Expected to not bind any group"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Calavera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ldap