vines 0.3.2 → 0.4.0
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.
- data/README +5 -9
- data/Rakefile +11 -9
- data/conf/config.rb +30 -4
- data/lib/vines/cluster/connection.rb +26 -0
- data/lib/vines/cluster/publisher.rb +55 -0
- data/lib/vines/cluster/pubsub.rb +92 -0
- data/lib/vines/cluster/sessions.rb +125 -0
- data/lib/vines/cluster/subscriber.rb +108 -0
- data/lib/vines/cluster.rb +246 -0
- data/lib/vines/command/init.rb +21 -24
- data/lib/vines/config/host.rb +48 -8
- data/lib/vines/config/port.rb +5 -0
- data/lib/vines/config/pubsub.rb +108 -0
- data/lib/vines/config.rb +74 -20
- data/lib/vines/jid.rb +14 -0
- data/lib/vines/router.rb +69 -55
- data/lib/vines/stanza/iq/disco_info.rb +22 -9
- data/lib/vines/stanza/iq/disco_items.rb +6 -3
- data/lib/vines/stanza/iq/ping.rb +1 -1
- data/lib/vines/stanza/iq/private_storage.rb +4 -8
- data/lib/vines/stanza/iq/roster.rb +6 -14
- data/lib/vines/stanza/iq/session.rb +2 -7
- data/lib/vines/stanza/iq/vcard.rb +4 -6
- data/lib/vines/stanza/iq/version.rb +1 -1
- data/lib/vines/stanza/iq.rb +8 -10
- data/lib/vines/stanza/presence/subscribe.rb +3 -11
- data/lib/vines/stanza/presence/subscribed.rb +16 -29
- data/lib/vines/stanza/presence/unsubscribe.rb +3 -15
- data/lib/vines/stanza/presence/unsubscribed.rb +3 -16
- data/lib/vines/stanza/presence.rb +30 -0
- data/lib/vines/stanza/pubsub/create.rb +39 -0
- data/lib/vines/stanza/pubsub/delete.rb +41 -0
- data/lib/vines/stanza/pubsub/publish.rb +66 -0
- data/lib/vines/stanza/pubsub/subscribe.rb +44 -0
- data/lib/vines/stanza/pubsub/unsubscribe.rb +30 -0
- data/lib/vines/stanza/pubsub.rb +22 -0
- data/lib/vines/stanza.rb +72 -22
- data/lib/vines/storage/couchdb.rb +46 -65
- data/lib/vines/storage/local.rb +20 -14
- data/lib/vines/storage/mongodb.rb +132 -0
- data/lib/vines/storage/null.rb +39 -0
- data/lib/vines/storage/redis.rb +61 -68
- data/lib/vines/storage/sql.rb +73 -69
- data/lib/vines/storage.rb +1 -1
- data/lib/vines/stream/client/bind.rb +2 -2
- data/lib/vines/stream/client/session.rb +71 -16
- data/lib/vines/stream/component/handshake.rb +1 -0
- data/lib/vines/stream/component/ready.rb +2 -2
- data/lib/vines/stream/http/session.rb +2 -0
- data/lib/vines/stream/http.rb +0 -6
- data/lib/vines/stream/server/final_restart.rb +1 -0
- data/lib/vines/stream/server/outbound/final_features.rb +1 -0
- data/lib/vines/stream/server/ready.rb +6 -2
- data/lib/vines/stream/server.rb +4 -3
- data/lib/vines/stream.rb +10 -6
- data/lib/vines/version.rb +1 -1
- data/lib/vines.rb +48 -22
- data/test/cluster/publisher_test.rb +45 -0
- data/test/cluster/sessions_test.rb +54 -0
- data/test/cluster/subscriber_test.rb +94 -0
- data/test/config/host_test.rb +100 -21
- data/test/config/pubsub_test.rb +181 -0
- data/test/config_test.rb +225 -43
- data/test/jid_test.rb +7 -0
- data/test/router_test.rb +181 -9
- data/test/stanza/iq/disco_info_test.rb +8 -6
- data/test/stanza/iq/disco_items_test.rb +3 -3
- data/test/stanza/iq/private_storage_test.rb +8 -19
- data/test/stanza/iq/roster_test.rb +1 -1
- data/test/stanza/iq/session_test.rb +3 -6
- data/test/stanza/iq/vcard_test.rb +6 -2
- data/test/stanza/iq/version_test.rb +3 -2
- data/test/stanza/iq_test.rb +5 -5
- data/test/stanza/message_test.rb +3 -2
- data/test/stanza/presence/probe_test.rb +2 -1
- data/test/stanza/pubsub/create_test.rb +138 -0
- data/test/stanza/pubsub/delete_test.rb +142 -0
- data/test/stanza/pubsub/publish_test.rb +373 -0
- data/test/stanza/pubsub/subscribe_test.rb +186 -0
- data/test/stanza/pubsub/unsubscribe_test.rb +179 -0
- data/test/stanza_test.rb +2 -1
- data/test/storage/local_test.rb +26 -25
- data/test/storage/mock_mongo.rb +40 -0
- data/test/storage/mock_redis.rb +98 -0
- data/test/storage/mongodb_test.rb +81 -0
- data/test/storage/null_test.rb +30 -0
- data/test/storage/redis_test.rb +3 -36
- data/test/stream/component/handshake_test.rb +4 -0
- data/test/stream/component/ready_test.rb +2 -1
- data/test/stream/server/ready_test.rb +7 -1
- data/web/404.html +5 -3
- data/web/chat/coffeescripts/chat.coffee +9 -5
- data/web/chat/javascripts/app.js +1 -1
- data/web/chat/javascripts/chat.js +14 -8
- data/web/chat/stylesheets/chat.css +4 -1
- data/web/lib/coffeescripts/button.coffee +9 -5
- data/web/lib/coffeescripts/filter.coffee +1 -1
- data/web/lib/coffeescripts/login.coffee +14 -1
- data/web/lib/coffeescripts/session.coffee +8 -11
- data/web/lib/images/dark-gray.png +0 -0
- data/web/lib/images/light-gray.png +0 -0
- data/web/lib/images/logo-large.png +0 -0
- data/web/lib/images/logo-small.png +0 -0
- data/web/lib/images/white.png +0 -0
- data/web/lib/javascripts/base.js +9 -8
- data/web/lib/javascripts/button.js +20 -12
- data/web/lib/javascripts/filter.js +1 -1
- data/web/lib/javascripts/icons.js +7 -1
- data/web/lib/javascripts/jquery.js +4 -4
- data/web/lib/javascripts/login.js +16 -2
- data/web/lib/javascripts/raphael.js +5 -7
- data/web/lib/javascripts/session.js +10 -14
- data/web/lib/stylesheets/base.css +7 -11
- data/web/lib/stylesheets/login.css +31 -27
- metadata +100 -34
data/test/config_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'minitest/autorun'
|
5
6
|
|
@@ -17,12 +18,12 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
17
18
|
Vines::Config.new do
|
18
19
|
host 'wonderland.lit' do
|
19
20
|
storage 'fs' do
|
20
|
-
dir
|
21
|
+
dir Dir.tmpdir
|
21
22
|
end
|
22
23
|
end
|
23
24
|
host 'WONDERLAND.LIT' do
|
24
25
|
storage 'fs' do
|
25
|
-
dir
|
26
|
+
dir Dir.tmpdir
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -34,7 +35,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
34
35
|
Vines::Config.new do
|
35
36
|
host 'wonderland.lit', 'wonderland.lit' do
|
36
37
|
storage 'fs' do
|
37
|
-
dir
|
38
|
+
dir Dir.tmpdir
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -45,7 +46,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
45
46
|
config = Vines::Config.configure do
|
46
47
|
host 'wonderland.lit' do
|
47
48
|
storage :fs do
|
48
|
-
dir
|
49
|
+
dir Dir.tmpdir
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -56,11 +57,12 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
56
57
|
def test_vhost
|
57
58
|
config = Vines::Config.new do
|
58
59
|
host 'wonderland.lit' do
|
59
|
-
storage(:fs) { dir
|
60
|
+
storage(:fs) { dir Dir.tmpdir }
|
60
61
|
end
|
61
62
|
end
|
62
63
|
assert_equal ['wonderland.lit'], config.vhosts.keys
|
63
64
|
assert config.vhost?('wonderland.lit')
|
65
|
+
refute config.vhost?('alice@wonderland.lit')
|
64
66
|
refute config.vhost?('tea.wonderland.lit')
|
65
67
|
refute config.vhost?('bogus')
|
66
68
|
end
|
@@ -68,7 +70,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
68
70
|
def test_port_lookup
|
69
71
|
config = Vines::Config.new do
|
70
72
|
host 'wonderland.lit' do
|
71
|
-
storage(:fs) { dir
|
73
|
+
storage(:fs) { dir Dir.tmpdir }
|
72
74
|
end
|
73
75
|
client
|
74
76
|
end
|
@@ -80,6 +82,9 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
80
82
|
def test_duplicate_client
|
81
83
|
assert_raises(RuntimeError) do
|
82
84
|
Vines::Config.new do
|
85
|
+
host 'wonderland.lit' do
|
86
|
+
storage(:fs) { dir Dir.tmpdir }
|
87
|
+
end
|
83
88
|
client
|
84
89
|
client
|
85
90
|
end
|
@@ -89,6 +94,9 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
89
94
|
def test_duplicate_server
|
90
95
|
assert_raises(RuntimeError) do
|
91
96
|
Vines::Config.new do
|
97
|
+
host 'wonderland.lit' do
|
98
|
+
storage(:fs) { dir Dir.tmpdir }
|
99
|
+
end
|
92
100
|
server
|
93
101
|
server
|
94
102
|
end
|
@@ -98,6 +106,9 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
98
106
|
def test_duplicate_http
|
99
107
|
assert_raises(RuntimeError) do
|
100
108
|
Vines::Config.new do
|
109
|
+
host 'wonderland.lit' do
|
110
|
+
storage(:fs) { dir Dir.tmpdir }
|
111
|
+
end
|
101
112
|
http
|
102
113
|
http
|
103
114
|
end
|
@@ -107,16 +118,61 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
107
118
|
def test_duplicate_component
|
108
119
|
assert_raises(RuntimeError) do
|
109
120
|
Vines::Config.new do
|
121
|
+
host 'wonderland.lit' do
|
122
|
+
storage(:fs) { dir Dir.tmpdir }
|
123
|
+
end
|
110
124
|
component
|
111
125
|
component
|
112
126
|
end
|
113
127
|
end
|
114
128
|
end
|
115
129
|
|
130
|
+
def test_duplicate_cluster
|
131
|
+
assert_raises(RuntimeError) do
|
132
|
+
Vines::Config.new do
|
133
|
+
host 'wonderland.lit' do
|
134
|
+
storage(:fs) { dir Dir.tmpdir }
|
135
|
+
end
|
136
|
+
cluster {}
|
137
|
+
cluster {}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_missing_cluster
|
143
|
+
config = Vines::Config.new do
|
144
|
+
host 'wonderland.lit' do
|
145
|
+
storage(:fs) { dir Dir.tmpdir }
|
146
|
+
end
|
147
|
+
end
|
148
|
+
assert_nil config.cluster
|
149
|
+
refute config.cluster?
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_cluster
|
153
|
+
config = Vines::Config.new do
|
154
|
+
host 'wonderland.lit' do
|
155
|
+
storage(:fs) { dir Dir.tmpdir }
|
156
|
+
end
|
157
|
+
cluster do
|
158
|
+
host 'redis.wonderland.lit'
|
159
|
+
port 12345
|
160
|
+
database 8
|
161
|
+
password 'secr3t'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
refute_nil config.cluster
|
165
|
+
assert config.cluster?
|
166
|
+
assert_equal 'redis.wonderland.lit', config.cluster.host
|
167
|
+
assert_equal 12345, config.cluster.port
|
168
|
+
assert_equal 8, config.cluster.database
|
169
|
+
assert_equal 'secr3t', config.cluster.password
|
170
|
+
end
|
171
|
+
|
116
172
|
def test_default_client
|
117
173
|
config = Vines::Config.new do
|
118
174
|
host 'wonderland.lit' do
|
119
|
-
storage(:fs) { dir
|
175
|
+
storage(:fs) { dir Dir.tmpdir }
|
120
176
|
end
|
121
177
|
client
|
122
178
|
end
|
@@ -135,7 +191,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
135
191
|
def test_configured_client
|
136
192
|
config = Vines::Config.new do
|
137
193
|
host 'wonderland.lit' do
|
138
|
-
storage(:fs) { dir
|
194
|
+
storage(:fs) { dir Dir.tmpdir }
|
139
195
|
end
|
140
196
|
client '0.0.0.1', 42 do
|
141
197
|
max_stanza_size 60_000
|
@@ -157,7 +213,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
157
213
|
def test_max_stanza_size
|
158
214
|
config = Vines::Config.new do
|
159
215
|
host 'wonderland.lit' do
|
160
|
-
storage(:fs) { dir
|
216
|
+
storage(:fs) { dir Dir.tmpdir }
|
161
217
|
end
|
162
218
|
client do
|
163
219
|
max_stanza_size 0
|
@@ -169,7 +225,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
169
225
|
def test_default_server
|
170
226
|
config = Vines::Config.new do
|
171
227
|
host 'wonderland.lit' do
|
172
|
-
storage(:fs) { dir
|
228
|
+
storage(:fs) { dir Dir.tmpdir }
|
173
229
|
end
|
174
230
|
server
|
175
231
|
end
|
@@ -188,7 +244,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
188
244
|
def test_configured_server
|
189
245
|
config = Vines::Config.new do
|
190
246
|
host 'wonderland.lit' do
|
191
|
-
storage(:fs) { dir
|
247
|
+
storage(:fs) { dir Dir.tmpdir }
|
192
248
|
end
|
193
249
|
server '0.0.0.1', 42 do
|
194
250
|
max_stanza_size 60_000
|
@@ -199,7 +255,10 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
199
255
|
refute_nil port
|
200
256
|
assert config.s2s?('verona.lit')
|
201
257
|
assert config.s2s?('denmark.lit')
|
202
|
-
assert
|
258
|
+
assert config.s2s?(Vines::JID.new('denmark.lit'))
|
259
|
+
refute config.s2s?(Vines::JID.new('hamlet@denmark.lit'))
|
260
|
+
refute config.s2s?('bogus')
|
261
|
+
refute config.s2s?(nil)
|
203
262
|
assert_equal Vines::Config::ServerPort, port.class
|
204
263
|
assert_equal '0.0.0.1', port.host
|
205
264
|
assert_equal 42, port.port
|
@@ -212,7 +271,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
212
271
|
def test_default_http
|
213
272
|
config = Vines::Config.new do
|
214
273
|
host 'wonderland.lit' do
|
215
|
-
storage(:fs) { dir
|
274
|
+
storage(:fs) { dir Dir.tmpdir }
|
216
275
|
end
|
217
276
|
http
|
218
277
|
end
|
@@ -233,7 +292,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
233
292
|
def test_configured_http
|
234
293
|
config = Vines::Config.new do
|
235
294
|
host 'wonderland.lit' do
|
236
|
-
storage(:fs) { dir
|
295
|
+
storage(:fs) { dir Dir.tmpdir }
|
237
296
|
end
|
238
297
|
http '0.0.0.1', 42 do
|
239
298
|
bind '/custom'
|
@@ -259,7 +318,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
259
318
|
def test_default_component
|
260
319
|
config = Vines::Config.new do
|
261
320
|
host 'wonderland.lit' do
|
262
|
-
storage(:fs) { dir
|
321
|
+
storage(:fs) { dir Dir.tmpdir }
|
263
322
|
end
|
264
323
|
component
|
265
324
|
end
|
@@ -277,7 +336,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
277
336
|
def test_configured_component
|
278
337
|
config = Vines::Config.new do
|
279
338
|
host 'wonderland.lit' do
|
280
|
-
storage(:fs) { dir
|
339
|
+
storage(:fs) { dir Dir.tmpdir }
|
281
340
|
end
|
282
341
|
component '0.0.0.1', 42 do
|
283
342
|
max_stanza_size 60_000
|
@@ -299,7 +358,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
299
358
|
config = Vines::Config.new do
|
300
359
|
log 'bogus'
|
301
360
|
host 'wonderland.lit' do
|
302
|
-
storage(:fs) { dir
|
361
|
+
storage(:fs) { dir Dir.tmpdir }
|
303
362
|
end
|
304
363
|
end
|
305
364
|
end
|
@@ -309,20 +368,30 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
309
368
|
config = Vines::Config.new do
|
310
369
|
log :error
|
311
370
|
host 'wonderland.lit' do
|
312
|
-
storage(:fs) { dir
|
371
|
+
storage(:fs) { dir Dir.tmpdir }
|
313
372
|
end
|
314
373
|
end
|
315
374
|
assert_equal Logger::ERROR, Class.new.extend(Vines::Log).log.level
|
316
375
|
end
|
317
376
|
|
377
|
+
def test_null_storage
|
378
|
+
config = Vines::Config.new do
|
379
|
+
host 'wonderland.lit' do
|
380
|
+
storage(:fs) { dir Dir.tmpdir }
|
381
|
+
end
|
382
|
+
end
|
383
|
+
assert_equal Vines::Storage::Local, config.storage('wonderland.lit').class
|
384
|
+
assert_equal Vines::Storage::Null, config.storage('bogus').class
|
385
|
+
end
|
386
|
+
|
318
387
|
def test_cross_domain_messages
|
319
388
|
config = Vines::Config.new do
|
320
389
|
host 'wonderland.lit' do
|
321
|
-
storage(:fs) { dir
|
390
|
+
storage(:fs) { dir Dir.tmpdir }
|
322
391
|
end
|
323
392
|
host 'verona.lit' do
|
324
393
|
cross_domain_messages true
|
325
|
-
storage(:fs) { dir
|
394
|
+
storage(:fs) { dir Dir.tmpdir }
|
326
395
|
end
|
327
396
|
end
|
328
397
|
refute config.vhosts['wonderland.lit'].cross_domain_messages?
|
@@ -332,12 +401,14 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
332
401
|
def test_local_jid?
|
333
402
|
config = Vines::Config.new do
|
334
403
|
host 'wonderland.lit', 'verona.lit' do
|
335
|
-
storage(:fs) { dir
|
404
|
+
storage(:fs) { dir Dir.tmpdir }
|
336
405
|
end
|
337
406
|
end
|
338
407
|
refute config.local_jid?(nil)
|
339
408
|
refute config.local_jid?('alice@wonderland.lit', nil)
|
340
409
|
assert config.local_jid?('alice@wonderland.lit')
|
410
|
+
assert config.local_jid?(Vines::JID.new('alice@wonderland.lit'))
|
411
|
+
assert config.local_jid?(Vines::JID.new('wonderland.lit'))
|
341
412
|
assert config.local_jid?('alice@wonderland.lit', 'romeo@verona.lit')
|
342
413
|
refute config.local_jid?('alice@wonderland.lit', 'romeo@bogus.lit')
|
343
414
|
refute config.local_jid?('alice@tea.wonderland.lit')
|
@@ -347,7 +418,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
347
418
|
def test_missing_addresses_not_allowed
|
348
419
|
config = Vines::Config.new do
|
349
420
|
host 'wonderland.lit', 'verona.lit' do
|
350
|
-
storage(:fs) { dir
|
421
|
+
storage(:fs) { dir Dir.tmpdir }
|
351
422
|
end
|
352
423
|
end
|
353
424
|
refute config.allowed?(nil, nil)
|
@@ -357,19 +428,21 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
357
428
|
def test_same_domain_allowed
|
358
429
|
config = Vines::Config.new do
|
359
430
|
host 'wonderland.lit', 'verona.lit' do
|
360
|
-
storage(:fs) { dir
|
431
|
+
storage(:fs) { dir Dir.tmpdir }
|
361
432
|
end
|
362
433
|
end
|
363
434
|
alice = Vines::JID.new('alice@wonderland.lit')
|
364
435
|
hatter = Vines::JID.new('hatter@wonderland.lit')
|
365
436
|
assert config.allowed?(alice, hatter)
|
437
|
+
assert config.allowed?(hatter, alice)
|
438
|
+
assert config.allowed?('wonderland.lit', alice)
|
366
439
|
end
|
367
440
|
|
368
441
|
def test_both_vhosts_with_cross_domain_allowed
|
369
442
|
config = Vines::Config.new do
|
370
443
|
host 'wonderland.lit', 'verona.lit' do
|
371
444
|
cross_domain_messages true
|
372
|
-
storage(:fs) { dir
|
445
|
+
storage(:fs) { dir Dir.tmpdir }
|
373
446
|
end
|
374
447
|
end
|
375
448
|
alice = Vines::JID.new('alice@wonderland.lit')
|
@@ -382,11 +455,11 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
382
455
|
config = Vines::Config.new do
|
383
456
|
host 'wonderland.lit' do
|
384
457
|
cross_domain_messages true
|
385
|
-
storage(:fs) { dir
|
458
|
+
storage(:fs) { dir Dir.tmpdir }
|
386
459
|
end
|
387
460
|
host 'verona.lit' do
|
388
461
|
cross_domain_messages false
|
389
|
-
storage(:fs) { dir
|
462
|
+
storage(:fs) { dir Dir.tmpdir }
|
390
463
|
end
|
391
464
|
end
|
392
465
|
alice = Vines::JID.new('alice@wonderland.lit')
|
@@ -395,11 +468,70 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
395
468
|
refute config.allowed?(romeo, alice)
|
396
469
|
end
|
397
470
|
|
471
|
+
def test_same_domain_component_to_pubsub_allowed
|
472
|
+
config = Vines::Config.new do
|
473
|
+
host 'wonderland.lit' do
|
474
|
+
cross_domain_messages false
|
475
|
+
storage(:fs) { dir Dir.tmpdir }
|
476
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
477
|
+
pubsub 'games'
|
478
|
+
end
|
479
|
+
end
|
480
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
481
|
+
tea = Vines::JID.new('tea.wonderland.lit')
|
482
|
+
pubsub = Vines::JID.new('games.wonderland.lit')
|
483
|
+
assert config.allowed?(alice, pubsub)
|
484
|
+
assert config.allowed?(pubsub, alice)
|
485
|
+
assert config.allowed?(tea, pubsub)
|
486
|
+
assert config.allowed?(pubsub, tea)
|
487
|
+
end
|
488
|
+
|
489
|
+
def test_cross_domain_component_to_pubsub_allowed
|
490
|
+
config = Vines::Config.new do
|
491
|
+
host 'wonderland.lit', 'verona.lit' do
|
492
|
+
cross_domain_messages true
|
493
|
+
storage(:fs) { dir Dir.tmpdir }
|
494
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
495
|
+
pubsub 'games'
|
496
|
+
end
|
497
|
+
end
|
498
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
499
|
+
tea = Vines::JID.new('tea.wonderland.lit')
|
500
|
+
pubsub = Vines::JID.new('games.verona.lit')
|
501
|
+
assert config.allowed?(alice, pubsub)
|
502
|
+
assert config.allowed?(pubsub, alice)
|
503
|
+
assert config.allowed?(tea, pubsub)
|
504
|
+
assert config.allowed?(pubsub, tea)
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_cross_domain_component_to_pubsub_not_allowed
|
508
|
+
config = Vines::Config.new do
|
509
|
+
host 'wonderland.lit' do
|
510
|
+
cross_domain_messages true
|
511
|
+
storage(:fs) { dir Dir.tmpdir }
|
512
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
513
|
+
pubsub 'games'
|
514
|
+
end
|
515
|
+
host 'verona.lit' do
|
516
|
+
cross_domain_messages false
|
517
|
+
storage(:fs) { dir Dir.tmpdir }
|
518
|
+
components 'party' => 'secr3t'
|
519
|
+
end
|
520
|
+
end
|
521
|
+
romeo = Vines::JID.new('romeo@party.verona.lit')
|
522
|
+
party = Vines::JID.new('party.verona.lit')
|
523
|
+
pubsub = Vines::JID.new('games.wonderland.lit')
|
524
|
+
refute config.allowed?(romeo, pubsub)
|
525
|
+
refute config.allowed?(pubsub, romeo)
|
526
|
+
refute config.allowed?(party, pubsub)
|
527
|
+
refute config.allowed?(pubsub, party)
|
528
|
+
end
|
529
|
+
|
398
530
|
def test_same_domain_component_to_component_allowed
|
399
531
|
config = Vines::Config.new do
|
400
532
|
host 'wonderland.lit' do
|
401
533
|
cross_domain_messages false
|
402
|
-
storage(:fs) { dir
|
534
|
+
storage(:fs) { dir Dir.tmpdir }
|
403
535
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
404
536
|
end
|
405
537
|
end
|
@@ -414,7 +546,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
414
546
|
config = Vines::Config.new do
|
415
547
|
host 'wonderland.lit', 'verona.lit' do
|
416
548
|
cross_domain_messages true
|
417
|
-
storage(:fs) { dir
|
549
|
+
storage(:fs) { dir Dir.tmpdir }
|
418
550
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
419
551
|
end
|
420
552
|
end
|
@@ -428,14 +560,12 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
428
560
|
config = Vines::Config.new do
|
429
561
|
host 'wonderland.lit' do
|
430
562
|
cross_domain_messages true
|
431
|
-
storage(:fs) { dir
|
563
|
+
storage(:fs) { dir Dir.tmpdir }
|
432
564
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
433
565
|
end
|
434
|
-
end
|
435
|
-
config = Vines::Config.new do
|
436
566
|
host 'verona.lit' do
|
437
567
|
cross_domain_messages false
|
438
|
-
storage(:fs) { dir
|
568
|
+
storage(:fs) { dir Dir.tmpdir }
|
439
569
|
components 'party' => 'secr3t'
|
440
570
|
end
|
441
571
|
end
|
@@ -449,7 +579,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
449
579
|
config = Vines::Config.new do
|
450
580
|
host 'wonderland.lit' do
|
451
581
|
cross_domain_messages false
|
452
|
-
storage(:fs) { dir
|
582
|
+
storage(:fs) { dir Dir.tmpdir }
|
453
583
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
454
584
|
end
|
455
585
|
end
|
@@ -463,7 +593,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
463
593
|
config = Vines::Config.new do
|
464
594
|
host 'wonderland.lit', 'verona.lit' do
|
465
595
|
cross_domain_messages true
|
466
|
-
storage(:fs) { dir
|
596
|
+
storage(:fs) { dir Dir.tmpdir }
|
467
597
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
468
598
|
end
|
469
599
|
end
|
@@ -477,14 +607,12 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
477
607
|
config = Vines::Config.new do
|
478
608
|
host 'wonderland.lit' do
|
479
609
|
cross_domain_messages true
|
480
|
-
storage(:fs) { dir
|
610
|
+
storage(:fs) { dir Dir.tmpdir }
|
481
611
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
482
612
|
end
|
483
|
-
end
|
484
|
-
config = Vines::Config.new do
|
485
613
|
host 'verona.lit' do
|
486
614
|
cross_domain_messages false
|
487
|
-
storage(:fs) { dir
|
615
|
+
storage(:fs) { dir Dir.tmpdir }
|
488
616
|
end
|
489
617
|
end
|
490
618
|
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
@@ -497,12 +625,12 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
497
625
|
config = Vines::Config.new do
|
498
626
|
host 'wonderland.lit' do
|
499
627
|
cross_domain_messages true
|
500
|
-
storage(:fs) { dir
|
628
|
+
storage(:fs) { dir Dir.tmpdir }
|
501
629
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
502
630
|
end
|
503
631
|
host 'verona.lit' do
|
504
632
|
cross_domain_messages false
|
505
|
-
storage(:fs) { dir
|
633
|
+
storage(:fs) { dir Dir.tmpdir }
|
506
634
|
components 'tea' => 'secr3t', cake: 'passw0rd'
|
507
635
|
end
|
508
636
|
end
|
@@ -515,15 +643,69 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
515
643
|
refute config.allowed?(hamlet, romeo)
|
516
644
|
end
|
517
645
|
|
646
|
+
def test_same_domain_user_to_pubsub_allowed
|
647
|
+
config = Vines::Config.new do
|
648
|
+
host 'wonderland.lit' do
|
649
|
+
cross_domain_messages false
|
650
|
+
storage(:fs) { dir Dir.tmpdir }
|
651
|
+
pubsub 'games'
|
652
|
+
end
|
653
|
+
end
|
654
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
655
|
+
pubsub = Vines::JID.new('games.wonderland.lit')
|
656
|
+
assert config.allowed?(alice, pubsub)
|
657
|
+
assert config.allowed?(pubsub, alice)
|
658
|
+
end
|
659
|
+
|
660
|
+
def test_cross_domain_user_to_pubsub_not_allowed
|
661
|
+
config = Vines::Config.new do
|
662
|
+
host 'wonderland.lit' do
|
663
|
+
cross_domain_messages true
|
664
|
+
storage(:fs) { dir Dir.tmpdir }
|
665
|
+
pubsub 'games'
|
666
|
+
end
|
667
|
+
host 'verona.lit' do
|
668
|
+
cross_domain_messages false
|
669
|
+
storage(:fs) { dir Dir.tmpdir }
|
670
|
+
end
|
671
|
+
end
|
672
|
+
pubsub = Vines::JID.new('games.wonderland.lit')
|
673
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
674
|
+
refute config.allowed?(pubsub, romeo)
|
675
|
+
refute config.allowed?(romeo, pubsub)
|
676
|
+
end
|
677
|
+
|
678
|
+
def test_remote_user_to_pubsub_allowed
|
679
|
+
config = Vines::Config.new do
|
680
|
+
host 'wonderland.lit' do
|
681
|
+
cross_domain_messages true
|
682
|
+
storage(:fs) { dir Dir.tmpdir }
|
683
|
+
pubsub 'games'
|
684
|
+
end
|
685
|
+
host 'verona.lit' do
|
686
|
+
cross_domain_messages false
|
687
|
+
storage(:fs) { dir Dir.tmpdir }
|
688
|
+
pubsub 'games'
|
689
|
+
end
|
690
|
+
end
|
691
|
+
wonderland = Vines::JID.new('games.wonderland.lit')
|
692
|
+
verona = Vines::JID.new('games.verona.lit')
|
693
|
+
hamlet = Vines::JID.new('hamlet@denmark.lit')
|
694
|
+
assert config.allowed?(wonderland, hamlet)
|
695
|
+
assert config.allowed?(hamlet, wonderland)
|
696
|
+
refute config.allowed?(verona, hamlet)
|
697
|
+
refute config.allowed?(hamlet, verona)
|
698
|
+
end
|
699
|
+
|
518
700
|
def test_remote_user_to_local_user_allowed
|
519
701
|
config = Vines::Config.new do
|
520
702
|
host 'wonderland.lit' do
|
521
703
|
cross_domain_messages true
|
522
|
-
storage(:fs) { dir
|
704
|
+
storage(:fs) { dir Dir.tmpdir }
|
523
705
|
end
|
524
706
|
host 'verona.lit' do
|
525
707
|
cross_domain_messages false
|
526
|
-
storage(:fs) { dir
|
708
|
+
storage(:fs) { dir Dir.tmpdir }
|
527
709
|
end
|
528
710
|
end
|
529
711
|
alice = Vines::JID.new('alice@wonderland.lit')
|
@@ -539,7 +721,7 @@ class ConfigTest < MiniTest::Unit::TestCase
|
|
539
721
|
config = Vines::Config.new do
|
540
722
|
host 'wonderland.lit' do
|
541
723
|
cross_domain_messages true
|
542
|
-
storage(:fs) { dir
|
724
|
+
storage(:fs) { dir Dir.tmpdir }
|
543
725
|
end
|
544
726
|
end
|
545
727
|
romeo = Vines::JID.new('romeo@verona.lit')
|
data/test/jid_test.rb
CHANGED
@@ -14,6 +14,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
14
14
|
assert_equal '', jid.to_s
|
15
15
|
assert_equal '', jid.bare.to_s
|
16
16
|
assert jid.empty?
|
17
|
+
refute jid.domain?
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -32,6 +33,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
32
33
|
assert_nil jid.node
|
33
34
|
assert_nil jid.resource
|
34
35
|
assert_equal jid, jid.bare
|
36
|
+
assert jid.domain?
|
35
37
|
refute jid.empty?
|
36
38
|
end
|
37
39
|
|
@@ -42,6 +44,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
42
44
|
assert_equal 'alice', jid.node
|
43
45
|
assert_nil jid.resource
|
44
46
|
assert_equal jid, jid.bare
|
47
|
+
refute jid.domain?
|
45
48
|
refute jid.empty?
|
46
49
|
end
|
47
50
|
|
@@ -52,6 +55,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
52
55
|
assert_equal 'alice', jid.node
|
53
56
|
assert_nil jid.resource
|
54
57
|
assert_equal jid, jid.bare
|
58
|
+
refute jid.domain?
|
55
59
|
refute jid.empty?
|
56
60
|
end
|
57
61
|
|
@@ -62,6 +66,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
62
66
|
assert_equal 'alice', jid.node
|
63
67
|
assert_equal 'tea', jid.resource
|
64
68
|
refute_equal jid, jid.bare
|
69
|
+
refute jid.domain?
|
65
70
|
refute jid.empty?
|
66
71
|
end
|
67
72
|
|
@@ -72,6 +77,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
72
77
|
assert_equal 'alice', jid.node
|
73
78
|
assert_equal 'tea', jid.resource
|
74
79
|
refute_equal jid, jid.bare
|
80
|
+
refute jid.domain?
|
75
81
|
refute jid.empty?
|
76
82
|
end
|
77
83
|
|
@@ -87,6 +93,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
87
93
|
assert_nil jid.node
|
88
94
|
assert_equal 'wonderland.lit', jid.domain
|
89
95
|
assert_equal 'foo/bar@blarg', jid.resource
|
96
|
+
refute jid.domain?
|
90
97
|
end
|
91
98
|
|
92
99
|
def test_empty_part_raises
|