net-ldap 0.16.2 → 0.16.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ class TestSSLBER < Test::Unit::TestCase
5
5
  # Transmits str to @to and reads it back from @from.
6
6
  #
7
7
  def transmit(str)
8
- Timeout::timeout(1) do
8
+ Timeout.timeout(1) do
9
9
  @to.write(str)
10
10
  @to.close
11
11
 
@@ -22,18 +22,22 @@ class TestSSLBER < Test::Unit::TestCase
22
22
  #
23
23
  # TODO: Replace test with real socket
24
24
  # https://github.com/ruby-ldap/ruby-net-ldap/pull/121#discussion_r18746386
25
- flexmock(OpenSSL::SSL::SSLSocket).
26
- new_instances.should_receive(:connect => nil)
25
+ flexmock(OpenSSL::SSL::SSLSocket)
26
+ .new_instances.should_receive(:connect => nil)
27
27
 
28
28
  @to = Net::LDAP::Connection.wrap_with_ssl(@to)
29
29
  @from = Net::LDAP::Connection.wrap_with_ssl(@from)
30
30
  end
31
31
 
32
32
  def test_transmit_strings
33
+ omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket"
34
+
33
35
  assert_equal "foo", transmit("foo")
34
36
  end
35
37
 
36
38
  def test_transmit_ber_encoded_numbers
39
+ omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket"
40
+
37
41
  @to.write 1234.to_ber
38
42
  assert_equal 1234, @from.read_ber
39
43
  end
@@ -15,7 +15,6 @@
15
15
  #------------------------------------------------
16
16
 
17
17
  module LdapServer
18
-
19
18
  LdapServerAsnSyntax = {
20
19
  :application => {
21
20
  :constructed => {
@@ -46,7 +45,7 @@ module LdapServer
46
45
  @data ||= ""; @data << data
47
46
  while pdu = @data.read_ber!(LdapServerAsnSyntax)
48
47
  begin
49
- handle_ldap_pdu pdu
48
+ handle_ldap_pdu pdu
50
49
  rescue
51
50
  $logger.error "closing connection due to error #{$!}"
52
51
  close_connection
@@ -87,9 +86,7 @@ module LdapServer
87
86
  end
88
87
  end
89
88
 
90
-
91
-
92
- #--
89
+ # --
93
90
  # Search Response ::=
94
91
  # CHOICE {
95
92
  # entry [APPLICATION 4] SEQUENCE {
@@ -119,9 +116,9 @@ module LdapServer
119
116
  # pdu[1][7] is the list of requested attributes.
120
117
  # If it's an empty array, that means that *all* attributes were requested.
121
118
  requested_attrs = if pdu[1][7].length > 0
122
- pdu[1][7].map(&:downcase)
123
- else
124
- :all
119
+ pdu[1][7].map(&:downcase)
120
+ else
121
+ :all
125
122
  end
126
123
 
127
124
  filters = pdu[1][6]
@@ -131,13 +128,13 @@ module LdapServer
131
128
  end
132
129
 
133
130
  # TODO, what if this returns nil?
134
- filter = Net::LDAP::Filter.parse_ldap_filter( filters )
131
+ filter = Net::LDAP::Filter.parse_ldap_filter(filters)
135
132
 
136
133
  $ldif.each do |dn, entry|
137
- if filter.match( entry )
134
+ if filter.match(entry)
138
135
  attrs = []
139
136
  entry.each do |k, v|
140
- if requested_attrs == :all or requested_attrs.include?(k.downcase)
137
+ if requested_attrs == :all || requested_attrs.include?(k.downcase)
141
138
  attrvals = v.map(&:to_ber).to_ber_set
142
139
  attrs << [k.to_ber, attrvals].to_ber_sequence
143
140
  end
@@ -149,32 +146,27 @@ module LdapServer
149
146
  end
150
147
  end
151
148
 
152
-
153
149
  send_ldap_response 5, pdu[0].to_i, 0, "", "Was that what you wanted?"
154
150
  end
155
151
 
156
-
157
-
158
152
  def send_ldap_response pkt_tag, msgid, code, dn, text
159
- send_data( [msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)].to_ber )
153
+ send_data([msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)].to_ber)
160
154
  end
161
-
162
155
  end
163
156
 
164
-
165
157
  #------------------------------------------------
166
158
 
167
159
  # Rather bogus, a global method, which reads a HARDCODED filename
168
160
  # parses out LDIF data. It will be used to serve LDAP queries out of this server.
169
161
  #
170
162
  def load_test_data
171
- ary = File.readlines( "./testdata.ldif" )
163
+ ary = File.readlines("./testdata.ldif")
172
164
  hash = {}
173
- while line = ary.shift and line.chomp!
165
+ while (line = ary.shift) && line.chomp!
174
166
  if line =~ /^dn:[\s]*/i
175
167
  dn = $'
176
168
  hash[dn] = {}
177
- while attr = ary.shift and attr.chomp! and attr =~ /^([\w]+)[\s]*:[\s]*/
169
+ while (attr = ary.shift) && attr.chomp! && attr =~ /^([\w]+)[\s]*:[\s]*/
178
170
  hash[dn][$1.downcase] ||= []
179
171
  hash[dn][$1.downcase] << $'
180
172
  end
@@ -183,7 +175,6 @@ def load_test_data
183
175
  hash
184
176
  end
185
177
 
186
-
187
178
  #------------------------------------------------
188
179
 
189
180
  if __FILE__ == $0
@@ -204,6 +195,6 @@ if __FILE__ == $0
204
195
  EventMachine.run do
205
196
  $logger.info "starting LDAP server on 127.0.0.1 port 3890"
206
197
  EventMachine.start_server "127.0.0.1", 3890, LdapServer
207
- EventMachine.add_periodic_timer 60, proc {$logger.info "heartbeat"}
198
+ EventMachine.add_periodic_timer 60, proc { $logger.info "heartbeat" }
208
199
  end
209
200
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.2
4
+ version: 0.16.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -10,10 +10,10 @@ authors:
10
10
  - Kaspar Schiess
11
11
  - Austin Ziegler
12
12
  - Michael Schaarschmidt
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-11-18 00:00:00.000000000 Z
16
+ date: 2020-08-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: flexmock
@@ -35,28 +35,28 @@ dependencies:
35
35
  requirements:
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: '10.0'
38
+ version: 12.3.3
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: '10.0'
45
+ version: 12.3.3
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rubocop
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: 0.42.0
52
+ version: 0.49.0
53
53
  type: :development
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.42.0
59
+ version: 0.49.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: test-unit
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,7 @@ homepage: http://github.com/ruby-ldap/ruby-net-ldap
190
190
  licenses:
191
191
  - MIT
192
192
  metadata: {}
193
- post_install_message:
193
+ post_install_message:
194
194
  rdoc_options:
195
195
  - "--main"
196
196
  - README.rdoc
@@ -207,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubygems_version: 3.0.1
211
- signing_key:
210
+ rubygems_version: 3.1.2
211
+ signing_key:
212
212
  specification_version: 4
213
213
  summary: Net::LDAP for Ruby (also called net-ldap) implements client access for the
214
214
  Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing