vines 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README.md +48 -0
- data/Rakefile +6 -58
- data/bin/vines +12 -2
- data/conf/certs/ca-bundle.crt +568 -39
- data/conf/config.rb +9 -42
- data/lib/vines.rb +1 -8
- data/lib/vines/command/cert.rb +4 -4
- data/lib/vines/command/init.rb +3 -3
- data/lib/vines/config.rb +9 -0
- data/lib/vines/kit.rb +2 -7
- data/lib/vines/storage/local.rb +50 -17
- data/lib/vines/store.rb +6 -4
- data/lib/vines/stream.rb +1 -1
- data/lib/vines/stream/http/session.rb +0 -0
- data/lib/vines/stream/http/sessions.rb +0 -0
- data/lib/vines/stream/parser.rb +3 -2
- data/lib/vines/token_bucket.rb +19 -10
- data/lib/vines/version.rb +1 -1
- data/test/cluster/publisher_test.rb +45 -33
- data/test/cluster/sessions_test.rb +32 -39
- data/test/cluster/subscriber_test.rb +93 -78
- data/test/config/host_test.rb +2 -4
- data/test/config/pubsub_test.rb +132 -126
- data/test/config_test.rb +2 -4
- data/test/contact_test.rb +80 -66
- data/test/error_test.rb +54 -55
- data/test/jid_test.rb +1 -2
- data/test/kit_test.rb +22 -17
- data/test/router_test.rb +187 -146
- data/test/stanza/iq/disco_info_test.rb +59 -59
- data/test/stanza/iq/disco_items_test.rb +36 -34
- data/test/stanza/iq/private_storage_test.rb +138 -143
- data/test/stanza/iq/roster_test.rb +198 -175
- data/test/stanza/iq/session_test.rb +17 -18
- data/test/stanza/iq/vcard_test.rb +117 -116
- data/test/stanza/iq/version_test.rb +47 -46
- data/test/stanza/iq_test.rb +53 -49
- data/test/stanza/message_test.rb +92 -89
- data/test/stanza/presence/probe_test.rb +2 -5
- data/test/stanza/presence/subscribe_test.rb +67 -54
- data/test/stanza/pubsub/create_test.rb +86 -108
- data/test/stanza/pubsub/delete_test.rb +141 -114
- data/test/stanza/pubsub/publish_test.rb +256 -320
- data/test/stanza/pubsub/subscribe_test.rb +169 -150
- data/test/stanza/pubsub/unsubscribe_test.rb +111 -142
- data/test/stanza_test.rb +61 -54
- data/test/storage/ldap_test.rb +1 -2
- data/test/storage/local_test.rb +3 -5
- data/test/storage/null_test.rb +3 -4
- data/test/storage/storage_tests.rb +1 -3
- data/test/storage_test.rb +1 -2
- data/test/store_test.rb +1 -2
- data/test/stream/client/auth_test.rb +61 -63
- data/test/stream/client/ready_test.rb +7 -8
- data/test/stream/client/session_test.rb +19 -18
- data/test/stream/component/handshake_test.rb +40 -37
- data/test/stream/component/ready_test.rb +76 -61
- data/test/stream/component/start_test.rb +7 -8
- data/test/stream/http/auth_test.rb +3 -4
- data/test/stream/http/ready_test.rb +52 -60
- data/test/stream/http/request_test.rb +1 -3
- data/test/stream/http/sessions_test.rb +2 -3
- data/test/stream/http/start_test.rb +3 -4
- data/test/stream/parser_test.rb +3 -4
- data/test/stream/sasl_test.rb +105 -86
- data/test/stream/server/auth_test.rb +40 -36
- data/test/stream/server/outbound/auth_test.rb +3 -4
- data/test/stream/server/ready_test.rb +51 -51
- data/test/test_helper.rb +42 -0
- data/test/token_bucket_test.rb +38 -18
- data/test/user_test.rb +79 -49
- data/vines.gemspec +33 -0
- data/web/chat/javascripts/app.js +1 -1
- data/web/lib/coffeescripts/layout.coffee +1 -1
- data/web/lib/javascripts/base.js +10 -10
- data/web/lib/javascripts/jquery.js +4 -4
- metadata +31 -128
- data/README +0 -35
- data/lib/vines/storage/couchdb.rb +0 -129
- data/lib/vines/storage/mongodb.rb +0 -132
- data/lib/vines/storage/redis.rb +0 -127
- data/lib/vines/storage/sql.rb +0 -220
- data/test/rake_test_loader.rb +0 -17
- data/test/storage/couchdb_test.rb +0 -107
- data/test/storage/mock_mongo.rb +0 -40
- data/test/storage/mongodb_test.rb +0 -81
- data/test/storage/redis_test.rb +0 -51
- data/test/storage/sql_test.rb +0 -62
@@ -1,78 +1,78 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'vines'
|
5
|
-
require 'ext/nokogiri'
|
6
|
-
require 'minitest/autorun'
|
3
|
+
require 'test_helper'
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
describe Vines::Stanza::Iq::DiscoInfo do
|
6
|
+
subject { Vines::Stanza::Iq::DiscoInfo.new(xml, stream) }
|
7
|
+
let(:stream) { MiniTest::Mock.new }
|
8
|
+
let(:alice) { Vines::User.new(jid: 'alice@wonderland.lit/home') }
|
9
|
+
let(:config) do
|
10
|
+
Vines::Config.new do
|
13
11
|
host 'wonderland.lit' do
|
14
12
|
storage(:fs) { dir Dir.tmpdir }
|
15
13
|
end
|
16
14
|
end
|
17
|
-
@stream = MiniTest::Mock.new
|
18
|
-
@stream.expect(:user, ALICE)
|
19
|
-
@stream.expect(:config, @config)
|
20
15
|
end
|
21
16
|
|
22
|
-
|
17
|
+
let(:xml) do
|
23
18
|
query = %q{<query xmlns="http://jabber.org/protocol/disco#info"/>}
|
24
|
-
node
|
25
|
-
|
26
|
-
expected = node(%Q{
|
27
|
-
<iq from="wonderland.lit" id="42" to="#{ALICE.jid}" type="result">
|
28
|
-
<query xmlns="http://jabber.org/protocol/disco#info">
|
29
|
-
<identity category="server" type="im"/>
|
30
|
-
<feature var="http://jabber.org/protocol/disco#info"/>
|
31
|
-
<feature var="http://jabber.org/protocol/disco#items"/>
|
32
|
-
<feature var="urn:xmpp:ping"/>
|
33
|
-
<feature var="vcard-temp"/>
|
34
|
-
<feature var="jabber:iq:version"/>
|
35
|
-
</query>
|
36
|
-
</iq>
|
37
|
-
}.strip.gsub(/\n|\s{2,}/, ''))
|
38
|
-
|
39
|
-
@config.vhost('wonderland.lit').private_storage false
|
40
|
-
@stream.expect(:write, nil, [expected])
|
41
|
-
|
42
|
-
stanza = Vines::Stanza::Iq::DiscoInfo.new(node, @stream)
|
43
|
-
stanza.process
|
44
|
-
assert @stream.verify
|
19
|
+
node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
45
20
|
end
|
46
21
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<identity category="server" type="im"/>
|
55
|
-
<feature var="http://jabber.org/protocol/disco#info"/>
|
56
|
-
<feature var="http://jabber.org/protocol/disco#items"/>
|
57
|
-
<feature var="urn:xmpp:ping"/>
|
58
|
-
<feature var="vcard-temp"/>
|
59
|
-
<feature var="jabber:iq:version"/>
|
60
|
-
<feature var="jabber:iq:private"/>
|
61
|
-
</query>
|
62
|
-
</iq>
|
63
|
-
}.strip.gsub(/\n|\s{2,}/, ''))
|
22
|
+
before do
|
23
|
+
class << stream
|
24
|
+
attr_accessor :config, :user
|
25
|
+
end
|
26
|
+
stream.config = config
|
27
|
+
stream.user = alice
|
28
|
+
end
|
64
29
|
|
65
|
-
|
66
|
-
|
30
|
+
describe 'when private storage is disabled' do
|
31
|
+
let(:expected) do
|
32
|
+
node(%Q{
|
33
|
+
<iq from="wonderland.lit" id="42" to="#{alice.jid}" type="result">
|
34
|
+
<query xmlns="http://jabber.org/protocol/disco#info">
|
35
|
+
<identity category="server" type="im"/>
|
36
|
+
<feature var="http://jabber.org/protocol/disco#info"/>
|
37
|
+
<feature var="http://jabber.org/protocol/disco#items"/>
|
38
|
+
<feature var="urn:xmpp:ping"/>
|
39
|
+
<feature var="vcard-temp"/>
|
40
|
+
<feature var="jabber:iq:version"/>
|
41
|
+
</query>
|
42
|
+
</iq>
|
43
|
+
})
|
44
|
+
end
|
67
45
|
|
68
|
-
stanza
|
69
|
-
|
70
|
-
|
46
|
+
it 'returns info stanza without the private storage feature' do
|
47
|
+
config.vhost('wonderland.lit').private_storage false
|
48
|
+
stream.expect :write, nil, [expected]
|
49
|
+
subject.process
|
50
|
+
stream.verify
|
51
|
+
end
|
71
52
|
end
|
72
53
|
|
73
|
-
private
|
54
|
+
describe 'when private storage is enabled' do
|
55
|
+
let(:expected) do
|
56
|
+
node(%Q{
|
57
|
+
<iq from="wonderland.lit" id="42" to="#{alice.jid}" type="result">
|
58
|
+
<query xmlns="http://jabber.org/protocol/disco#info">
|
59
|
+
<identity category="server" type="im"/>
|
60
|
+
<feature var="http://jabber.org/protocol/disco#info"/>
|
61
|
+
<feature var="http://jabber.org/protocol/disco#items"/>
|
62
|
+
<feature var="urn:xmpp:ping"/>
|
63
|
+
<feature var="vcard-temp"/>
|
64
|
+
<feature var="jabber:iq:version"/>
|
65
|
+
<feature var="jabber:iq:private"/>
|
66
|
+
</query>
|
67
|
+
</iq>
|
68
|
+
})
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
71
|
+
it 'announces private storage feature in info stanza result' do
|
72
|
+
config.vhost('wonderland.lit').private_storage true
|
73
|
+
stream.expect :write, nil, [expected]
|
74
|
+
subject.process
|
75
|
+
stream.verify
|
76
|
+
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,47 +1,49 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_component_items
|
14
|
-
query = %q{<query xmlns="http://jabber.org/protocol/disco#items"/>}
|
15
|
-
node = node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
16
|
-
|
17
|
-
expected = node(%q{
|
18
|
-
<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/home" type="result">
|
19
|
-
<query xmlns="http://jabber.org/protocol/disco#items">
|
20
|
-
<item jid="cake.wonderland.lit"/>
|
21
|
-
<item jid="tea.wonderland.lit"/>
|
22
|
-
</query>
|
23
|
-
</iq>
|
24
|
-
}.strip.gsub(/\n|\s{2,}/, ''))
|
25
|
-
|
26
|
-
config = Vines::Config.new do
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
describe Vines::Stanza::Iq::DiscoItems do
|
6
|
+
subject { Vines::Stanza::Iq::DiscoItems.new(xml, stream) }
|
7
|
+
let(:stream) { MiniTest::Mock.new }
|
8
|
+
let(:alice) { Vines::User.new(jid: 'alice@wonderland.lit/home') }
|
9
|
+
let(:config) do
|
10
|
+
Vines::Config.new do
|
27
11
|
host 'wonderland.lit' do
|
28
12
|
storage(:fs) { dir Dir.tmpdir }
|
29
13
|
components 'tea' => 'secr3t', 'cake' => 'passw0rd'
|
30
14
|
end
|
31
15
|
end
|
16
|
+
end
|
32
17
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert @stream.verify
|
18
|
+
before do
|
19
|
+
class << stream
|
20
|
+
attr_accessor :config, :user
|
21
|
+
end
|
22
|
+
stream.config = config
|
23
|
+
stream.user = alice
|
40
24
|
end
|
41
25
|
|
42
|
-
|
26
|
+
describe 'when querying server items' do
|
27
|
+
let(:xml) do
|
28
|
+
query = %q{<query xmlns="http://jabber.org/protocol/disco#items"/>}
|
29
|
+
node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:result) do
|
33
|
+
node(%q{
|
34
|
+
<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/home" type="result">
|
35
|
+
<query xmlns="http://jabber.org/protocol/disco#items">
|
36
|
+
<item jid="cake.wonderland.lit"/>
|
37
|
+
<item jid="tea.wonderland.lit"/>
|
38
|
+
</query>
|
39
|
+
</iq>
|
40
|
+
})
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
it 'includes component domains in output' do
|
44
|
+
stream.expect :write, nil, [result]
|
45
|
+
subject.process
|
46
|
+
stream.verify
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
describe Vines::Stanza::Iq::PrivateStorage do
|
6
|
+
subject { Vines::Stanza::Iq::PrivateStorage.new(xml, stream) }
|
7
|
+
let(:alice) { Vines::User.new(jid: 'alice@wonderland.lit/tea') }
|
8
|
+
let(:storage) { MiniTest::Mock.new }
|
9
|
+
let(:stream) { MiniTest::Mock.new }
|
10
|
+
let(:config) do
|
11
|
+
Vines::Config.new do
|
12
12
|
host 'wonderland.lit' do
|
13
13
|
storage(:fs) { dir Dir.tmpdir }
|
14
14
|
private_storage true
|
@@ -16,174 +16,169 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
28
|
-
assert_raises(Vines::StanzaErrors::ServiceUnavailable) { stanza.process }
|
29
|
-
assert @stream.verify
|
19
|
+
before do
|
20
|
+
class << stream
|
21
|
+
attr_accessor :config, :domain, :user
|
22
|
+
end
|
23
|
+
stream.config = config
|
24
|
+
stream.user = alice
|
25
|
+
stream.domain = 'wonderland.lit'
|
30
26
|
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
describe 'when private storage feature is disabled' do
|
29
|
+
let(:xml) do
|
30
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
31
|
+
node(%Q{<iq id="42" type="get">#{query}</iq>})
|
32
|
+
end
|
36
33
|
|
37
|
-
|
34
|
+
before do
|
35
|
+
config.vhost('wonderland.lit').private_storage false
|
36
|
+
end
|
38
37
|
|
39
|
-
stanza
|
40
|
-
|
41
|
-
|
38
|
+
it 'raises a service-unavailable stanza error' do
|
39
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::ServiceUnavailable
|
40
|
+
stream.verify
|
41
|
+
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@stream.expect(:domain, 'wonderland.lit')
|
50
|
-
@stream.expect(:config, @config)
|
44
|
+
describe 'when retrieving a fragment for another user jid' do
|
45
|
+
let(:xml) do
|
46
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
47
|
+
node(%Q{<iq id="42" to="hatter@wonderland.lit" type="get">#{query}</iq>})
|
48
|
+
end
|
51
49
|
|
52
|
-
stanza
|
53
|
-
|
54
|
-
|
50
|
+
it 'raises a forbidden stanza error' do
|
51
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::Forbidden
|
52
|
+
stream.verify
|
53
|
+
end
|
55
54
|
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@stream.expect(:domain, 'wonderland.lit')
|
63
|
-
@stream.expect(:config, @config)
|
56
|
+
describe 'when get stanza contains zero child elements' do
|
57
|
+
let(:xml) do
|
58
|
+
query = %q{<query xmlns="jabber:iq:private"></query>}
|
59
|
+
node(%Q{<iq id="42" type="get">#{query}</iq>})
|
60
|
+
end
|
64
61
|
|
65
|
-
stanza
|
66
|
-
|
67
|
-
|
62
|
+
it 'raises a not-acceptable stanza error' do
|
63
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::NotAcceptable
|
64
|
+
stream.verify
|
65
|
+
end
|
68
66
|
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@stream.expect(:domain, 'wonderland.lit')
|
76
|
-
@stream.expect(:config, @config)
|
68
|
+
describe 'when get stanza contains more than one child element' do
|
69
|
+
let(:xml) do
|
70
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/><two xmlns="b"/></query>}
|
71
|
+
node(%Q{<iq id="42" type="get">#{query}</iq>})
|
72
|
+
end
|
77
73
|
|
78
|
-
stanza
|
79
|
-
|
80
|
-
|
74
|
+
it 'raises a not-acceptable stanza error' do
|
75
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::NotAcceptable
|
76
|
+
stream.verify
|
77
|
+
end
|
81
78
|
end
|
82
79
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
@stream.expect(:domain, 'wonderland.lit')
|
89
|
-
@stream.expect(:config, @config)
|
80
|
+
describe 'when get stanza is missing a namespace' do
|
81
|
+
let(:xml) do
|
82
|
+
query = %q{<query xmlns="jabber:iq:private"><one/></query>}
|
83
|
+
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
84
|
+
end
|
90
85
|
|
91
|
-
stanza
|
92
|
-
|
93
|
-
|
86
|
+
it 'raises a not-acceptable stanza error' do
|
87
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::NotAcceptable
|
88
|
+
stream.verify
|
89
|
+
end
|
94
90
|
end
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
storage = MiniTest::Mock.new
|
102
|
-
storage.expect(:find_fragment, nil, [alice.jid, node.elements[0].elements[0]])
|
92
|
+
describe 'when get stanza is missing fragment' do
|
93
|
+
let(:xml) do
|
94
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
95
|
+
node(%Q{<iq id="42" type="get">#{query}</iq>})
|
96
|
+
end
|
103
97
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
98
|
+
before do
|
99
|
+
storage.expect :find_fragment, nil, [alice.jid, xml.elements[0].elements[0]]
|
100
|
+
stream.expect :storage, storage, ['wonderland.lit']
|
101
|
+
end
|
108
102
|
|
109
|
-
stanza
|
110
|
-
|
111
|
-
|
112
|
-
|
103
|
+
it 'raises an item-not-found stanza error' do
|
104
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::ItemNotFound
|
105
|
+
stream.verify
|
106
|
+
storage.verify
|
107
|
+
end
|
113
108
|
end
|
114
109
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
data = %q{<one xmlns="a"><child>data</child></one>}
|
121
|
-
query = %Q{<query xmlns="jabber:iq:private">#{data}</query>}
|
122
|
-
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result">#{query}</iq>})
|
110
|
+
describe 'when get finds fragment successfully' do
|
111
|
+
let(:xml) do
|
112
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
113
|
+
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
114
|
+
end
|
123
115
|
|
124
|
-
|
125
|
-
|
116
|
+
before do
|
117
|
+
data = %q{<one xmlns="a"><child>data</child></one>}
|
118
|
+
query = %Q{<query xmlns="jabber:iq:private">#{data}</query>}
|
119
|
+
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result">#{query}</iq>})
|
126
120
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
@stream.expect(:write, nil, [expected])
|
121
|
+
storage.expect :find_fragment, node(data), [alice.jid, xml.elements[0].elements[0]]
|
122
|
+
stream.expect :storage, storage, ['wonderland.lit']
|
123
|
+
stream.expect :write, nil, [expected]
|
124
|
+
end
|
132
125
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
126
|
+
it 'writes a response to the stream' do
|
127
|
+
subject.process
|
128
|
+
stream.verify
|
129
|
+
storage.verify
|
130
|
+
end
|
137
131
|
end
|
138
132
|
|
139
|
-
|
140
|
-
|
141
|
-
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
142
|
-
node = node(%Q{<iq id="42" type="set">#{query}</iq>})
|
143
|
-
|
144
|
-
storage = MiniTest::Mock.new
|
145
|
-
storage.expect(:save_fragment, nil, [alice.jid, node.elements[0].elements[0]])
|
133
|
+
describe 'when saving a fragment' do
|
134
|
+
let(:result) { node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result"/>}) }
|
146
135
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@stream.expect(:user, alice)
|
153
|
-
@stream.expect(:write, nil, [expected])
|
154
|
-
|
155
|
-
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
156
|
-
stanza.process
|
157
|
-
assert @stream.verify
|
158
|
-
assert storage.verify
|
159
|
-
end
|
136
|
+
before do
|
137
|
+
storage.expect :save_fragment, nil, [alice.jid, xml.elements[0].elements[0]]
|
138
|
+
stream.expect :storage, storage, ['wonderland.lit']
|
139
|
+
stream.expect :write, nil, [result]
|
140
|
+
end
|
160
141
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
142
|
+
describe 'and stanza contains zero child elements' do
|
143
|
+
let(:xml) do
|
144
|
+
query = %q{<query xmlns="jabber:iq:private"></query>}
|
145
|
+
node(%Q{<iq id="42" type="set">#{query}</iq>})
|
146
|
+
end
|
165
147
|
|
166
|
-
|
167
|
-
|
168
|
-
|
148
|
+
it 'raises a not-acceptable stanza error' do
|
149
|
+
-> { subject.process }.must_raise Vines::StanzaErrors::NotAcceptable
|
150
|
+
end
|
151
|
+
end
|
169
152
|
|
170
|
-
|
153
|
+
describe 'and a single single fragment saves successfully' do
|
154
|
+
let(:xml) do
|
155
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
156
|
+
node(%Q{<iq id="42" type="set">#{query}</iq>})
|
157
|
+
end
|
171
158
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
159
|
+
it 'writes a result to the stream' do
|
160
|
+
subject.process
|
161
|
+
stream.verify
|
162
|
+
storage.verify
|
163
|
+
end
|
164
|
+
end
|
177
165
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
166
|
+
describe 'and two fragments save successfully' do
|
167
|
+
let(:xml) do
|
168
|
+
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/><two xmlns="a"/></query>}
|
169
|
+
node(%Q{<iq id="42" type="set">#{query}</iq>})
|
170
|
+
end
|
183
171
|
|
184
|
-
|
172
|
+
before do
|
173
|
+
storage.expect :save_fragment, nil, [alice.jid, xml.elements[0].elements[1]]
|
174
|
+
stream.expect :storage, storage, ['wonderland.lit']
|
175
|
+
end
|
185
176
|
|
186
|
-
|
187
|
-
|
177
|
+
it 'writes a result to the stream' do
|
178
|
+
subject.process
|
179
|
+
stream.verify
|
180
|
+
storage.verify
|
181
|
+
end
|
182
|
+
end
|
188
183
|
end
|
189
184
|
end
|