blather 0.8.1 → 0.8.2

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.
@@ -1,33 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Blather::Stream::Component do
4
- class MockServer; end
5
- module ServerMock
6
- def receive_data(data)
7
- @server ||= MockServer.new
8
- @server.receive_data data, self
4
+ let(:client) { mock 'Client' }
5
+ let(:server_port) { 50000 - rand(1000) }
6
+ let(:jid) { 'comp.id' }
7
+
8
+ before do
9
+ [:unbind, :post_init, :jid=].each do |m|
10
+ client.stubs(m) unless client.respond_to?(m)
9
11
  end
12
+ client.stubs(:jid).returns jid
10
13
  end
11
14
 
12
15
  def mocked_server(times = nil, &block)
13
- @client ||= mock()
14
- @client.stubs(:unbind) unless @client.respond_to?(:unbind)
15
- @client.stubs(:jid=) unless @client.respond_to?(:jid=)
16
-
17
- port = 50000 - rand(1000)
18
-
19
16
  MockServer.any_instance.expects(:receive_data).send(*(times ? [:times, times] : [:at_least, 1])).with &block
20
17
  EventMachine::run {
21
18
  # Mocked server
22
- EventMachine::start_server '127.0.0.1', port, ServerMock
19
+ EventMachine::start_server '127.0.0.1', server_port, ServerMock
23
20
 
24
21
  # Blather::Stream connection
25
- EM.connect('127.0.0.1', port, Blather::Stream::Component, @client, @jid || 'comp.id', 'secret') { |c| @stream = c }
22
+ EM.connect('127.0.0.1', server_port, Blather::Stream::Component, client, jid, 'secret') { |c| @stream = c }
26
23
  }
27
24
  end
28
25
 
26
+ after { sleep 0.1; @stream.cleanup if @stream }
27
+
29
28
  it 'can be started' do
30
- client = mock()
31
29
  params = [client, 'comp.id', 'secret', 'host', 1234]
32
30
  EM.expects(:connect).with do |*parms|
33
31
  parms[0] == 'host' &&
@@ -58,12 +56,11 @@ describe Blather::Stream::Component do
58
56
  end
59
57
 
60
58
  it 'raises a NoConnection exception if the connection is unbound before it can be completed' do
61
- @client = mock
62
59
  proc do
63
60
  EventMachine::run {
64
61
  EM.add_timer(0.5) { EM.stop if EM.reactor_running? }
65
62
 
66
- Blather::Stream::Component.start @client, @jid || Blather::JID.new('n@d/r'), 'pass', '127.0.0.1', 50000 - rand(1000)
63
+ Blather::Stream::Component.start client, jid, 'pass', '127.0.0.1', 50000 - rand(1000)
67
64
  }
68
65
  end.should raise_error Blather::Stream::ConnectionFailed
69
66
  end
@@ -73,8 +70,8 @@ describe Blather::Stream::Component do
73
70
  end
74
71
 
75
72
  it 'sends stanzas to the client when the stream is ready' do
76
- @client = mock(:post_init)
77
- @client.expects(:receive_data).with do |n|
73
+ client.stubs :post_init
74
+ client.expects(:receive_data).with do |n|
78
75
  EM.stop
79
76
  n.kind_of? Blather::XMPPNode
80
77
  end
@@ -97,9 +94,8 @@ describe Blather::Stream::Component do
97
94
  end
98
95
 
99
96
  it 'sends stanzas to the wire ensuring "from" is set' do
100
- client = mock()
101
- client.stubs(:jid)
102
- client.stubs(:jid=)
97
+ EM.expects(:next_tick).at_least(1).yields
98
+
103
99
  msg = Blather::Stanza::Message.new 'to@jid.com', 'body'
104
100
  comp = Blather::Stream::Component.new nil, client, 'jid.com', 'pass'
105
101
  comp.expects(:send_data).with { |s| s.should match(/^<message[^>]*from="jid\.com"/) }
@@ -16,6 +16,8 @@ describe Blather::Stream::Parser do
16
16
 
17
17
  subject { Blather::Stream::Parser.new client }
18
18
 
19
+ after { subject.finish }
20
+
19
21
  def process(*data)
20
22
  client.latch = CountDownLatch.new 1
21
23
  data.each { |d| subject.receive_data d }
@@ -1,32 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Blather::CertStore do
4
- before do
5
- @pem = "-----BEGIN CERTIFICATE-----\nMIIDszCCApugAwIBAgIETiZC5TANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJV\nUzERMA8GA1UECAwIQ29sb3JhZG8xDzANBgNVBAcMBkRlbnZlcjEaMBgGA1UECgwR\nVmluZXMgWE1QUCBTZXJ2ZXIxFDASBgNVBAMMC3Z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MDzXB8vTDUE\nWmsD9g0621WqNz2x6lY5IYr7azE2C46Tpb9FOeSAAd83Zka4acaL\n-----END CERTIFICATE-----\n"
6
- @cert = File.open("./test.crt", 'w') {|f| f.write(@pem) }
7
- @store = Blather::CertStore.new("./")
8
- end
4
+ let(:cert_dir) { File.expand_path '../../fixtures', File.dirname(__FILE__) }
5
+ let(:cert_path) { File.join cert_dir, 'certificate.crt' }
6
+ let(:cert) { File.read cert_path }
9
7
 
10
- after do
11
- File.delete("./test.crt")
8
+ subject do
9
+ Blather::CertStore.new cert_dir
12
10
  end
13
11
 
14
12
  it 'can verify valid cert' do
15
- @store.trusted?(@pem).tap do |trusted|
16
- trusted.should == true
17
- end
13
+ subject.trusted?(cert).should be_true
18
14
  end
19
15
 
20
16
  it 'can verify invalid cert' do
21
- @store.trusted?(@pem.gsub("L", "a")).tap do |trusted|
22
- trusted.should == nil
23
- end
17
+ subject.trusted?(cert[0..(cert.length/2)]).should be_nil
24
18
  end
25
19
 
26
- it 'can verify without a cert store' do
20
+ it 'cannot verify when the cert authority is not trusted' do
27
21
  @store = Blather::CertStore.new("../")
28
- @store.trusted?(@pem).tap do |trusted|
29
- trusted.should == true
30
- end
22
+ @store.trusted?(cert).should be_false
31
23
  end
32
24
  end
@@ -31,4 +31,4 @@ describe Blather do
31
31
  end
32
32
 
33
33
  end
34
- end
34
+ end
@@ -0,0 +1,13 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICAzCCAWwCCQDvLJRwh2NPnjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJH
3
+ QjETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
4
+ cyBQdHkgTHRkMCAXDTEyMTIyMDAxMjgyOVoYDzI4MzQwNTA1MDEyODI5WjBFMQsw
5
+ CQYDVQQGEwJHQjETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
6
+ ZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDj
7
+ EoRb/MYNjHrxq6cu6TVyM4hcimy5WWy369BvarONxpmHlrvDUiMQoZNBxyV//hZH
8
+ Y3JSHrNxMCxU1vShghNZzNEZg45UBWMs3LS/IHnFvf+4gYbffEJCGMhjyx4zAxRA
9
+ gegDAYIeGHtWAA6SIe4SIzsMtAJC0Nf8H3AZJdjvSwIDAQABMA0GCSqGSIb3DQEB
10
+ BQUAA4GBAGkyf9MlpCesU7jxiZbI3jIdCEMiG5XsGp0c+nELufcsus4MySN0xZTt
11
+ zvBBvWLpbv8zkxkw+kamvksObslx4G6hg1RvKP/Zdjue5mVnUTNKlXu/wQOTVPNo
12
+ V3iBcJUwe3uIIlt2szA6o5BRt29XSLiNIJvFhAHCVg+3VioXChRr
13
+ -----END CERTIFICATE-----
@@ -1,5 +1,4 @@
1
1
  require 'blather'
2
- require 'mocha'
3
2
  require 'countdownlatch'
4
3
 
5
4
  Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
@@ -0,0 +1,8 @@
1
+ class MockServer; end
2
+
3
+ module ServerMock
4
+ def receive_data(data)
5
+ @server ||= MockServer.new
6
+ @server.receive_data data, self
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-17 00:00:00.000000000 Z
13
+ date: 2013-01-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: eventmachine
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.6
22
+ version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 0.12.6
30
+ version: 1.0.0
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: nokogiri
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -35,7 +35,10 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 1.5.5
38
+ version: '1.5'
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.5.6
39
42
  type: :runtime
40
43
  prerelease: false
41
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +46,10 @@ dependencies:
43
46
  requirements:
44
47
  - - ~>
45
48
  - !ruby/object:Gem::Version
46
- version: 1.5.5
49
+ version: '1.5'
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 1.5.6
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: niceogiri
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +153,7 @@ dependencies:
147
153
  requirements:
148
154
  - - ~>
149
155
  - !ruby/object:Gem::Version
150
- version: 0.9.12
156
+ version: '0.9'
151
157
  type: :development
152
158
  prerelease: false
153
159
  version_requirements: !ruby/object:Gem::Requirement
@@ -155,7 +161,7 @@ dependencies:
155
161
  requirements:
156
162
  - - ~>
157
163
  - !ruby/object:Gem::Version
158
- version: 0.9.12
164
+ version: '0.9'
159
165
  - !ruby/object:Gem::Dependency
160
166
  name: guard-rspec
161
167
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +185,7 @@ dependencies:
179
185
  requirements:
180
186
  - - ~>
181
187
  - !ruby/object:Gem::Version
182
- version: 0.6.1
188
+ version: '0.6'
183
189
  type: :development
184
190
  prerelease: false
185
191
  version_requirements: !ruby/object:Gem::Requirement
@@ -187,7 +193,7 @@ dependencies:
187
193
  requirements:
188
194
  - - ~>
189
195
  - !ruby/object:Gem::Version
190
- version: 0.6.1
196
+ version: '0.6'
191
197
  - !ruby/object:Gem::Dependency
192
198
  name: bluecloth
193
199
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +226,22 @@ dependencies:
220
226
  - - ! '>='
221
227
  - !ruby/object:Gem::Version
222
228
  version: '0'
229
+ - !ruby/object:Gem::Dependency
230
+ name: rb-fsevent
231
+ requirement: !ruby/object:Gem::Requirement
232
+ none: false
233
+ requirements:
234
+ - - ~>
235
+ - !ruby/object:Gem::Version
236
+ version: '0.9'
237
+ type: :development
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ none: false
241
+ requirements:
242
+ - - ~>
243
+ - !ruby/object:Gem::Version
244
+ version: '0.9'
223
245
  description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
224
246
  email: blather@adhearsion.com
225
247
  executables: []
@@ -228,8 +250,6 @@ extra_rdoc_files:
228
250
  - LICENSE
229
251
  - README.md
230
252
  files:
231
- - .autotest
232
- - .gemtest
233
253
  - .gitignore
234
254
  - .rspec
235
255
  - .travis.yml
@@ -239,7 +259,6 @@ files:
239
259
  - LICENSE
240
260
  - README.md
241
261
  - Rakefile
242
- - TODO.md
243
262
  - blather.gemspec
244
263
  - examples/certs/README
245
264
  - examples/certs/ca-bundle.crt
@@ -372,8 +391,10 @@ files:
372
391
  - spec/blather/stream/ssl_spec.rb
373
392
  - spec/blather/xmpp_node_spec.rb
374
393
  - spec/blather_spec.rb
394
+ - spec/fixtures/certificate.crt
375
395
  - spec/fixtures/pubsub.rb
376
396
  - spec/spec_helper.rb
397
+ - spec/support/mock_server.rb
377
398
  - yard/templates/default/class/html/handlers.erb
378
399
  - yard/templates/default/class/setup.rb
379
400
  - yard/templates/default/class/text/handlers.erb
@@ -392,7 +413,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
392
413
  version: '0'
393
414
  segments:
394
415
  - 0
395
- hash: -4475657027413970395
416
+ hash: -2918212399470142251
396
417
  required_rubygems_version: !ruby/object:Gem::Requirement
397
418
  none: false
398
419
  requirements:
@@ -401,10 +422,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
422
  version: '0'
402
423
  segments:
403
424
  - 0
404
- hash: -4475657027413970395
425
+ hash: -2918212399470142251
405
426
  requirements: []
406
427
  rubyforge_project:
407
- rubygems_version: 1.8.23
428
+ rubygems_version: 1.8.24
408
429
  signing_key:
409
430
  specification_version: 3
410
431
  summary: Simpler XMPP built for speed
@@ -461,5 +482,8 @@ test_files:
461
482
  - spec/blather/stream/ssl_spec.rb
462
483
  - spec/blather/xmpp_node_spec.rb
463
484
  - spec/blather_spec.rb
485
+ - spec/fixtures/certificate.crt
464
486
  - spec/fixtures/pubsub.rb
465
487
  - spec/spec_helper.rb
488
+ - spec/support/mock_server.rb
489
+ has_rdoc:
data/.autotest DELETED
@@ -1,13 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- ignore = %w[.git examples ext pkg .DS_Store CHANGELOG LICENSE VERSION.yml README.rdoc .autotest Rakefile blather.gemspec]
3
-
4
- ignore.each { |exception| at.add_exception(exception) }
5
-
6
- at.clear_mappings
7
-
8
- at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| filename }
9
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/#{m[1]}_spec.rb"] }
10
- at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
11
- at.files_matching %r%^spec/.*_spec\.rb$%
12
- }
13
- end
data/.gemtest DELETED
File without changes
data/TODO.md DELETED
@@ -1,2 +0,0 @@
1
- * Cleanup implementation of X stanzas
2
- * Cleanup implementation of PubSub Subscribe Events