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
data/test/rake_test_loader.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
# Use the latest MiniTest gem instead of the buggy
|
4
|
-
# version included with Ruby 1.9.2.
|
5
|
-
gem 'minitest', '~> 2.12.1'
|
6
|
-
|
7
|
-
# Load the test files from the command line.
|
8
|
-
|
9
|
-
ARGV.each do |f|
|
10
|
-
next if f =~ /^-/
|
11
|
-
|
12
|
-
if f =~ /\*/
|
13
|
-
FileList[f].to_a.each { |fn| require File.expand_path(fn) }
|
14
|
-
else
|
15
|
-
require File.expand_path(f)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'storage_tests'
|
4
|
-
require 'vines'
|
5
|
-
require 'minitest/autorun'
|
6
|
-
|
7
|
-
class CouchDBTest < MiniTest::Unit::TestCase
|
8
|
-
include StorageTests
|
9
|
-
|
10
|
-
URL = 'http://localhost:5984/xmpp_testcase'.freeze
|
11
|
-
|
12
|
-
def setup
|
13
|
-
EMLoop.new do
|
14
|
-
database(:put)
|
15
|
-
save_doc({'_id' => 'user:empty@wonderland.lit'})
|
16
|
-
|
17
|
-
save_doc({
|
18
|
-
'_id' => 'user:no_password@wonderland.lit',
|
19
|
-
'type' => 'User',
|
20
|
-
'foo' => 'bar'})
|
21
|
-
|
22
|
-
save_doc({
|
23
|
-
'_id' => 'user:clear_password@wonderland.lit',
|
24
|
-
'type' => 'User',
|
25
|
-
'password' => 'secret'})
|
26
|
-
|
27
|
-
save_doc({
|
28
|
-
'_id' => 'user:bcrypt_password@wonderland.lit',
|
29
|
-
'type' => 'User',
|
30
|
-
'password' => BCrypt::Password.create('secret')})
|
31
|
-
|
32
|
-
save_doc({
|
33
|
-
'_id' => 'user:full@wonderland.lit',
|
34
|
-
'type' => 'User',
|
35
|
-
'password' => BCrypt::Password.create('secret'),
|
36
|
-
'name' => 'Tester',
|
37
|
-
'roster' => {
|
38
|
-
'contact1@wonderland.lit' => {
|
39
|
-
'name' => 'Contact1',
|
40
|
-
'groups' => %w[Group1 Group2]
|
41
|
-
},
|
42
|
-
'contact2@wonderland.lit' => {
|
43
|
-
'name' => 'Contact2',
|
44
|
-
'groups' => %w[Group3 Group4]
|
45
|
-
}
|
46
|
-
}
|
47
|
-
})
|
48
|
-
|
49
|
-
save_doc({
|
50
|
-
'_id' => 'vcard:full@wonderland.lit',
|
51
|
-
'type' => 'Vcard',
|
52
|
-
'card' => VCARD.to_xml
|
53
|
-
})
|
54
|
-
|
55
|
-
save_doc({
|
56
|
-
'_id' => "fragment:full@wonderland.lit:#{FRAGMENT_ID}",
|
57
|
-
'type' => 'Fragment',
|
58
|
-
'xml' => FRAGMENT.to_xml
|
59
|
-
})
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def teardown
|
64
|
-
EMLoop.new do
|
65
|
-
database(:delete)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def save_doc(doc)
|
70
|
-
fiber = Fiber.current
|
71
|
-
http = EM::HttpRequest.new(URL).post(
|
72
|
-
:head => {'Content-Type' => 'application/json'},
|
73
|
-
:body => doc.to_json)
|
74
|
-
http.callback { fiber.resume }
|
75
|
-
http.errback { raise 'save_doc failed' }
|
76
|
-
Fiber.yield
|
77
|
-
end
|
78
|
-
|
79
|
-
def database(method=:put)
|
80
|
-
fiber = Fiber.current
|
81
|
-
http = EM::HttpRequest.new(URL).send(method)
|
82
|
-
http.callback { fiber.resume }
|
83
|
-
http.errback { raise "#{method} database failed" }
|
84
|
-
Fiber.yield
|
85
|
-
end
|
86
|
-
|
87
|
-
def storage
|
88
|
-
Vines::Storage::CouchDB.new do
|
89
|
-
host 'localhost'
|
90
|
-
port 5984
|
91
|
-
database 'xmpp_testcase'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_init
|
96
|
-
EMLoop.new do
|
97
|
-
assert_raises(RuntimeError) { Vines::Storage::CouchDB.new {} }
|
98
|
-
assert_raises(RuntimeError) { Vines::Storage::CouchDB.new { host 'localhost' } }
|
99
|
-
# shouldn't raise an error
|
100
|
-
Vines::Storage::CouchDB.new do
|
101
|
-
host 'localhost'
|
102
|
-
port '5984'
|
103
|
-
database 'test'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
data/test/storage/mock_mongo.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# A mock implementation of the Mongo::Connection class.
|
4
|
-
class MockMongo
|
5
|
-
def initialize
|
6
|
-
@collections = collections
|
7
|
-
end
|
8
|
-
|
9
|
-
def collection(name)
|
10
|
-
@collections[name]
|
11
|
-
end
|
12
|
-
|
13
|
-
def clear
|
14
|
-
@collections = collections
|
15
|
-
end
|
16
|
-
|
17
|
-
def collections
|
18
|
-
{
|
19
|
-
users: MockCollection.new,
|
20
|
-
vcards: MockCollection.new,
|
21
|
-
fragments: MockCollection.new
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
class MockCollection
|
26
|
-
def initialize
|
27
|
-
@docs = {}
|
28
|
-
end
|
29
|
-
|
30
|
-
def find_one(doc)
|
31
|
-
id = doc['_id'] || doc[:_id]
|
32
|
-
@docs[id]
|
33
|
-
end
|
34
|
-
|
35
|
-
def save(doc, opts={})
|
36
|
-
id = doc['_id'] || doc[:_id]
|
37
|
-
@docs[id] = doc
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'mock_mongo'
|
4
|
-
require 'storage_tests'
|
5
|
-
require 'vines'
|
6
|
-
require 'minitest/autorun'
|
7
|
-
|
8
|
-
class MongoDBTest < MiniTest::Unit::TestCase
|
9
|
-
include StorageTests
|
10
|
-
|
11
|
-
MOCK_MONGO = MockMongo.new
|
12
|
-
|
13
|
-
def setup
|
14
|
-
EMLoop.new do
|
15
|
-
db = MOCK_MONGO
|
16
|
-
db.collection(:users).save({'_id' => 'empty@wonderland.lit'})
|
17
|
-
db.collection(:users).save({'_id' => 'no_password@wonderland.lit', 'foo' => 'bar'})
|
18
|
-
db.collection(:users).save({'_id' => 'clear_password@wonderland.lit', 'password' => 'secret'})
|
19
|
-
db.collection(:users).save({'_id' => 'bcrypt_password@wonderland.lit', 'password' => BCrypt::Password.create('secret')})
|
20
|
-
db.collection(:users).save({
|
21
|
-
'_id' => 'full@wonderland.lit',
|
22
|
-
'password' => BCrypt::Password.create('secret'),
|
23
|
-
'name' => 'Tester',
|
24
|
-
'roster' => {
|
25
|
-
'contact1@wonderland.lit' => {
|
26
|
-
'name' => 'Contact1',
|
27
|
-
'groups' => %w[Group1 Group2]
|
28
|
-
},
|
29
|
-
'contact2@wonderland.lit' => {
|
30
|
-
'name' => 'Contact2',
|
31
|
-
'groups' => %w[Group3 Group4]
|
32
|
-
}
|
33
|
-
}
|
34
|
-
})
|
35
|
-
db.collection(:vcards).save({'_id' => 'full@wonderland.lit', 'card' => VCARD.to_xml})
|
36
|
-
db.collection(:fragments).save({'_id' => "full@wonderland.lit:#{FRAGMENT_ID}", 'xml' => FRAGMENT.to_xml})
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def teardown
|
41
|
-
MOCK_MONGO.clear
|
42
|
-
end
|
43
|
-
|
44
|
-
def storage
|
45
|
-
storage = Vines::Storage::MongoDB.new do
|
46
|
-
host 'localhost', 27017
|
47
|
-
database 'xmpp_testcase'
|
48
|
-
end
|
49
|
-
def storage.db
|
50
|
-
MongoDBTest::MOCK_MONGO
|
51
|
-
end
|
52
|
-
storage
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_init
|
56
|
-
EMLoop.new do
|
57
|
-
# missing database
|
58
|
-
assert_raises(RuntimeError) { Vines::Storage::MongoDB.new {} }
|
59
|
-
# missing a host
|
60
|
-
assert_raises(RuntimeError) { Vines::Storage::MongoDB.new { database 'test' } }
|
61
|
-
# duplicate hosts
|
62
|
-
assert_raises(RuntimeError) do
|
63
|
-
Vines::Storage::MongoDB.new do
|
64
|
-
host 'localhost', 27017
|
65
|
-
host 'localhost', 27017
|
66
|
-
database 'test'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
# shouldn't raise an error
|
70
|
-
Vines::Storage::MongoDB.new do
|
71
|
-
host 'localhost', 27017
|
72
|
-
database 'test'
|
73
|
-
end
|
74
|
-
Vines::Storage::MongoDB.new do
|
75
|
-
host 'localhost', 27017
|
76
|
-
host 'localhost', 27018
|
77
|
-
database 'test'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/test/storage/redis_test.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'mock_redis'
|
4
|
-
require 'storage_tests'
|
5
|
-
require 'vines'
|
6
|
-
require 'minitest/autorun'
|
7
|
-
|
8
|
-
class RedisTest < MiniTest::Unit::TestCase
|
9
|
-
include StorageTests
|
10
|
-
|
11
|
-
MOCK_REDIS = MockRedis.new
|
12
|
-
|
13
|
-
def setup
|
14
|
-
EMLoop.new do
|
15
|
-
db = MOCK_REDIS
|
16
|
-
db.set('user:empty@wonderland.lit', {}.to_json)
|
17
|
-
db.set('user:no_password@wonderland.lit', {'foo' => 'bar'}.to_json)
|
18
|
-
db.set('user:clear_password@wonderland.lit', {'password' => 'secret'}.to_json)
|
19
|
-
db.set('user:bcrypt_password@wonderland.lit', {'password' => BCrypt::Password.create('secret')}.to_json)
|
20
|
-
db.set('user:full@wonderland.lit', {
|
21
|
-
'password' => BCrypt::Password.create('secret'),
|
22
|
-
'name' => 'Tester'
|
23
|
-
}.to_json)
|
24
|
-
db.hmset('roster:full@wonderland.lit',
|
25
|
-
'contact1@wonderland.lit',
|
26
|
-
{'name' => 'Contact1', 'groups' => %w[Group1 Group2]}.to_json,
|
27
|
-
'contact2@wonderland.lit',
|
28
|
-
{'name' => 'Contact2', 'groups' => %w[Group3 Group4]}.to_json)
|
29
|
-
db.set('vcard:full@wonderland.lit', {'card' => VCARD.to_xml}.to_json)
|
30
|
-
db.hset('fragments:full@wonderland.lit', FRAGMENT_ID, {'xml' => FRAGMENT.to_xml}.to_json)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def teardown
|
35
|
-
MOCK_REDIS.flushdb
|
36
|
-
end
|
37
|
-
|
38
|
-
def storage
|
39
|
-
storage = Vines::Storage::Redis.new { host 'localhost'; port 6397 }
|
40
|
-
def storage.redis; RedisTest::MOCK_REDIS; end
|
41
|
-
storage
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_init_raises_no_errors
|
45
|
-
EMLoop.new do
|
46
|
-
Vines::Storage::Redis.new {}
|
47
|
-
Vines::Storage::Redis.new { host 'localhost' }
|
48
|
-
Vines::Storage::Redis.new { host'localhost'; port '6379' }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/test/storage/sql_test.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'storage_tests'
|
4
|
-
require 'vines'
|
5
|
-
require 'minitest/autorun'
|
6
|
-
|
7
|
-
class SqlTest < MiniTest::Unit::TestCase
|
8
|
-
include StorageTests
|
9
|
-
|
10
|
-
DB_FILE = "./xmpp_testcase.db"
|
11
|
-
ActiveRecord::Migration.verbose = false
|
12
|
-
|
13
|
-
def setup
|
14
|
-
storage.create_schema(:force => true)
|
15
|
-
Vines::Storage::Sql::User.new(:jid => 'empty@wonderland.lit', :name => '', :password => '').save
|
16
|
-
Vines::Storage::Sql::User.new(:jid => 'no_password@wonderland.lit', :name => '', :password => '').save
|
17
|
-
Vines::Storage::Sql::User.new(:jid => 'clear_password@wonderland.lit', :name => '',
|
18
|
-
:password => 'secret').save
|
19
|
-
Vines::Storage::Sql::User.new(:jid => 'bcrypt_password@wonderland.lit', :name => '',
|
20
|
-
:password => BCrypt::Password.create('secret')).save
|
21
|
-
groups = %w[Group1 Group2 Group3 Group4].map do |name|
|
22
|
-
Vines::Storage::Sql::Group.find_or_create_by_name(name)
|
23
|
-
end
|
24
|
-
full = Vines::Storage::Sql::User.new(
|
25
|
-
:jid => 'full@wonderland.lit',
|
26
|
-
:name => 'Tester',
|
27
|
-
:password => BCrypt::Password.create('secret'),
|
28
|
-
:vcard => VCARD.to_xml)
|
29
|
-
full.contacts << Vines::Storage::Sql::Contact.new(
|
30
|
-
:jid => 'contact1@wonderland.lit',
|
31
|
-
:name => 'Contact1',
|
32
|
-
:groups => groups[0, 2],
|
33
|
-
:subscription => 'both')
|
34
|
-
full.contacts << Vines::Storage::Sql::Contact.new(
|
35
|
-
:jid => 'contact2@wonderland.lit',
|
36
|
-
:name => 'Contact2',
|
37
|
-
:groups => groups[2, 2],
|
38
|
-
:subscription => 'both')
|
39
|
-
full.save
|
40
|
-
|
41
|
-
fragment = Vines::Storage::Sql::Fragment.new(
|
42
|
-
:user => full,
|
43
|
-
:root => 'characters',
|
44
|
-
:namespace => 'urn:wonderland',
|
45
|
-
:xml => FRAGMENT.to_xml)
|
46
|
-
fragment.save
|
47
|
-
end
|
48
|
-
|
49
|
-
def teardown
|
50
|
-
File.delete(DB_FILE) if File.exist?(DB_FILE)
|
51
|
-
end
|
52
|
-
|
53
|
-
def storage
|
54
|
-
Vines::Storage::Sql.new { adapter 'sqlite3'; database DB_FILE }
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_init
|
58
|
-
assert_raises(RuntimeError) { Vines::Storage::Sql.new {} }
|
59
|
-
assert_raises(RuntimeError) { Vines::Storage::Sql.new { adapter 'postgresql' } }
|
60
|
-
Vines::Storage::Sql.new { adapter 'sqlite3'; database ':memory:' } # shouldn't raise an error
|
61
|
-
end
|
62
|
-
end
|