vines 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/router_test.rb
CHANGED
@@ -1,30 +1,202 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'minitest/autorun'
|
5
6
|
|
6
7
|
class RouterTest < MiniTest::Unit::TestCase
|
7
8
|
def setup
|
8
9
|
@alice = Vines::JID.new('alice@wonderland.lit/tea')
|
9
|
-
@stream = MiniTest::Mock.new
|
10
|
-
@router = Vines::Router.new
|
11
10
|
@config = Vines::Config.new do
|
12
11
|
host 'wonderland.lit' do
|
13
|
-
storage(:fs) { dir
|
12
|
+
storage(:fs) { dir Dir.tmpdir }
|
13
|
+
components 'tea' => 'secr3t'
|
14
14
|
end
|
15
15
|
end
|
16
|
+
@router = Vines::Router.new(@config)
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_connected_resources
|
20
|
+
cake = 'alice@wonderland.lit/cake'
|
19
21
|
assert_equal 0, @router.connected_resources(@alice, @alice).size
|
22
|
+
assert_equal 0, @router.connected_resources(cake, @alice).size
|
23
|
+
assert_equal 0, @router.size
|
20
24
|
|
21
|
-
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@stream.expect(:user, Vines::User.new(jid: @alice))
|
25
|
-
@router << @stream
|
25
|
+
stream1, stream2 = stream(@alice), stream(cake)
|
26
|
+
@router << stream1
|
27
|
+
@router << stream2
|
26
28
|
|
27
29
|
assert_equal 1, @router.connected_resources(@alice, @alice).size
|
28
|
-
|
30
|
+
assert_equal @alice, @router.connected_resources(@alice, @alice)[0].user.jid
|
31
|
+
|
32
|
+
assert_equal 1, @router.connected_resources(cake, @alice).size
|
33
|
+
assert_equal cake, @router.connected_resources(cake, @alice)[0].user.jid.to_s
|
34
|
+
|
35
|
+
assert_equal 2, @router.connected_resources(@alice.bare, @alice).size
|
36
|
+
assert_equal 2, @router.size
|
37
|
+
assert stream1.verify
|
38
|
+
assert stream2.verify
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_connected_resources_checks_allowed
|
42
|
+
romeo = 'romeo@verona.lit/party'
|
43
|
+
stream1, stream2 = stream(@alice), stream(romeo)
|
44
|
+
@router << stream1
|
45
|
+
@router << stream2
|
46
|
+
|
47
|
+
assert_equal 2, @router.size
|
48
|
+
assert_equal 0, @router.connected_resources(@alice, romeo).size
|
49
|
+
@config.vhosts['wonderland.lit'].cross_domain_messages true
|
50
|
+
assert_equal 1, @router.connected_resources(@alice, romeo).size
|
51
|
+
|
52
|
+
assert stream1.verify
|
53
|
+
assert stream2.verify
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_available_resources
|
57
|
+
cake = 'alice@wonderland.lit/cake'
|
58
|
+
assert_equal 0, @router.available_resources(@alice, @alice).size
|
59
|
+
assert_equal 0, @router.available_resources(cake, @alice).size
|
60
|
+
assert_equal 0, @router.size
|
61
|
+
|
62
|
+
stream1, stream2 = stream(@alice), stream(cake)
|
63
|
+
stream1.expect(:available?, true)
|
64
|
+
stream2.expect(:available?, false)
|
65
|
+
@router << stream1
|
66
|
+
@router << stream2
|
67
|
+
|
68
|
+
assert_equal 1, @router.available_resources(@alice, @alice).size
|
69
|
+
assert_equal @alice, @router.available_resources(@alice, @alice)[0].user.jid
|
70
|
+
|
71
|
+
assert_equal 1, @router.available_resources(cake, @alice).size
|
72
|
+
assert_equal @alice, @router.available_resources(cake, @alice)[0].user.jid
|
73
|
+
|
74
|
+
assert_equal 1, @router.available_resources(@alice.bare, @alice).size
|
75
|
+
assert_equal @alice, @router.available_resources(@alice.bare, @alice)[0].user.jid
|
76
|
+
|
77
|
+
assert_equal 2, @router.size
|
78
|
+
assert stream1.verify
|
79
|
+
assert stream2.verify
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_interested_resources
|
83
|
+
hatter = 'hatter@wonderland.lit/cake'
|
84
|
+
assert_equal 0, @router.interested_resources(@alice, @alice).size
|
85
|
+
assert_equal 0, @router.interested_resources(hatter, @alice).size
|
86
|
+
assert_equal 0, @router.interested_resources(@alice, hatter, @alice).size
|
87
|
+
assert_equal 0, @router.size
|
88
|
+
|
89
|
+
stream1, stream2 = stream(@alice), stream(hatter)
|
90
|
+
stream1.expect(:interested?, true)
|
91
|
+
stream2.expect(:interested?, false)
|
92
|
+
@router << stream1
|
93
|
+
@router << stream2
|
94
|
+
|
95
|
+
assert_equal 0, @router.interested_resources('bogus@wonderland.lit', @alice).size
|
96
|
+
|
97
|
+
assert_equal 1, @router.interested_resources(@alice, hatter, @alice).size
|
98
|
+
assert_equal 1, @router.interested_resources([@alice, hatter], @alice).size
|
99
|
+
assert_equal @alice, @router.interested_resources(@alice, hatter, @alice)[0].user.jid
|
100
|
+
|
101
|
+
assert_equal 0, @router.interested_resources(hatter, @alice).size
|
102
|
+
assert_equal 0, @router.interested_resources([hatter], @alice).size
|
103
|
+
|
104
|
+
assert_equal 1, @router.interested_resources(@alice.bare, @alice).size
|
105
|
+
assert_equal @alice, @router.interested_resources(@alice.bare, @alice)[0].user.jid
|
106
|
+
|
107
|
+
assert_equal 2, @router.size
|
108
|
+
assert stream1.verify
|
109
|
+
assert stream2.verify
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_delete
|
113
|
+
hatter = 'hatter@wonderland.lit/cake'
|
114
|
+
assert_equal 0, @router.size
|
115
|
+
|
116
|
+
stream1, stream2 = stream(@alice), stream(hatter)
|
117
|
+
@router << stream1
|
118
|
+
@router << stream2
|
119
|
+
|
120
|
+
assert_equal 2, @router.size
|
121
|
+
|
122
|
+
@router.delete(stream2)
|
123
|
+
assert_equal 1, @router.size
|
124
|
+
|
125
|
+
@router.delete(stream2)
|
126
|
+
assert_equal 1, @router.size
|
127
|
+
|
128
|
+
@router.delete(stream1)
|
129
|
+
assert_equal 0, @router.size
|
130
|
+
|
131
|
+
assert stream1.verify
|
132
|
+
assert stream2.verify
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_multiple_component_streams_are_load_balanced
|
136
|
+
stream1 = component('tea.wonderland.lit')
|
137
|
+
stream2 = component('tea.wonderland.lit')
|
138
|
+
@router << stream1
|
139
|
+
@router << stream2
|
140
|
+
stanza = Nokogiri::XML('<message from="alice@wonderland.lit" to="tea.wonderland.lit">test</message>').root
|
141
|
+
100.times { @router.route(stanza) }
|
142
|
+
|
143
|
+
assert_equal 100, stream1.count + stream2.count
|
144
|
+
assert stream1.count > 33
|
145
|
+
assert stream2.count > 33
|
146
|
+
assert stream1.verify
|
147
|
+
assert stream2.verify
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_multiple_s2s_streams_are_load_balanced
|
151
|
+
@config.vhosts['wonderland.lit'].cross_domain_messages true
|
152
|
+
stream1 = s2s('wonderland.lit', 'verona.lit')
|
153
|
+
stream2 = s2s('wonderland.lit', 'verona.lit')
|
154
|
+
@router << stream1
|
155
|
+
@router << stream2
|
156
|
+
stanza = Nokogiri::XML('<message from="alice@wonderland.lit" to="romeo@verona.lit">test</message>').root
|
157
|
+
100.times { @router.route(stanza) }
|
158
|
+
|
159
|
+
assert_equal 100, stream1.count + stream2.count
|
160
|
+
assert stream1.count > 33
|
161
|
+
assert stream2.count > 33
|
162
|
+
assert stream1.verify
|
163
|
+
assert stream2.verify
|
164
|
+
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def stream(jid)
|
169
|
+
MiniTest::Mock.new.tap do |stream|
|
170
|
+
stream.expect(:connected?, true)
|
171
|
+
stream.expect(:stream_type, :client)
|
172
|
+
stream.expect(:user, Vines::User.new(jid: jid))
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def component(jid)
|
177
|
+
stream = MiniTest::Mock.new
|
178
|
+
stream.expect(:stream_type, :component)
|
179
|
+
stream.expect(:remote_domain, jid)
|
180
|
+
stream.expect(:ready?, true)
|
181
|
+
def stream.count; @count || 0; end
|
182
|
+
def stream.write(stanza)
|
183
|
+
@count ||= 0
|
184
|
+
@count += 1
|
185
|
+
end
|
186
|
+
stream
|
187
|
+
end
|
188
|
+
|
189
|
+
def s2s(domain, remote_domain)
|
190
|
+
stream = MiniTest::Mock.new
|
191
|
+
stream.expect(:stream_type, :server)
|
192
|
+
stream.expect(:domain, domain)
|
193
|
+
stream.expect(:remote_domain, remote_domain)
|
194
|
+
stream.expect(:ready?, true)
|
195
|
+
def stream.count; @count || 0; end
|
196
|
+
def stream.write(stanza)
|
197
|
+
@count ||= 0
|
198
|
+
@count += 1
|
199
|
+
end
|
200
|
+
stream
|
29
201
|
end
|
30
202
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -8,10 +9,13 @@ class DiscoInfoTest < MiniTest::Unit::TestCase
|
|
8
9
|
ALICE = Vines::User.new(:jid => 'alice@wonderland.lit/home')
|
9
10
|
|
10
11
|
def setup
|
11
|
-
@config =
|
12
|
+
@config = Vines::Config.new do
|
13
|
+
host 'wonderland.lit' do
|
14
|
+
storage(:fs) { dir Dir.tmpdir }
|
15
|
+
end
|
16
|
+
end
|
12
17
|
@stream = MiniTest::Mock.new
|
13
18
|
@stream.expect(:user, ALICE)
|
14
|
-
@stream.expect(:domain, 'wonderland.lit')
|
15
19
|
@stream.expect(:config, @config)
|
16
20
|
end
|
17
21
|
|
@@ -32,13 +36,12 @@ class DiscoInfoTest < MiniTest::Unit::TestCase
|
|
32
36
|
</iq>
|
33
37
|
}.strip.gsub(/\n|\s{2,}/, ''))
|
34
38
|
|
35
|
-
@config.
|
39
|
+
@config.vhosts['wonderland.lit'].private_storage false
|
36
40
|
@stream.expect(:write, nil, [expected])
|
37
41
|
|
38
42
|
stanza = Vines::Stanza::Iq::DiscoInfo.new(node, @stream)
|
39
43
|
stanza.process
|
40
44
|
assert @stream.verify
|
41
|
-
assert @config.verify
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_private_storage_enabled
|
@@ -59,13 +62,12 @@ class DiscoInfoTest < MiniTest::Unit::TestCase
|
|
59
62
|
</iq>
|
60
63
|
}.strip.gsub(/\n|\s{2,}/, ''))
|
61
64
|
|
62
|
-
@config.
|
65
|
+
@config.vhosts['wonderland.lit'].private_storage true
|
63
66
|
@stream.expect(:write, nil, [expected])
|
64
67
|
|
65
68
|
stanza = Vines::Stanza::Iq::DiscoInfo.new(node, @stream)
|
66
69
|
stanza.process
|
67
70
|
assert @stream.verify
|
68
|
-
assert @config.verify
|
69
71
|
end
|
70
72
|
|
71
73
|
private
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -24,15 +25,14 @@ class DiscoItemsTest < MiniTest::Unit::TestCase
|
|
24
25
|
|
25
26
|
config = Vines::Config.new do
|
26
27
|
host 'wonderland.lit' do
|
27
|
-
storage(:fs) { dir
|
28
|
+
storage(:fs) { dir Dir.tmpdir }
|
28
29
|
components 'tea' => 'secr3t', 'cake' => 'passw0rd'
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
@stream.expect(:config, config)
|
33
33
|
@stream.expect(:user, Vines::User.new(:jid => 'alice@wonderland.lit/home'))
|
34
|
-
@stream.expect(:domain, 'wonderland.lit')
|
35
34
|
@stream.expect(:write, nil, [expected])
|
35
|
+
@stream.expect(:config, config)
|
36
36
|
|
37
37
|
stanza = Vines::Stanza::Iq::DiscoItems.new(node, @stream)
|
38
38
|
stanza.process
|
@@ -1,27 +1,32 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
6
7
|
|
7
8
|
class PrivateStorageTest < MiniTest::Unit::TestCase
|
8
9
|
def setup
|
9
|
-
@config = MiniTest::Mock.new
|
10
10
|
@stream = MiniTest::Mock.new
|
11
|
+
@config = Vines::Config.new do
|
12
|
+
host 'wonderland.lit' do
|
13
|
+
storage(:fs) { dir Dir.tmpdir }
|
14
|
+
private_storage true
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def test_feature_disabled_raises_error
|
14
20
|
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
15
21
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
16
22
|
|
17
|
-
@config.
|
23
|
+
@config.vhosts['wonderland.lit'].private_storage false
|
18
24
|
@stream.expect(:domain, 'wonderland.lit')
|
19
25
|
@stream.expect(:config, @config)
|
20
26
|
|
21
27
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
22
28
|
assert_raises(Vines::StanzaErrors::ServiceUnavailable) { stanza.process }
|
23
29
|
assert @stream.verify
|
24
|
-
assert @config.verify
|
25
30
|
end
|
26
31
|
|
27
32
|
def test_get_another_user_fragment_raises_error
|
@@ -41,14 +46,12 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
41
46
|
query = %q{<query xmlns="jabber:iq:private"></query>}
|
42
47
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
43
48
|
|
44
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
45
49
|
@stream.expect(:domain, 'wonderland.lit')
|
46
50
|
@stream.expect(:config, @config)
|
47
51
|
|
48
52
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
49
53
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
50
54
|
assert @stream.verify
|
51
|
-
assert @config.verify
|
52
55
|
end
|
53
56
|
|
54
57
|
def test_get_with_two_children_raises_error
|
@@ -56,14 +59,12 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
56
59
|
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/><two xmlns="b"/></query>}
|
57
60
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
58
61
|
|
59
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
60
62
|
@stream.expect(:domain, 'wonderland.lit')
|
61
63
|
@stream.expect(:config, @config)
|
62
64
|
|
63
65
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
64
66
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
65
67
|
assert @stream.verify
|
66
|
-
assert @config.verify
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_set_with_zero_children_raises_error
|
@@ -71,14 +72,12 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
71
72
|
query = %q{<query xmlns="jabber:iq:private"></query>}
|
72
73
|
node = node(%Q{<iq id="42" type="set">#{query}</iq>})
|
73
74
|
|
74
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
75
75
|
@stream.expect(:domain, 'wonderland.lit')
|
76
76
|
@stream.expect(:config, @config)
|
77
77
|
|
78
78
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
79
79
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
80
80
|
assert @stream.verify
|
81
|
-
assert @config.verify
|
82
81
|
end
|
83
82
|
|
84
83
|
def test_get_without_namespace_raises_error
|
@@ -86,14 +85,12 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
86
85
|
query = %q{<query xmlns="jabber:iq:private"><one/></query>}
|
87
86
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
88
87
|
|
89
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
90
88
|
@stream.expect(:domain, 'wonderland.lit')
|
91
89
|
@stream.expect(:config, @config)
|
92
90
|
|
93
91
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
94
92
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
95
93
|
assert @stream.verify
|
96
|
-
assert @config.verify
|
97
94
|
end
|
98
95
|
|
99
96
|
def test_get_missing_fragment_raises_error
|
@@ -104,7 +101,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
104
101
|
storage = MiniTest::Mock.new
|
105
102
|
storage.expect(:find_fragment, nil, [alice.jid, node.elements[0].elements[0]])
|
106
103
|
|
107
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
108
104
|
@stream.expect(:domain, 'wonderland.lit')
|
109
105
|
@stream.expect(:config, @config)
|
110
106
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -113,7 +109,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
113
109
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
114
110
|
assert_raises(Vines::StanzaErrors::ItemNotFound) { stanza.process }
|
115
111
|
assert @stream.verify
|
116
|
-
assert @config.verify
|
117
112
|
assert storage.verify
|
118
113
|
end
|
119
114
|
|
@@ -129,7 +124,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
129
124
|
storage = MiniTest::Mock.new
|
130
125
|
storage.expect(:find_fragment, node(data), [alice.jid, node.elements[0].elements[0]])
|
131
126
|
|
132
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
133
127
|
@stream.expect(:domain, 'wonderland.lit')
|
134
128
|
@stream.expect(:config, @config)
|
135
129
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -139,7 +133,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
139
133
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
140
134
|
stanza.process
|
141
135
|
assert @stream.verify
|
142
|
-
assert @config.verify
|
143
136
|
assert storage.verify
|
144
137
|
end
|
145
138
|
|
@@ -153,7 +146,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
153
146
|
|
154
147
|
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result"/>})
|
155
148
|
|
156
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
157
149
|
@stream.expect(:domain, 'wonderland.lit')
|
158
150
|
@stream.expect(:config, @config)
|
159
151
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -163,7 +155,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
163
155
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
164
156
|
stanza.process
|
165
157
|
assert @stream.verify
|
166
|
-
assert @config.verify
|
167
158
|
assert storage.verify
|
168
159
|
end
|
169
160
|
|
@@ -178,7 +169,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
178
169
|
|
179
170
|
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result"/>})
|
180
171
|
|
181
|
-
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
182
172
|
@stream.expect(:domain, 'wonderland.lit')
|
183
173
|
@stream.expect(:config, @config)
|
184
174
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -188,7 +178,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
188
178
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
189
179
|
stanza.process
|
190
180
|
assert @stream.verify
|
191
|
-
assert @config.verify
|
192
181
|
assert storage.verify
|
193
182
|
end
|
194
183
|
|
@@ -169,7 +169,7 @@ class RosterTest < MiniTest::Unit::TestCase
|
|
169
169
|
@stream.expect(:update_user_streams, nil, [alice])
|
170
170
|
@stream.expect(:domain, 'wonderland.lit')
|
171
171
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
172
|
-
expected = node(%
|
172
|
+
expected = node(%Q{<iq id="42" to="#{alice.jid}" type="result"/>})
|
173
173
|
@stream.expect(:write, nil, [expected])
|
174
174
|
|
175
175
|
node = node(%q{
|
@@ -8,14 +8,11 @@ class SessionTest < MiniTest::Unit::TestCase
|
|
8
8
|
def test_session
|
9
9
|
stream = MiniTest::Mock.new
|
10
10
|
stream.expect(:domain, 'wonderland.lit')
|
11
|
-
|
11
|
+
stream.expect(:user, Vines::User.new(jid: 'alice@wonderland.lit/tea'))
|
12
|
+
expected = node(%q{<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/tea" type="result"/>})
|
12
13
|
stream.expect(:write, nil, [expected])
|
13
14
|
|
14
|
-
node = node(
|
15
|
-
%q{<iq id="42" to="wonderland.lit" type="set">
|
16
|
-
<session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
|
17
|
-
</iq>})
|
18
|
-
|
15
|
+
node = node(%q{<iq id="42" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>})
|
19
16
|
stanza = Vines::Stanza::Iq::Session.new(node, stream)
|
20
17
|
stanza.process
|
21
18
|
assert stream.verify
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -9,7 +10,8 @@ class VcardTest < MiniTest::Unit::TestCase
|
|
9
10
|
@stream = MiniTest::Mock.new
|
10
11
|
@config = Vines::Config.new do
|
11
12
|
host 'wonderland.lit' do
|
12
|
-
|
13
|
+
cross_domain_messages true
|
14
|
+
storage(:fs) { dir Dir.tmpdir }
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -40,6 +42,7 @@ class VcardTest < MiniTest::Unit::TestCase
|
|
40
42
|
storage = MiniTest::Mock.new
|
41
43
|
storage.expect(:find_vcard, card, [alice.jid.bare])
|
42
44
|
|
45
|
+
@stream.expect(:config, @config)
|
43
46
|
@stream.expect(:user, alice)
|
44
47
|
@stream.expect(:domain, 'wonderland.lit')
|
45
48
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -68,7 +71,6 @@ class VcardTest < MiniTest::Unit::TestCase
|
|
68
71
|
|
69
72
|
@stream.expect(:config, @config)
|
70
73
|
@stream.expect(:user, alice)
|
71
|
-
@stream.expect(:domain, 'wonderland.lit')
|
72
74
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
73
75
|
expected = node(%q{
|
74
76
|
<iq from="hatter@wonderland.lit" id="42" to="alice@wonderland.lit/tea" type="result">
|
@@ -91,6 +93,7 @@ class VcardTest < MiniTest::Unit::TestCase
|
|
91
93
|
storage = MiniTest::Mock.new
|
92
94
|
storage.expect(:find_vcard, nil, [alice.jid.bare])
|
93
95
|
|
96
|
+
@stream.expect(:config, @config)
|
94
97
|
@stream.expect(:user, alice)
|
95
98
|
@stream.expect(:domain, 'wonderland.lit')
|
96
99
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -121,6 +124,7 @@ class VcardTest < MiniTest::Unit::TestCase
|
|
121
124
|
storage = MiniTest::Mock.new
|
122
125
|
storage.expect(:save_vcard, nil, [alice.jid, card])
|
123
126
|
|
127
|
+
@stream.expect(:config, @config)
|
124
128
|
@stream.expect(:user, alice)
|
125
129
|
@stream.expect(:domain, 'wonderland.lit')
|
126
130
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -9,7 +10,7 @@ class VersionTest < MiniTest::Unit::TestCase
|
|
9
10
|
@stream = MiniTest::Mock.new
|
10
11
|
@config = Vines::Config.new do
|
11
12
|
host 'wonderland.lit' do
|
12
|
-
storage(:fs) { dir
|
13
|
+
storage(:fs) { dir Dir.tmpdir }
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -21,7 +22,6 @@ class VersionTest < MiniTest::Unit::TestCase
|
|
21
22
|
router = MiniTest::Mock.new
|
22
23
|
router.expect(:route, nil, [node])
|
23
24
|
|
24
|
-
@stream.expect(:domain, 'wonderland.lit')
|
25
25
|
@stream.expect(:config, @config)
|
26
26
|
@stream.expect(:user, alice)
|
27
27
|
@stream.expect(:router, router)
|
@@ -36,6 +36,7 @@ class VersionTest < MiniTest::Unit::TestCase
|
|
36
36
|
alice = Vines::User.new(:jid => 'alice@wonderland.lit/tea')
|
37
37
|
node = node(%q{<iq id="42" type="get"><query xmlns="jabber:iq:version"/></iq>})
|
38
38
|
|
39
|
+
@stream.expect(:config, @config)
|
39
40
|
@stream.expect(:user, alice)
|
40
41
|
@stream.expect(:domain, 'wonderland.lit')
|
41
42
|
|
data/test/stanza/iq_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -7,10 +8,9 @@ require 'minitest/autorun'
|
|
7
8
|
class IqTest < MiniTest::Unit::TestCase
|
8
9
|
def setup
|
9
10
|
@stream = MiniTest::Mock.new
|
10
|
-
@
|
11
|
-
@config = Vines::Config.new do
|
11
|
+
@config = Vines::Config.new do
|
12
12
|
host 'wonderland.lit' do
|
13
|
-
storage(:fs) { dir
|
13
|
+
storage(:fs) { dir Dir.tmpdir }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -39,12 +39,12 @@ class IqTest < MiniTest::Unit::TestCase
|
|
39
39
|
}.strip.gsub(/\n|\s{2,}/, ''))
|
40
40
|
|
41
41
|
recipient = MiniTest::Mock.new
|
42
|
+
recipient.expect(:user, alice, [])
|
42
43
|
recipient.expect(:write, nil, [node])
|
43
44
|
|
44
45
|
@stream.expect(:config, @config)
|
45
46
|
@stream.expect(:user, hatter)
|
46
|
-
@stream.expect(:
|
47
|
-
@stream.expect(:available_resources, [recipient], [alice.jid.to_s])
|
47
|
+
@stream.expect(:connected_resources, [recipient], [alice.jid.to_s])
|
48
48
|
|
49
49
|
stanza = Vines::Stanza::Iq.new(node, @stream)
|
50
50
|
stanza.process
|
data/test/stanza/message_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -9,7 +10,7 @@ class MessageTest < MiniTest::Unit::TestCase
|
|
9
10
|
@stream = MiniTest::Mock.new
|
10
11
|
@config = Vines::Config.new do
|
11
12
|
host 'wonderland.lit' do
|
12
|
-
storage(:fs) { dir
|
13
|
+
storage(:fs) { dir Dir.tmpdir }
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -82,7 +83,7 @@ class MessageTest < MiniTest::Unit::TestCase
|
|
82
83
|
recipient.expect(:write, nil, [expected])
|
83
84
|
|
84
85
|
@config.host 'verona.lit' do
|
85
|
-
storage(:fs) { dir
|
86
|
+
storage(:fs) { dir Dir.tmpdir }
|
86
87
|
end
|
87
88
|
|
88
89
|
@stream.expect(:config, @config)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'vines'
|
4
5
|
require 'ext/nokogiri'
|
5
6
|
require 'minitest/autorun'
|
@@ -10,7 +11,7 @@ class ProbeTest < MiniTest::Unit::TestCase
|
|
10
11
|
@stream = MiniTest::Mock.new
|
11
12
|
@config = Vines::Config.new do
|
12
13
|
host 'wonderland.lit' do
|
13
|
-
storage(:fs) { dir
|
14
|
+
storage(:fs) { dir Dir.tmpdir }
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|