diaspora-vines 0.1.2
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 +7 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +7 -0
- data/Rakefile +23 -0
- data/bin/vines +4 -0
- data/conf/certs/README +39 -0
- data/conf/certs/ca-bundle.crt +3895 -0
- data/conf/config.rb +42 -0
- data/lib/vines/cli.rb +132 -0
- 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/bcrypt.rb +12 -0
- data/lib/vines/command/cert.rb +50 -0
- data/lib/vines/command/init.rb +68 -0
- data/lib/vines/command/ldap.rb +38 -0
- data/lib/vines/command/restart.rb +12 -0
- data/lib/vines/command/schema.rb +24 -0
- data/lib/vines/command/start.rb +28 -0
- data/lib/vines/command/stop.rb +18 -0
- data/lib/vines/config/host.rb +125 -0
- data/lib/vines/config/port.rb +132 -0
- data/lib/vines/config/pubsub.rb +108 -0
- data/lib/vines/config.rb +223 -0
- data/lib/vines/contact.rb +111 -0
- data/lib/vines/daemon.rb +78 -0
- data/lib/vines/error.rb +150 -0
- data/lib/vines/jid.rb +95 -0
- data/lib/vines/kit.rb +23 -0
- data/lib/vines/log.rb +24 -0
- data/lib/vines/router.rb +179 -0
- data/lib/vines/stanza/iq/auth.rb +18 -0
- data/lib/vines/stanza/iq/disco_info.rb +45 -0
- data/lib/vines/stanza/iq/disco_items.rb +29 -0
- data/lib/vines/stanza/iq/error.rb +16 -0
- data/lib/vines/stanza/iq/ping.rb +16 -0
- data/lib/vines/stanza/iq/private_storage.rb +83 -0
- data/lib/vines/stanza/iq/query.rb +10 -0
- data/lib/vines/stanza/iq/result.rb +16 -0
- data/lib/vines/stanza/iq/roster.rb +140 -0
- data/lib/vines/stanza/iq/session.rb +17 -0
- data/lib/vines/stanza/iq/vcard.rb +56 -0
- data/lib/vines/stanza/iq/version.rb +25 -0
- data/lib/vines/stanza/iq.rb +48 -0
- data/lib/vines/stanza/message.rb +40 -0
- data/lib/vines/stanza/presence/error.rb +23 -0
- data/lib/vines/stanza/presence/probe.rb +37 -0
- data/lib/vines/stanza/presence/subscribe.rb +42 -0
- data/lib/vines/stanza/presence/subscribed.rb +51 -0
- data/lib/vines/stanza/presence/unavailable.rb +15 -0
- data/lib/vines/stanza/presence/unsubscribe.rb +38 -0
- data/lib/vines/stanza/presence/unsubscribed.rb +38 -0
- data/lib/vines/stanza/presence.rb +141 -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 +175 -0
- data/lib/vines/storage/ldap.rb +71 -0
- data/lib/vines/storage/local.rb +139 -0
- data/lib/vines/storage/null.rb +39 -0
- data/lib/vines/storage/sql.rb +138 -0
- data/lib/vines/storage.rb +239 -0
- data/lib/vines/store.rb +110 -0
- data/lib/vines/stream/client/auth.rb +74 -0
- data/lib/vines/stream/client/auth_restart.rb +29 -0
- data/lib/vines/stream/client/bind.rb +72 -0
- data/lib/vines/stream/client/bind_restart.rb +24 -0
- data/lib/vines/stream/client/closed.rb +13 -0
- data/lib/vines/stream/client/ready.rb +17 -0
- data/lib/vines/stream/client/session.rb +210 -0
- data/lib/vines/stream/client/start.rb +27 -0
- data/lib/vines/stream/client/tls.rb +38 -0
- data/lib/vines/stream/client.rb +84 -0
- data/lib/vines/stream/component/handshake.rb +26 -0
- data/lib/vines/stream/component/ready.rb +23 -0
- data/lib/vines/stream/component/start.rb +19 -0
- data/lib/vines/stream/component.rb +58 -0
- data/lib/vines/stream/http/auth.rb +22 -0
- data/lib/vines/stream/http/bind.rb +32 -0
- data/lib/vines/stream/http/bind_restart.rb +37 -0
- data/lib/vines/stream/http/ready.rb +29 -0
- data/lib/vines/stream/http/request.rb +172 -0
- data/lib/vines/stream/http/session.rb +120 -0
- data/lib/vines/stream/http/sessions.rb +65 -0
- data/lib/vines/stream/http/start.rb +23 -0
- data/lib/vines/stream/http.rb +157 -0
- data/lib/vines/stream/parser.rb +79 -0
- data/lib/vines/stream/sasl.rb +128 -0
- data/lib/vines/stream/server/auth.rb +13 -0
- data/lib/vines/stream/server/auth_restart.rb +13 -0
- data/lib/vines/stream/server/final_restart.rb +21 -0
- data/lib/vines/stream/server/outbound/auth.rb +31 -0
- data/lib/vines/stream/server/outbound/auth_restart.rb +20 -0
- data/lib/vines/stream/server/outbound/auth_result.rb +32 -0
- data/lib/vines/stream/server/outbound/final_features.rb +28 -0
- data/lib/vines/stream/server/outbound/final_restart.rb +20 -0
- data/lib/vines/stream/server/outbound/start.rb +20 -0
- data/lib/vines/stream/server/outbound/tls.rb +30 -0
- data/lib/vines/stream/server/outbound/tls_result.rb +34 -0
- data/lib/vines/stream/server/ready.rb +24 -0
- data/lib/vines/stream/server/start.rb +13 -0
- data/lib/vines/stream/server/tls.rb +13 -0
- data/lib/vines/stream/server.rb +150 -0
- data/lib/vines/stream/state.rb +60 -0
- data/lib/vines/stream.rb +247 -0
- data/lib/vines/token_bucket.rb +55 -0
- data/lib/vines/user.rb +123 -0
- data/lib/vines/version.rb +6 -0
- data/lib/vines/xmpp_server.rb +25 -0
- data/lib/vines.rb +203 -0
- data/test/cluster/publisher_test.rb +57 -0
- data/test/cluster/sessions_test.rb +47 -0
- data/test/cluster/subscriber_test.rb +109 -0
- data/test/config/host_test.rb +369 -0
- data/test/config/pubsub_test.rb +187 -0
- data/test/config_test.rb +732 -0
- data/test/contact_test.rb +102 -0
- data/test/error_test.rb +58 -0
- data/test/ext/nokogiri.rb +14 -0
- data/test/jid_test.rb +147 -0
- data/test/kit_test.rb +31 -0
- data/test/router_test.rb +243 -0
- data/test/stanza/iq/disco_info_test.rb +78 -0
- data/test/stanza/iq/disco_items_test.rb +49 -0
- data/test/stanza/iq/private_storage_test.rb +184 -0
- data/test/stanza/iq/roster_test.rb +229 -0
- data/test/stanza/iq/session_test.rb +25 -0
- data/test/stanza/iq/vcard_test.rb +146 -0
- data/test/stanza/iq/version_test.rb +64 -0
- data/test/stanza/iq_test.rb +70 -0
- data/test/stanza/message_test.rb +126 -0
- data/test/stanza/presence/probe_test.rb +50 -0
- data/test/stanza/presence/subscribe_test.rb +83 -0
- data/test/stanza/pubsub/create_test.rb +116 -0
- data/test/stanza/pubsub/delete_test.rb +169 -0
- data/test/stanza/pubsub/publish_test.rb +309 -0
- data/test/stanza/pubsub/subscribe_test.rb +205 -0
- data/test/stanza/pubsub/unsubscribe_test.rb +148 -0
- data/test/stanza_test.rb +85 -0
- data/test/storage/ldap_test.rb +201 -0
- data/test/storage/local_test.rb +59 -0
- data/test/storage/mock_redis.rb +97 -0
- data/test/storage/null_test.rb +29 -0
- data/test/storage/storage_tests.rb +182 -0
- data/test/storage_test.rb +85 -0
- data/test/store_test.rb +130 -0
- data/test/stream/client/auth_test.rb +137 -0
- data/test/stream/client/ready_test.rb +47 -0
- data/test/stream/client/session_test.rb +27 -0
- data/test/stream/component/handshake_test.rb +52 -0
- data/test/stream/component/ready_test.rb +103 -0
- data/test/stream/component/start_test.rb +39 -0
- data/test/stream/http/auth_test.rb +70 -0
- data/test/stream/http/ready_test.rb +86 -0
- data/test/stream/http/request_test.rb +209 -0
- data/test/stream/http/sessions_test.rb +49 -0
- data/test/stream/http/start_test.rb +50 -0
- data/test/stream/parser_test.rb +122 -0
- data/test/stream/sasl_test.rb +195 -0
- data/test/stream/server/auth_test.rb +61 -0
- data/test/stream/server/outbound/auth_test.rb +75 -0
- data/test/stream/server/ready_test.rb +98 -0
- data/test/test_helper.rb +42 -0
- data/test/token_bucket_test.rb +44 -0
- data/test/user_test.rb +96 -0
- data/vines.gemspec +30 -0
- metadata +387 -0
data/test/config_test.rb
ADDED
@@ -0,0 +1,732 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
describe Vines::Config do
|
6
|
+
def test_missing_host
|
7
|
+
assert_raises(RuntimeError) do
|
8
|
+
Vines::Config.new do
|
9
|
+
# missing hosts
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_duplicate_host
|
15
|
+
assert_raises(RuntimeError) do
|
16
|
+
Vines::Config.new do
|
17
|
+
host 'wonderland.lit' do
|
18
|
+
storage 'fs' do
|
19
|
+
dir Dir.tmpdir
|
20
|
+
end
|
21
|
+
end
|
22
|
+
host 'WONDERLAND.LIT' do
|
23
|
+
storage 'fs' do
|
24
|
+
dir Dir.tmpdir
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_duplicate_host_in_one_call
|
32
|
+
assert_raises(RuntimeError) do
|
33
|
+
Vines::Config.new do
|
34
|
+
host 'wonderland.lit', 'wonderland.lit' do
|
35
|
+
storage 'fs' do
|
36
|
+
dir Dir.tmpdir
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_configure
|
44
|
+
config = Vines::Config.configure do
|
45
|
+
host 'wonderland.lit' do
|
46
|
+
storage :fs do
|
47
|
+
dir Dir.tmpdir
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
refute_nil config
|
52
|
+
assert_same config, Vines::Config.instance
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_vhost
|
56
|
+
config = Vines::Config.new do
|
57
|
+
host 'wonderland.lit' do
|
58
|
+
storage(:fs) { dir Dir.tmpdir }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
refute_nil config.vhost('wonderland.lit')
|
62
|
+
refute_nil config.vhost(Vines::JID.new('wonderland.lit'))
|
63
|
+
assert config.vhost?('wonderland.lit')
|
64
|
+
assert config.vhost?(Vines::JID.new('wonderland.lit'))
|
65
|
+
refute config.vhost?('alice@wonderland.lit')
|
66
|
+
refute config.vhost?('tea.wonderland.lit')
|
67
|
+
refute config.vhost?('bogus')
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_port_lookup
|
71
|
+
config = Vines::Config.new do
|
72
|
+
host 'wonderland.lit' do
|
73
|
+
storage(:fs) { dir Dir.tmpdir }
|
74
|
+
end
|
75
|
+
client
|
76
|
+
end
|
77
|
+
refute_nil config[:client]
|
78
|
+
assert_raises(ArgumentError) { config[:server] }
|
79
|
+
assert_raises(ArgumentError) { config[:bogus] }
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_duplicate_client
|
83
|
+
assert_raises(RuntimeError) do
|
84
|
+
Vines::Config.new do
|
85
|
+
host 'wonderland.lit' do
|
86
|
+
storage(:fs) { dir Dir.tmpdir }
|
87
|
+
end
|
88
|
+
client
|
89
|
+
client
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_duplicate_server
|
95
|
+
assert_raises(RuntimeError) do
|
96
|
+
Vines::Config.new do
|
97
|
+
host 'wonderland.lit' do
|
98
|
+
storage(:fs) { dir Dir.tmpdir }
|
99
|
+
end
|
100
|
+
server
|
101
|
+
server
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_duplicate_http
|
107
|
+
assert_raises(RuntimeError) do
|
108
|
+
Vines::Config.new do
|
109
|
+
host 'wonderland.lit' do
|
110
|
+
storage(:fs) { dir Dir.tmpdir }
|
111
|
+
end
|
112
|
+
http
|
113
|
+
http
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_duplicate_component
|
119
|
+
assert_raises(RuntimeError) do
|
120
|
+
Vines::Config.new do
|
121
|
+
host 'wonderland.lit' do
|
122
|
+
storage(:fs) { dir Dir.tmpdir }
|
123
|
+
end
|
124
|
+
component
|
125
|
+
component
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
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
|
+
|
172
|
+
def test_default_client
|
173
|
+
config = Vines::Config.new do
|
174
|
+
host 'wonderland.lit' do
|
175
|
+
storage(:fs) { dir Dir.tmpdir }
|
176
|
+
end
|
177
|
+
client
|
178
|
+
end
|
179
|
+
port = config.ports.first
|
180
|
+
refute_nil port
|
181
|
+
assert_equal Vines::Config::ClientPort, port.class
|
182
|
+
assert_equal '0.0.0.0', port.host
|
183
|
+
assert_equal 5222, port.port
|
184
|
+
assert_equal 131_072, port.max_stanza_size
|
185
|
+
assert_equal 5, port.max_resources_per_account
|
186
|
+
assert_equal Vines::Stream::Client, port.stream
|
187
|
+
assert_same config, port.config
|
188
|
+
assert_equal 1, config.ports.size
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_configured_client
|
192
|
+
config = Vines::Config.new do
|
193
|
+
host 'wonderland.lit' do
|
194
|
+
storage(:fs) { dir Dir.tmpdir }
|
195
|
+
end
|
196
|
+
client '0.0.0.1', 42 do
|
197
|
+
max_stanza_size 60_000
|
198
|
+
max_resources_per_account 1
|
199
|
+
end
|
200
|
+
end
|
201
|
+
port = config.ports.first
|
202
|
+
refute_nil port
|
203
|
+
assert_equal Vines::Config::ClientPort, port.class
|
204
|
+
assert_equal '0.0.0.1', port.host
|
205
|
+
assert_equal 42, port.port
|
206
|
+
assert_equal 60_000, port.max_stanza_size
|
207
|
+
assert_equal 1, port.max_resources_per_account
|
208
|
+
assert_equal Vines::Stream::Client, port.stream
|
209
|
+
assert_same config, port.config
|
210
|
+
assert_equal 1, config.ports.size
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_max_stanza_size
|
214
|
+
config = Vines::Config.new do
|
215
|
+
host 'wonderland.lit' do
|
216
|
+
storage(:fs) { dir Dir.tmpdir }
|
217
|
+
end
|
218
|
+
client do
|
219
|
+
max_stanza_size 0
|
220
|
+
end
|
221
|
+
end
|
222
|
+
assert_equal 10_000, config.ports.first.max_stanza_size
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_default_server
|
226
|
+
config = Vines::Config.new do
|
227
|
+
host 'wonderland.lit' do
|
228
|
+
storage(:fs) { dir Dir.tmpdir }
|
229
|
+
end
|
230
|
+
server
|
231
|
+
end
|
232
|
+
port = config.ports.first
|
233
|
+
refute_nil port
|
234
|
+
assert !config.s2s?('verona.lit')
|
235
|
+
assert_equal Vines::Config::ServerPort, port.class
|
236
|
+
assert_equal '0.0.0.0', port.host
|
237
|
+
assert_equal 5269, port.port
|
238
|
+
assert_equal 131_072, port.max_stanza_size
|
239
|
+
assert_equal Vines::Stream::Server, port.stream
|
240
|
+
assert_same config, port.config
|
241
|
+
assert_equal 1, config.ports.size
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_configured_server
|
245
|
+
config = Vines::Config.new do
|
246
|
+
host 'wonderland.lit' do
|
247
|
+
storage(:fs) { dir Dir.tmpdir }
|
248
|
+
end
|
249
|
+
server '0.0.0.1', 42 do
|
250
|
+
max_stanza_size 60_000
|
251
|
+
hosts ['verona.lit', 'denmark.lit']
|
252
|
+
end
|
253
|
+
end
|
254
|
+
port = config.ports.first
|
255
|
+
refute_nil port
|
256
|
+
assert config.s2s?('verona.lit')
|
257
|
+
assert config.s2s?('denmark.lit')
|
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)
|
262
|
+
assert_equal Vines::Config::ServerPort, port.class
|
263
|
+
assert_equal '0.0.0.1', port.host
|
264
|
+
assert_equal 42, port.port
|
265
|
+
assert_equal 60_000, port.max_stanza_size
|
266
|
+
assert_equal Vines::Stream::Server, port.stream
|
267
|
+
assert_same config, port.config
|
268
|
+
assert_equal 1, config.ports.size
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_default_http
|
272
|
+
config = Vines::Config.new do
|
273
|
+
host 'wonderland.lit' do
|
274
|
+
storage(:fs) { dir Dir.tmpdir }
|
275
|
+
end
|
276
|
+
http
|
277
|
+
end
|
278
|
+
port = config.ports.first
|
279
|
+
refute_nil port
|
280
|
+
assert_equal Vines::Config::HttpPort, port.class
|
281
|
+
assert_equal '0.0.0.0', port.host
|
282
|
+
assert_equal 5280, port.port
|
283
|
+
assert_equal 131_072, port.max_stanza_size
|
284
|
+
assert_equal 5, port.max_resources_per_account
|
285
|
+
assert_equal File.join(Dir.pwd, 'web'), port.root
|
286
|
+
assert_equal '/xmpp', port.bind
|
287
|
+
assert_equal Vines::Stream::Http, port.stream
|
288
|
+
assert_same config, port.config
|
289
|
+
assert_equal 1, config.ports.size
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_configured_http
|
293
|
+
config = Vines::Config.new do
|
294
|
+
host 'wonderland.lit' do
|
295
|
+
storage(:fs) { dir Dir.tmpdir }
|
296
|
+
end
|
297
|
+
http '0.0.0.1', 42 do
|
298
|
+
bind '/custom'
|
299
|
+
max_stanza_size 60_000
|
300
|
+
max_resources_per_account 1
|
301
|
+
root '/var/www/html'
|
302
|
+
end
|
303
|
+
end
|
304
|
+
port = config.ports.first
|
305
|
+
refute_nil port
|
306
|
+
assert_equal Vines::Config::HttpPort, port.class
|
307
|
+
assert_equal '0.0.0.1', port.host
|
308
|
+
assert_equal 42, port.port
|
309
|
+
assert_equal 60_000, port.max_stanza_size
|
310
|
+
assert_equal 1, port.max_resources_per_account
|
311
|
+
assert_equal '/var/www/html', port.root
|
312
|
+
assert_equal '/custom', port.bind
|
313
|
+
assert_equal Vines::Stream::Http, port.stream
|
314
|
+
assert_same config, port.config
|
315
|
+
assert_equal 1, config.ports.size
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_default_component
|
319
|
+
config = Vines::Config.new do
|
320
|
+
host 'wonderland.lit' do
|
321
|
+
storage(:fs) { dir Dir.tmpdir }
|
322
|
+
end
|
323
|
+
component
|
324
|
+
end
|
325
|
+
port = config.ports.first
|
326
|
+
refute_nil port
|
327
|
+
assert_equal Vines::Config::ComponentPort, port.class
|
328
|
+
assert_equal '0.0.0.0', port.host
|
329
|
+
assert_equal 5347, port.port
|
330
|
+
assert_equal 131_072, port.max_stanza_size
|
331
|
+
assert_equal Vines::Stream::Component, port.stream
|
332
|
+
assert_same config, port.config
|
333
|
+
assert_equal 1, config.ports.size
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_configured_component
|
337
|
+
config = Vines::Config.new do
|
338
|
+
host 'wonderland.lit' do
|
339
|
+
storage(:fs) { dir Dir.tmpdir }
|
340
|
+
end
|
341
|
+
component '0.0.0.1', 42 do
|
342
|
+
max_stanza_size 60_000
|
343
|
+
end
|
344
|
+
end
|
345
|
+
port = config.ports.first
|
346
|
+
refute_nil port
|
347
|
+
assert_equal Vines::Config::ComponentPort, port.class
|
348
|
+
assert_equal '0.0.0.1', port.host
|
349
|
+
assert_equal 42, port.port
|
350
|
+
assert_equal 60_000, port.max_stanza_size
|
351
|
+
assert_equal Vines::Stream::Component, port.stream
|
352
|
+
assert_same config, port.config
|
353
|
+
assert_equal 1, config.ports.size
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_invalid_log_level
|
357
|
+
assert_raises(RuntimeError) do
|
358
|
+
config = Vines::Config.new do
|
359
|
+
log 'bogus'
|
360
|
+
host 'wonderland.lit' do
|
361
|
+
storage(:fs) { dir Dir.tmpdir }
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_valid_log_level
|
368
|
+
config = Vines::Config.new do
|
369
|
+
log :error
|
370
|
+
host 'wonderland.lit' do
|
371
|
+
storage(:fs) { dir Dir.tmpdir }
|
372
|
+
end
|
373
|
+
end
|
374
|
+
assert_equal Logger::ERROR, Class.new.extend(Vines::Log).log.level
|
375
|
+
end
|
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
|
+
|
387
|
+
def test_cross_domain_messages
|
388
|
+
config = Vines::Config.new do
|
389
|
+
host 'wonderland.lit' do
|
390
|
+
storage(:fs) { dir Dir.tmpdir }
|
391
|
+
end
|
392
|
+
host 'verona.lit' do
|
393
|
+
cross_domain_messages true
|
394
|
+
storage(:fs) { dir Dir.tmpdir }
|
395
|
+
end
|
396
|
+
end
|
397
|
+
refute config.vhost('wonderland.lit').cross_domain_messages?
|
398
|
+
assert config.vhost('verona.lit').cross_domain_messages?
|
399
|
+
end
|
400
|
+
|
401
|
+
def test_local_jid?
|
402
|
+
config = Vines::Config.new do
|
403
|
+
host 'wonderland.lit', 'verona.lit' do
|
404
|
+
storage(:fs) { dir Dir.tmpdir }
|
405
|
+
end
|
406
|
+
end
|
407
|
+
refute config.local_jid?(nil)
|
408
|
+
refute config.local_jid?('alice@wonderland.lit', nil)
|
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'))
|
412
|
+
assert config.local_jid?('alice@wonderland.lit', 'romeo@verona.lit')
|
413
|
+
refute config.local_jid?('alice@wonderland.lit', 'romeo@bogus.lit')
|
414
|
+
refute config.local_jid?('alice@tea.wonderland.lit')
|
415
|
+
refute config.local_jid?('alice@bogus.lit')
|
416
|
+
end
|
417
|
+
|
418
|
+
def test_missing_addresses_not_allowed
|
419
|
+
config = Vines::Config.new do
|
420
|
+
host 'wonderland.lit', 'verona.lit' do
|
421
|
+
storage(:fs) { dir Dir.tmpdir }
|
422
|
+
end
|
423
|
+
end
|
424
|
+
refute config.allowed?(nil, nil)
|
425
|
+
refute config.allowed?('', '')
|
426
|
+
end
|
427
|
+
|
428
|
+
def test_same_domain_allowed
|
429
|
+
config = Vines::Config.new do
|
430
|
+
host 'wonderland.lit', 'verona.lit' do
|
431
|
+
storage(:fs) { dir Dir.tmpdir }
|
432
|
+
end
|
433
|
+
end
|
434
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
435
|
+
hatter = Vines::JID.new('hatter@wonderland.lit')
|
436
|
+
assert config.allowed?(alice, hatter)
|
437
|
+
assert config.allowed?(hatter, alice)
|
438
|
+
assert config.allowed?('wonderland.lit', alice)
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_both_vhosts_with_cross_domain_allowed
|
442
|
+
config = Vines::Config.new do
|
443
|
+
host 'wonderland.lit', 'verona.lit' do
|
444
|
+
cross_domain_messages true
|
445
|
+
storage(:fs) { dir Dir.tmpdir }
|
446
|
+
end
|
447
|
+
end
|
448
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
449
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
450
|
+
assert config.allowed?(alice, romeo)
|
451
|
+
assert config.allowed?(romeo, alice)
|
452
|
+
end
|
453
|
+
|
454
|
+
def test_one_vhost_with_cross_domain_not_allowed
|
455
|
+
config = Vines::Config.new do
|
456
|
+
host 'wonderland.lit' do
|
457
|
+
cross_domain_messages true
|
458
|
+
storage(:fs) { dir Dir.tmpdir }
|
459
|
+
end
|
460
|
+
host 'verona.lit' do
|
461
|
+
cross_domain_messages false
|
462
|
+
storage(:fs) { dir Dir.tmpdir }
|
463
|
+
end
|
464
|
+
end
|
465
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
466
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
467
|
+
refute config.allowed?(alice, romeo)
|
468
|
+
refute config.allowed?(romeo, alice)
|
469
|
+
end
|
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
|
+
|
530
|
+
def test_same_domain_component_to_component_allowed
|
531
|
+
config = Vines::Config.new do
|
532
|
+
host 'wonderland.lit' do
|
533
|
+
cross_domain_messages false
|
534
|
+
storage(:fs) { dir Dir.tmpdir }
|
535
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
536
|
+
end
|
537
|
+
end
|
538
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
539
|
+
hatter = Vines::JID.new('hatter@cake.wonderland.lit')
|
540
|
+
assert config.allowed?(alice, alice)
|
541
|
+
assert config.allowed?(alice, hatter)
|
542
|
+
assert config.allowed?(hatter, alice)
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_cross_domain_component_to_component_allowed
|
546
|
+
config = Vines::Config.new do
|
547
|
+
host 'wonderland.lit', 'verona.lit' do
|
548
|
+
cross_domain_messages true
|
549
|
+
storage(:fs) { dir Dir.tmpdir }
|
550
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
551
|
+
end
|
552
|
+
end
|
553
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
554
|
+
romeo = Vines::JID.new('romeo@cake.verona.lit')
|
555
|
+
assert config.allowed?(alice, romeo)
|
556
|
+
assert config.allowed?(romeo, alice)
|
557
|
+
end
|
558
|
+
|
559
|
+
def test_cross_domain_component_to_component_not_allowed
|
560
|
+
config = Vines::Config.new do
|
561
|
+
host 'wonderland.lit' do
|
562
|
+
cross_domain_messages true
|
563
|
+
storage(:fs) { dir Dir.tmpdir }
|
564
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
565
|
+
end
|
566
|
+
host 'verona.lit' do
|
567
|
+
cross_domain_messages false
|
568
|
+
storage(:fs) { dir Dir.tmpdir }
|
569
|
+
components 'party' => 'secr3t'
|
570
|
+
end
|
571
|
+
end
|
572
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
573
|
+
romeo = Vines::JID.new('romeo@party.verona.lit')
|
574
|
+
refute config.allowed?(alice, romeo)
|
575
|
+
refute config.allowed?(romeo, alice)
|
576
|
+
end
|
577
|
+
|
578
|
+
def test_same_domain_user_to_component_allowed
|
579
|
+
config = Vines::Config.new do
|
580
|
+
host 'wonderland.lit' do
|
581
|
+
cross_domain_messages false
|
582
|
+
storage(:fs) { dir Dir.tmpdir }
|
583
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
584
|
+
end
|
585
|
+
end
|
586
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
587
|
+
comp = Vines::JID.new('hatter@cake.wonderland.lit')
|
588
|
+
assert config.allowed?(alice, comp)
|
589
|
+
assert config.allowed?(comp, alice)
|
590
|
+
end
|
591
|
+
|
592
|
+
def test_cross_domain_user_to_component_allowed
|
593
|
+
config = Vines::Config.new do
|
594
|
+
host 'wonderland.lit', 'verona.lit' do
|
595
|
+
cross_domain_messages true
|
596
|
+
storage(:fs) { dir Dir.tmpdir }
|
597
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
598
|
+
end
|
599
|
+
end
|
600
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
601
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
602
|
+
assert config.allowed?(alice, romeo)
|
603
|
+
assert config.allowed?(romeo, alice)
|
604
|
+
end
|
605
|
+
|
606
|
+
def test_cross_domain_user_to_component_not_allowed
|
607
|
+
config = Vines::Config.new do
|
608
|
+
host 'wonderland.lit' do
|
609
|
+
cross_domain_messages true
|
610
|
+
storage(:fs) { dir Dir.tmpdir }
|
611
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
612
|
+
end
|
613
|
+
host 'verona.lit' do
|
614
|
+
cross_domain_messages false
|
615
|
+
storage(:fs) { dir Dir.tmpdir }
|
616
|
+
end
|
617
|
+
end
|
618
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
619
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
620
|
+
refute config.allowed?(alice, romeo)
|
621
|
+
refute config.allowed?(romeo, alice)
|
622
|
+
end
|
623
|
+
|
624
|
+
def test_remote_user_to_component_allowed
|
625
|
+
config = Vines::Config.new do
|
626
|
+
host 'wonderland.lit' do
|
627
|
+
cross_domain_messages true
|
628
|
+
storage(:fs) { dir Dir.tmpdir }
|
629
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
630
|
+
end
|
631
|
+
host 'verona.lit' do
|
632
|
+
cross_domain_messages false
|
633
|
+
storage(:fs) { dir Dir.tmpdir }
|
634
|
+
components 'tea' => 'secr3t', cake: 'passw0rd'
|
635
|
+
end
|
636
|
+
end
|
637
|
+
alice = Vines::JID.new('alice@tea.wonderland.lit')
|
638
|
+
romeo = Vines::JID.new('romeo@tea.verona.lit')
|
639
|
+
hamlet = Vines::JID.new('hamlet@denmark.lit')
|
640
|
+
assert config.allowed?(alice, hamlet)
|
641
|
+
assert config.allowed?(hamlet, alice)
|
642
|
+
refute config.allowed?(romeo, hamlet)
|
643
|
+
refute config.allowed?(hamlet, romeo)
|
644
|
+
end
|
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
|
+
|
700
|
+
def test_remote_user_to_local_user_allowed
|
701
|
+
config = Vines::Config.new do
|
702
|
+
host 'wonderland.lit' do
|
703
|
+
cross_domain_messages true
|
704
|
+
storage(:fs) { dir Dir.tmpdir }
|
705
|
+
end
|
706
|
+
host 'verona.lit' do
|
707
|
+
cross_domain_messages false
|
708
|
+
storage(:fs) { dir Dir.tmpdir }
|
709
|
+
end
|
710
|
+
end
|
711
|
+
alice = Vines::JID.new('alice@wonderland.lit')
|
712
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
713
|
+
hamlet = Vines::JID.new('hamlet@denmark.lit')
|
714
|
+
assert config.allowed?(alice, hamlet)
|
715
|
+
assert config.allowed?(hamlet, alice)
|
716
|
+
refute config.allowed?(romeo, hamlet)
|
717
|
+
refute config.allowed?(hamlet, romeo)
|
718
|
+
end
|
719
|
+
|
720
|
+
def test_remote_user_to_remote_user_not_allowed
|
721
|
+
config = Vines::Config.new do
|
722
|
+
host 'wonderland.lit' do
|
723
|
+
cross_domain_messages true
|
724
|
+
storage(:fs) { dir Dir.tmpdir }
|
725
|
+
end
|
726
|
+
end
|
727
|
+
romeo = Vines::JID.new('romeo@verona.lit')
|
728
|
+
hamlet = Vines::JID.new('hamlet@denmark.lit')
|
729
|
+
refute config.allowed?(romeo, hamlet)
|
730
|
+
refute config.allowed?(hamlet, romeo)
|
731
|
+
end
|
732
|
+
end
|