stomp 1.4.5 → 1.4.10
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 +4 -4
- data/CHANGELOG.md +39 -1
- data/CONTRIBUTORS.md +749 -0
- data/README.md +74 -752
- data/Rakefile +1 -1
- data/examples/conn_get.rb +122 -0
- data/examples/conn_put.rb +111 -0
- data/examples/conn_put_pace.rb +117 -0
- data/examples/conn_putget.rb +8 -1
- data/examples/contributors.rb +14 -1
- data/examples/examplogger.rb +33 -11
- data/examples/logexamp.rb +3 -0
- data/examples/putget_file.rb +2 -2
- data/examples/showver.rb +4 -0
- data/examples/ssl/SSL.md +1 -1
- data/examples/ssl/ssl_common.rb +24 -0
- data/examples/ssl/uc3/{ssl_uc3.rb → ssl_uc3_from_files.rb} +0 -0
- data/examples/ssl/uc3/{ssl_uc3_ciphers.rb → ssl_uc3_from_files_ciphers.rb} +0 -0
- data/examples/ssl/uc3/ssl_uc3_without_files.rb +69 -0
- data/examples/ssl/uc3/ssl_uc3_without_files_ciphers.rb +65 -0
- data/examples/stomp_common.rb +1 -0
- data/lib/client/utils.rb +1 -0
- data/lib/connection/heartbeats.rb +1 -1
- data/lib/connection/netio.rb +81 -29
- data/lib/connection/utils.rb +1 -0
- data/lib/stomp/connection.rb +1 -0
- data/lib/stomp/sslparams.rb +19 -5
- data/lib/stomp/version.rb +5 -3
- data/spec/connection_spec.rb +1 -1
- data/stomp.gemspec +13 -6
- data/test/test_anonymous.rb +94 -3
- data/test/test_client.rb +210 -76
- data/test/test_codec.rb +13 -0
- data/test/test_connection.rb +113 -1
- data/test/test_connection1p.rb +87 -2
- data/test/test_helper.rb +1 -1
- data/test/test_message.rb +29 -5
- data/test/test_ssl.rb +54 -0
- data/test/test_urlogin.rb +19 -2
- metadata +12 -6
data/test/test_connection1p.rb
CHANGED
@@ -17,6 +17,7 @@ class TestConnection1P < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def setup
|
19
19
|
@conn = get_connection()
|
20
|
+
@tc1dbg = ENV['TC1DBG'] || ENV['TDBGALL'] ? true : false
|
20
21
|
end
|
21
22
|
|
22
23
|
def teardown
|
@@ -25,11 +26,17 @@ class TestConnection1P < Test::Unit::TestCase
|
|
25
26
|
|
26
27
|
# Test basic connection open.
|
27
28
|
def test_conn_1p_0000
|
29
|
+
mn = "test_conn_1p_0000" if @tc1dbg
|
30
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
28
31
|
assert @conn.open?
|
32
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
29
33
|
end
|
30
34
|
|
31
35
|
# Test missing connect headers - part 1.
|
32
36
|
def test_conn_1p_0010
|
37
|
+
mn = "test_conn_1p_0010" if @tc1dbg
|
38
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
39
|
+
|
33
40
|
@conn.disconnect
|
34
41
|
#
|
35
42
|
cha = {:host => "localhost"}
|
@@ -40,11 +47,15 @@ class TestConnection1P < Test::Unit::TestCase
|
|
40
47
|
chb = {"accept-version" => "1.0"}
|
41
48
|
assert_raise Stomp::Error::ProtocolErrorConnect do
|
42
49
|
_ = Stomp::Connection.open(user, passcode, host, port, false, 5, chb)
|
43
|
-
end
|
50
|
+
end
|
51
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
44
52
|
end
|
45
53
|
|
46
54
|
# Test missing connect headers - part 2.
|
47
55
|
def test_conn_1p_0015
|
56
|
+
mn = "test_conn_1p_0015" if @tc1dbg
|
57
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
58
|
+
|
48
59
|
@conn.disconnect
|
49
60
|
#
|
50
61
|
cha = {:host => "localhost"}
|
@@ -68,10 +79,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
68
79
|
assert_raise Stomp::Error::ProtocolErrorConnect do
|
69
80
|
_ = Stomp::Connection.open(hash)
|
70
81
|
end
|
82
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
71
83
|
end
|
72
84
|
|
73
85
|
# Test requesting only a 1.0 connection.
|
74
86
|
def test_conn_1p_0020
|
87
|
+
mn = "test_conn_1p_0020" if @tc1dbg
|
88
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
89
|
+
|
75
90
|
@conn.disconnect
|
76
91
|
#
|
77
92
|
cha = {:host => "localhost", "accept-version" => "1.0"}
|
@@ -80,10 +95,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
80
95
|
conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
81
96
|
conn.disconnect
|
82
97
|
assert_equal conn.protocol, Stomp::SPL_10
|
98
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
83
99
|
end
|
84
100
|
|
85
101
|
# Test requesting only a 1.1+ connection.
|
86
102
|
def test_conn_1p_0030
|
103
|
+
mn = "test_conn_1p_0030" if @tc1dbg
|
104
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
105
|
+
|
87
106
|
@conn.disconnect
|
88
107
|
#
|
89
108
|
cha = get_conn_headers()
|
@@ -91,10 +110,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
91
110
|
conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
92
111
|
conn.disconnect
|
93
112
|
assert conn.protocol >= Stomp::SPL_11
|
113
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
94
114
|
end
|
95
115
|
|
96
116
|
# Test basic request for no heartbeats.
|
97
117
|
def test_conn_1p_0040
|
118
|
+
mn = "test_conn_1p_0040" if @tc1dbg
|
119
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
120
|
+
|
98
121
|
@conn.disconnect
|
99
122
|
#
|
100
123
|
cha = get_conn_headers()
|
@@ -103,10 +126,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
103
126
|
conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
104
127
|
conn.disconnect
|
105
128
|
assert conn.protocol >= Stomp::SPL_11
|
129
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
106
130
|
end
|
107
131
|
|
108
132
|
# Test malformed heartbeat header.
|
109
133
|
def test_conn_1p_0050
|
134
|
+
mn = "test_conn_1p_0050" if @tc1dbg
|
135
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
136
|
+
|
110
137
|
@conn.disconnect
|
111
138
|
#
|
112
139
|
cha = get_conn_headers()
|
@@ -114,10 +141,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
114
141
|
assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
|
115
142
|
_ = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
116
143
|
end
|
144
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
117
145
|
end
|
118
146
|
|
119
147
|
# Test malformed heartbeat header.
|
120
148
|
def test_conn_11h_0060
|
149
|
+
mn = "test_conn_1p_0060" if @tc1dbg
|
150
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
151
|
+
|
121
152
|
@conn.disconnect
|
122
153
|
#
|
123
154
|
cha = get_conn_headers()
|
@@ -125,10 +156,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
125
156
|
assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
|
126
157
|
_ = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
127
158
|
end
|
159
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
128
160
|
end
|
129
161
|
|
130
162
|
# Test a valid heartbeat header.
|
131
163
|
def test_conn_1p_0070
|
164
|
+
mn = "test_conn_1p_0070" if @tc1dbg
|
165
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
166
|
+
|
132
167
|
@conn.disconnect
|
133
168
|
#
|
134
169
|
cha = get_conn_headers()
|
@@ -138,10 +173,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
138
173
|
conn.disconnect
|
139
174
|
assert conn.hbsend_interval > 0
|
140
175
|
assert conn.hbrecv_interval > 0
|
176
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
141
177
|
end
|
142
178
|
|
143
179
|
# Test only sending heartbeats.
|
144
180
|
def test_conn_1p_0080
|
181
|
+
mn = "test_conn_1p_0080" if @tc1dbg
|
182
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
183
|
+
|
145
184
|
@conn.disconnect
|
146
185
|
#
|
147
186
|
cha = get_conn_headers()
|
@@ -154,10 +193,15 @@ class TestConnection1P < Test::Unit::TestCase
|
|
154
193
|
conn.set_logger(nil)
|
155
194
|
conn.disconnect
|
156
195
|
hb_asserts_send(conn)
|
196
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
157
197
|
end if ENV['STOMP_HB11LONG']
|
158
198
|
|
159
199
|
# Test only receiving heartbeats.
|
200
|
+
# This is a no-no with Artemis, you must send, see docs
|
160
201
|
def test_conn_1p_0090
|
202
|
+
mn = "test_conn_1p_0090" if @tc1dbg
|
203
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
204
|
+
|
161
205
|
@conn.disconnect
|
162
206
|
#
|
163
207
|
cha = get_conn_headers()
|
@@ -171,10 +215,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
171
215
|
conn.set_logger(nil)
|
172
216
|
conn.disconnect
|
173
217
|
hb_asserts_recv(conn)
|
174
|
-
|
218
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
219
|
+
end if ENV['STOMP_HB11LONG'] && !ENV['STOMP_ARTEMIS']
|
175
220
|
|
176
221
|
# Test sending and receiving heartbeats.
|
177
222
|
def test_conn_1p_0100
|
223
|
+
mn = "test_conn_1p_0100" if @tc1dbg
|
224
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
225
|
+
|
178
226
|
@conn.disconnect
|
179
227
|
#
|
180
228
|
cha = get_conn_headers()
|
@@ -188,10 +236,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
188
236
|
conn.set_logger(nil)
|
189
237
|
conn.disconnect
|
190
238
|
hb_asserts_both(conn)
|
239
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
191
240
|
end if ENV['STOMP_HB11LONG']
|
192
241
|
|
193
242
|
# Test valid UTF8 data.
|
194
243
|
def test_conn_1p_0110
|
244
|
+
mn = "test_conn_1p_0110" if @tc1dbg
|
245
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
246
|
+
|
195
247
|
@conn.disconnect
|
196
248
|
#
|
197
249
|
cha = get_conn_headers()
|
@@ -219,10 +271,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
219
271
|
assert conn.valid_utf8?(string), "good unicode specs 01: #{string}"
|
220
272
|
end
|
221
273
|
conn.disconnect
|
274
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
222
275
|
end
|
223
276
|
|
224
277
|
# Test invalid UTF8 data.
|
225
278
|
def test_conn_1p_0120
|
279
|
+
mn = "test_conn_1p_0120" if @tc1dbg
|
280
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
281
|
+
|
226
282
|
@conn.disconnect
|
227
283
|
#
|
228
284
|
cha = get_conn_headers()
|
@@ -253,11 +309,15 @@ class TestConnection1P < Test::Unit::TestCase
|
|
253
309
|
assert !conn.valid_utf8?(string), "bad unicode specs 01: #{string}"
|
254
310
|
end
|
255
311
|
conn.disconnect
|
312
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
256
313
|
end
|
257
314
|
|
258
315
|
# Repeated headers test. Brokers have a lot of freedom given the verbiage
|
259
316
|
# in the specs.
|
260
317
|
def test_conn_1p_0124
|
318
|
+
mn = "test_conn_1p_0124" if @tc1dbg
|
319
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
320
|
+
|
261
321
|
dest = make_destination
|
262
322
|
msg = "payload: #{Time.now.to_f}"
|
263
323
|
shdrs = { "key1" => "val1", "key2" => "val2",
|
@@ -276,18 +336,26 @@ class TestConnection1P < Test::Unit::TestCase
|
|
276
336
|
end
|
277
337
|
#
|
278
338
|
@conn.unsubscribe dest, :id => sid
|
339
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
279
340
|
end
|
280
341
|
|
281
342
|
# Test frozen headers.
|
282
343
|
def test_conn_1p_0127
|
344
|
+
mn = "test_conn_1p_0127" if @tc1dbg
|
345
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
346
|
+
|
283
347
|
dest = make_destination
|
284
348
|
sid = @conn.uuid()
|
285
349
|
sid.freeze
|
286
350
|
@conn.subscribe dest, :id => sid
|
351
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
287
352
|
end
|
288
353
|
|
289
354
|
# Test heartbeats with send and receive.
|
290
355
|
def test_conn_1p_0130
|
356
|
+
mn = "test_conn_1p_0130" if @tc1dbg
|
357
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
358
|
+
|
291
359
|
@conn.disconnect
|
292
360
|
#
|
293
361
|
cha = get_conn_headers()
|
@@ -301,10 +369,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
301
369
|
conn.set_logger(nil)
|
302
370
|
conn.disconnect
|
303
371
|
hb_asserts_both(conn)
|
372
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
304
373
|
end if ENV['STOMP_HB11LONG']
|
305
374
|
|
306
375
|
# Test heartbeats with send and receive.
|
307
376
|
def test_conn_1p_0135
|
377
|
+
mn = "test_conn_1p_0135" if @tc1dbg
|
378
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
379
|
+
|
308
380
|
@conn.disconnect
|
309
381
|
#
|
310
382
|
cha = get_conn_headers()
|
@@ -318,10 +390,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
318
390
|
conn.set_logger(nil)
|
319
391
|
conn.disconnect
|
320
392
|
hb_asserts_both(conn)
|
393
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
321
394
|
end if ENV['STOMP_HB11LONG']
|
322
395
|
|
323
396
|
# Test heartbeats with send and receive.
|
324
397
|
def test_conn_1p_0140
|
398
|
+
mn = "test_conn_1p_0140" if @tc1dbg
|
399
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
400
|
+
|
325
401
|
@conn.disconnect
|
326
402
|
#
|
327
403
|
cha = get_conn_headers()
|
@@ -335,10 +411,14 @@ class TestConnection1P < Test::Unit::TestCase
|
|
335
411
|
conn.set_logger(nil)
|
336
412
|
conn.disconnect
|
337
413
|
hb_asserts_both(conn)
|
414
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
338
415
|
end if ENV['STOMP_HB11LONG']
|
339
416
|
|
340
417
|
# Test very basic encoding / decoding of headers
|
341
418
|
def test_conn_1p_0200
|
419
|
+
mn = "test_conn_1p_0200" if @tc1dbg
|
420
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
421
|
+
|
342
422
|
@conn.disconnect
|
343
423
|
#
|
344
424
|
cha = get_conn_headers()
|
@@ -363,11 +443,15 @@ class TestConnection1P < Test::Unit::TestCase
|
|
363
443
|
assert received.headers[k] == v, "Mismatch: #{k},#{v}"
|
364
444
|
}
|
365
445
|
conn.disconnect
|
446
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
366
447
|
end unless ENV['STOMP_RABBIT']
|
367
448
|
|
368
449
|
# Test that 1.1+ connections do not break suppress_content_length
|
369
450
|
# (Issue #52)
|
370
451
|
def test_conn_1p_0210
|
452
|
+
mn = "test_conn_1p_0210" if @tc1dbg
|
453
|
+
p [ "01", mn, "starts" ] if @tc1dbg
|
454
|
+
|
371
455
|
msg = "payload: #{Time.now.to_f}"
|
372
456
|
dest = make_destination
|
373
457
|
shdrs = { :suppress_content_length => true }
|
@@ -379,6 +463,7 @@ class TestConnection1P < Test::Unit::TestCase
|
|
379
463
|
received = @conn.receive
|
380
464
|
assert_equal msg, received.body
|
381
465
|
assert_nil received.headers["content-length"], "No content length expected."
|
466
|
+
p [ "99", mn, "ends" ] if @tc1dbg
|
382
467
|
end if ENV['STOMP_AMQ11']
|
383
468
|
|
384
469
|
private
|
data/test/test_helper.rb
CHANGED
data/test/test_message.rb
CHANGED
@@ -37,7 +37,8 @@ class TestMessage < Test::Unit::TestCase
|
|
37
37
|
"bad byte: \372",
|
38
38
|
"\004\b{\f:\tbody\"\001\207\004\b{\b:\016statusmsg\"\aOK:\017statuscodei\000:\tdata{\t:\voutput\"3Enabled, not running, last run 693 seconds ago:\frunningi\000:\fenabledi\006:\flastrunl+\aE\021\022M:\rsenderid\"\032xx.xx.xx.xx:\016requestid\"%849d647bbe3e421ea19ac9f947bbdde4:\020senderagent\"\fpuppetd:\016msgtarget\"%/topic/mcollective.puppetd.reply:\thash\"\001\257ZdQqtaDmmdD0jZinnEcpN+YbkxQDn8uuCnwsQdvGHau6d+gxnnfPLUddWRSb\nZNMs+sQUXgJNfcV1eVBn1H+Z8QQmzYXVDMqz7J43jmgloz5PsLVbN9K3PmX/\ngszqV/WpvIyAqm98ennWqSzpwMuiCC4q2Jr3s3Gm6bUJ6UkKXnY=\n:\fmsgtimel+\a\372\023\022M"
|
39
39
|
]
|
40
|
-
|
40
|
+
#
|
41
|
+
@tmsdbg = ENV['TMSDBG'] || ENV['TDBGALL'] ? true : false
|
41
42
|
end
|
42
43
|
|
43
44
|
def teardown
|
@@ -46,6 +47,8 @@ class TestMessage < Test::Unit::TestCase
|
|
46
47
|
|
47
48
|
# Various message bodies, including the failing test case reported
|
48
49
|
def test_0010_kcode
|
50
|
+
mn = "test_0010_kcode" if @tmsdbg
|
51
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
49
52
|
#
|
50
53
|
dest = make_destination
|
51
54
|
if @conn.protocol == Stomp::SPL_10
|
@@ -60,10 +63,14 @@ class TestMessage < Test::Unit::TestCase
|
|
60
63
|
assert_instance_of Stomp::Message , msg, "type check for #{abody}"
|
61
64
|
assert_equal abody, msg.body, "equal check for #{abody}"
|
62
65
|
end
|
66
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
63
67
|
end
|
64
68
|
|
65
69
|
# All possible byte values
|
66
70
|
def test_0020_kcode
|
71
|
+
mn = "test_0020_kcode" if @tmsdbg
|
72
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
73
|
+
|
67
74
|
#
|
68
75
|
abody = ""
|
69
76
|
"\000".upto("\377") {|abyte| abody << abyte }
|
@@ -78,11 +85,15 @@ class TestMessage < Test::Unit::TestCase
|
|
78
85
|
@conn.publish dest, abody
|
79
86
|
msg = @conn.receive
|
80
87
|
assert_instance_of Stomp::Message , msg, "type check for #{abody}"
|
81
|
-
|
88
|
+
assert_equal abody, msg.body, "equal check for #{abody}"
|
89
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
82
90
|
end
|
83
91
|
|
84
92
|
# A single byte at a time
|
85
93
|
def test_0030_kcode
|
94
|
+
mn = "test_0030_kcode" if @tmsdbg
|
95
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
96
|
+
|
86
97
|
#
|
87
98
|
dest = make_destination
|
88
99
|
if @conn.protocol == Stomp::SPL_10
|
@@ -97,11 +108,15 @@ class TestMessage < Test::Unit::TestCase
|
|
97
108
|
msg = @conn.receive
|
98
109
|
assert_instance_of Stomp::Message , msg, "type check for #{abody}"
|
99
110
|
assert_equal abody, msg.body, "equal check for #{abody}"
|
100
|
-
|
111
|
+
end
|
112
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
101
113
|
end
|
102
114
|
|
103
115
|
# Test various valid and invalid frames.
|
104
|
-
|
116
|
+
def test_0040_msg_create
|
117
|
+
mn = "test_0040_msg_create" if @tmsdbg
|
118
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
119
|
+
|
105
120
|
#
|
106
121
|
assert_raise(Stomp::Error::InvalidFormat) {
|
107
122
|
_ = Stomp::Message.new("junk", false)
|
@@ -130,10 +145,14 @@ class TestMessage < Test::Unit::TestCase
|
|
130
145
|
_ = Stomp::Message.new("RECEIPT\nh1:val1\n\njunk\0\n", false)
|
131
146
|
_ = Stomp::Message.new("ERROR\nh1:val1\n\njunk\0\n", false)
|
132
147
|
|
133
|
-
|
148
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
149
|
+
end
|
134
150
|
|
135
151
|
# Test multiple headers with the same key
|
136
152
|
def test_0050_mh_msg_create
|
153
|
+
mn = "test_0050_mh_msg_create" if @tmsdbg
|
154
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
155
|
+
|
137
156
|
aframe = bframe = nil
|
138
157
|
amsg = "MESSAGE\n" +
|
139
158
|
"h1:val1\n" +
|
@@ -155,10 +174,14 @@ class TestMessage < Test::Unit::TestCase
|
|
155
174
|
assert_equal "val3", bframe.headers["h2"][0], "Expected val3"
|
156
175
|
assert_equal "val2", bframe.headers["h2"][1], "Expected val2"
|
157
176
|
assert_equal "val1", bframe.headers["h2"][2], "Expected val1"
|
177
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
158
178
|
end
|
159
179
|
|
160
180
|
# Test headers with empty key / value
|
161
181
|
def test_0060_hdr_ekv
|
182
|
+
mn = "test_0060_hdr_ekv" if @tmsdbg
|
183
|
+
p [ "01", mn, "starts" ] if @tmsdbg
|
184
|
+
|
162
185
|
#
|
163
186
|
amsg = "MESSAGE\n" +
|
164
187
|
"h1:val1\n" +
|
@@ -185,6 +208,7 @@ class TestMessage < Test::Unit::TestCase
|
|
185
208
|
_ = Stomp::Message.new(amsg, false)
|
186
209
|
end
|
187
210
|
_ = Stomp::Message.new(amsg, true)
|
211
|
+
p [ "99", mn, "ends" ] if @tmsdbg
|
188
212
|
end
|
189
213
|
|
190
214
|
end
|
data/test/test_ssl.rb
CHANGED
@@ -17,6 +17,7 @@ class TestSSL < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def setup
|
19
19
|
@conn = get_ssl_connection()
|
20
|
+
@tssdbg = ENV['TSSDBG'] || ENV['TDBGALL'] ? true : false
|
20
21
|
end
|
21
22
|
|
22
23
|
def teardown
|
@@ -24,38 +25,90 @@ class TestSSL < Test::Unit::TestCase
|
|
24
25
|
end
|
25
26
|
#
|
26
27
|
def test_ssl_0000
|
28
|
+
mn = "test_ssl_0000" if @tssdbg
|
29
|
+
p [ "01", mn, "starts" ] if @tssdbg
|
27
30
|
assert @conn.open?
|
31
|
+
p [ "99", mn, "ends" ] if @tssdbg
|
28
32
|
end
|
29
33
|
|
30
34
|
# Test SSLParams basic.
|
31
35
|
def test_ssl_0010_parms
|
36
|
+
mn = "test_ssl_0010_parms" if @tssdbg
|
37
|
+
p [ "01", mn, "starts" ] if @tssdbg
|
38
|
+
|
32
39
|
ssl_params = Stomp::SSLParams.new
|
33
40
|
assert ssl_params.ts_files.nil?
|
34
41
|
assert ssl_params.cert_file.nil?
|
35
42
|
assert ssl_params.key_file.nil?
|
36
43
|
assert ssl_params.fsck.nil?
|
44
|
+
p [ "99", mn, "ends" ] if @tssdbg
|
37
45
|
end
|
38
46
|
|
39
47
|
# Test using correct parameters.
|
40
48
|
def test_ssl_0020_noraise
|
49
|
+
mn = "test_ssl_0020_noraise" if @tssdbg
|
50
|
+
p [ "01", mn, "starts" ] if @tssdbg
|
51
|
+
|
41
52
|
_ = Stomp::SSLParams.new(:cert_file => "dummy1", :key_file => "dummy2")
|
53
|
+
_ = Stomp::SSLParams.new(:cert_file => "dummy1", :key_text => "dummy3")
|
54
|
+
_ = Stomp::SSLParams.new(:cert_text => "dummy1", :key_file => "dummy2")
|
55
|
+
_ = Stomp::SSLParams.new(:cert_text => "dummy4", :key_text => "dummy3")
|
42
56
|
_ = Stomp::SSLParams.new(:ts_files => "dummyts1")
|
43
57
|
_ = Stomp::SSLParams.new(:ts_files => "dummyts1",
|
44
58
|
:cert_file => "dummy1", :key_file => "dummy2")
|
59
|
+
p [ "99", mn, "ends" ] if @tssdbg
|
45
60
|
end
|
46
61
|
|
47
62
|
# Test using incorrect / incomplete parameters.
|
48
63
|
def test_ssl_0030_raise
|
64
|
+
mn = "test_ssl_0030_raise" if @tssdbg
|
65
|
+
p [ "01", mn, "starts" ] if @tssdbg
|
66
|
+
|
67
|
+
key_text = '-----BEGIN PRIVATE KEY-----
|
68
|
+
fake_key
|
69
|
+
-----END PRIVATE KEY-----'
|
70
|
+
cert_text = '------BEGIN CERTIFICATE-----
|
71
|
+
fake_cert
|
72
|
+
------END CERTIFICATE-----'
|
73
|
+
|
49
74
|
assert_raise(Stomp::Error::SSLClientParamsError) {
|
50
75
|
_ = Stomp::SSLParams.new(:cert_file => "dummy1")
|
51
76
|
}
|
77
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
78
|
+
_ = Stomp::SSLParams.new(:cert_text => cert_text)
|
79
|
+
}
|
52
80
|
assert_raise(Stomp::Error::SSLClientParamsError) {
|
53
81
|
_ = Stomp::SSLParams.new(:key_file => "dummy2")
|
54
82
|
}
|
83
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
84
|
+
_ = Stomp::SSLParams.new(:key_text => key_text)
|
85
|
+
}
|
86
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
87
|
+
_ = Stomp::SSLParams.new(:cert_text => cert_text, :cert_file => "dummy1")
|
88
|
+
}
|
89
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
90
|
+
_ = Stomp::SSLParams.new(:key_text => key_text, :cert_text => cert_text, :cert_file => "dummy1")
|
91
|
+
}
|
92
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
93
|
+
_ = Stomp::SSLParams.new(:key_file => "dummy2", :cert_text => cert_text, :cert_file => "dummy1")
|
94
|
+
}
|
95
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
96
|
+
_ = Stomp::SSLParams.new(:key_text => key_text, :key_file => "dummy2")
|
97
|
+
}
|
98
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
99
|
+
_ = Stomp::SSLParams.new(:cert_file => "dummy1", :key_text => key_text, :key_file => "dummy2")
|
100
|
+
}
|
101
|
+
assert_raise(Stomp::Error::SSLClientParamsError) {
|
102
|
+
_ = Stomp::SSLParams.new(:cert_text => cert_text, :key_text => key_text, :key_file => "dummy2")
|
103
|
+
}
|
104
|
+
p [ "99", mn, "ends" ] if @tssdbg
|
55
105
|
end
|
56
106
|
|
57
107
|
# Test that :fsck works.
|
58
108
|
def test_ssl_0040_fsck
|
109
|
+
mn = "test_ssl_0040_fsck" if @tssdbg
|
110
|
+
p [ "01", mn, "starts" ] if @tssdbg
|
111
|
+
|
59
112
|
assert_raise(Stomp::Error::SSLNoCertFileError) {
|
60
113
|
_ = Stomp::SSLParams.new(:cert_file => "dummy1",
|
61
114
|
:key_file => "dummy2", :fsck => true)
|
@@ -68,6 +121,7 @@ class TestSSL < Test::Unit::TestCase
|
|
68
121
|
_ = Stomp::SSLParams.new(:ts_files => "/tmp/not-likely-here.txt",
|
69
122
|
:fsck => true)
|
70
123
|
}
|
124
|
+
p [ "99", mn, "ends" ] if @tssdbg
|
71
125
|
end
|
72
126
|
|
73
127
|
#
|