blather 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/LICENSE +2 -0
  2. data/README.rdoc +54 -29
  3. data/Rakefile +94 -13
  4. data/VERSION.yml +4 -0
  5. data/examples/drb_client.rb +2 -4
  6. data/examples/echo.rb +13 -8
  7. data/examples/pubsub/cli.rb +64 -0
  8. data/examples/pubsub/ping_pong.rb +18 -0
  9. data/examples/pubsub/pubsub_dsl.rb +52 -0
  10. data/examples/pubsub_client.rb +39 -0
  11. data/examples/rosterprint.rb +14 -0
  12. data/examples/xmpp4r/echo.rb +35 -0
  13. data/ext/extconf.rb +65 -0
  14. data/lib/blather.rb +18 -121
  15. data/lib/blather/client.rb +13 -0
  16. data/lib/blather/client/client.rb +165 -0
  17. data/lib/blather/client/dsl.rb +99 -0
  18. data/lib/blather/client/pubsub.rb +53 -0
  19. data/lib/blather/client/pubsub/node.rb +27 -0
  20. data/lib/blather/core_ext/active_support.rb +1 -0
  21. data/lib/blather/core_ext/libxml.rb +7 -1
  22. data/lib/blather/errors.rb +39 -18
  23. data/lib/blather/errors/sasl_error.rb +87 -0
  24. data/lib/blather/errors/stanza_error.rb +262 -0
  25. data/lib/blather/errors/stream_error.rb +253 -0
  26. data/lib/blather/jid.rb +9 -16
  27. data/lib/blather/roster.rb +9 -0
  28. data/lib/blather/roster_item.rb +7 -4
  29. data/lib/blather/stanza.rb +19 -25
  30. data/lib/blather/stanza/disco.rb +9 -0
  31. data/lib/blather/stanza/disco/disco_info.rb +84 -0
  32. data/lib/blather/stanza/disco/disco_items.rb +59 -0
  33. data/lib/blather/stanza/iq.rb +16 -4
  34. data/lib/blather/stanza/iq/query.rb +6 -4
  35. data/lib/blather/stanza/iq/roster.rb +38 -38
  36. data/lib/blather/stanza/pubsub.rb +33 -0
  37. data/lib/blather/stanza/pubsub/affiliations.rb +52 -0
  38. data/lib/blather/stanza/pubsub/errors.rb +9 -0
  39. data/lib/blather/stanza/pubsub/event.rb +21 -0
  40. data/lib/blather/stanza/pubsub/items.rb +59 -0
  41. data/lib/blather/stanza/pubsub/owner.rb +9 -0
  42. data/lib/blather/stanza/pubsub/subscriptions.rb +57 -0
  43. data/lib/blather/stream.rb +125 -57
  44. data/lib/blather/stream/client.rb +26 -0
  45. data/lib/blather/stream/component.rb +34 -0
  46. data/lib/blather/stream/parser.rb +17 -27
  47. data/lib/blather/stream/resource.rb +21 -24
  48. data/lib/blather/stream/sasl.rb +60 -37
  49. data/lib/blather/stream/session.rb +12 -19
  50. data/lib/blather/stream/stream_handler.rb +39 -0
  51. data/lib/blather/stream/tls.rb +22 -18
  52. data/lib/blather/xmpp_node.rb +91 -17
  53. data/spec/blather/core_ext/libxml_spec.rb +58 -0
  54. data/spec/blather/errors/sasl_error_spec.rb +56 -0
  55. data/spec/blather/errors/stanza_error_spec.rb +148 -0
  56. data/spec/blather/errors/stream_error_spec.rb +114 -0
  57. data/spec/blather/errors_spec.rb +40 -0
  58. data/spec/blather/jid_spec.rb +0 -7
  59. data/spec/blather/roster_item_spec.rb +5 -0
  60. data/spec/blather/roster_spec.rb +6 -6
  61. data/spec/blather/stanza/discos/disco_info_spec.rb +207 -0
  62. data/spec/blather/stanza/discos/disco_items_spec.rb +136 -0
  63. data/spec/blather/stanza/iq/query_spec.rb +9 -2
  64. data/spec/blather/stanza/iq/roster_spec.rb +117 -1
  65. data/spec/blather/stanza/iq_spec.rb +29 -0
  66. data/spec/blather/stanza/presence/subscription_spec.rb +12 -1
  67. data/spec/blather/stanza/presence_spec.rb +29 -0
  68. data/spec/blather/stanza/pubsub/affiliations_spec.rb +46 -0
  69. data/spec/blather/stanza/pubsub/items_spec.rb +59 -0
  70. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +63 -0
  71. data/spec/blather/stanza/pubsub_spec.rb +26 -0
  72. data/spec/blather/stanza_spec.rb +13 -1
  73. data/spec/blather/stream/client_spec.rb +787 -0
  74. data/spec/blather/stream/component_spec.rb +86 -0
  75. data/spec/blather/xmpp_node_spec.rb +75 -22
  76. data/spec/fixtures/pubsub.rb +157 -0
  77. data/spec/spec_helper.rb +6 -14
  78. metadata +86 -74
  79. data/CHANGELOG +0 -5
  80. data/Manifest +0 -47
  81. data/blather.gemspec +0 -41
  82. data/lib/blather/stanza/error.rb +0 -31
  83. data/spec/blather/stream_spec.rb +0 -462
  84. data/spec/build_safe.rb +0 -20
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Smick
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-21 00:00:00 -08:00
12
+ date: 2009-05-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
23
+ version: 0.12.6
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: libxml-ruby
@@ -30,89 +30,85 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.7
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: echoe
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
33
+ version: 1.1.3
44
34
  version:
45
35
  description: An evented XMPP library written on EventMachine and libxml-ruby
46
36
  email: sprsquish@gmail.com
47
37
  executables: []
48
38
 
49
- extensions: []
50
-
39
+ extensions:
40
+ - ext/extconf.rb
51
41
  extra_rdoc_files:
52
- - CHANGELOG
53
- - lib/autotest/discover.rb
54
- - lib/autotest/spec.rb
55
- - lib/blather/core_ext/active_support.rb
56
- - lib/blather/core_ext/libxml.rb
57
- - lib/blather/errors.rb
58
- - lib/blather/jid.rb
59
- - lib/blather/roster.rb
60
- - lib/blather/roster_item.rb
61
- - lib/blather/stanza/error.rb
62
- - lib/blather/stanza/iq/query.rb
63
- - lib/blather/stanza/iq/roster.rb
64
- - lib/blather/stanza/iq.rb
65
- - lib/blather/stanza/message.rb
66
- - lib/blather/stanza/presence/status.rb
67
- - lib/blather/stanza/presence/subscription.rb
68
- - lib/blather/stanza/presence.rb
69
- - lib/blather/stanza.rb
70
- - lib/blather/stream/parser.rb
71
- - lib/blather/stream/resource.rb
72
- - lib/blather/stream/sasl.rb
73
- - lib/blather/stream/session.rb
74
- - lib/blather/stream/tls.rb
75
- - lib/blather/stream.rb
76
- - lib/blather/xmpp_node.rb
77
- - lib/blather.rb
78
42
  - LICENSE
79
43
  - README.rdoc
80
44
  files:
81
- - CHANGELOG
45
+ - LICENSE
46
+ - README.rdoc
47
+ - Rakefile
48
+ - VERSION.yml
82
49
  - examples/drb_client.rb
83
50
  - examples/echo.rb
51
+ - examples/pubsub/cli.rb
52
+ - examples/pubsub/ping_pong.rb
53
+ - examples/pubsub/pubsub_dsl.rb
54
+ - examples/pubsub_client.rb
55
+ - examples/rosterprint.rb
56
+ - examples/xmpp4r/echo.rb
84
57
  - lib/autotest/discover.rb
85
58
  - lib/autotest/spec.rb
59
+ - lib/blather.rb
60
+ - lib/blather/client.rb
61
+ - lib/blather/client/client.rb
62
+ - lib/blather/client/dsl.rb
63
+ - lib/blather/client/pubsub.rb
64
+ - lib/blather/client/pubsub/node.rb
86
65
  - lib/blather/core_ext/active_support.rb
87
66
  - lib/blather/core_ext/libxml.rb
88
67
  - lib/blather/errors.rb
68
+ - lib/blather/errors/sasl_error.rb
69
+ - lib/blather/errors/stanza_error.rb
70
+ - lib/blather/errors/stream_error.rb
89
71
  - lib/blather/jid.rb
90
72
  - lib/blather/roster.rb
91
73
  - lib/blather/roster_item.rb
92
- - lib/blather/stanza/error.rb
74
+ - lib/blather/stanza.rb
75
+ - lib/blather/stanza/disco.rb
76
+ - lib/blather/stanza/disco/disco_info.rb
77
+ - lib/blather/stanza/disco/disco_items.rb
78
+ - lib/blather/stanza/iq.rb
93
79
  - lib/blather/stanza/iq/query.rb
94
80
  - lib/blather/stanza/iq/roster.rb
95
- - lib/blather/stanza/iq.rb
96
81
  - lib/blather/stanza/message.rb
82
+ - lib/blather/stanza/presence.rb
97
83
  - lib/blather/stanza/presence/status.rb
98
84
  - lib/blather/stanza/presence/subscription.rb
99
- - lib/blather/stanza/presence.rb
100
- - lib/blather/stanza.rb
85
+ - lib/blather/stanza/pubsub.rb
86
+ - lib/blather/stanza/pubsub/affiliations.rb
87
+ - lib/blather/stanza/pubsub/errors.rb
88
+ - lib/blather/stanza/pubsub/event.rb
89
+ - lib/blather/stanza/pubsub/items.rb
90
+ - lib/blather/stanza/pubsub/owner.rb
91
+ - lib/blather/stanza/pubsub/subscriptions.rb
92
+ - lib/blather/stream.rb
93
+ - lib/blather/stream/client.rb
94
+ - lib/blather/stream/component.rb
101
95
  - lib/blather/stream/parser.rb
102
96
  - lib/blather/stream/resource.rb
103
97
  - lib/blather/stream/sasl.rb
104
98
  - lib/blather/stream/session.rb
99
+ - lib/blather/stream/stream_handler.rb
105
100
  - lib/blather/stream/tls.rb
106
- - lib/blather/stream.rb
107
101
  - lib/blather/xmpp_node.rb
108
- - lib/blather.rb
109
- - LICENSE
110
- - Manifest
111
- - Rakefile
112
- - README.rdoc
102
+ - spec/blather/core_ext/libxml_spec.rb
103
+ - spec/blather/errors/sasl_error_spec.rb
104
+ - spec/blather/errors/stanza_error_spec.rb
105
+ - spec/blather/errors/stream_error_spec.rb
106
+ - spec/blather/errors_spec.rb
113
107
  - spec/blather/jid_spec.rb
114
108
  - spec/blather/roster_item_spec.rb
115
109
  - spec/blather/roster_spec.rb
110
+ - spec/blather/stanza/discos/disco_info_spec.rb
111
+ - spec/blather/stanza/discos/disco_items_spec.rb
116
112
  - spec/blather/stanza/iq/query_spec.rb
117
113
  - spec/blather/stanza/iq/roster_spec.rb
118
114
  - spec/blather/stanza/iq_spec.rb
@@ -120,29 +116,23 @@ files:
120
116
  - spec/blather/stanza/presence/status_spec.rb
121
117
  - spec/blather/stanza/presence/subscription_spec.rb
122
118
  - spec/blather/stanza/presence_spec.rb
119
+ - spec/blather/stanza/pubsub/affiliations_spec.rb
120
+ - spec/blather/stanza/pubsub/items_spec.rb
121
+ - spec/blather/stanza/pubsub/subscriptions_spec.rb
122
+ - spec/blather/stanza/pubsub_spec.rb
123
123
  - spec/blather/stanza_spec.rb
124
- - spec/blather/stream_spec.rb
124
+ - spec/blather/stream/client_spec.rb
125
+ - spec/blather/stream/component_spec.rb
125
126
  - spec/blather/xmpp_node_spec.rb
126
- - spec/build_safe.rb
127
+ - spec/fixtures/pubsub.rb
127
128
  - spec/spec_helper.rb
128
- - blather.gemspec
129
129
  has_rdoc: true
130
- homepage: http://github.com/sprsquish/blather/tree/master
130
+ homepage: http://github.com/sprsquish/blather
131
+ licenses: []
132
+
131
133
  post_install_message:
132
134
  rdoc_options:
133
- - --line-numbers
134
- - --inline-source
135
- - --title
136
- - Blather
137
- - --main
138
- - README.rdoc
139
- - -S
140
- - -T
141
- - hanna
142
- - --main
143
- - README.rdoc
144
- - --exclude
145
- - autotest
135
+ - --charset=UTF-8
146
136
  require_paths:
147
137
  - lib
148
138
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -155,19 +145,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
145
  requirements:
156
146
  - - ">="
157
147
  - !ruby/object:Gem::Version
158
- version: "1.2"
148
+ version: "0"
159
149
  version:
160
150
  requirements: []
161
151
 
162
152
  rubyforge_project: squishtech
163
- rubygems_version: 1.3.1
153
+ rubygems_version: 1.3.2
164
154
  signing_key:
165
- specification_version: 2
155
+ specification_version: 3
166
156
  summary: An evented XMPP library written on EventMachine and libxml-ruby
167
157
  test_files:
158
+ - spec/blather/core_ext/libxml_spec.rb
159
+ - spec/blather/errors/sasl_error_spec.rb
160
+ - spec/blather/errors/stanza_error_spec.rb
161
+ - spec/blather/errors/stream_error_spec.rb
162
+ - spec/blather/errors_spec.rb
168
163
  - spec/blather/jid_spec.rb
169
164
  - spec/blather/roster_item_spec.rb
170
165
  - spec/blather/roster_spec.rb
166
+ - spec/blather/stanza/discos/disco_info_spec.rb
167
+ - spec/blather/stanza/discos/disco_items_spec.rb
171
168
  - spec/blather/stanza/iq/query_spec.rb
172
169
  - spec/blather/stanza/iq/roster_spec.rb
173
170
  - spec/blather/stanza/iq_spec.rb
@@ -175,6 +172,21 @@ test_files:
175
172
  - spec/blather/stanza/presence/status_spec.rb
176
173
  - spec/blather/stanza/presence/subscription_spec.rb
177
174
  - spec/blather/stanza/presence_spec.rb
175
+ - spec/blather/stanza/pubsub/affiliations_spec.rb
176
+ - spec/blather/stanza/pubsub/items_spec.rb
177
+ - spec/blather/stanza/pubsub/subscriptions_spec.rb
178
+ - spec/blather/stanza/pubsub_spec.rb
178
179
  - spec/blather/stanza_spec.rb
179
- - spec/blather/stream_spec.rb
180
+ - spec/blather/stream/client_spec.rb
181
+ - spec/blather/stream/component_spec.rb
180
182
  - spec/blather/xmpp_node_spec.rb
183
+ - spec/fixtures/pubsub.rb
184
+ - spec/spec_helper.rb
185
+ - examples/drb_client.rb
186
+ - examples/echo.rb
187
+ - examples/pubsub/cli.rb
188
+ - examples/pubsub/ping_pong.rb
189
+ - examples/pubsub/pubsub_dsl.rb
190
+ - examples/pubsub_client.rb
191
+ - examples/rosterprint.rb
192
+ - examples/xmpp4r/echo.rb
data/CHANGELOG DELETED
@@ -1,5 +0,0 @@
1
- v0.2.1 Upgrade to libxml 0.9.7
2
-
3
- v0.2 Overhaul the DSL to look more like Sinatra
4
-
5
- v0.1 Initial release (birth!)
data/Manifest DELETED
@@ -1,47 +0,0 @@
1
- CHANGELOG
2
- examples/drb_client.rb
3
- examples/echo.rb
4
- lib/autotest/discover.rb
5
- lib/autotest/spec.rb
6
- lib/blather/core_ext/active_support.rb
7
- lib/blather/core_ext/libxml.rb
8
- lib/blather/errors.rb
9
- lib/blather/jid.rb
10
- lib/blather/roster.rb
11
- lib/blather/roster_item.rb
12
- lib/blather/stanza/error.rb
13
- lib/blather/stanza/iq/query.rb
14
- lib/blather/stanza/iq/roster.rb
15
- lib/blather/stanza/iq.rb
16
- lib/blather/stanza/message.rb
17
- lib/blather/stanza/presence/status.rb
18
- lib/blather/stanza/presence/subscription.rb
19
- lib/blather/stanza/presence.rb
20
- lib/blather/stanza.rb
21
- lib/blather/stream/parser.rb
22
- lib/blather/stream/resource.rb
23
- lib/blather/stream/sasl.rb
24
- lib/blather/stream/session.rb
25
- lib/blather/stream/tls.rb
26
- lib/blather/stream.rb
27
- lib/blather/xmpp_node.rb
28
- lib/blather.rb
29
- LICENSE
30
- Manifest
31
- Rakefile
32
- README.rdoc
33
- spec/blather/jid_spec.rb
34
- spec/blather/roster_item_spec.rb
35
- spec/blather/roster_spec.rb
36
- spec/blather/stanza/iq/query_spec.rb
37
- spec/blather/stanza/iq/roster_spec.rb
38
- spec/blather/stanza/iq_spec.rb
39
- spec/blather/stanza/message_spec.rb
40
- spec/blather/stanza/presence/status_spec.rb
41
- spec/blather/stanza/presence/subscription_spec.rb
42
- spec/blather/stanza/presence_spec.rb
43
- spec/blather/stanza_spec.rb
44
- spec/blather/stream_spec.rb
45
- spec/blather/xmpp_node_spec.rb
46
- spec/build_safe.rb
47
- spec/spec_helper.rb
@@ -1,41 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{blather}
5
- s.version = "0.2.1"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Jeff Smick"]
9
- s.date = %q{2008-12-21}
10
- s.description = %q{An evented XMPP library written on EventMachine and libxml-ruby}
11
- s.email = %q{sprsquish@gmail.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/autotest/discover.rb", "lib/autotest/spec.rb", "lib/blather/core_ext/active_support.rb", "lib/blather/core_ext/libxml.rb", "lib/blather/errors.rb", "lib/blather/jid.rb", "lib/blather/roster.rb", "lib/blather/roster_item.rb", "lib/blather/stanza/error.rb", "lib/blather/stanza/iq/query.rb", "lib/blather/stanza/iq/roster.rb", "lib/blather/stanza/iq.rb", "lib/blather/stanza/message.rb", "lib/blather/stanza/presence/status.rb", "lib/blather/stanza/presence/subscription.rb", "lib/blather/stanza/presence.rb", "lib/blather/stanza.rb", "lib/blather/stream/parser.rb", "lib/blather/stream/resource.rb", "lib/blather/stream/sasl.rb", "lib/blather/stream/session.rb", "lib/blather/stream/tls.rb", "lib/blather/stream.rb", "lib/blather/xmpp_node.rb", "lib/blather.rb", "LICENSE", "README.rdoc"]
13
- s.files = ["CHANGELOG", "examples/drb_client.rb", "examples/echo.rb", "lib/autotest/discover.rb", "lib/autotest/spec.rb", "lib/blather/core_ext/active_support.rb", "lib/blather/core_ext/libxml.rb", "lib/blather/errors.rb", "lib/blather/jid.rb", "lib/blather/roster.rb", "lib/blather/roster_item.rb", "lib/blather/stanza/error.rb", "lib/blather/stanza/iq/query.rb", "lib/blather/stanza/iq/roster.rb", "lib/blather/stanza/iq.rb", "lib/blather/stanza/message.rb", "lib/blather/stanza/presence/status.rb", "lib/blather/stanza/presence/subscription.rb", "lib/blather/stanza/presence.rb", "lib/blather/stanza.rb", "lib/blather/stream/parser.rb", "lib/blather/stream/resource.rb", "lib/blather/stream/sasl.rb", "lib/blather/stream/session.rb", "lib/blather/stream/tls.rb", "lib/blather/stream.rb", "lib/blather/xmpp_node.rb", "lib/blather.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "spec/blather/jid_spec.rb", "spec/blather/roster_item_spec.rb", "spec/blather/roster_spec.rb", "spec/blather/stanza/iq/query_spec.rb", "spec/blather/stanza/iq/roster_spec.rb", "spec/blather/stanza/iq_spec.rb", "spec/blather/stanza/message_spec.rb", "spec/blather/stanza/presence/status_spec.rb", "spec/blather/stanza/presence/subscription_spec.rb", "spec/blather/stanza/presence_spec.rb", "spec/blather/stanza_spec.rb", "spec/blather/stream_spec.rb", "spec/blather/xmpp_node_spec.rb", "spec/build_safe.rb", "spec/spec_helper.rb", "blather.gemspec"]
14
- s.has_rdoc = true
15
- s.homepage = %q{http://github.com/sprsquish/blather/tree/master}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Blather", "--main", "README.rdoc", "-S", "-T", "hanna", "--main", "README.rdoc", "--exclude", "autotest"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{squishtech}
19
- s.rubygems_version = %q{1.3.1}
20
- s.summary = %q{An evented XMPP library written on EventMachine and libxml-ruby}
21
- s.test_files = ["spec/blather/jid_spec.rb", "spec/blather/roster_item_spec.rb", "spec/blather/roster_spec.rb", "spec/blather/stanza/iq/query_spec.rb", "spec/blather/stanza/iq/roster_spec.rb", "spec/blather/stanza/iq_spec.rb", "spec/blather/stanza/message_spec.rb", "spec/blather/stanza/presence/status_spec.rb", "spec/blather/stanza/presence/subscription_spec.rb", "spec/blather/stanza/presence_spec.rb", "spec/blather/stanza_spec.rb", "spec/blather/stream_spec.rb", "spec/blather/xmpp_node_spec.rb"]
22
-
23
- if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
- s.specification_version = 2
26
-
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
29
- s.add_runtime_dependency(%q<libxml-ruby>, [">= 0.9.7"])
30
- s.add_development_dependency(%q<echoe>, [">= 0"])
31
- else
32
- s.add_dependency(%q<eventmachine>, [">= 0"])
33
- s.add_dependency(%q<libxml-ruby>, [">= 0.9.7"])
34
- s.add_dependency(%q<echoe>, [">= 0"])
35
- end
36
- else
37
- s.add_dependency(%q<eventmachine>, [">= 0"])
38
- s.add_dependency(%q<libxml-ruby>, [">= 0.9.7"])
39
- s.add_dependency(%q<echoe>, [">= 0"])
40
- end
41
- end
@@ -1,31 +0,0 @@
1
- module Blather
2
- class Stanza
3
-
4
- ##
5
- # Base Error stanza
6
- class Error < Stanza
7
- def self.new_from(stanza, defined_condition, type, text = nil)
8
- err = XMPPNode.new(defined_condition)
9
- err['type'] = type
10
- err.xmlns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
11
-
12
- if text
13
- text = XMPPNode.new('text', text)
14
- text.xmlns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
15
- err << text
16
- end
17
-
18
- elem = stanza.copy(true)
19
- elem.type = 'error'
20
- elem << err
21
-
22
- elem
23
- end
24
-
25
- def error?
26
- true
27
- end
28
- end #ErrorStanza
29
-
30
- end #Stanza
31
- end
@@ -1,462 +0,0 @@
1
- require File.join(File.dirname(__FILE__), *%w[.. spec_helper])
2
-
3
- describe 'Blather::Stream' do
4
- class MockStream; include Stream; end
5
- def mock_stream(&block)
6
- @client = mock()
7
- @client.stubs(:jid=)
8
- stream = MockStream.new @client, JID.new('n@d/r'), 'pass'
9
-
10
- stream.expects(:send_data).at_least(1).with &block
11
- stream
12
- end
13
-
14
- it 'can be started' do
15
- client = mock()
16
- params = [client, 'n@d/r', 'pass', 'host', 1234]
17
- EM.expects(:connect).with do |*parms|
18
- parms[0] == 'host' &&
19
- parms[1] == 1234 &&
20
- parms[3] == client &&
21
- parms[5] == 'pass' &&
22
- parms[4] == JID.new('n@d/r')
23
- end
24
-
25
- Stream.start *(params)
26
- end
27
-
28
- it 'can figure out the host to use based on the jid' do
29
- client = mock()
30
- params = [client, 'n@d/r', 'pass', 'd', 5222]
31
- EM.expects(:connect).with do |*parms|
32
- parms[0] == 'd' &&
33
- parms[1] == 5222 &&
34
- parms[3] == client &&
35
- parms[5] == 'pass' &&
36
- parms[4] == JID.new('n@d/r')
37
- end
38
-
39
- Stream.start client, 'n@d/r', 'pass'
40
- end
41
-
42
- it 'starts the stream once the connection is complete' do
43
- s = mock_stream { |d| d =~ /stream:stream/ }
44
- s.connection_completed
45
- end
46
-
47
- it 'sends stanzas to the client when the stream is ready' do
48
- client = mock()
49
- client.stubs(:jid=)
50
- client.expects(:call)
51
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
52
-
53
- stream.expects(:send_data).with do |val|
54
- val.must_match(/stream:stream/)
55
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><message to='a@b/c' from='d@e/f' type='chat' xml:lang='en'><body>Message!</body></message>"
56
- end
57
- stream.connection_completed
58
- end
59
-
60
- it 'puts itself in the stopped state when unbound' do
61
- stream = mock_stream do |val|
62
- val.must_match(/stream:stream/)
63
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
64
-
65
- stream.stopped?.wont_equal true
66
- stream.unbind
67
- stream.stopped?.must_equal true
68
- end
69
- stream.connection_completed
70
- end
71
-
72
- it 'stops when sent </stream:stream>' do
73
- state = nil
74
- stream = mock_stream do |val|
75
- case state
76
- when nil
77
- val.must_match(/stream:stream/)
78
- state = :started
79
-
80
- when :started
81
- stream.stopped?.wont_equal true
82
- state = :stopped
83
- stream.receive_data "</stream:stream>"
84
- true
85
-
86
- when :stopped
87
- stream.stopped?.must_equal true
88
- val.must_equal "</stream:stream>"
89
- true
90
-
91
- else
92
- false
93
-
94
- end
95
- end
96
- stream.connection_completed
97
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
98
- end
99
-
100
- it 'raises an error when it receives stream:error' do
101
- lambda do
102
- state = nil
103
- stream = mock_stream do |val|
104
- case state
105
- when nil
106
- val.must_match(/stream:stream/)
107
- state = :started
108
-
109
- when :started
110
- stream.stopped?.wont_equal true
111
- state = :stopped
112
- stream.receive_data "<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>"
113
- true
114
-
115
- when :stopped
116
- stream.stopped?.must_equal true
117
- val.must_equal "</stream:stream>"
118
- true
119
-
120
- else
121
- false
122
-
123
- end
124
- end
125
- stream.connection_completed
126
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
127
- end.must_raise(StreamError)
128
- end
129
-
130
- it 'starts TLS when asked' do
131
- state = nil
132
- stream = mock_stream do |val|
133
- case state
134
- when nil
135
- val.must_match(/stream:stream/)
136
- state = :started
137
-
138
- when :started
139
- val.must_match(/starttls/)
140
- true
141
-
142
- else
143
- false
144
-
145
- end
146
- end
147
- stream.connection_completed
148
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
149
- end
150
-
151
- it 'connects via SASL MD5 when asked' do
152
- Time.any_instance.stubs(:to_f).returns(1.1)
153
-
154
- state = nil
155
- client = mock()
156
- client.stubs(:jid=)
157
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
158
-
159
- stream.expects(:send_data).times(5).with do |val|
160
- case state
161
- when nil
162
- val.must_match(/stream:stream/)
163
- state = :started
164
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>"
165
- true
166
-
167
- when :started
168
- val.must_match(/auth.*DIGEST\-MD5/)
169
- state = :auth_sent
170
- stream.receive_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==</challenge>"
171
- true
172
-
173
- when :auth_sent
174
- val.must_equal('<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixjaGFyc2V0PXV0Zi04LHVzZXJuYW1lPSJuIixyZWFsbT0ic29tZXJlYWxtIixjbm9uY2U9Ijc3N2Q0NWJiYmNkZjUwZDQ5YzQyYzcwYWQ3YWNmNWZlIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2QiLHJlc3BvbnNlPTZiNTlhY2Q1ZWJmZjhjZTA0NTYzMGFiMDU2Zjg3MTdm</response>')
175
- state = :response1_sent
176
- stream.receive_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZAo=</challenge>"
177
- true
178
-
179
- when :response1_sent
180
- val.must_equal('<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>')
181
- state = :response2_sent
182
- stream.receive_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"
183
- true
184
-
185
- when :response2_sent
186
- val.must_match(/stream:stream/)
187
- state = :complete
188
- true
189
-
190
- else
191
- false
192
-
193
- end
194
- end
195
- stream.connection_completed
196
- end
197
-
198
- it 'will connect via SSL PLAIN when asked' do
199
- state = nil
200
- client = mock()
201
- client.stubs(:jid=)
202
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
203
-
204
- stream.expects(:send_data).times(3).with do |val|
205
- case state
206
- when nil
207
- val.must_match(/stream:stream/)
208
- state = :started
209
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
210
- true
211
-
212
- when :started
213
- val.must_equal('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>')
214
- state = :auth_sent
215
- stream.receive_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"
216
- true
217
-
218
- when :auth_sent
219
- val.must_match(/stream:stream/)
220
- state = :complete
221
- true
222
-
223
- else
224
- false
225
-
226
- end
227
- end
228
- stream.connection_completed
229
- end
230
-
231
- it 'will connect via SSL ANONYMOUS when asked' do
232
- state = nil
233
- client = mock()
234
- client.stubs(:jid=)
235
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
236
-
237
- stream.expects(:send_data).times(3).with do |val|
238
- case state
239
- when nil
240
- val.must_match(/stream:stream/)
241
- state = :started
242
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
243
- true
244
-
245
- when :started
246
- val.must_equal('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS">bg==</auth>')
247
- state = :auth_sent
248
- stream.receive_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"
249
- true
250
-
251
- when :auth_sent
252
- val.must_match(/stream:stream/)
253
- state = :complete
254
- true
255
-
256
- else
257
- false
258
-
259
- end
260
- end
261
- stream.connection_completed
262
- end
263
-
264
- it 'tried each possible mechanism until it fails completely' do
265
- state = nil
266
- client = mock()
267
- client.stubs(:jid=)
268
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
269
-
270
- stream.expects(:send_data).times(5).with do |val|
271
- case state
272
- when nil
273
- val.must_match(/stream:stream/)
274
- state = :started
275
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
276
- true
277
-
278
- when :started
279
- val.must_match(/mechanism="DIGEST-MD5"/)
280
- state = :failed_md5
281
- stream.receive_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"
282
- true
283
-
284
- when :failed_md5
285
- val.must_match(/mechanism="PLAIN"/)
286
- state = :failed_plain
287
- stream.receive_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"
288
- true
289
-
290
- when :failed_plain
291
- val.must_match(/mechanism="ANONYMOUS"/)
292
- state = :failed_anon
293
- stream.receive_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"
294
- true
295
-
296
- when :failed_anon
297
- val.must_match(/\/stream:stream/)
298
- state = :complete
299
- true
300
-
301
- else
302
- false
303
-
304
- end
305
- end
306
- stream.connection_completed
307
- end
308
-
309
- it 'tries each mechanism until it succeeds' do
310
- state = nil
311
- client = mock()
312
- client.stubs(:jid=)
313
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
314
-
315
- stream.expects(:send_data).times(4).with do |val|
316
- case state
317
- when nil
318
- val.must_match(/stream:stream/)
319
- state = :started
320
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
321
- true
322
-
323
- when :started
324
- val.must_match(/mechanism="DIGEST-MD5"/)
325
- state = :failed_md5
326
- stream.receive_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"
327
- true
328
-
329
- when :failed_md5
330
- val.must_match(/mechanism="PLAIN"/)
331
- state = :plain_sent
332
- stream.receive_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"
333
- true
334
-
335
- when :plain_sent
336
- val.must_match(/stream:stream/)
337
- state = :complete
338
- true
339
-
340
- else
341
- false
342
-
343
- end
344
- end
345
- stream.connection_completed
346
- end
347
-
348
- it 'raises an exception when an unknown mechanism is sent' do
349
- state = nil
350
- client = mock()
351
- client.stubs(:jid=)
352
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
353
-
354
- stream.expects(:send_data).times(2).with do |val|
355
- if !state
356
- state = :started
357
- val.must_match(/stream:stream/)
358
- lambda do
359
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>UNKNOWN</mechanism></mechanisms></stream:features>"
360
- end.must_raise(Stream::SASL::UnknownMechanism)
361
-
362
- else
363
- val.must_match(/failure(.*)invalid\-mechanism/)
364
-
365
- end
366
- end
367
- stream.connection_completed
368
- end
369
-
370
- it 'will bind to a resource set by the server' do
371
- state = nil
372
- class Client; attr_accessor :jid; end
373
- client = Client.new
374
-
375
- jid = JID.new('n@d')
376
- stream = MockStream.new client, jid, 'pass'
377
-
378
- stream.expects(:send_data).times(2).with do |val|
379
- case state
380
- when nil
381
- val.must_match(/stream:stream/)
382
- state = :started
383
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></stream:features>"
384
- true
385
-
386
- when :started
387
- val.must_match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>})
388
- val =~ %r{<iq[^>]+id="([^"]+)"}
389
- state = :complete
390
- stream.receive_data "<iq type='result' id='#{$1}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{jid}/server_resource</jid></bind></iq>"
391
- client.jid.must_equal JID.new('n@d/server_resource')
392
- true
393
-
394
- else
395
- false
396
-
397
- end
398
- end
399
- stream.connection_completed
400
- end
401
-
402
- it 'will bind to a resource set by the client' do
403
- state = nil
404
- class Client; attr_accessor :jid; end
405
- client = Client.new
406
-
407
- jid = JID.new('n@d/r')
408
- stream = MockStream.new client, jid, 'pass'
409
-
410
- stream.expects(:send_data).times(2).with do |val|
411
- case state
412
- when nil
413
- val.must_match(/stream:stream/)
414
- state = :started
415
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></stream:features>"
416
- true
417
-
418
- when :started
419
- val.must_match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>r</resource></bind>})
420
- val =~ %r{<iq[^>]+id="([^"]+)"}
421
- state = :complete
422
- stream.receive_data "<iq type='result' id='#{$1}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{jid}</jid></bind></iq>"
423
- client.jid.must_equal JID.new('n@d/r')
424
- true
425
-
426
- else
427
- false
428
-
429
- end
430
- end
431
- stream.connection_completed
432
- end
433
-
434
- it 'will establish a session if requested' do
435
- state = nil
436
- client = mock()
437
- client.stubs(:jid=)
438
- stream = MockStream.new client, JID.new('n@d/r'), 'pass'
439
-
440
- client.expects(:stream_started)
441
- stream.expects(:send_data).times(2).with do |val|
442
- case state
443
- when nil
444
- val.must_match(/stream:stream/)
445
- state = :started
446
- stream.receive_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features>"
447
- true
448
-
449
- when :started
450
- val.must_match('<iq id="[^"]+" type="set" to="d"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>')
451
- state = :completed
452
- stream.receive_data "<iq from='d' type='result' id='#{val[/id="([^"]+)"/,1]}'/>"
453
- true
454
-
455
- else
456
- false
457
-
458
- end
459
- end
460
- stream.connection_completed
461
- end
462
- end