vines 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +12 -2
- data/conf/config.rb +1 -0
- data/lib/vines/config.rb +8 -0
- data/lib/vines/contact.rb +2 -4
- data/lib/vines/error.rb +1 -1
- data/lib/vines/router.rb +26 -18
- data/lib/vines/stanza/presence.rb +3 -1
- data/lib/vines/stanza.rb +8 -1
- data/lib/vines/stream/client/bind.rb +9 -1
- data/lib/vines/stream/client/session.rb +146 -0
- data/lib/vines/stream/client.rb +19 -78
- data/lib/vines/stream/component.rb +6 -2
- 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 +36 -0
- data/lib/vines/stream/http/ready.rb +25 -0
- data/lib/vines/stream/http/request.rb +33 -0
- data/lib/vines/stream/http/session.rb +116 -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 +119 -77
- data/lib/vines/stream/server.rb +8 -3
- data/lib/vines/stream/state.rb +6 -1
- data/lib/vines/stream.rb +31 -19
- data/lib/vines/user.rb +2 -4
- data/lib/vines/version.rb +1 -1
- data/lib/vines.rb +10 -4
- data/test/config_test.rb +34 -33
- data/test/contact_test.rb +42 -0
- data/test/error_test.rb +2 -2
- data/test/jid_test.rb +7 -7
- data/test/kit_test.rb +10 -10
- data/test/rake_test_loader.rb +9 -0
- data/test/router_test.rb +4 -3
- data/test/stanza/iq/roster_test.rb +8 -10
- data/test/stanza/iq/session_test.rb +2 -3
- data/test/stanza/iq/vcard_test.rb +4 -5
- data/test/stanza/message_test.rb +17 -11
- data/test/stanza/presence/subscribe_test.rb +3 -4
- data/test/storage/couchdb_test.rb +9 -10
- data/test/storage/ldap_test.rb +30 -37
- data/test/storage/local_test.rb +6 -6
- data/test/storage/redis_test.rb +6 -6
- data/test/storage/sql_test.rb +5 -5
- data/test/storage/storage_tests.rb +11 -11
- data/test/storage_test.rb +4 -5
- data/test/stream/client/auth_test.rb +15 -16
- data/test/stream/client/ready_test.rb +4 -5
- data/test/stream/client/session_test.rb +21 -0
- data/test/stream/component/handshake_test.rb +6 -7
- data/test/stream/component/ready_test.rb +9 -10
- data/test/stream/component/start_test.rb +6 -7
- data/test/stream/http/auth_test.rb +68 -0
- data/test/stream/http/ready_test.rb +56 -0
- data/test/stream/http/sessions_test.rb +50 -0
- data/test/stream/http/start_test.rb +51 -0
- data/test/stream/parser_test.rb +5 -5
- data/test/stream/server/outbound/auth_test.rb +12 -13
- data/test/stream/server/ready_test.rb +10 -11
- data/test/token_bucket_test.rb +7 -7
- data/test/user_test.rb +8 -6
- metadata +45 -14
- data/lib/vines/stream/http/http_request.rb +0 -22
- data/lib/vines/stream/http/http_state.rb +0 -139
- data/lib/vines/stream/http/http_states.rb +0 -53
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class HttpAuthTest < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@stream = MiniTest::Mock.new
|
9
|
+
@state = Vines::Stream::Http::Auth.new(@stream, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_missing_body_raises_error
|
13
|
+
node = node('<presence type="unavailable"/>')
|
14
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_body_with_missing_namespace_raises_error
|
18
|
+
node = node('<body rid="42" sid="12"/>')
|
19
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_missing_rid_raises_error
|
23
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" sid="12"/>')
|
24
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_invalid_session_raises_error
|
28
|
+
@stream.expect(:valid_session?, false, ['12'])
|
29
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"/>')
|
30
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
31
|
+
assert @stream.verify
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_empty_body_raises_error
|
35
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"/>')
|
36
|
+
@stream.expect(:valid_session?, true, ['12'])
|
37
|
+
@stream.expect(:parse_body, [], [node])
|
38
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
39
|
+
assert @stream.verify
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_body_with_two_children_raises_error
|
43
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"><message/><message/></body>')
|
44
|
+
message = node('<message/>')
|
45
|
+
@stream.expect(:valid_session?, true, ['12'])
|
46
|
+
@stream.expect(:parse_body, [message, message], [node])
|
47
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
48
|
+
assert @stream.verify
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_valid_body_processes
|
52
|
+
auth = node(%Q{<auth xmlns="#{Vines::NAMESPACES[:sasl]}" mechanism="PLAIN"/>})
|
53
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"></body>')
|
54
|
+
node << auth
|
55
|
+
@stream.expect(:valid_session?, true, ['12'])
|
56
|
+
@stream.expect(:parse_body, [auth], [node])
|
57
|
+
# this error means we correctly called the parent method Client#node
|
58
|
+
@stream.expect(:error, nil, [Vines::SaslErrors::MalformedRequest.new])
|
59
|
+
@state.node(node)
|
60
|
+
assert @stream.verify
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def node(xml)
|
66
|
+
Nokogiri::XML(xml).root
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class HttpReadyTest < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@stream = MiniTest::Mock.new
|
9
|
+
@state = Vines::Stream::Http::Ready.new(@stream, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_missing_body_raises_error
|
13
|
+
node = node('<presence type="unavailable"/>')
|
14
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_body_with_missing_namespace_raises_error
|
18
|
+
node = node('<body rid="42" sid="12"/>')
|
19
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_missing_rid_raises_error
|
23
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" sid="12"/>')
|
24
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_invalid_session_raises_error
|
28
|
+
@stream.expect(:valid_session?, false, ['12'])
|
29
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"/>')
|
30
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
31
|
+
assert @stream.verify
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_valid_body_processes
|
35
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"/>')
|
36
|
+
@stream.expect(:valid_session?, true, ['12'])
|
37
|
+
@stream.expect(:parse_body, [], [node])
|
38
|
+
@state.node(node)
|
39
|
+
assert @stream.verify
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_terminate
|
43
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12" type="terminate"/>')
|
44
|
+
@stream.expect(:valid_session?, true, ['12'])
|
45
|
+
@stream.expect(:parse_body, [], [node])
|
46
|
+
@stream.expect(:terminate, nil)
|
47
|
+
@state.node(node)
|
48
|
+
assert @stream.verify
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def node(xml)
|
54
|
+
Nokogiri::XML(xml).root
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class SessionsTest < MiniTest::Unit::TestCase
|
7
|
+
class MockSessions < Vines::Stream::Http::Sessions
|
8
|
+
def start_timer
|
9
|
+
# do nothing
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@sessions = MockSessions.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_session_add_and_delete
|
18
|
+
session = MiniTest::Mock.new
|
19
|
+
assert_nil @sessions['42']
|
20
|
+
@sessions['42'] = session
|
21
|
+
assert_equal session, @sessions['42']
|
22
|
+
@sessions.delete('42')
|
23
|
+
assert_nil @sessions['42']
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_access_singleton_through_class_methods
|
27
|
+
session = MiniTest::Mock.new
|
28
|
+
assert_nil MockSessions['42']
|
29
|
+
MockSessions['42'] = session
|
30
|
+
assert_equal session, MockSessions['42']
|
31
|
+
MockSessions.delete('42')
|
32
|
+
assert_nil MockSessions['42']
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_cleanup
|
36
|
+
live = MiniTest::Mock.new
|
37
|
+
live.expect(:expired?, false)
|
38
|
+
|
39
|
+
dead = MiniTest::Mock.new
|
40
|
+
dead.expect(:expired?, true)
|
41
|
+
dead.expect(:close, nil)
|
42
|
+
|
43
|
+
@sessions['live'] = live
|
44
|
+
@sessions['dead'] = dead
|
45
|
+
|
46
|
+
@sessions.send(:cleanup)
|
47
|
+
assert live.verify
|
48
|
+
assert dead.verify
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'vines'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class HttpStartTest < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@stream = MiniTest::Mock.new
|
9
|
+
@state = Vines::Stream::Http::Start.new(@stream)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_missing_body_raises_error
|
13
|
+
node = node('<presence type="unavailable"/>')
|
14
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_body_with_missing_namespace_raises_error
|
18
|
+
node = node('<body rid="42" sid="12"/>')
|
19
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_missing_session_starts_stream
|
23
|
+
EM.run do
|
24
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="12"/>')
|
25
|
+
@stream.expect(:start, nil, [node])
|
26
|
+
@stream.expect(:advance, nil, [Vines::Stream::Http::Auth.new(@stream)])
|
27
|
+
@state.node(node)
|
28
|
+
assert @stream.verify
|
29
|
+
EM.stop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_valid_session_resumes_stream
|
34
|
+
EM.run do
|
35
|
+
node = node('<body xmlns="http://jabber.org/protocol/httpbind" rid="42" sid="123"/>')
|
36
|
+
session = MiniTest::Mock.new
|
37
|
+
session.expect(:resume, nil, [@stream, node])
|
38
|
+
Vines::Stream::Http::Sessions['123'] = session
|
39
|
+
@state.node(node)
|
40
|
+
assert @stream.verify
|
41
|
+
assert session.verify
|
42
|
+
EM.stop
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def node(xml)
|
49
|
+
Nokogiri::XML(xml).root
|
50
|
+
end
|
51
|
+
end
|
data/test/stream/parser_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vines'
|
4
|
-
require '
|
4
|
+
require 'minitest/autorun'
|
5
5
|
|
6
|
-
class ParserTest <
|
6
|
+
class ParserTest < MiniTest::Unit::TestCase
|
7
7
|
STREAM_START = '<stream:stream to="wonderland.lit" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">'.freeze
|
8
8
|
|
9
9
|
def setup
|
@@ -61,7 +61,7 @@ class ParserTest < Test::Unit::TestCase
|
|
61
61
|
assert_equal 1, @events.size
|
62
62
|
stream = @events.shift
|
63
63
|
assert_equal 'stream', stream.name
|
64
|
-
|
64
|
+
refute_nil stream.namespace
|
65
65
|
assert_equal 'stream', stream.namespace.prefix
|
66
66
|
assert_equal 'http://etherx.jabber.org/streams', stream.namespace.href
|
67
67
|
expected = {'xmlns' => 'jabber:client', 'xmlns:stream' => 'http://etherx.jabber.org/streams'}
|
@@ -98,7 +98,7 @@ class ParserTest < Test::Unit::TestCase
|
|
98
98
|
assert_nil iq.namespace
|
99
99
|
|
100
100
|
query = iq.elements.first
|
101
|
-
|
101
|
+
refute_nil query.namespace
|
102
102
|
assert_nil query.namespace.prefix
|
103
103
|
assert_equal 'jabber:iq:roster', query.namespace.href
|
104
104
|
expected = {'xmlns' => 'jabber:iq:roster'}
|
@@ -112,7 +112,7 @@ class ParserTest < Test::Unit::TestCase
|
|
112
112
|
@events.shift # discard stream
|
113
113
|
error = @events.shift
|
114
114
|
assert_equal 'error', error.name
|
115
|
-
|
115
|
+
refute_nil error.namespace
|
116
116
|
assert_equal 'stream', error.namespace.prefix
|
117
117
|
assert_equal 'http://etherx.jabber.org/streams', error.namespace.href
|
118
118
|
expected = {'xmlns:stream' => 'http://etherx.jabber.org/streams'}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vines'
|
4
|
-
require 'minitest/
|
5
|
-
require 'test/unit'
|
4
|
+
require 'minitest/autorun'
|
6
5
|
|
7
|
-
class OutboundAuthTest <
|
6
|
+
class OutboundAuthTest < MiniTest::Unit::TestCase
|
8
7
|
def setup
|
9
8
|
@stream = MiniTest::Mock.new
|
10
9
|
@state = Vines::Stream::Server::Outbound::Auth.new(@stream)
|
@@ -12,50 +11,50 @@ class OutboundAuthTest < Test::Unit::TestCase
|
|
12
11
|
|
13
12
|
def test_invalid_element
|
14
13
|
node = node('<message/>')
|
15
|
-
|
14
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
16
15
|
end
|
17
16
|
|
18
17
|
def test_invalid_sasl_element
|
19
18
|
node = node(%Q{<message xmlns="#{Vines::NAMESPACES[:sasl]}"/>})
|
20
|
-
|
19
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
21
20
|
end
|
22
21
|
|
23
22
|
def test_missing_namespace
|
24
23
|
node = node('<stream:features/>')
|
25
|
-
|
24
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
26
25
|
end
|
27
26
|
|
28
27
|
def test_invalid_namespace
|
29
28
|
node = node('<stream:features xmlns="bogus"/>')
|
30
|
-
|
29
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
31
30
|
end
|
32
31
|
|
33
32
|
def test_missing_mechanisms
|
34
33
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams"/>})
|
35
|
-
|
34
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
36
35
|
end
|
37
36
|
|
38
37
|
def test_missing_mechanisms_namespace
|
39
38
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms/></stream:features>})
|
40
|
-
|
39
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
41
40
|
end
|
42
41
|
|
43
42
|
def test_missing_mechanism
|
44
43
|
mechanisms = %q{<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>}
|
45
44
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams">#{mechanisms}</stream:features>})
|
46
|
-
|
45
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_missing_mechanism_text
|
50
49
|
mechanisms = %q{<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism></mechanism></mechanisms>}
|
51
50
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams">#{mechanisms}</stream:features>})
|
52
|
-
|
51
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
53
52
|
end
|
54
53
|
|
55
54
|
def test_invalid_mechanism_text
|
56
55
|
mechanisms = %q{<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>BOGUS</mechanism></mechanisms>}
|
57
56
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams">#{mechanisms}</stream:features>})
|
58
|
-
|
57
|
+
assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
|
59
58
|
end
|
60
59
|
|
61
60
|
def test_valid_mechanism
|
@@ -65,7 +64,7 @@ class OutboundAuthTest < Test::Unit::TestCase
|
|
65
64
|
@stream.expect(:advance, nil, [Vines::Stream::Server::Outbound::AuthResult.new(@stream)])
|
66
65
|
mechanisms = %q{<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>EXTERNAL</mechanism></mechanisms>}
|
67
66
|
node = node(%Q{<stream:features xmlns:stream="http://etherx.jabber.org/streams">#{mechanisms}</stream:features>})
|
68
|
-
|
67
|
+
@state.node(node)
|
69
68
|
assert @stream.verify
|
70
69
|
end
|
71
70
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vines'
|
4
|
-
require 'minitest/
|
5
|
-
require 'test/unit'
|
4
|
+
require 'minitest/autorun'
|
6
5
|
|
7
|
-
class ServerReadyTest <
|
6
|
+
class ServerReadyTest < MiniTest::Unit::TestCase
|
8
7
|
STANZAS = []
|
9
8
|
|
10
9
|
def setup
|
@@ -34,7 +33,7 @@ class ServerReadyTest < Test::Unit::TestCase
|
|
34
33
|
@stream.expect(:domain, 'verona.lit')
|
35
34
|
@stream.expect(:user=, nil, [Vines::User.new(:jid => 'alice@wonderland.lit')])
|
36
35
|
node = node(%Q{<message from="alice@wonderland.lit" to="romeo@verona.lit"/>})
|
37
|
-
|
36
|
+
@state.node(node)
|
38
37
|
assert_equal 1, STANZAS.size
|
39
38
|
assert STANZAS.map {|s| s.verify }.all?
|
40
39
|
assert @stream.verify
|
@@ -42,35 +41,35 @@ class ServerReadyTest < Test::Unit::TestCase
|
|
42
41
|
|
43
42
|
def test_unsupported_stanza_type
|
44
43
|
node = node('<bogus/>')
|
45
|
-
|
44
|
+
assert_raises(Vines::StreamErrors::UnsupportedStanzaType) { @state.node(node) }
|
46
45
|
assert STANZAS.empty?
|
47
46
|
assert @stream.verify
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_improper_addressing_missing_to
|
51
50
|
node = node(%Q{<message from="alice@wonderland.lit"/>})
|
52
|
-
|
51
|
+
assert_raises(Vines::StreamErrors::ImproperAddressing) { @state.node(node) }
|
53
52
|
assert_equal 1, STANZAS.size
|
54
53
|
assert @stream.verify
|
55
54
|
end
|
56
55
|
|
57
56
|
def test_improper_addressing_empty_to
|
58
57
|
node = node(%Q{<message from="alice@wonderland.lit" to=" "/>})
|
59
|
-
|
58
|
+
assert_raises(Vines::StreamErrors::ImproperAddressing) { @state.node(node) }
|
60
59
|
assert_equal 1, STANZAS.size
|
61
60
|
assert @stream.verify
|
62
61
|
end
|
63
62
|
|
64
63
|
def test_improper_addressing_missing_from
|
65
64
|
node = node(%Q{<message to="romeo@verona.lit"/>})
|
66
|
-
|
65
|
+
assert_raises(Vines::StreamErrors::ImproperAddressing) { @state.node(node) }
|
67
66
|
assert_equal 1, STANZAS.size
|
68
67
|
assert @stream.verify
|
69
68
|
end
|
70
69
|
|
71
70
|
def test_improper_addressing_empty_from
|
72
71
|
node = node(%Q{<message from=" " to="romeo@verona.lit"/>})
|
73
|
-
|
72
|
+
assert_raises(Vines::StreamErrors::ImproperAddressing) { @state.node(node) }
|
74
73
|
assert_equal 1, STANZAS.size
|
75
74
|
assert @stream.verify
|
76
75
|
end
|
@@ -78,7 +77,7 @@ class ServerReadyTest < Test::Unit::TestCase
|
|
78
77
|
def test_invalid_from
|
79
78
|
@stream.expect(:remote_domain, 'wonderland.lit')
|
80
79
|
node = node(%Q{<message from="alice@bogus.lit" to="romeo@verona.lit"/>})
|
81
|
-
|
80
|
+
assert_raises(Vines::StreamErrors::InvalidFrom) { @state.node(node) }
|
82
81
|
assert_equal 1, STANZAS.size
|
83
82
|
assert @stream.verify
|
84
83
|
end
|
@@ -87,7 +86,7 @@ class ServerReadyTest < Test::Unit::TestCase
|
|
87
86
|
@stream.expect(:remote_domain, 'wonderland.lit')
|
88
87
|
@stream.expect(:domain, 'verona.lit')
|
89
88
|
node = node(%Q{<message from="alice@wonderland.lit" to="romeo@bogus.lit"/>})
|
90
|
-
|
89
|
+
assert_raises(Vines::StreamErrors::HostUnknown) { @state.node(node) }
|
91
90
|
assert_equal 1, STANZAS.size
|
92
91
|
assert @stream.verify
|
93
92
|
end
|
data/test/token_bucket_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vines'
|
4
|
-
require '
|
4
|
+
require 'minitest/autorun'
|
5
5
|
|
6
|
-
class TokenBucketTest <
|
6
|
+
class TokenBucketTest < MiniTest::Unit::TestCase
|
7
7
|
def test_init
|
8
8
|
assert_raises(ArgumentError) { Vines::TokenBucket.new(0, 1) }
|
9
9
|
assert_raises(ArgumentError) { Vines::TokenBucket.new(1, 0) }
|
@@ -14,11 +14,11 @@ class TokenBucketTest < Test::Unit::TestCase
|
|
14
14
|
def test_take
|
15
15
|
bucket = Vines::TokenBucket.new(10, 1)
|
16
16
|
assert_raises(ArgumentError) { bucket.take(-1) }
|
17
|
-
assert
|
18
|
-
assert
|
19
|
-
assert
|
17
|
+
assert !bucket.take(11)
|
18
|
+
assert bucket.take(10)
|
19
|
+
assert !bucket.take(1)
|
20
20
|
sleep(1)
|
21
|
-
assert
|
22
|
-
assert
|
21
|
+
assert bucket.take(1)
|
22
|
+
assert !bucket.take(1)
|
23
23
|
end
|
24
24
|
end
|
data/test/user_test.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'vines'
|
4
|
-
require '
|
4
|
+
require 'minitest/autorun'
|
5
5
|
|
6
|
-
class UserTest <
|
6
|
+
class UserTest < MiniTest::Unit::TestCase
|
7
7
|
def test_equality
|
8
8
|
alice = Vines::User.new(:jid => 'alice@wonderland.lit')
|
9
9
|
alice2 = Vines::User.new(:jid => 'alice@wonderland.lit')
|
10
10
|
hatter = Vines::User.new(:jid => 'hatter@wonderland.lit')
|
11
11
|
|
12
|
+
assert_nil alice <=> 42
|
13
|
+
|
12
14
|
assert alice == alice2
|
13
15
|
assert alice.eql?(alice2)
|
14
16
|
assert alice.hash == alice2.hash
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
refute alice == hatter
|
19
|
+
refute alice.eql?(hatter)
|
20
|
+
refute alice.hash == hatter.hash
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_initialize_missing_jid
|
@@ -24,7 +26,7 @@ class UserTest < Test::Unit::TestCase
|
|
24
26
|
|
25
27
|
def test_initialize_missing_roster
|
26
28
|
user = Vines::User.new(:jid => 'alice@wonderland.lit')
|
27
|
-
|
29
|
+
refute_nil user.roster
|
28
30
|
assert_equal 0, user.roster.size
|
29
31
|
end
|
30
32
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: vines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David Graham
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05-
|
14
|
+
date: 2011-05-19 00:00:00 -06:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -70,40 +70,40 @@ dependencies:
|
|
70
70
|
type: :runtime
|
71
71
|
version_requirements: *id005
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
73
|
+
name: http_parser.rb
|
74
74
|
prerelease: false
|
75
75
|
requirement: &id006 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
78
78
|
- - ~>
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: "0.
|
80
|
+
version: "0.5"
|
81
81
|
type: :runtime
|
82
82
|
version_requirements: *id006
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: net-ldap
|
85
85
|
prerelease: false
|
86
86
|
requirement: &id007 !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
89
89
|
- - ~>
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: "
|
91
|
+
version: "0.2"
|
92
92
|
type: :runtime
|
93
93
|
version_requirements: *id007
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
95
|
+
name: nokogiri
|
96
96
|
prerelease: false
|
97
97
|
requirement: &id008 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: "1.
|
102
|
+
version: "1.4"
|
103
103
|
type: :runtime
|
104
104
|
version_requirements: *id008
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
106
|
+
name: minitest
|
107
107
|
prerelease: false
|
108
108
|
requirement: &id009 !ruby/object:Gem::Requirement
|
109
109
|
none: false
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
type: :development
|
115
115
|
version_requirements: *id009
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
|
-
name:
|
117
|
+
name: rake
|
118
118
|
prerelease: false
|
119
119
|
requirement: &id010 !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
@@ -124,6 +124,17 @@ dependencies:
|
|
124
124
|
version: "0"
|
125
125
|
type: :development
|
126
126
|
version_requirements: *id010
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: sqlite3
|
129
|
+
prerelease: false
|
130
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
type: :development
|
137
|
+
version_requirements: *id011
|
127
138
|
description: |-
|
128
139
|
Vines is an XMPP chat server that supports thousands of
|
129
140
|
simultaneous connections by using EventMachine for asynchronous IO. User data
|
@@ -194,6 +205,7 @@ files:
|
|
194
205
|
- lib/vines/stream/client/bind_restart.rb
|
195
206
|
- lib/vines/stream/client/closed.rb
|
196
207
|
- lib/vines/stream/client/ready.rb
|
208
|
+
- lib/vines/stream/client/session.rb
|
197
209
|
- lib/vines/stream/client/start.rb
|
198
210
|
- lib/vines/stream/client/tls.rb
|
199
211
|
- lib/vines/stream/client.rb
|
@@ -201,9 +213,14 @@ files:
|
|
201
213
|
- lib/vines/stream/component/ready.rb
|
202
214
|
- lib/vines/stream/component/start.rb
|
203
215
|
- lib/vines/stream/component.rb
|
204
|
-
- lib/vines/stream/http/
|
205
|
-
- lib/vines/stream/http/
|
206
|
-
- lib/vines/stream/http/
|
216
|
+
- lib/vines/stream/http/auth.rb
|
217
|
+
- lib/vines/stream/http/bind.rb
|
218
|
+
- lib/vines/stream/http/bind_restart.rb
|
219
|
+
- lib/vines/stream/http/ready.rb
|
220
|
+
- lib/vines/stream/http/request.rb
|
221
|
+
- lib/vines/stream/http/session.rb
|
222
|
+
- lib/vines/stream/http/sessions.rb
|
223
|
+
- lib/vines/stream/http/start.rb
|
207
224
|
- lib/vines/stream/http.rb
|
208
225
|
- lib/vines/stream/parser.rb
|
209
226
|
- lib/vines/stream/server/auth.rb
|
@@ -232,10 +249,12 @@ files:
|
|
232
249
|
- conf/certs/README
|
233
250
|
- conf/config.rb
|
234
251
|
- test/config_test.rb
|
252
|
+
- test/contact_test.rb
|
235
253
|
- test/error_test.rb
|
236
254
|
- test/ext/nokogiri.rb
|
237
255
|
- test/jid_test.rb
|
238
256
|
- test/kit_test.rb
|
257
|
+
- test/rake_test_loader.rb
|
239
258
|
- test/router_test.rb
|
240
259
|
- test/stanza/iq/roster_test.rb
|
241
260
|
- test/stanza/iq/session_test.rb
|
@@ -251,9 +270,14 @@ files:
|
|
251
270
|
- test/storage_test.rb
|
252
271
|
- test/stream/client/auth_test.rb
|
253
272
|
- test/stream/client/ready_test.rb
|
273
|
+
- test/stream/client/session_test.rb
|
254
274
|
- test/stream/component/handshake_test.rb
|
255
275
|
- test/stream/component/ready_test.rb
|
256
276
|
- test/stream/component/start_test.rb
|
277
|
+
- test/stream/http/auth_test.rb
|
278
|
+
- test/stream/http/ready_test.rb
|
279
|
+
- test/stream/http/sessions_test.rb
|
280
|
+
- test/stream/http/start_test.rb
|
257
281
|
- test/stream/parser_test.rb
|
258
282
|
- test/stream/server/outbound/auth_test.rb
|
259
283
|
- test/stream/server/ready_test.rb
|
@@ -273,7 +297,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
273
297
|
requirements:
|
274
298
|
- - ">="
|
275
299
|
- !ruby/object:Gem::Version
|
276
|
-
version: 1.9.
|
300
|
+
version: 1.9.2
|
277
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
302
|
none: false
|
279
303
|
requirements:
|
@@ -289,10 +313,12 @@ specification_version: 3
|
|
289
313
|
summary: Vines is an XMPP chat server that's easy to install and run.
|
290
314
|
test_files:
|
291
315
|
- test/config_test.rb
|
316
|
+
- test/contact_test.rb
|
292
317
|
- test/error_test.rb
|
293
318
|
- test/ext/nokogiri.rb
|
294
319
|
- test/jid_test.rb
|
295
320
|
- test/kit_test.rb
|
321
|
+
- test/rake_test_loader.rb
|
296
322
|
- test/router_test.rb
|
297
323
|
- test/stanza/iq/roster_test.rb
|
298
324
|
- test/stanza/iq/session_test.rb
|
@@ -308,9 +334,14 @@ test_files:
|
|
308
334
|
- test/storage_test.rb
|
309
335
|
- test/stream/client/auth_test.rb
|
310
336
|
- test/stream/client/ready_test.rb
|
337
|
+
- test/stream/client/session_test.rb
|
311
338
|
- test/stream/component/handshake_test.rb
|
312
339
|
- test/stream/component/ready_test.rb
|
313
340
|
- test/stream/component/start_test.rb
|
341
|
+
- test/stream/http/auth_test.rb
|
342
|
+
- test/stream/http/ready_test.rb
|
343
|
+
- test/stream/http/sessions_test.rb
|
344
|
+
- test/stream/http/start_test.rb
|
314
345
|
- test/stream/parser_test.rb
|
315
346
|
- test/stream/server/outbound/auth_test.rb
|
316
347
|
- test/stream/server/ready_test.rb
|