socialcast-net-ldap 0.1.7 → 0.1.8

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.
@@ -2,22 +2,22 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  archive-tar-minitar (0.5.2)
5
- diff-lcs (1.1.2)
6
- flexmock (0.8.11)
5
+ diff-lcs (1.2.4)
6
+ flexmock (1.3.2)
7
7
  hoe (2.8.0)
8
8
  rake (>= 0.8.7)
9
9
  hoe-git (1.3.0)
10
10
  hoe (>= 2.2.0)
11
11
  metaid (1.0)
12
12
  rake (0.8.7)
13
- rspec (2.3.0)
14
- rspec-core (~> 2.3.0)
15
- rspec-expectations (~> 2.3.0)
16
- rspec-mocks (~> 2.3.0)
17
- rspec-core (2.3.1)
18
- rspec-expectations (2.3.0)
19
- diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.3.0)
13
+ rspec (2.14.1)
14
+ rspec-core (~> 2.14.0)
15
+ rspec-expectations (~> 2.14.0)
16
+ rspec-mocks (~> 2.14.0)
17
+ rspec-core (2.14.6)
18
+ rspec-expectations (2.14.3)
19
+ diff-lcs (>= 1.1.3, < 2.0)
20
+ rspec-mocks (2.14.4)
21
21
 
22
22
  PLATFORMS
23
23
  ruby
@@ -25,7 +25,6 @@ lib/net/ldap/password.rb
25
25
  lib/net/ldap/pdu.rb
26
26
  lib/net/ldif.rb
27
27
  lib/net/snmp.rb
28
- spec/integration/ssl_ber_spec.rb
29
28
  spec/spec.opts
30
29
  spec/spec_helper.rb
31
30
  spec/unit/ber/ber_spec.rb
@@ -246,7 +246,7 @@ require 'net/ldap/entry'
246
246
  # and then keeps it open while it executes a user-supplied block.
247
247
  # Net::LDAP#open closes the connection on completion of the block.
248
248
  class Net::LDAP
249
- VERSION = "0.1.7"
249
+ VERSION = "0.1.8"
250
250
 
251
251
  class LdapError < StandardError; end
252
252
 
@@ -1124,9 +1124,10 @@ class Net::LDAP::Connection #:nodoc:
1124
1124
  end
1125
1125
  end
1126
1126
 
1127
- def self.wrap_with_ssl(io)
1127
+ def self.wrap_with_ssl(io, options = {})
1128
1128
  raise Net::LDAP::LdapError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
1129
1129
  ctx = OpenSSL::SSL::SSLContext.new
1130
+ ctx.ssl_version = options[:ssl_version] if options.has_key?(:ssl_version)
1130
1131
  conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
1131
1132
  conn.connect
1132
1133
  conn.sync_close = true
@@ -1165,7 +1166,7 @@ class Net::LDAP::Connection #:nodoc:
1165
1166
  def setup_encryption(args)
1166
1167
  case args[:method]
1167
1168
  when :simple_tls
1168
- @conn = self.class.wrap_with_ssl(@conn)
1169
+ @conn = self.class.wrap_with_ssl(@conn, args)
1169
1170
  # additional branches requiring server validation and peer certs, etc.
1170
1171
  # go here.
1171
1172
  when :start_tls
@@ -1178,7 +1179,7 @@ class Net::LDAP::Connection #:nodoc:
1178
1179
  pdu = Net::LDAP::PDU.new(be)
1179
1180
  raise Net::LDAP::LdapError, "no start_tls result" if pdu.nil?
1180
1181
  if pdu.result_code.zero?
1181
- @conn = self.class.wrap_with_ssl(@conn)
1182
+ @conn = self.class.wrap_with_ssl(@conn, args)
1182
1183
  else
1183
1184
  raise Net::LDAP::LdapError, "start_tls failed: #{pdu.result_code}"
1184
1185
  end
@@ -1328,7 +1329,7 @@ class Net::LDAP::Connection #:nodoc:
1328
1329
  # in the protocol.
1329
1330
  #++
1330
1331
  def search(args = {})
1331
- search_filter = (args && args[:filter]) ||
1332
+ search_filter = (args && args[:filter]) ||
1332
1333
  Net::LDAP::Filter.eq("objectclass", "*")
1333
1334
  search_filter = Net::LDAP::Filter.construct(search_filter) if search_filter.is_a?(String)
1334
1335
  search_base = (args && args[:base]) || "dc=example, dc=com"
@@ -1518,7 +1519,7 @@ class Net::LDAP::Connection #:nodoc:
1518
1519
 
1519
1520
  request = [old_dn.to_ber, new_rdn.to_ber, delete_attrs.to_ber]
1520
1521
  request << new_superior.to_ber unless new_superior == nil
1521
-
1522
+
1522
1523
  pkt = [next_msgid.to_ber, request.to_ber_appsequence(12)].to_ber_sequence
1523
1524
  @conn.write pkt
1524
1525
 
@@ -1,2 +1,2 @@
1
1
  --format specdoc
2
- --colour
2
+ --colour
@@ -7,11 +7,11 @@ describe Net::LDAP::Connection do
7
7
  flexmock(TCPSocket).
8
8
  should_receive(:new).and_raise(Errno::ECONNREFUSED)
9
9
  end
10
-
10
+
11
11
  it "should raise LdapError" do
12
12
  lambda {
13
13
  Net::LDAP::Connection.new(
14
- :server => 'test.mocked.com',
14
+ :server => 'test.mocked.com',
15
15
  :port => 636)
16
16
  }.should raise_error(Net::LDAP::LdapError)
17
17
  end
@@ -21,11 +21,11 @@ describe Net::LDAP::Connection do
21
21
  flexmock(TCPSocket).
22
22
  should_receive(:new).and_raise(SocketError)
23
23
  end
24
-
24
+
25
25
  it "should raise LdapError" do
26
26
  lambda {
27
27
  Net::LDAP::Connection.new(
28
- :server => 'test.mocked.com',
28
+ :server => 'test.mocked.com',
29
29
  :port => 636)
30
30
  }.should raise_error(Net::LDAP::LdapError)
31
31
  end
@@ -35,14 +35,35 @@ describe Net::LDAP::Connection do
35
35
  flexmock(TCPSocket).
36
36
  should_receive(:new).and_raise(NameError)
37
37
  end
38
-
38
+
39
39
  it "should rethrow the exception" do
40
40
  lambda {
41
41
  Net::LDAP::Connection.new(
42
- :server => 'test.mocked.com',
42
+ :server => 'test.mocked.com',
43
43
  :port => 636)
44
44
  }.should raise_error(NameError)
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ describe "wrap_with_ssl" do
49
+ before(:each) do
50
+ @conn = flexmock(TCPSocket).should_receive(:new).and_return(flexmock('tcpsocket'))
51
+ @ssl_con = flexmock('sslsocket')
52
+ @ssl_con.should_receive(:connect)
53
+ @ssl_con.should_receive(:sync_close=)
54
+ flexmock(OpenSSL::SSL::SSLSocket).should_receive(:new).and_return(@ssl_con)
55
+ end
56
+ it "allows no options to be passed" do
57
+ flexmock(OpenSSL::SSL::SSLContext).new_instances.should_receive(:ssl_version=).never
58
+ Net::LDAP::Connection.wrap_with_ssl(@conn).should eql(@ssl_con)
59
+ end
60
+ it "allows options to be passed" do
61
+ flexmock(OpenSSL::SSL::SSLContext).new_instances.should_receive(:ssl_version=).never
62
+ Net::LDAP::Connection.wrap_with_ssl(@conn, {}).should eql(@ssl_con)
63
+ end
64
+ it "communicates over the ssl_version configured" do
65
+ flexmock(OpenSSL::SSL::SSLContext).new_instances.should_receive(:ssl_version=).with(:SSLv3)
66
+ Net::LDAP::Connection.wrap_with_ssl(@conn, {:ssl_version => :SSLv3}).should eql(@ssl_con)
67
+ end
68
+ end
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-net-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-07-03 00:00:00.000000000 Z
16
+ date: 2013-10-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: archive-tar-minitar
@@ -168,8 +168,6 @@ files:
168
168
  bGliL25ldC9sZGlmLnJi
169
169
  - !binary |-
170
170
  bGliL25ldC9zbm1wLnJi
171
- - !binary |-
172
- c3BlYy9pbnRlZ3JhdGlvbi9zc2xfYmVyX3NwZWMucmI=
173
171
  - !binary |-
174
172
  c3BlYy9zcGVjLm9wdHM=
175
173
  - !binary |-
@@ -226,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
224
  version: '0'
227
225
  requirements: []
228
226
  rubyforge_project: socialcast-net-ldap
229
- rubygems_version: 1.8.24
227
+ rubygems_version: 1.8.27
230
228
  signing_key:
231
229
  specification_version: 3
232
230
  summary: Pure Ruby LDAP support library with most client features and some server
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'net/ldap'
4
-
5
- describe "BER serialisation (SSL)" do
6
- # Transmits str to #to and reads it back from #from.
7
- #
8
- def transmit(str)
9
- to.write(str)
10
- to.close
11
-
12
- from.read
13
- end
14
-
15
- attr_reader :to, :from
16
- before(:each) do
17
- @from, @to = IO.pipe
18
-
19
- flexmock(OpenSSL::SSL::SSLSocket).
20
- new_instances.should_receive(:connect => nil)
21
-
22
- @to = Net::LDAP::Connection.wrap_with_ssl(to)
23
- @from = Net::LDAP::Connection.wrap_with_ssl(from)
24
- end
25
-
26
- it "should transmit strings" do
27
- transmit('foo').should == 'foo'
28
- end
29
- it "should correctly transmit numbers" do
30
- to.write 1234.to_ber
31
- from.read_ber.should == 1234
32
- end
33
- end