vines 0.2.1 → 0.3.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 +1 -1
- data/Rakefile +10 -10
- data/conf/certs/ca-bundle.crt +112 -378
- data/conf/config.rb +18 -9
- data/lib/vines.rb +8 -1
- data/lib/vines/command/cert.rb +2 -1
- data/lib/vines/command/init.rb +11 -0
- data/lib/vines/command/ldap.rb +6 -3
- data/lib/vines/command/schema.rb +1 -1
- data/lib/vines/config.rb +57 -146
- data/lib/vines/config/host.rb +85 -0
- data/lib/vines/config/port.rb +111 -0
- data/lib/vines/contact.rb +1 -1
- data/lib/vines/jid.rb +26 -4
- data/lib/vines/kit.rb +6 -0
- data/lib/vines/log.rb +24 -0
- data/lib/vines/router.rb +70 -38
- data/lib/vines/stanza.rb +45 -8
- data/lib/vines/stanza/iq.rb +3 -3
- data/lib/vines/stanza/iq/disco_info.rb +5 -1
- data/lib/vines/stanza/iq/disco_items.rb +3 -0
- data/lib/vines/stanza/iq/private_storage.rb +9 -5
- data/lib/vines/stanza/iq/roster.rb +11 -12
- data/lib/vines/stanza/iq/vcard.rb +4 -4
- data/lib/vines/stanza/iq/version.rb +25 -0
- data/lib/vines/stanza/message.rb +4 -5
- data/lib/vines/stanza/presence.rb +20 -18
- data/lib/vines/stanza/presence/probe.rb +3 -4
- data/lib/vines/stanza/presence/subscribe.rb +4 -3
- data/lib/vines/stanza/presence/subscribed.rb +6 -5
- data/lib/vines/stanza/presence/unsubscribe.rb +4 -4
- data/lib/vines/stanza/presence/unsubscribed.rb +4 -3
- data/lib/vines/storage/couchdb.rb +3 -3
- data/lib/vines/storage/ldap.rb +19 -8
- data/lib/vines/storage/local.rb +23 -12
- data/lib/vines/storage/redis.rb +3 -3
- data/lib/vines/storage/sql.rb +5 -5
- data/lib/vines/stream.rb +40 -6
- data/lib/vines/stream/client.rb +5 -6
- data/lib/vines/stream/client/auth.rb +3 -2
- data/lib/vines/stream/client/bind.rb +2 -2
- data/lib/vines/stream/client/bind_restart.rb +1 -2
- data/lib/vines/stream/client/ready.rb +2 -0
- data/lib/vines/stream/client/session.rb +13 -4
- data/lib/vines/stream/client/tls.rb +1 -0
- data/lib/vines/stream/component.rb +6 -5
- data/lib/vines/stream/component/ready.rb +5 -6
- data/lib/vines/stream/http.rb +10 -4
- data/lib/vines/stream/http/request.rb +23 -2
- data/lib/vines/stream/server.rb +13 -11
- data/lib/vines/stream/server/outbound/auth_result.rb +1 -0
- data/lib/vines/stream/server/outbound/tls_result.rb +1 -0
- data/lib/vines/stream/server/ready.rb +2 -2
- data/lib/vines/user.rb +2 -1
- data/lib/vines/version.rb +1 -1
- data/test/config/host_test.rb +292 -0
- data/test/config_test.rb +244 -103
- data/test/contact_test.rb +7 -1
- data/test/jid_test.rb +48 -0
- data/test/router_test.rb +16 -47
- data/test/stanza/iq/disco_info_test.rb +76 -0
- data/test/stanza/iq/disco_items_test.rb +47 -0
- data/test/stanza/iq/private_storage_test.rb +33 -10
- data/test/stanza/iq/roster_test.rb +15 -5
- data/test/stanza/iq/vcard_test.rb +8 -25
- data/test/stanza/iq/version_test.rb +62 -0
- data/test/stanza/iq_test.rb +13 -10
- data/test/stanza/message_test.rb +16 -24
- data/test/stanza/presence/probe_test.rb +52 -0
- data/test/stanza/presence/subscribe_test.rb +1 -5
- data/test/stanza_test.rb +77 -0
- data/test/stream/client/auth_test.rb +1 -0
- data/test/stream/client/ready_test.rb +2 -0
- data/test/stream/client/session_test.rb +7 -2
- data/test/stream/component/ready_test.rb +19 -36
- data/test/stream/http/request_test.rb +22 -2
- data/test/stream/server/ready_test.rb +14 -21
- data/web/404.html +9 -3
- data/web/chat/index.html +2 -2
- data/web/chat/javascripts/app.js +1 -1
- data/web/chat/stylesheets/chat.css +4 -9
- data/web/lib/coffeescripts/layout.coffee +2 -2
- data/web/{chat → lib}/coffeescripts/logout.coffee +0 -0
- data/web/lib/coffeescripts/notification.coffee +14 -0
- data/web/lib/coffeescripts/session.coffee +28 -24
- data/web/lib/coffeescripts/transfer.coffee +37 -34
- data/web/lib/javascripts/base.js +8 -8
- data/web/lib/javascripts/icons.js +3 -0
- data/web/lib/javascripts/jquery.js +4 -18
- data/web/lib/javascripts/layout.js +2 -2
- data/web/{chat → lib}/javascripts/logout.js +0 -0
- data/web/lib/javascripts/notification.js +26 -0
- data/web/lib/javascripts/session.js +20 -16
- data/web/lib/javascripts/transfer.js +45 -55
- data/web/lib/stylesheets/base.css +45 -9
- metadata +31 -15
data/test/contact_test.rb
CHANGED
@@ -21,8 +21,14 @@ class ContactTest < MiniTest::Unit::TestCase
|
|
21
21
|
refute alice.hash == hatter.hash
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def test_initialize_missing_jid_raises
|
25
25
|
assert_raises(ArgumentError) { Vines::Contact.new }
|
26
|
+
assert_raises(ArgumentError) { Vines::Contact.new(:jid => '') }
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_initialize_domain_only_jid_does_not_raise
|
30
|
+
contact = Vines::Contact.new(:jid => 'tea.wonderland.lit')
|
31
|
+
assert_equal 'tea.wonderland.lit', contact.jid.to_s
|
26
32
|
end
|
27
33
|
|
28
34
|
def test_to_roster_xml_sorts_groups
|
data/test/jid_test.rb
CHANGED
@@ -13,6 +13,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
13
13
|
assert_equal '', jid.domain
|
14
14
|
assert_equal '', jid.to_s
|
15
15
|
assert_equal '', jid.bare.to_s
|
16
|
+
assert jid.empty?
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -31,6 +32,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
31
32
|
assert_nil jid.node
|
32
33
|
assert_nil jid.resource
|
33
34
|
assert_equal jid, jid.bare
|
35
|
+
refute jid.empty?
|
34
36
|
end
|
35
37
|
|
36
38
|
def test_bare_jid
|
@@ -40,6 +42,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
40
42
|
assert_equal 'alice', jid.node
|
41
43
|
assert_nil jid.resource
|
42
44
|
assert_equal jid, jid.bare
|
45
|
+
refute jid.empty?
|
43
46
|
end
|
44
47
|
|
45
48
|
def test_parsed_bare_jid
|
@@ -49,6 +52,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
49
52
|
assert_equal 'alice', jid.node
|
50
53
|
assert_nil jid.resource
|
51
54
|
assert_equal jid, jid.bare
|
55
|
+
refute jid.empty?
|
52
56
|
end
|
53
57
|
|
54
58
|
def test_full_jid
|
@@ -58,6 +62,7 @@ class JidTest < MiniTest::Unit::TestCase
|
|
58
62
|
assert_equal 'alice', jid.node
|
59
63
|
assert_equal 'tea', jid.resource
|
60
64
|
refute_equal jid, jid.bare
|
65
|
+
refute jid.empty?
|
61
66
|
end
|
62
67
|
|
63
68
|
def test_parsed_full_jid
|
@@ -67,5 +72,48 @@ class JidTest < MiniTest::Unit::TestCase
|
|
67
72
|
assert_equal 'alice', jid.node
|
68
73
|
assert_equal 'tea', jid.resource
|
69
74
|
refute_equal jid, jid.bare
|
75
|
+
refute jid.empty?
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_node_with_separators_in_resource
|
79
|
+
jid = Vines::JID.new('alice@wonderland.lit/foo/bar@blarg')
|
80
|
+
assert_equal 'alice', jid.node
|
81
|
+
assert_equal 'wonderland.lit', jid.domain
|
82
|
+
assert_equal 'foo/bar@blarg', jid.resource
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_missing_node_with_separators_in_resource
|
86
|
+
jid = Vines::JID.new('wonderland.lit/foo/bar@blarg')
|
87
|
+
assert_nil jid.node
|
88
|
+
assert_equal 'wonderland.lit', jid.domain
|
89
|
+
assert_equal 'foo/bar@blarg', jid.resource
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_empty_part_raises
|
93
|
+
assert_raises(ArgumentError) { Vines::JID.new('@wonderland.lit') }
|
94
|
+
assert_raises(ArgumentError) { Vines::JID.new('wonderland.lit/') }
|
95
|
+
assert_raises(ArgumentError) { Vines::JID.new('@') }
|
96
|
+
assert_raises(ArgumentError) { Vines::JID.new('alice@') }
|
97
|
+
assert_raises(ArgumentError) { Vines::JID.new('/') }
|
98
|
+
assert_raises(ArgumentError) { Vines::JID.new('/res') }
|
99
|
+
assert_raises(ArgumentError) { Vines::JID.new('@/') }
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_invalid_characters
|
103
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice"s@wonderland.lit}) }
|
104
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice&s@wonderland.lit}) }
|
105
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice's@wonderland.lit}) }
|
106
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice:s@wonderland.lit}) }
|
107
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice<s@wonderland.lit}) }
|
108
|
+
assert_raises(ArgumentError) { Vines::JID.new(%q{alice>s@wonderland.lit}) }
|
109
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice\u0000s@wonderland.lit") }
|
110
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice\ts@wonderland.lit") }
|
111
|
+
assert_raises(ArgumentError) { Vines::JID.new(" alice@wonderland.lit") }
|
112
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice@wonderland.lit ") }
|
113
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice s@wonderland.lit") }
|
114
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice@w onderland.lit") }
|
115
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice@wonderland.lit/ res") }
|
116
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice@w\u0000onderland.lit") }
|
117
|
+
assert_raises(ArgumentError) { Vines::JID.new("alice@wonderland.lit/\u0000res") }
|
70
118
|
end
|
71
119
|
end
|
data/test/router_test.rb
CHANGED
@@ -5,57 +5,26 @@ require 'minitest/autorun'
|
|
5
5
|
|
6
6
|
class RouterTest < MiniTest::Unit::TestCase
|
7
7
|
def setup
|
8
|
+
@alice = Vines::JID.new('alice@wonderland.lit/tea')
|
9
|
+
@stream = MiniTest::Mock.new
|
8
10
|
@router = Vines::Router.new
|
11
|
+
@config = Vines::Config.new do
|
12
|
+
host 'wonderland.lit' do
|
13
|
+
storage(:fs) { dir '.' }
|
14
|
+
end
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
|
-
def
|
12
|
-
|
13
|
-
stanza.expect(:name, 'auth')
|
14
|
-
assert @router.local?(stanza)
|
15
|
-
assert stanza.verify
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_stanza_missing_to_is_local
|
19
|
-
stanza = MiniTest::Mock.new
|
20
|
-
stanza.expect(:name, 'message')
|
21
|
-
stanza.expect(:[], nil, ['to'])
|
22
|
-
assert @router.local?(stanza)
|
23
|
-
assert stanza.verify
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_stanza_with_local_jid_is_local
|
27
|
-
config = MiniTest::Mock.new
|
28
|
-
config.expect(:vhost?, true, ['wonderland.lit'])
|
29
|
-
stream = MiniTest::Mock.new
|
30
|
-
stream.expect(:config, config)
|
31
|
-
stream.expect(:stream_type, :client)
|
32
|
-
@router << stream
|
33
|
-
|
34
|
-
stanza = MiniTest::Mock.new
|
35
|
-
stanza.expect(:name, 'message')
|
36
|
-
stanza.expect(:[], 'alice@wonderland.lit', ['to'])
|
37
|
-
assert @router.local?(stanza)
|
38
|
-
|
39
|
-
assert stanza.verify
|
40
|
-
assert stream.verify
|
41
|
-
assert config.verify
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_stanza_with_remote_jid_is_not_local
|
45
|
-
config = MiniTest::Mock.new
|
46
|
-
config.expect(:vhost?, false, ['wonderland.lit'])
|
47
|
-
stream = MiniTest::Mock.new
|
48
|
-
stream.expect(:config, config)
|
49
|
-
stream.expect(:stream_type, :client)
|
50
|
-
@router << stream
|
18
|
+
def test_connected_resources
|
19
|
+
assert_equal 0, @router.connected_resources(@alice, @alice).size
|
51
20
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
21
|
+
@stream.expect(:config, @config)
|
22
|
+
@stream.expect(:stream_type, :client)
|
23
|
+
@stream.expect(:connected?, true)
|
24
|
+
@stream.expect(:user, Vines::User.new(jid: @alice))
|
25
|
+
@router << @stream
|
56
26
|
|
57
|
-
|
58
|
-
assert stream.verify
|
59
|
-
assert config.verify
|
27
|
+
assert_equal 1, @router.connected_resources(@alice, @alice).size
|
28
|
+
assert @stream.verify
|
60
29
|
end
|
61
30
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'ext/nokogiri'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
class DiscoInfoTest < MiniTest::Unit::TestCase
|
8
|
+
ALICE = Vines::User.new(:jid => 'alice@wonderland.lit/home')
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@config = MiniTest::Mock.new
|
12
|
+
@stream = MiniTest::Mock.new
|
13
|
+
@stream.expect(:user, ALICE)
|
14
|
+
@stream.expect(:domain, 'wonderland.lit')
|
15
|
+
@stream.expect(:config, @config)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_private_storage_disabled
|
19
|
+
query = %q{<query xmlns="http://jabber.org/protocol/disco#info"/>}
|
20
|
+
node = node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
21
|
+
|
22
|
+
expected = node(%Q{
|
23
|
+
<iq from="wonderland.lit" id="42" to="#{ALICE.jid}" type="result">
|
24
|
+
<query xmlns="http://jabber.org/protocol/disco#info">
|
25
|
+
<identity category="server" type="im"/>
|
26
|
+
<feature var="http://jabber.org/protocol/disco#info"/>
|
27
|
+
<feature var="http://jabber.org/protocol/disco#items"/>
|
28
|
+
<feature var="urn:xmpp:ping"/>
|
29
|
+
<feature var="vcard-temp"/>
|
30
|
+
<feature var="jabber:iq:version"/>
|
31
|
+
</query>
|
32
|
+
</iq>
|
33
|
+
}.strip.gsub(/\n|\s{2,}/, ''))
|
34
|
+
|
35
|
+
@config.expect(:private_storage?, false, ['wonderland.lit'])
|
36
|
+
@stream.expect(:write, nil, [expected])
|
37
|
+
|
38
|
+
stanza = Vines::Stanza::Iq::DiscoInfo.new(node, @stream)
|
39
|
+
stanza.process
|
40
|
+
assert @stream.verify
|
41
|
+
assert @config.verify
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_private_storage_enabled
|
45
|
+
query = %q{<query xmlns="http://jabber.org/protocol/disco#info"/>}
|
46
|
+
node = node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
47
|
+
|
48
|
+
expected = node(%Q{
|
49
|
+
<iq from="wonderland.lit" id="42" to="#{ALICE.jid}" type="result">
|
50
|
+
<query xmlns="http://jabber.org/protocol/disco#info">
|
51
|
+
<identity category="server" type="im"/>
|
52
|
+
<feature var="http://jabber.org/protocol/disco#info"/>
|
53
|
+
<feature var="http://jabber.org/protocol/disco#items"/>
|
54
|
+
<feature var="urn:xmpp:ping"/>
|
55
|
+
<feature var="vcard-temp"/>
|
56
|
+
<feature var="jabber:iq:version"/>
|
57
|
+
<feature var="jabber:iq:private"/>
|
58
|
+
</query>
|
59
|
+
</iq>
|
60
|
+
}.strip.gsub(/\n|\s{2,}/, ''))
|
61
|
+
|
62
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
63
|
+
@stream.expect(:write, nil, [expected])
|
64
|
+
|
65
|
+
stanza = Vines::Stanza::Iq::DiscoInfo.new(node, @stream)
|
66
|
+
stanza.process
|
67
|
+
assert @stream.verify
|
68
|
+
assert @config.verify
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def node(xml)
|
74
|
+
Nokogiri::XML(xml).root
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'ext/nokogiri'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
class DiscoItemsTest < MiniTest::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@stream = MiniTest::Mock.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_component_items
|
13
|
+
query = %q{<query xmlns="http://jabber.org/protocol/disco#items"/>}
|
14
|
+
node = node(%Q{<iq id="42" to="wonderland.lit" type="get">#{query}</iq>})
|
15
|
+
|
16
|
+
expected = node(%q{
|
17
|
+
<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/home" type="result">
|
18
|
+
<query xmlns="http://jabber.org/protocol/disco#items">
|
19
|
+
<item jid="cake.wonderland.lit"/>
|
20
|
+
<item jid="tea.wonderland.lit"/>
|
21
|
+
</query>
|
22
|
+
</iq>
|
23
|
+
}.strip.gsub(/\n|\s{2,}/, ''))
|
24
|
+
|
25
|
+
config = Vines::Config.new do
|
26
|
+
host 'wonderland.lit' do
|
27
|
+
storage(:fs) { dir '.' }
|
28
|
+
components 'tea' => 'secr3t', 'cake' => 'passw0rd'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@stream.expect(:config, config)
|
33
|
+
@stream.expect(:user, Vines::User.new(:jid => 'alice@wonderland.lit/home'))
|
34
|
+
@stream.expect(:domain, 'wonderland.lit')
|
35
|
+
@stream.expect(:write, nil, [expected])
|
36
|
+
|
37
|
+
stanza = Vines::Stanza::Iq::DiscoItems.new(node, @stream)
|
38
|
+
stanza.process
|
39
|
+
assert @stream.verify
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def node(xml)
|
45
|
+
Nokogiri::XML(xml).root
|
46
|
+
end
|
47
|
+
end
|
@@ -6,6 +6,7 @@ require 'minitest/autorun'
|
|
6
6
|
|
7
7
|
class PrivateStorageTest < MiniTest::Unit::TestCase
|
8
8
|
def setup
|
9
|
+
@config = MiniTest::Mock.new
|
9
10
|
@stream = MiniTest::Mock.new
|
10
11
|
end
|
11
12
|
|
@@ -13,11 +14,14 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
13
14
|
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
14
15
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
15
16
|
|
16
|
-
@
|
17
|
+
@config.expect(:private_storage?, false, ['wonderland.lit'])
|
18
|
+
@stream.expect(:domain, 'wonderland.lit')
|
19
|
+
@stream.expect(:config, @config)
|
17
20
|
|
18
21
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
19
22
|
assert_raises(Vines::StanzaErrors::ServiceUnavailable) { stanza.process }
|
20
23
|
assert @stream.verify
|
24
|
+
assert @config.verify
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_get_another_user_fragment_raises_error
|
@@ -25,7 +29,6 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
25
29
|
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/></query>}
|
26
30
|
node = node(%Q{<iq id="42" to="hatter@wonderland.lit" type="get">#{query}</iq>})
|
27
31
|
|
28
|
-
@stream.expect(:private_storage?, true)
|
29
32
|
@stream.expect(:user, alice)
|
30
33
|
|
31
34
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
@@ -38,11 +41,14 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
38
41
|
query = %q{<query xmlns="jabber:iq:private"></query>}
|
39
42
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
40
43
|
|
41
|
-
@
|
44
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
45
|
+
@stream.expect(:domain, 'wonderland.lit')
|
46
|
+
@stream.expect(:config, @config)
|
42
47
|
|
43
48
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
44
49
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
45
50
|
assert @stream.verify
|
51
|
+
assert @config.verify
|
46
52
|
end
|
47
53
|
|
48
54
|
def test_get_with_two_children_raises_error
|
@@ -50,11 +56,14 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
50
56
|
query = %q{<query xmlns="jabber:iq:private"><one xmlns="a"/><two xmlns="b"/></query>}
|
51
57
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
52
58
|
|
53
|
-
@
|
59
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
60
|
+
@stream.expect(:domain, 'wonderland.lit')
|
61
|
+
@stream.expect(:config, @config)
|
54
62
|
|
55
63
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
56
64
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
57
65
|
assert @stream.verify
|
66
|
+
assert @config.verify
|
58
67
|
end
|
59
68
|
|
60
69
|
def test_set_with_zero_children_raises_error
|
@@ -62,11 +71,14 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
62
71
|
query = %q{<query xmlns="jabber:iq:private"></query>}
|
63
72
|
node = node(%Q{<iq id="42" type="set">#{query}</iq>})
|
64
73
|
|
65
|
-
@
|
74
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
75
|
+
@stream.expect(:domain, 'wonderland.lit')
|
76
|
+
@stream.expect(:config, @config)
|
66
77
|
|
67
78
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
68
79
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
69
80
|
assert @stream.verify
|
81
|
+
assert @config.verify
|
70
82
|
end
|
71
83
|
|
72
84
|
def test_get_without_namespace_raises_error
|
@@ -74,11 +86,14 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
74
86
|
query = %q{<query xmlns="jabber:iq:private"><one/></query>}
|
75
87
|
node = node(%Q{<iq id="42" type="get">#{query}</iq>})
|
76
88
|
|
77
|
-
@
|
89
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
90
|
+
@stream.expect(:domain, 'wonderland.lit')
|
91
|
+
@stream.expect(:config, @config)
|
78
92
|
|
79
93
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
80
94
|
assert_raises(Vines::StanzaErrors::NotAcceptable) { stanza.process }
|
81
95
|
assert @stream.verify
|
96
|
+
assert @config.verify
|
82
97
|
end
|
83
98
|
|
84
99
|
def test_get_missing_fragment_raises_error
|
@@ -89,14 +104,16 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
89
104
|
storage = MiniTest::Mock.new
|
90
105
|
storage.expect(:find_fragment, nil, [alice.jid, node.elements[0].elements[0]])
|
91
106
|
|
92
|
-
@
|
107
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
93
108
|
@stream.expect(:domain, 'wonderland.lit')
|
109
|
+
@stream.expect(:config, @config)
|
94
110
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
95
111
|
@stream.expect(:user, alice)
|
96
112
|
|
97
113
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
98
114
|
assert_raises(Vines::StanzaErrors::ItemNotFound) { stanza.process }
|
99
115
|
assert @stream.verify
|
116
|
+
assert @config.verify
|
100
117
|
assert storage.verify
|
101
118
|
end
|
102
119
|
|
@@ -112,8 +129,9 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
112
129
|
storage = MiniTest::Mock.new
|
113
130
|
storage.expect(:find_fragment, node(data), [alice.jid, node.elements[0].elements[0]])
|
114
131
|
|
115
|
-
@
|
132
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
116
133
|
@stream.expect(:domain, 'wonderland.lit')
|
134
|
+
@stream.expect(:config, @config)
|
117
135
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
118
136
|
@stream.expect(:user, alice)
|
119
137
|
@stream.expect(:write, nil, [expected])
|
@@ -121,6 +139,7 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
121
139
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
122
140
|
stanza.process
|
123
141
|
assert @stream.verify
|
142
|
+
assert @config.verify
|
124
143
|
assert storage.verify
|
125
144
|
end
|
126
145
|
|
@@ -134,8 +153,9 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
134
153
|
|
135
154
|
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result"/>})
|
136
155
|
|
137
|
-
@
|
156
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
138
157
|
@stream.expect(:domain, 'wonderland.lit')
|
158
|
+
@stream.expect(:config, @config)
|
139
159
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
140
160
|
@stream.expect(:user, alice)
|
141
161
|
@stream.expect(:write, nil, [expected])
|
@@ -143,6 +163,7 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
143
163
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
144
164
|
stanza.process
|
145
165
|
assert @stream.verify
|
166
|
+
assert @config.verify
|
146
167
|
assert storage.verify
|
147
168
|
end
|
148
169
|
|
@@ -157,8 +178,9 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
157
178
|
|
158
179
|
expected = node(%Q{<iq from="#{alice.jid}" id="42" to="#{alice.jid}" type="result"/>})
|
159
180
|
|
160
|
-
@
|
181
|
+
@config.expect(:private_storage?, true, ['wonderland.lit'])
|
161
182
|
@stream.expect(:domain, 'wonderland.lit')
|
183
|
+
@stream.expect(:config, @config)
|
162
184
|
@stream.expect(:storage, storage, ['wonderland.lit'])
|
163
185
|
@stream.expect(:user, alice)
|
164
186
|
@stream.expect(:write, nil, [expected])
|
@@ -166,6 +188,7 @@ class PrivateStorageTest < MiniTest::Unit::TestCase
|
|
166
188
|
stanza = Vines::Stanza::Iq::PrivateStorage.new(node, @stream)
|
167
189
|
stanza.process
|
168
190
|
assert @stream.verify
|
191
|
+
assert @config.verify
|
169
192
|
assert storage.verify
|
170
193
|
end
|
171
194
|
|