vines 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/LICENSE +19 -0
  2. data/README +34 -0
  3. data/Rakefile +55 -0
  4. data/bin/vines +95 -0
  5. data/conf/certs/README +32 -0
  6. data/conf/certs/ca-bundle.crt +3987 -0
  7. data/conf/config.rb +114 -0
  8. data/lib/vines.rb +155 -0
  9. data/lib/vines/command/bcrypt.rb +12 -0
  10. data/lib/vines/command/cert.rb +49 -0
  11. data/lib/vines/command/init.rb +58 -0
  12. data/lib/vines/command/ldap.rb +35 -0
  13. data/lib/vines/command/restart.rb +12 -0
  14. data/lib/vines/command/schema.rb +24 -0
  15. data/lib/vines/command/start.rb +28 -0
  16. data/lib/vines/command/stop.rb +18 -0
  17. data/lib/vines/config.rb +191 -0
  18. data/lib/vines/contact.rb +99 -0
  19. data/lib/vines/daemon.rb +78 -0
  20. data/lib/vines/error.rb +150 -0
  21. data/lib/vines/jid.rb +56 -0
  22. data/lib/vines/kit.rb +23 -0
  23. data/lib/vines/router.rb +125 -0
  24. data/lib/vines/stanza.rb +55 -0
  25. data/lib/vines/stanza/iq.rb +50 -0
  26. data/lib/vines/stanza/iq/auth.rb +18 -0
  27. data/lib/vines/stanza/iq/disco_info.rb +25 -0
  28. data/lib/vines/stanza/iq/disco_items.rb +23 -0
  29. data/lib/vines/stanza/iq/error.rb +16 -0
  30. data/lib/vines/stanza/iq/ping.rb +16 -0
  31. data/lib/vines/stanza/iq/query.rb +10 -0
  32. data/lib/vines/stanza/iq/result.rb +16 -0
  33. data/lib/vines/stanza/iq/roster.rb +153 -0
  34. data/lib/vines/stanza/iq/session.rb +22 -0
  35. data/lib/vines/stanza/iq/vcard.rb +58 -0
  36. data/lib/vines/stanza/message.rb +41 -0
  37. data/lib/vines/stanza/presence.rb +119 -0
  38. data/lib/vines/stanza/presence/error.rb +23 -0
  39. data/lib/vines/stanza/presence/probe.rb +38 -0
  40. data/lib/vines/stanza/presence/subscribe.rb +66 -0
  41. data/lib/vines/stanza/presence/subscribed.rb +64 -0
  42. data/lib/vines/stanza/presence/unavailable.rb +15 -0
  43. data/lib/vines/stanza/presence/unsubscribe.rb +57 -0
  44. data/lib/vines/stanza/presence/unsubscribed.rb +50 -0
  45. data/lib/vines/storage.rb +216 -0
  46. data/lib/vines/storage/couchdb.rb +119 -0
  47. data/lib/vines/storage/ldap.rb +59 -0
  48. data/lib/vines/storage/local.rb +66 -0
  49. data/lib/vines/storage/redis.rb +108 -0
  50. data/lib/vines/storage/sql.rb +174 -0
  51. data/lib/vines/store.rb +51 -0
  52. data/lib/vines/stream.rb +198 -0
  53. data/lib/vines/stream/client.rb +131 -0
  54. data/lib/vines/stream/client/auth.rb +94 -0
  55. data/lib/vines/stream/client/auth_restart.rb +33 -0
  56. data/lib/vines/stream/client/bind.rb +58 -0
  57. data/lib/vines/stream/client/bind_restart.rb +25 -0
  58. data/lib/vines/stream/client/closed.rb +13 -0
  59. data/lib/vines/stream/client/ready.rb +15 -0
  60. data/lib/vines/stream/client/start.rb +27 -0
  61. data/lib/vines/stream/client/tls.rb +37 -0
  62. data/lib/vines/stream/component.rb +53 -0
  63. data/lib/vines/stream/component/handshake.rb +25 -0
  64. data/lib/vines/stream/component/ready.rb +24 -0
  65. data/lib/vines/stream/component/start.rb +19 -0
  66. data/lib/vines/stream/http.rb +111 -0
  67. data/lib/vines/stream/http/http_request.rb +22 -0
  68. data/lib/vines/stream/http/http_state.rb +139 -0
  69. data/lib/vines/stream/http/http_states.rb +53 -0
  70. data/lib/vines/stream/parser.rb +78 -0
  71. data/lib/vines/stream/server.rb +126 -0
  72. data/lib/vines/stream/server/auth.rb +13 -0
  73. data/lib/vines/stream/server/auth_restart.rb +19 -0
  74. data/lib/vines/stream/server/final_restart.rb +20 -0
  75. data/lib/vines/stream/server/outbound/auth.rb +31 -0
  76. data/lib/vines/stream/server/outbound/auth_restart.rb +20 -0
  77. data/lib/vines/stream/server/outbound/auth_result.rb +28 -0
  78. data/lib/vines/stream/server/outbound/final_features.rb +27 -0
  79. data/lib/vines/stream/server/outbound/final_restart.rb +20 -0
  80. data/lib/vines/stream/server/outbound/start.rb +20 -0
  81. data/lib/vines/stream/server/outbound/tls.rb +30 -0
  82. data/lib/vines/stream/server/outbound/tls_result.rb +31 -0
  83. data/lib/vines/stream/server/ready.rb +20 -0
  84. data/lib/vines/stream/server/start.rb +13 -0
  85. data/lib/vines/stream/server/tls.rb +13 -0
  86. data/lib/vines/stream/state.rb +55 -0
  87. data/lib/vines/token_bucket.rb +46 -0
  88. data/lib/vines/user.rb +124 -0
  89. data/lib/vines/version.rb +5 -0
  90. data/lib/vines/xmpp_server.rb +25 -0
  91. data/test/config_test.rb +396 -0
  92. data/test/error_test.rb +59 -0
  93. data/test/ext/nokogiri.rb +14 -0
  94. data/test/jid_test.rb +71 -0
  95. data/test/kit_test.rb +21 -0
  96. data/test/router_test.rb +60 -0
  97. data/test/stanza/iq/roster_test.rb +198 -0
  98. data/test/stanza/iq/session_test.rb +30 -0
  99. data/test/stanza/iq/vcard_test.rb +159 -0
  100. data/test/stanza/message_test.rb +124 -0
  101. data/test/stanza/presence/subscribe_test.rb +75 -0
  102. data/test/storage/couchdb_test.rb +102 -0
  103. data/test/storage/ldap_test.rb +207 -0
  104. data/test/storage/local_test.rb +54 -0
  105. data/test/storage/redis_test.rb +75 -0
  106. data/test/storage/sql_test.rb +55 -0
  107. data/test/storage/storage_tests.rb +134 -0
  108. data/test/storage_test.rb +90 -0
  109. data/test/stream/client/auth_test.rb +127 -0
  110. data/test/stream/client/ready_test.rb +47 -0
  111. data/test/stream/component/handshake_test.rb +46 -0
  112. data/test/stream/component/ready_test.rb +105 -0
  113. data/test/stream/component/start_test.rb +41 -0
  114. data/test/stream/parser_test.rb +121 -0
  115. data/test/stream/server/outbound/auth_test.rb +77 -0
  116. data/test/stream/server/ready_test.rb +100 -0
  117. data/test/token_bucket_test.rb +24 -0
  118. data/test/user_test.rb +64 -0
  119. metadata +318 -0
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'vines'
4
+ require 'test/unit'
5
+
6
+ class TokenBucketTest < Test::Unit::TestCase
7
+ def test_init
8
+ assert_raises(ArgumentError) { Vines::TokenBucket.new(0, 1) }
9
+ assert_raises(ArgumentError) { Vines::TokenBucket.new(1, 0) }
10
+ assert_raises(ArgumentError) { Vines::TokenBucket.new(-1, 1) }
11
+ assert_raises(ArgumentError) { Vines::TokenBucket.new(1, -1) }
12
+ end
13
+
14
+ def test_take
15
+ bucket = Vines::TokenBucket.new(10, 1)
16
+ assert_raises(ArgumentError) { bucket.take(-1) }
17
+ assert(!bucket.take(11))
18
+ assert(bucket.take(10))
19
+ assert(!bucket.take(1))
20
+ sleep(1)
21
+ assert(bucket.take(1))
22
+ assert(!bucket.take(1))
23
+ end
24
+ end
data/test/user_test.rb ADDED
@@ -0,0 +1,64 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'vines'
4
+ require 'test/unit'
5
+
6
+ class UserTest < Test::Unit::TestCase
7
+ def test_equality
8
+ alice = Vines::User.new(:jid => 'alice@wonderland.lit')
9
+ alice2 = Vines::User.new(:jid => 'alice@wonderland.lit')
10
+ hatter = Vines::User.new(:jid => 'hatter@wonderland.lit')
11
+
12
+ assert alice == alice2
13
+ assert alice.eql?(alice2)
14
+ assert alice.hash == alice2.hash
15
+
16
+ assert alice != hatter
17
+ assert !alice.eql?(hatter)
18
+ assert alice.hash != hatter.hash
19
+ end
20
+
21
+ def test_initialize_missing_jid
22
+ assert_raises(ArgumentError) { Vines::User.new }
23
+ end
24
+
25
+ def test_initialize_missing_roster
26
+ user = Vines::User.new(:jid => 'alice@wonderland.lit')
27
+ assert_not_nil user.roster
28
+ assert_equal 0, user.roster.size
29
+ end
30
+
31
+ def test_update_from
32
+ user = Vines::User.new(:jid => 'alice@wonderland.lit', :name => 'Alice', :password => "secr3t")
33
+ user.roster << Vines::Contact.new(:jid => 'hatter@wonderland.lit', :name => "Hatter")
34
+
35
+ updated = Vines::User.new(:jid => 'alice2@wonderland.lit', :name => 'Alice 2', :password => "secr3t 2")
36
+ updated.roster << Vines::Contact.new(:jid => 'cat@wonderland.lit', :name => "Cheshire")
37
+
38
+ user.update_from(updated)
39
+ assert_equal 'alice@wonderland.lit', user.jid.to_s
40
+ assert_equal 'Alice 2', user.name
41
+ assert_equal 'secr3t 2', user.password
42
+ assert_equal 1, user.roster.size
43
+ assert_equal Vines::Contact.new(:jid => 'cat@wonderland.lit'), user.roster.first
44
+ # make sure we cloned roster entries
45
+ updated.roster.first.name = 'Updated Contact 2'
46
+ assert_equal 'Cheshire', user.roster.first.name
47
+ end
48
+
49
+ def test_to_roster_xml_contacts_and_groups_are_sorted
50
+ user = Vines::User.new(:jid => 'alice@wonderland.lit', :name => 'Alice', :password => "secr3t")
51
+ user.roster << Vines::Contact.new(:jid => 'b@wonderland.lit', :name => "Contact 2", :groups => %w[C])
52
+ user.roster << Vines::Contact.new(:jid => 'a@wonderland.lit', :name => "Contact 1", :groups => %w[B A])
53
+
54
+ expected = %q{
55
+ <iq id="42" type="result">
56
+ <query xmlns="jabber:iq:roster">
57
+ <item jid="a@wonderland.lit" name="Contact 1" subscription="none"><group>A</group><group>B</group></item>
58
+ <item jid="b@wonderland.lit" name="Contact 2" subscription="none"><group>C</group></item>
59
+ </query>
60
+ </iq>}.strip.gsub(/\n/, '').gsub(/\s{2,}/, '')
61
+
62
+ assert_equal expected, user.to_roster_xml(42).to_xml(:indent => 0).gsub(/\n/, '')
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,318 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vines
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - David Graham
9
+ - Chris Johnson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-05-08 00:00:00 -06:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: activerecord
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: "3.0"
26
+ type: :runtime
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
29
+ name: bcrypt-ruby
30
+ prerelease: false
31
+ requirement: &id002 !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: "2.1"
37
+ type: :runtime
38
+ version_requirements: *id002
39
+ - !ruby/object:Gem::Dependency
40
+ name: em-http-request
41
+ prerelease: false
42
+ requirement: &id003 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0.beta.3
48
+ type: :runtime
49
+ version_requirements: *id003
50
+ - !ruby/object:Gem::Dependency
51
+ name: em-redis
52
+ prerelease: false
53
+ requirement: &id004 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: "0.3"
59
+ type: :runtime
60
+ version_requirements: *id004
61
+ - !ruby/object:Gem::Dependency
62
+ name: eventmachine
63
+ prerelease: false
64
+ requirement: &id005 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0.beta.3
70
+ type: :runtime
71
+ version_requirements: *id005
72
+ - !ruby/object:Gem::Dependency
73
+ name: net-ldap
74
+ prerelease: false
75
+ requirement: &id006 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ~>
79
+ - !ruby/object:Gem::Version
80
+ version: "0.2"
81
+ type: :runtime
82
+ version_requirements: *id006
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ prerelease: false
86
+ requirement: &id007 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: "1.4"
92
+ type: :runtime
93
+ version_requirements: *id007
94
+ - !ruby/object:Gem::Dependency
95
+ name: thin
96
+ prerelease: false
97
+ requirement: &id008 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: "1.2"
103
+ type: :runtime
104
+ version_requirements: *id008
105
+ - !ruby/object:Gem::Dependency
106
+ name: rake
107
+ prerelease: false
108
+ requirement: &id009 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ type: :development
115
+ version_requirements: *id009
116
+ - !ruby/object:Gem::Dependency
117
+ name: sqlite3
118
+ prerelease: false
119
+ requirement: &id010 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: "0"
125
+ type: :development
126
+ version_requirements: *id010
127
+ description: |-
128
+ Vines is an XMPP chat server that supports thousands of
129
+ simultaneous connections by using EventMachine for asynchronous IO. User data
130
+ is stored in a SQL database, CouchDB, Redis, the file system, or a custom storage
131
+ implementation that you provide. LDAP authentication can be used so user names
132
+ and passwords aren't stored in the chat database. SSL encryption is mandatory on
133
+ all client and server connections.
134
+ email:
135
+ - david@negativecode.com
136
+ - chris@negativecode.com
137
+ executables:
138
+ - vines
139
+ extensions: []
140
+
141
+ extra_rdoc_files: []
142
+
143
+ files:
144
+ - LICENSE
145
+ - Rakefile
146
+ - README
147
+ - bin/vines
148
+ - lib/vines/command/bcrypt.rb
149
+ - lib/vines/command/cert.rb
150
+ - lib/vines/command/init.rb
151
+ - lib/vines/command/ldap.rb
152
+ - lib/vines/command/restart.rb
153
+ - lib/vines/command/schema.rb
154
+ - lib/vines/command/start.rb
155
+ - lib/vines/command/stop.rb
156
+ - lib/vines/config.rb
157
+ - lib/vines/contact.rb
158
+ - lib/vines/daemon.rb
159
+ - lib/vines/error.rb
160
+ - lib/vines/jid.rb
161
+ - lib/vines/kit.rb
162
+ - lib/vines/router.rb
163
+ - lib/vines/stanza/iq/auth.rb
164
+ - lib/vines/stanza/iq/disco_info.rb
165
+ - lib/vines/stanza/iq/disco_items.rb
166
+ - lib/vines/stanza/iq/error.rb
167
+ - lib/vines/stanza/iq/ping.rb
168
+ - lib/vines/stanza/iq/query.rb
169
+ - lib/vines/stanza/iq/result.rb
170
+ - lib/vines/stanza/iq/roster.rb
171
+ - lib/vines/stanza/iq/session.rb
172
+ - lib/vines/stanza/iq/vcard.rb
173
+ - lib/vines/stanza/iq.rb
174
+ - lib/vines/stanza/message.rb
175
+ - lib/vines/stanza/presence/error.rb
176
+ - lib/vines/stanza/presence/probe.rb
177
+ - lib/vines/stanza/presence/subscribe.rb
178
+ - lib/vines/stanza/presence/subscribed.rb
179
+ - lib/vines/stanza/presence/unavailable.rb
180
+ - lib/vines/stanza/presence/unsubscribe.rb
181
+ - lib/vines/stanza/presence/unsubscribed.rb
182
+ - lib/vines/stanza/presence.rb
183
+ - lib/vines/stanza.rb
184
+ - lib/vines/storage/couchdb.rb
185
+ - lib/vines/storage/ldap.rb
186
+ - lib/vines/storage/local.rb
187
+ - lib/vines/storage/redis.rb
188
+ - lib/vines/storage/sql.rb
189
+ - lib/vines/storage.rb
190
+ - lib/vines/store.rb
191
+ - lib/vines/stream/client/auth.rb
192
+ - lib/vines/stream/client/auth_restart.rb
193
+ - lib/vines/stream/client/bind.rb
194
+ - lib/vines/stream/client/bind_restart.rb
195
+ - lib/vines/stream/client/closed.rb
196
+ - lib/vines/stream/client/ready.rb
197
+ - lib/vines/stream/client/start.rb
198
+ - lib/vines/stream/client/tls.rb
199
+ - lib/vines/stream/client.rb
200
+ - lib/vines/stream/component/handshake.rb
201
+ - lib/vines/stream/component/ready.rb
202
+ - lib/vines/stream/component/start.rb
203
+ - lib/vines/stream/component.rb
204
+ - lib/vines/stream/http/http_request.rb
205
+ - lib/vines/stream/http/http_state.rb
206
+ - lib/vines/stream/http/http_states.rb
207
+ - lib/vines/stream/http.rb
208
+ - lib/vines/stream/parser.rb
209
+ - lib/vines/stream/server/auth.rb
210
+ - lib/vines/stream/server/auth_restart.rb
211
+ - lib/vines/stream/server/final_restart.rb
212
+ - lib/vines/stream/server/outbound/auth.rb
213
+ - lib/vines/stream/server/outbound/auth_restart.rb
214
+ - lib/vines/stream/server/outbound/auth_result.rb
215
+ - lib/vines/stream/server/outbound/final_features.rb
216
+ - lib/vines/stream/server/outbound/final_restart.rb
217
+ - lib/vines/stream/server/outbound/start.rb
218
+ - lib/vines/stream/server/outbound/tls.rb
219
+ - lib/vines/stream/server/outbound/tls_result.rb
220
+ - lib/vines/stream/server/ready.rb
221
+ - lib/vines/stream/server/start.rb
222
+ - lib/vines/stream/server/tls.rb
223
+ - lib/vines/stream/server.rb
224
+ - lib/vines/stream/state.rb
225
+ - lib/vines/stream.rb
226
+ - lib/vines/token_bucket.rb
227
+ - lib/vines/user.rb
228
+ - lib/vines/version.rb
229
+ - lib/vines/xmpp_server.rb
230
+ - lib/vines.rb
231
+ - conf/certs/ca-bundle.crt
232
+ - conf/certs/README
233
+ - conf/config.rb
234
+ - test/config_test.rb
235
+ - test/error_test.rb
236
+ - test/ext/nokogiri.rb
237
+ - test/jid_test.rb
238
+ - test/kit_test.rb
239
+ - test/router_test.rb
240
+ - test/stanza/iq/roster_test.rb
241
+ - test/stanza/iq/session_test.rb
242
+ - test/stanza/iq/vcard_test.rb
243
+ - test/stanza/message_test.rb
244
+ - test/stanza/presence/subscribe_test.rb
245
+ - test/storage/couchdb_test.rb
246
+ - test/storage/ldap_test.rb
247
+ - test/storage/local_test.rb
248
+ - test/storage/redis_test.rb
249
+ - test/storage/sql_test.rb
250
+ - test/storage/storage_tests.rb
251
+ - test/storage_test.rb
252
+ - test/stream/client/auth_test.rb
253
+ - test/stream/client/ready_test.rb
254
+ - test/stream/component/handshake_test.rb
255
+ - test/stream/component/ready_test.rb
256
+ - test/stream/component/start_test.rb
257
+ - test/stream/parser_test.rb
258
+ - test/stream/server/outbound/auth_test.rb
259
+ - test/stream/server/ready_test.rb
260
+ - test/token_bucket_test.rb
261
+ - test/user_test.rb
262
+ has_rdoc: true
263
+ homepage: http://www.getvines.com
264
+ licenses: []
265
+
266
+ post_install_message:
267
+ rdoc_options: []
268
+
269
+ require_paths:
270
+ - lib
271
+ required_ruby_version: !ruby/object:Gem::Requirement
272
+ none: false
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: 1.9.1
277
+ required_rubygems_version: !ruby/object:Gem::Requirement
278
+ none: false
279
+ requirements:
280
+ - - ">="
281
+ - !ruby/object:Gem::Version
282
+ version: "0"
283
+ requirements: []
284
+
285
+ rubyforge_project:
286
+ rubygems_version: 1.6.2
287
+ signing_key:
288
+ specification_version: 3
289
+ summary: Vines is an XMPP chat server that's easy to install and run.
290
+ test_files:
291
+ - test/config_test.rb
292
+ - test/error_test.rb
293
+ - test/ext/nokogiri.rb
294
+ - test/jid_test.rb
295
+ - test/kit_test.rb
296
+ - test/router_test.rb
297
+ - test/stanza/iq/roster_test.rb
298
+ - test/stanza/iq/session_test.rb
299
+ - test/stanza/iq/vcard_test.rb
300
+ - test/stanza/message_test.rb
301
+ - test/stanza/presence/subscribe_test.rb
302
+ - test/storage/couchdb_test.rb
303
+ - test/storage/ldap_test.rb
304
+ - test/storage/local_test.rb
305
+ - test/storage/redis_test.rb
306
+ - test/storage/sql_test.rb
307
+ - test/storage/storage_tests.rb
308
+ - test/storage_test.rb
309
+ - test/stream/client/auth_test.rb
310
+ - test/stream/client/ready_test.rb
311
+ - test/stream/component/handshake_test.rb
312
+ - test/stream/component/ready_test.rb
313
+ - test/stream/component/start_test.rb
314
+ - test/stream/parser_test.rb
315
+ - test/stream/server/outbound/auth_test.rb
316
+ - test/stream/server/ready_test.rb
317
+ - test/token_bucket_test.rb
318
+ - test/user_test.rb