eventmachine 1.2.0.1-x64-mingw32 → 1.2.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module EventMachine
2
- VERSION = "1.2.0.1"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -1521,6 +1521,12 @@ module EventMachine
1521
1521
  elsif opcode == ConnectionCompleted
1522
1522
  c = @conns[conn_binding] or raise ConnectionNotBound, "received ConnectionCompleted for unknown signature: #{conn_binding}"
1523
1523
  c.connection_completed
1524
+ elsif opcode == SslHandshakeCompleted
1525
+ c = @conns[conn_binding] or raise ConnectionNotBound, "received SslHandshakeCompleted for unknown signature: #{conn_binding}"
1526
+ c.ssl_handshake_completed
1527
+ elsif opcode == SslVerify
1528
+ c = @conns[conn_binding] or raise ConnectionNotBound, "received SslVerify for unknown signature: #{conn_binding}"
1529
+ c.close_connection if c.ssl_verify_peer(data) == false
1524
1530
  elsif opcode == TimerFired
1525
1531
  t = @timers.delete( data )
1526
1532
  return if t == false # timer cancelled
@@ -77,6 +77,8 @@ module EventMachine
77
77
  ConnectionNotifyWritable = 107
78
78
  # @private
79
79
  SslHandshakeCompleted = 108
80
+ # @private
81
+ SslVerify = 109
80
82
 
81
83
  # Exceptions that are defined in rubymain.cpp
82
84
  class ConnectionError < RuntimeError; end
@@ -0,0 +1,13 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new(:test_pure) do |t|
4
+ t.libs << 'tests'
5
+ t.libs << 'lib'
6
+ t.test_files = Dir.glob('tests/**/test_pure*.rb') + Dir.glob('tests/**/test_ssl*.rb')
7
+ t.warning = true
8
+ end
9
+
10
+ task :test_em_pure_ruby do
11
+ ENV['EM_PURE_RUBY'] = 'true'
12
+ Rake::Task['test_pure'].execute
13
+ end
@@ -1,8 +1,11 @@
1
+ require 'em/pure_ruby' if ENV['EM_PURE_RUBY']
1
2
  require 'eventmachine'
2
3
  require 'test/unit'
3
4
  require 'rbconfig'
4
5
  require 'socket'
5
6
 
7
+ puts "EM Library Type: #{EM.library_type}"
8
+
6
9
  class Test::Unit::TestCase
7
10
  class EMTestTimeout < StandardError ; end
8
11
 
@@ -171,6 +171,38 @@ class TestBasic < Test::Unit::TestCase
171
171
  assert_equal local_ip, ip
172
172
  end
173
173
 
174
+ def test_invalid_address_bind_connect_dst
175
+ e = nil
176
+ EM.run do
177
+ begin
178
+ EM.bind_connect('localhost', nil, 'invalid.invalid', 80)
179
+ rescue Exception => e
180
+ # capture the exception
181
+ ensure
182
+ EM.stop
183
+ end
184
+ end
185
+
186
+ assert_kind_of(EventMachine::ConnectionError, e)
187
+ assert_match(/unable to resolve address:.*not known/, e.message)
188
+ end
189
+
190
+ def test_invalid_address_bind_connect_src
191
+ e = nil
192
+ EM.run do
193
+ begin
194
+ EM.bind_connect('invalid.invalid', nil, 'localhost', 80)
195
+ rescue Exception => e
196
+ # capture the exception
197
+ ensure
198
+ EM.stop
199
+ end
200
+ end
201
+
202
+ assert_kind_of(EventMachine::ConnectionError, e)
203
+ assert_match(/invalid bind address:.*not known/, e.message)
204
+ end
205
+
174
206
  def test_reactor_thread?
175
207
  assert !EM.reactor_thread?
176
208
  EM.run { assert EM.reactor_thread?; EM.stop }
@@ -72,6 +72,30 @@ class TestLineText2 < Test::Unit::TestCase
72
72
  assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
73
73
  end
74
74
 
75
+ class RegexDelimiter
76
+ include EM::Protocols::LineText2
77
+ attr_reader :lines
78
+ def initialize *args
79
+ super
80
+ @delim = /[A-D]/
81
+ set_delimiter @delim
82
+ end
83
+ def receive_line line
84
+ (@lines ||= []) << line
85
+ end
86
+ end
87
+
88
+ def test_regex_delimiter
89
+ testdata = %Q(LineaALinebBLinecCLinedD)
90
+
91
+ a = RegexDelimiter.new
92
+ a.receive_data testdata
93
+ assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
94
+
95
+ a = RegexDelimiter.new
96
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
97
+ assert_equal( ["Linea", "Lineb", "Linec", "Lined"], a.lines )
98
+ end
75
99
 
76
100
  #--
77
101
  # Test two lines followed by an empty line, ten bytes of binary data, then
@@ -85,4 +85,55 @@ class TestPure < Test::Unit::TestCase
85
85
  assert a
86
86
  end
87
87
 
88
+ module TLSServer
89
+ def post_init
90
+ start_tls
91
+ end
92
+
93
+ def ssl_handshake_completed
94
+ $server_handshake_completed = true
95
+ end
96
+
97
+ def receive_data(data)
98
+ $server_received_data = data
99
+ send_data(data)
100
+ end
101
+ end
102
+
103
+ module TLSClient
104
+ def post_init
105
+ start_tls
106
+ end
107
+
108
+ def ssl_handshake_completed
109
+ $client_handshake_completed = true
110
+ end
111
+
112
+ def connection_completed
113
+ send_data('Hello World!')
114
+ end
115
+
116
+ def receive_data(data)
117
+ $client_received_data = data
118
+ close_connection
119
+ end
120
+
121
+ def unbind
122
+ EM.stop_event_loop
123
+ end
124
+ end
125
+
126
+ def test_start_tls
127
+ $client_handshake_completed, $server_handshake_completed = false, false
128
+ $client_received_data, $server_received_data = nil, nil
129
+ EM.run do
130
+ EM.start_server("127.0.0.1", 16789, TLSServer)
131
+ EM.connect("127.0.0.1", 16789, TLSClient)
132
+ end
133
+
134
+ assert($client_handshake_completed)
135
+ assert($server_handshake_completed)
136
+ assert($client_received_data == "Hello World!")
137
+ assert($server_received_data == "Hello World!")
138
+ end
88
139
  end
@@ -7,7 +7,7 @@ class TestSslDhParam < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  module Client
10
- def connection_completed
10
+ def post_init
11
11
  start_tls
12
12
  end
13
13
 
@@ -46,6 +46,7 @@ class TestSslDhParam < Test::Unit::TestCase
46
46
 
47
47
  def test_no_dhparam
48
48
  omit_unless(EM.ssl?)
49
+ omit_if(EM.library_type == :pure_ruby) # DH will work with defaults
49
50
  omit_if(rbx?)
50
51
 
51
52
  $client_handshake_completed, $server_handshake_completed = false, false
@@ -2,7 +2,7 @@ require 'em_test_helper'
2
2
 
3
3
  class TestSslEcdhCurve < Test::Unit::TestCase
4
4
  module Client
5
- def connection_completed
5
+ def post_init
6
6
  start_tls
7
7
  end
8
8
 
@@ -56,6 +56,7 @@ class TestSslEcdhCurve < Test::Unit::TestCase
56
56
 
57
57
  def test_ecdh_curve
58
58
  omit_unless(EM.ssl?)
59
+ omit_if(EM.library_type == :pure_ruby && RUBY_VERSION < "2.3.0")
59
60
  omit_if(rbx?)
60
61
 
61
62
  $client_handshake_completed, $server_handshake_completed = false, false
@@ -16,7 +16,7 @@ if EM.ssl?
16
16
  EM.stop_event_loop
17
17
  end
18
18
 
19
- def connection_completed
19
+ def post_init
20
20
  start_tls(:ssl_version => :tlsv1, :sni_hostname => 'example.com')
21
21
  end
22
22
  end
@@ -25,21 +25,21 @@ if EM.ssl?
25
25
 
26
26
  module ClientAny
27
27
  include Client
28
- def connection_completed
28
+ def post_init
29
29
  start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2))
30
30
  end
31
31
  end
32
32
 
33
33
  module ClientDefault
34
34
  include Client
35
- def connection_completed
35
+ def post_init
36
36
  start_tls
37
37
  end
38
38
  end
39
39
 
40
40
  module ClientSSLv3
41
41
  include Client
42
- def connection_completed
42
+ def post_init
43
43
  start_tls(:ssl_version => %w(SSLv3))
44
44
  end
45
45
  end
@@ -98,6 +98,7 @@ class TestSslVerify < Test::Unit::TestCase
98
98
 
99
99
  def test_accept_server
100
100
  omit_unless(EM.ssl?)
101
+ omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain
101
102
  omit_if(rbx?)
102
103
  $client_handshake_completed, $server_handshake_completed = false, false
103
104
  EM.run {
@@ -112,6 +113,7 @@ class TestSslVerify < Test::Unit::TestCase
112
113
 
113
114
  def test_deny_server
114
115
  omit_unless(EM.ssl?)
116
+ omit_if(EM.library_type == :pure_ruby) # Server has a default cert chain
115
117
  omit_if(rbx?)
116
118
  $client_handshake_completed, $server_handshake_completed = false, false
117
119
  EM.run {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.1
4
+ version: 1.2.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-16 00:00:00.000000000 Z
12
+ date: 2016-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -198,6 +198,7 @@ files:
198
198
  - lib/rubyeventmachine.rb
199
199
  - rakelib/package.rake
200
200
  - rakelib/test.rake
201
+ - rakelib/test_pure.rake
201
202
  - tests/client.crt
202
203
  - tests/client.key
203
204
  - tests/dhparam.pem