blather 1.2.0 → 2.0.0
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.
- checksums.yaml +5 -5
- data/.travis.yml +7 -7
- data/CHANGELOG.md +8 -0
- data/blather.gemspec +6 -6
- data/lib/blather.rb +1 -1
- data/lib/blather/client/client.rb +30 -6
- data/lib/blather/version.rb +1 -1
- data/spec/blather/client/client_spec.rb +73 -68
- data/spec/blather/client/dsl/pubsub_spec.rb +121 -121
- data/spec/blather/client/dsl_spec.rb +9 -9
- data/spec/blather/errors/sasl_error_spec.rb +3 -3
- data/spec/blather/errors/stanza_error_spec.rb +26 -26
- data/spec/blather/errors/stream_error_spec.rb +22 -22
- data/spec/blather/errors_spec.rb +7 -7
- data/spec/blather/file_transfer_spec.rb +9 -9
- data/spec/blather/jid_spec.rb +29 -29
- data/spec/blather/roster_item_spec.rb +18 -18
- data/spec/blather/roster_spec.rb +18 -18
- data/spec/blather/stanza/discos/disco_info_spec.rb +56 -56
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +51 -51
- data/spec/blather/stanza/iq/ibb_spec.rb +15 -15
- data/spec/blather/stanza/iq/ping_spec.rb +8 -8
- data/spec/blather/stanza/iq/query_spec.rb +15 -15
- data/spec/blather/stanza/iq/roster_spec.rb +29 -29
- data/spec/blather/stanza/iq/s5b_spec.rb +7 -7
- data/spec/blather/stanza/iq/si_spec.rb +17 -17
- data/spec/blather/stanza/iq/vcard_spec.rb +19 -19
- data/spec/blather/stanza/iq_spec.rb +11 -11
- data/spec/blather/stanza/message/muc_user_spec.rb +32 -32
- data/spec/blather/stanza/message_spec.rb +53 -54
- data/spec/blather/stanza/presence/c_spec.rb +11 -11
- data/spec/blather/stanza/presence/muc_spec.rb +7 -7
- data/spec/blather/stanza/presence/muc_user_spec.rb +22 -22
- data/spec/blather/stanza/presence/status_spec.rb +33 -33
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -22
- data/spec/blather/stanza/presence_spec.rb +30 -30
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +24 -24
- data/spec/blather/stanza/pubsub/items_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +19 -19
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
- data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +13 -13
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
- data/spec/blather/stanza/pubsub_spec.rb +15 -15
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +160 -160
- data/spec/blather/stream/component_spec.rb +8 -10
- data/spec/blather/stream/parser_spec.rb +25 -25
- data/spec/blather/stream/ssl_spec.rb +3 -3
- data/spec/blather/xmpp_node_spec.rb +9 -9
- data/spec/blather_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -27
data/spec/blather/stanza_spec.rb
CHANGED
@@ -2,42 +2,42 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blather::Stanza do
|
4
4
|
it 'provides .next_id helper for generating new IDs' do
|
5
|
-
|
5
|
+
expect { Blather::Stanza.next_id }.to change Blather::Stanza, :next_id
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'provides a handler registration mechanism' do
|
9
9
|
class Registration < Blather::Stanza; register :handler_test, :handler, 'test:namespace'; end
|
10
|
-
Registration.handler_hierarchy.
|
11
|
-
Blather::Stanza.handler_list.
|
10
|
+
expect(Registration.handler_hierarchy).to include :handler_test
|
11
|
+
expect(Blather::Stanza.handler_list).to include :handler_test
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'can register based on handler' do
|
15
15
|
class RegisterHandler < Blather::Stanza; register :register_handler; end
|
16
|
-
Blather::Stanza.class_from_registration(:register_handler, nil).
|
16
|
+
expect(Blather::Stanza.class_from_registration(:register_handler, nil)).to eq(RegisterHandler)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can register based on given name' do
|
20
20
|
class RegisterName < Blather::Stanza; register :handler, :registered_name; end
|
21
|
-
Blather::Stanza.class_from_registration(:registered_name, nil).
|
21
|
+
expect(Blather::Stanza.class_from_registration(:registered_name, nil)).to eq(RegisterName)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'can register subclass handlers' do
|
25
25
|
class SuperClassRegister < Blather::Stanza; register :super_class; end
|
26
26
|
class SubClassRegister < SuperClassRegister; register :sub_class; end
|
27
|
-
SuperClassRegister.handler_hierarchy.
|
28
|
-
SubClassRegister.handler_hierarchy.
|
27
|
+
expect(SuperClassRegister.handler_hierarchy).not_to include :sub_class
|
28
|
+
expect(SubClassRegister.handler_hierarchy).to include :super_class
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'can import a node' do
|
32
32
|
s = Blather::Stanza.import Blather::XMPPNode.new('foo')
|
33
|
-
s.element_name.
|
33
|
+
expect(s.element_name).to eq('foo')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'provides an #error? helper' do
|
37
37
|
s = Blather::Stanza.new('message')
|
38
|
-
s.error
|
38
|
+
expect(s.error?).to eq(false)
|
39
39
|
s.type = :error
|
40
|
-
s.error
|
40
|
+
expect(s.error?).to eq(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'will generate a reply' do
|
@@ -46,9 +46,9 @@ describe Blather::Stanza do
|
|
46
46
|
s.to = t = Blather::JID.new('d@n/r')
|
47
47
|
|
48
48
|
r = s.reply
|
49
|
-
r.object_id.
|
50
|
-
r.from.
|
51
|
-
r.to.
|
49
|
+
expect(r.object_id).not_to equal s.object_id
|
50
|
+
expect(r.from).to eq(t)
|
51
|
+
expect(r.to).to eq(f)
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'convert to a reply' do
|
@@ -57,9 +57,9 @@ describe Blather::Stanza do
|
|
57
57
|
s.to = t = Blather::JID.new('d@n/r')
|
58
58
|
|
59
59
|
r = s.reply!
|
60
|
-
r.object_id.
|
61
|
-
r.from.
|
62
|
-
r.to.
|
60
|
+
expect(r.object_id).to eq(s.object_id)
|
61
|
+
expect(r.from).to eq(t)
|
62
|
+
expect(r.to).to eq(f)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'does not remove the body when replying' do
|
@@ -68,7 +68,7 @@ describe Blather::Stanza do
|
|
68
68
|
s.to = t = Blather::JID.new('d@n/r')
|
69
69
|
s << Blather::XMPPNode.new('query', s.document)
|
70
70
|
r = s.reply
|
71
|
-
r.children.empty
|
71
|
+
expect(r.children.empty?).to eq(false)
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'removes the body when replying if we ask to remove it' do
|
@@ -77,58 +77,58 @@ describe Blather::Stanza do
|
|
77
77
|
s.to = t = Blather::JID.new('d@n/r')
|
78
78
|
s << Blather::XMPPNode.new('query', s.document)
|
79
79
|
r = s.reply :remove_children => true
|
80
|
-
r.children.empty
|
80
|
+
expect(r.children.empty?).to eq(true)
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'provides "attr_accessor" for id' do
|
84
84
|
s = Blather::Stanza.new('message')
|
85
|
-
s.id.
|
86
|
-
s[:id].
|
85
|
+
expect(s.id).to be_nil
|
86
|
+
expect(s[:id]).to be_nil
|
87
87
|
|
88
88
|
s.id = '123'
|
89
|
-
s.id.
|
90
|
-
s[:id].
|
89
|
+
expect(s.id).to eq('123')
|
90
|
+
expect(s[:id]).to eq('123')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'provides "attr_accessor" for to' do
|
94
94
|
s = Blather::Stanza.new('message')
|
95
|
-
s.to.
|
96
|
-
s[:to].
|
95
|
+
expect(s.to).to be_nil
|
96
|
+
expect(s[:to]).to be_nil
|
97
97
|
|
98
98
|
s.to = Blather::JID.new('n@d/r')
|
99
|
-
s.to.
|
100
|
-
s.to.
|
99
|
+
expect(s.to).not_to be_nil
|
100
|
+
expect(s.to).to be_kind_of Blather::JID
|
101
101
|
|
102
|
-
s[:to].
|
103
|
-
s[:to].
|
102
|
+
expect(s[:to]).not_to be_nil
|
103
|
+
expect(s[:to]).to eq('n@d/r')
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'provides "attr_accessor" for from' do
|
107
107
|
s = Blather::Stanza.new('message')
|
108
|
-
s.from.
|
109
|
-
s[:from].
|
108
|
+
expect(s.from).to be_nil
|
109
|
+
expect(s[:from]).to be_nil
|
110
110
|
|
111
111
|
s.from = Blather::JID.new('n@d/r')
|
112
|
-
s.from.
|
113
|
-
s.from.
|
112
|
+
expect(s.from).not_to be_nil
|
113
|
+
expect(s.from).to be_kind_of Blather::JID
|
114
114
|
|
115
|
-
s[:from].
|
116
|
-
s[:from].
|
115
|
+
expect(s[:from]).not_to be_nil
|
116
|
+
expect(s[:from]).to eq('n@d/r')
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'provides "attr_accessor" for type' do
|
120
120
|
s = Blather::Stanza.new('message')
|
121
|
-
s.type.
|
122
|
-
s[:type].
|
121
|
+
expect(s.type).to be_nil
|
122
|
+
expect(s[:type]).to be_nil
|
123
123
|
|
124
124
|
s.type = 'testing'
|
125
|
-
s.type.
|
126
|
-
s[:type].
|
125
|
+
expect(s.type).not_to be_nil
|
126
|
+
expect(s[:type]).not_to be_nil
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'can be converted into an error by error name' do
|
130
130
|
s = Blather::Stanza.new('message')
|
131
131
|
err = s.as_error 'internal-server-error', 'cancel'
|
132
|
-
err.name.
|
132
|
+
expect(err.name).to eq(:internal_server_error)
|
133
133
|
end
|
134
134
|
end
|
@@ -31,11 +31,11 @@ describe Blather::Stream::Client do
|
|
31
31
|
it 'can be started' do
|
32
32
|
params = [client, 'n@d/r', 'pass', 'host', 1234]
|
33
33
|
EM.expects(:connect).with do |*parms|
|
34
|
-
parms[0].
|
35
|
-
parms[1].
|
36
|
-
parms[3].
|
37
|
-
parms[5].
|
38
|
-
parms[4].
|
34
|
+
expect(parms[0]).to eq('host')
|
35
|
+
expect(parms[1]).to eq(1234)
|
36
|
+
expect(parms[3]).to eq(client)
|
37
|
+
expect(parms[5]).to eq('pass')
|
38
|
+
expect(parms[4]).to eq(Blather::JID.new('n@d/r'))
|
39
39
|
end
|
40
40
|
|
41
41
|
Blather::Stream::Client.start *params
|
@@ -51,11 +51,11 @@ describe Blather::Stream::Client do
|
|
51
51
|
|
52
52
|
client = Class.new
|
53
53
|
EM.expects(:connect).with do |*parms|
|
54
|
-
parms[0].
|
55
|
-
parms[1].
|
56
|
-
parms[3].
|
57
|
-
parms[5].
|
58
|
-
parms[4].
|
54
|
+
expect(parms[0]).to eq('d')
|
55
|
+
expect(parms[1]).to eq(5222)
|
56
|
+
expect(parms[3]).to eq(client)
|
57
|
+
expect(parms[5]).to eq('pass')
|
58
|
+
expect(parms[4]).to eq(Blather::JID.new('n@d/r'))
|
59
59
|
end
|
60
60
|
|
61
61
|
Blather::Stream::Client.start client, 'n@d/r', 'pass'
|
@@ -69,11 +69,11 @@ describe Blather::Stream::Client do
|
|
69
69
|
client = Class.new
|
70
70
|
EM.expects(:connect).with do |*parms|
|
71
71
|
raise Blather::Stream::NoConnection if parms[0] == 'd'
|
72
|
-
parms[0].
|
73
|
-
parms[1].
|
74
|
-
parms[3].
|
75
|
-
parms[5].
|
76
|
-
parms[4].
|
72
|
+
expect(parms[0]).to eq('g')
|
73
|
+
expect(parms[1]).to eq(1234)
|
74
|
+
expect(parms[3]).to eq(client)
|
75
|
+
expect(parms[5]).to eq('pass')
|
76
|
+
expect(parms[4]).to eq(Blather::JID.new('n@d/r'))
|
77
77
|
end
|
78
78
|
Blather::Stream::Client.start client, 'n@d/r', 'pass'
|
79
79
|
end
|
@@ -85,11 +85,11 @@ describe Blather::Stream::Client do
|
|
85
85
|
|
86
86
|
client = Class.new
|
87
87
|
EM.expects(:connect).with do |*parms|
|
88
|
-
parms[0].
|
89
|
-
parms[1].
|
90
|
-
parms[3].
|
91
|
-
parms[5].
|
92
|
-
parms[4].
|
88
|
+
expect(parms[0]).to eq('d')
|
89
|
+
expect(parms[1]).to eq(5222)
|
90
|
+
expect(parms[3]).to eq(client)
|
91
|
+
expect(parms[5]).to eq('pass')
|
92
|
+
expect(parms[4]).to eq(Blather::JID.new('n@d/r'))
|
93
93
|
end
|
94
94
|
Blather::Stream::Client.start client, 'n@d/r', 'pass'
|
95
95
|
end
|
@@ -99,38 +99,38 @@ describe Blather::Stream::Client do
|
|
99
99
|
client = Class.new
|
100
100
|
params = [client, 'n@d/r', 'pass', nil, 5222]
|
101
101
|
EM.expects(:connect).with do |*parms|
|
102
|
-
parms[0].
|
103
|
-
parms[1].
|
104
|
-
parms[3].
|
105
|
-
parms[5].
|
106
|
-
parms[4].
|
102
|
+
expect(parms[0]).to eq('d')
|
103
|
+
expect(parms[1]).to eq(5222)
|
104
|
+
expect(parms[3]).to eq(client)
|
105
|
+
expect(parms[5]).to eq('pass')
|
106
|
+
expect(parms[4]).to eq(Blather::JID.new('n@d/r'))
|
107
107
|
end
|
108
108
|
|
109
109
|
Blather::Stream::Client.start client, 'n@d/r', 'pass'
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'raises a NoConnection exception if the connection is unbound before it can be completed' do
|
113
|
-
|
113
|
+
expect do
|
114
114
|
EventMachine::run {
|
115
115
|
EM.add_timer(0.5) { EM.stop if EM.reactor_running? }
|
116
116
|
|
117
117
|
Blather::Stream::Client.start client, jid, 'pass', '127.0.0.1', 50000 - rand(1000)
|
118
118
|
}
|
119
|
-
end.
|
119
|
+
end.to raise_error Blather::Stream::ConnectionFailed
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'starts the stream once the connection is complete' do
|
123
|
-
mocked_server(1) { |val, _| EM.stop; val.
|
123
|
+
mocked_server(1) { |val, _| EM.stop; expect(val).to match(/stream:stream/) }
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'sends stanzas to the client when the stream is ready' do
|
127
127
|
client.expects(:receive_data).with do |n|
|
128
128
|
EM.stop
|
129
|
-
n.
|
129
|
+
expect(n).to be_kind_of Blather::Stanza::Message
|
130
130
|
end
|
131
131
|
|
132
132
|
mocked_server(1) do |val, server|
|
133
|
-
val.
|
133
|
+
expect(val).to match(/stream:stream/)
|
134
134
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
135
135
|
server.send_data "<message to='a@b/c' from='d@e/f' type='chat' xml:lang='en'><body>Message!</body></message>"
|
136
136
|
server.send_data "</stream:stream>"
|
@@ -147,13 +147,13 @@ describe Blather::Stream::Client do
|
|
147
147
|
started = true
|
148
148
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
149
149
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
150
|
-
val.
|
150
|
+
expect(val).to match(/stream:stream/)
|
151
151
|
|
152
152
|
else
|
153
153
|
EM.stop
|
154
|
-
@stream.
|
154
|
+
expect(@stream).not_to be_stopped
|
155
155
|
@stream.unbind
|
156
|
-
@stream.
|
156
|
+
expect(@stream).to be_stopped
|
157
157
|
|
158
158
|
end
|
159
159
|
end
|
@@ -164,8 +164,8 @@ describe Blather::Stream::Client do
|
|
164
164
|
|
165
165
|
client.expects(:receive_data).with do |n|
|
166
166
|
EM.stop
|
167
|
-
state.
|
168
|
-
@stream.negotiating
|
167
|
+
expect(state).to eq(:negotiated)
|
168
|
+
expect(@stream.negotiating?).to eq(false)
|
169
169
|
end
|
170
170
|
|
171
171
|
mocked_server(2) do |val, server|
|
@@ -178,7 +178,7 @@ describe Blather::Stream::Client do
|
|
178
178
|
|
179
179
|
when :started
|
180
180
|
state = :negotiated
|
181
|
-
@stream.negotiating
|
181
|
+
expect(@stream.negotiating?).to eq(true)
|
182
182
|
server.send_data "<iq from='d' type='result' id='#{val[/id="([^"]+)"/,1]}' />"
|
183
183
|
server.send_data "<message to='a@b/c' from='d@e/f' type='chat' xml:lang='en'><body>Message!</body></message>"
|
184
184
|
true
|
@@ -199,17 +199,17 @@ describe Blather::Stream::Client do
|
|
199
199
|
state = :started
|
200
200
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>"
|
201
201
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
202
|
-
val.
|
202
|
+
expect(val).to match(/stream:stream/)
|
203
203
|
|
204
204
|
when :started
|
205
205
|
state = :stopped
|
206
206
|
server.send_data '</stream:stream>'
|
207
|
-
@stream.stopped
|
207
|
+
expect(@stream.stopped?).to eq(false)
|
208
208
|
|
209
209
|
when :stopped
|
210
210
|
EM.stop
|
211
|
-
@stream.stopped
|
212
|
-
val.
|
211
|
+
expect(@stream.stopped?).to eq(true)
|
212
|
+
expect(val).to eq('</stream:stream>')
|
213
213
|
|
214
214
|
else
|
215
215
|
EM.stop
|
@@ -221,9 +221,9 @@ describe Blather::Stream::Client do
|
|
221
221
|
|
222
222
|
it 'sends client an error on stream:error' do
|
223
223
|
client.expects(:receive_data).with do |v|
|
224
|
-
v.name.
|
225
|
-
v.text.
|
226
|
-
v.to_s.
|
224
|
+
expect(v.name).to eq(:conflict)
|
225
|
+
expect(v.text).to eq('Already signed in')
|
226
|
+
expect(v.to_s).to eq("Stream Error (conflict): #{v.text}")
|
227
227
|
end
|
228
228
|
|
229
229
|
state = nil
|
@@ -233,17 +233,17 @@ describe Blather::Stream::Client do
|
|
233
233
|
state = :started
|
234
234
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"
|
235
235
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
236
|
-
val.
|
236
|
+
expect(val).to match(/stream:stream/)
|
237
237
|
|
238
238
|
when :started
|
239
239
|
state = :stopped
|
240
240
|
server.send_data "<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams' />"
|
241
241
|
server.send_data "<text xmlns='urn:ietf:params:xml:ns:xmpp-streams'>Already signed in</text></stream:error>"
|
242
|
-
val.
|
242
|
+
expect(val).to match(/bind/)
|
243
243
|
|
244
244
|
when :stopped
|
245
245
|
EM.stop
|
246
|
-
val.
|
246
|
+
expect(val).to eq("</stream:stream>")
|
247
247
|
|
248
248
|
else
|
249
249
|
EM.stop
|
@@ -261,11 +261,11 @@ describe Blather::Stream::Client do
|
|
261
261
|
state = :started
|
262
262
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
263
263
|
server.send_data "<stream:features><auth xmlns='http://jabber.org/features/iq-auth'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
|
264
|
-
val.
|
264
|
+
expect(val).to match(/stream:stream/)
|
265
265
|
|
266
266
|
when :started
|
267
267
|
EM.stop
|
268
|
-
val.
|
268
|
+
expect(val).to match(/starttls/)
|
269
269
|
|
270
270
|
else
|
271
271
|
EM.stop
|
@@ -283,13 +283,13 @@ describe Blather::Stream::Client do
|
|
283
283
|
state = :started
|
284
284
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
285
285
|
server.send_data "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
|
286
|
-
val.
|
286
|
+
expect(val).to match(/stream:stream/)
|
287
287
|
|
288
288
|
when :started
|
289
289
|
state = :tls
|
290
290
|
@stream.expects(:start_tls)
|
291
291
|
server.send_data "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
|
292
|
-
val.
|
292
|
+
expect(val).to match(/starttls/)
|
293
293
|
|
294
294
|
when :tls
|
295
295
|
EM.stop
|
@@ -304,7 +304,7 @@ describe Blather::Stream::Client do
|
|
304
304
|
end
|
305
305
|
|
306
306
|
it 'will fail if TLS negotiation fails' do
|
307
|
-
client.expects(:receive_data).with { |v| v.
|
307
|
+
client.expects(:receive_data).with { |v| expect(v).to be_kind_of Blather::Stream::TLS::TLSFailure }
|
308
308
|
|
309
309
|
state = nil
|
310
310
|
mocked_server(3) do |val, server|
|
@@ -312,17 +312,17 @@ describe Blather::Stream::Client do
|
|
312
312
|
when nil
|
313
313
|
state = :started
|
314
314
|
server.send_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>"
|
315
|
-
val.
|
315
|
+
expect(val).to match(/stream:stream/)
|
316
316
|
|
317
317
|
when :started
|
318
318
|
state = :tls
|
319
319
|
@stream.expects(:start_tls).never
|
320
320
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/></stream:stream>"
|
321
|
-
val.
|
321
|
+
expect(val).to match(/starttls/)
|
322
322
|
|
323
323
|
when :tls
|
324
324
|
EM.stop
|
325
|
-
val.
|
325
|
+
expect(val).to eq("</stream:stream>")
|
326
326
|
|
327
327
|
else
|
328
328
|
EM.stop
|
@@ -334,7 +334,7 @@ describe Blather::Stream::Client do
|
|
334
334
|
|
335
335
|
it 'will fail if a bad node comes through TLS negotiations' do
|
336
336
|
client.expects(:receive_data).with do |v|
|
337
|
-
v.
|
337
|
+
expect(v).to be_kind_of Blather::Stream::TLS::TLSFailure
|
338
338
|
end
|
339
339
|
|
340
340
|
state = nil
|
@@ -344,17 +344,17 @@ describe Blather::Stream::Client do
|
|
344
344
|
state = :started
|
345
345
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
346
346
|
server.send_data "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
|
347
|
-
val.
|
347
|
+
expect(val).to match(/stream:stream/)
|
348
348
|
|
349
349
|
when :started
|
350
350
|
state = :tls
|
351
351
|
@stream.expects(:start_tls).never
|
352
352
|
server.send_data "<foo-bar xmlns='urn:ietf:params:xml:ns:xmpp-tls'/></stream:stream>"
|
353
|
-
val.
|
353
|
+
expect(val).to match(/starttls/)
|
354
354
|
|
355
355
|
when :tls
|
356
356
|
EM.stop
|
357
|
-
val.
|
357
|
+
expect(val).to eq("</stream:stream>")
|
358
358
|
|
359
359
|
else
|
360
360
|
EM.stop
|
@@ -373,27 +373,27 @@ describe Blather::Stream::Client do
|
|
373
373
|
when nil
|
374
374
|
state = :started
|
375
375
|
server.send_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>"
|
376
|
-
val.
|
376
|
+
expect(val).to match(/stream:stream/)
|
377
377
|
|
378
378
|
when :started
|
379
379
|
state = :auth_sent
|
380
380
|
server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==</challenge>"
|
381
|
-
val.
|
381
|
+
expect(val).to match(/auth.*DIGEST\-MD5/)
|
382
382
|
|
383
383
|
when :auth_sent
|
384
384
|
state = :response1_sent
|
385
385
|
server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZAo=</challenge>"
|
386
|
-
val.
|
386
|
+
expect(val).to eq('<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixjaGFyc2V0PXV0Zi04LHVzZXJuYW1lPSJuIixyZWFsbT0ic29tZXJlYWxtIixjbm9uY2U9Ijc3N2Q0NWJiYmNkZjUwZDQ5YzQyYzcwYWQ3YWNmNWZlIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2QiLHJlc3BvbnNlPTZiNTlhY2Q1ZWJmZjhjZTA0NTYzMGFiMDU2Zjg3MTdm</response>')
|
387
387
|
|
388
388
|
when :response1_sent
|
389
389
|
state = :response2_sent
|
390
390
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
391
|
-
val.
|
391
|
+
expect(val).to match(%r{<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"\s?/>})
|
392
392
|
|
393
393
|
when :response2_sent
|
394
394
|
EM.stop
|
395
395
|
state = :complete
|
396
|
-
val.
|
396
|
+
expect(val).to match(/stream:stream/)
|
397
397
|
|
398
398
|
else
|
399
399
|
EM.stop
|
@@ -410,17 +410,17 @@ describe Blather::Stream::Client do
|
|
410
410
|
when nil
|
411
411
|
state = :started
|
412
412
|
server.send_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>"
|
413
|
-
val.
|
413
|
+
expect(val).to match(/stream:stream/)
|
414
414
|
|
415
415
|
when :started
|
416
416
|
state = :auth_sent
|
417
417
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
418
|
-
Nokogiri::XML(val).to_xml.
|
418
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>').to_xml)
|
419
419
|
|
420
420
|
when :auth_sent
|
421
421
|
EM.stop
|
422
422
|
state = :complete
|
423
|
-
val.
|
423
|
+
expect(val).to match(/stream:stream/)
|
424
424
|
|
425
425
|
else
|
426
426
|
EM.stop
|
@@ -442,27 +442,27 @@ describe Blather::Stream::Client do
|
|
442
442
|
when nil
|
443
443
|
state = :started
|
444
444
|
server.send_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>"
|
445
|
-
val.
|
445
|
+
expect(val).to match(/stream:stream/)
|
446
446
|
|
447
447
|
when :started
|
448
448
|
state = :auth_sent
|
449
449
|
server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==</challenge>"
|
450
|
-
val.
|
450
|
+
expect(val).to match(/auth.*DIGEST\-MD5/)
|
451
451
|
|
452
452
|
when :auth_sent
|
453
453
|
state = :response1_sent
|
454
454
|
server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZAo=</challenge>"
|
455
|
-
val.
|
455
|
+
expect(val).to eq('<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixjaGFyc2V0PXV0Zi04LHVzZXJuYW1lPSJkb28iLHJlYWxtPSJzb21lcmVhbG0iLGNub25jZT0iNzc3ZDQ1YmJiY2RmNTBkNDljNDJjNzBhZDdhY2Y1ZmUiLG5jPTAwMDAwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvZCIscmVzcG9uc2U9YzBhMzQ4MDkyOWJmMDFiMWUyODc0NTE1YWQ5ZjNlYzE=</response>')
|
456
456
|
|
457
457
|
when :response1_sent
|
458
458
|
state = :response2_sent
|
459
459
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
460
|
-
val.
|
460
|
+
expect(val).to match(%r{<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"\s?/>})
|
461
461
|
|
462
462
|
when :response2_sent
|
463
463
|
EM.stop
|
464
464
|
state = :complete
|
465
|
-
val.
|
465
|
+
expect(val).to match(/stream:stream/)
|
466
466
|
|
467
467
|
else
|
468
468
|
EM.stop
|
@@ -479,17 +479,17 @@ describe Blather::Stream::Client do
|
|
479
479
|
when nil
|
480
480
|
state = :started
|
481
481
|
server.send_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>"
|
482
|
-
val.
|
482
|
+
expect(val).to match(/stream:stream/)
|
483
483
|
|
484
484
|
when :started
|
485
485
|
state = :auth_sent
|
486
486
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
487
|
-
Nokogiri::XML(val).to_xml.
|
487
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAGRvbwBwYXNz</auth>').to_xml)
|
488
488
|
|
489
489
|
when :auth_sent
|
490
490
|
EM.stop
|
491
491
|
state = :complete
|
492
|
-
val.
|
492
|
+
expect(val).to match(/stream:stream/)
|
493
493
|
|
494
494
|
else
|
495
495
|
EM.stop
|
@@ -507,17 +507,17 @@ describe Blather::Stream::Client do
|
|
507
507
|
when nil
|
508
508
|
state = :started
|
509
509
|
server.send_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>"
|
510
|
-
val.
|
510
|
+
expect(val).to match(/stream:stream/)
|
511
511
|
|
512
512
|
when :started
|
513
513
|
state = :auth_sent
|
514
514
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
515
|
-
Nokogiri::XML(val).to_xml.
|
515
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS"/>').to_xml)
|
516
516
|
|
517
517
|
when :auth_sent
|
518
518
|
EM.stop
|
519
519
|
state = :complete
|
520
|
-
val.
|
520
|
+
expect(val).to match(/stream:stream/)
|
521
521
|
|
522
522
|
else
|
523
523
|
EM.stop
|
@@ -537,17 +537,17 @@ describe Blather::Stream::Client do
|
|
537
537
|
when nil
|
538
538
|
state = :started
|
539
539
|
server.send_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>"
|
540
|
-
val.
|
540
|
+
expect(val).to match(/stream:stream/)
|
541
541
|
|
542
542
|
when :started
|
543
543
|
state = :auth_sent
|
544
544
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
545
|
-
Nokogiri::XML(val).to_xml.
|
545
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS"/>').to_xml)
|
546
546
|
|
547
547
|
when :auth_sent
|
548
548
|
EM.stop
|
549
549
|
state = :complete
|
550
|
-
val.
|
550
|
+
expect(val).to match(/stream:stream/)
|
551
551
|
|
552
552
|
else
|
553
553
|
EM.stop
|
@@ -558,7 +558,7 @@ describe Blather::Stream::Client do
|
|
558
558
|
end
|
559
559
|
|
560
560
|
it 'fails if asked to connect via ANONYMOUS but the server does not support it' do
|
561
|
-
client.expects(:receive_data).with { |s| s.
|
561
|
+
client.expects(:receive_data).with { |s| expect(s).to be_instance_of Blather::BlatherError }
|
562
562
|
|
563
563
|
state = nil
|
564
564
|
mocked_server(2) do |val, server|
|
@@ -567,11 +567,11 @@ describe Blather::Stream::Client do
|
|
567
567
|
state = :started
|
568
568
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
569
569
|
server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
|
570
|
-
val.
|
570
|
+
expect(val).to match(/stream:stream/)
|
571
571
|
|
572
572
|
when :started
|
573
573
|
EM.stop
|
574
|
-
val.
|
574
|
+
expect(val).to match(/stream:stream/)
|
575
575
|
|
576
576
|
else
|
577
577
|
EM.stop
|
@@ -584,8 +584,8 @@ describe Blather::Stream::Client do
|
|
584
584
|
|
585
585
|
it 'tries each possible mechanism until it fails completely' do
|
586
586
|
client.expects(:receive_data).with do |n|
|
587
|
-
n.
|
588
|
-
n.name.
|
587
|
+
expect(n).to be_kind_of(Blather::SASLError)
|
588
|
+
expect(n.name).to eq(:not_authorized)
|
589
589
|
end
|
590
590
|
|
591
591
|
state = nil
|
@@ -595,27 +595,27 @@ describe Blather::Stream::Client do
|
|
595
595
|
state = :started
|
596
596
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
597
597
|
server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
|
598
|
-
val.
|
598
|
+
expect(val).to match(/stream:stream/)
|
599
599
|
|
600
600
|
when :started
|
601
601
|
state = :failed_md5
|
602
602
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
603
|
-
val.
|
603
|
+
expect(val).to match(/mechanism="DIGEST-MD5"/)
|
604
604
|
|
605
605
|
when :failed_md5
|
606
606
|
state = :failed_plain
|
607
607
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
608
|
-
val.
|
608
|
+
expect(val).to match(/mechanism="PLAIN"/)
|
609
609
|
|
610
610
|
when :failed_plain
|
611
611
|
state = :failed_anon
|
612
612
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
613
|
-
val.
|
613
|
+
expect(val).to match(/mechanism="ANONYMOUS"/)
|
614
614
|
|
615
615
|
when :failed_anon
|
616
616
|
EM.stop
|
617
617
|
state = :complete
|
618
|
-
val.
|
618
|
+
expect(val).to match(/\/stream:stream/)
|
619
619
|
|
620
620
|
else
|
621
621
|
EM.stop
|
@@ -632,21 +632,21 @@ describe Blather::Stream::Client do
|
|
632
632
|
when nil
|
633
633
|
state = :started
|
634
634
|
server.send_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>"
|
635
|
-
val.
|
635
|
+
expect(val).to match(/stream:stream/)
|
636
636
|
|
637
637
|
when :started
|
638
638
|
state = :failed_md5
|
639
639
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
640
|
-
val.
|
640
|
+
expect(val).to match(/mechanism="DIGEST-MD5"/)
|
641
641
|
|
642
642
|
when :failed_md5
|
643
643
|
state = :plain_sent
|
644
644
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
645
|
-
val.
|
645
|
+
expect(val).to match(/mechanism="PLAIN"/)
|
646
646
|
|
647
647
|
when :plain_sent
|
648
648
|
EM.stop
|
649
|
-
val.
|
649
|
+
expect(val).to match(/stream:stream/)
|
650
650
|
|
651
651
|
else
|
652
652
|
EM.stop
|
@@ -664,17 +664,17 @@ describe Blather::Stream::Client do
|
|
664
664
|
state = :started
|
665
665
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
666
666
|
server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>CRAM-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
|
667
|
-
val.
|
667
|
+
expect(val).to match(/stream:stream/)
|
668
668
|
|
669
669
|
when :started
|
670
670
|
state = :auth_sent
|
671
671
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
672
|
-
Nokogiri::XML(val).to_xml.
|
672
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>').to_xml)
|
673
673
|
|
674
674
|
when :auth_sent
|
675
675
|
EM.stop
|
676
676
|
state = :complete
|
677
|
-
val.
|
677
|
+
expect(val).to match(/stream:stream/)
|
678
678
|
|
679
679
|
else
|
680
680
|
EM.stop
|
@@ -694,7 +694,7 @@ describe Blather::Stream::Client do
|
|
694
694
|
].each do |error_type|
|
695
695
|
it "fails on #{error_type}" do
|
696
696
|
client.expects(:receive_data).with do |n|
|
697
|
-
n.name.
|
697
|
+
expect(n.name).to eq(error_type.gsub('-','_').to_sym)
|
698
698
|
end
|
699
699
|
|
700
700
|
state = nil
|
@@ -703,17 +703,17 @@ describe Blather::Stream::Client do
|
|
703
703
|
when nil
|
704
704
|
state = :started
|
705
705
|
server.send_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>"
|
706
|
-
val.
|
706
|
+
expect(val).to match(/stream:stream/)
|
707
707
|
|
708
708
|
when :started
|
709
709
|
state = :auth_sent
|
710
710
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><#{error_type} /></failure>"
|
711
|
-
Nokogiri::XML(val).to_xml.
|
711
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>').to_xml)
|
712
712
|
|
713
713
|
when :auth_sent
|
714
714
|
EM.stop
|
715
715
|
state = :complete
|
716
|
-
val.
|
716
|
+
expect(val).to match(/\/stream:stream/)
|
717
717
|
|
718
718
|
else
|
719
719
|
EM.stop
|
@@ -726,8 +726,8 @@ describe Blather::Stream::Client do
|
|
726
726
|
|
727
727
|
it 'fails when an unknown node comes through during SASL negotiation' do
|
728
728
|
client.expects(:receive_data).with do |n|
|
729
|
-
n.
|
730
|
-
n.node.element_name.
|
729
|
+
expect(n).to be_instance_of Blather::UnknownResponse
|
730
|
+
expect(n.node.element_name).to eq('foo-bar')
|
731
731
|
end
|
732
732
|
|
733
733
|
state = nil
|
@@ -736,17 +736,17 @@ describe Blather::Stream::Client do
|
|
736
736
|
when nil
|
737
737
|
state = :started
|
738
738
|
server.send_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>"
|
739
|
-
val.
|
739
|
+
expect(val).to match(/stream:stream/)
|
740
740
|
|
741
741
|
when :started
|
742
742
|
state = :auth_sent
|
743
743
|
server.send_data "<foo-bar />"
|
744
|
-
Nokogiri::XML(val).to_xml.
|
744
|
+
expect(Nokogiri::XML(val).to_xml).to eq(Nokogiri::XML('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>').to_xml)
|
745
745
|
|
746
746
|
when :auth_sent
|
747
747
|
EM.stop
|
748
748
|
state = :complete
|
749
|
-
val.
|
749
|
+
expect(val).to match(/\/stream:stream/)
|
750
750
|
|
751
751
|
else
|
752
752
|
EM.stop
|
@@ -767,18 +767,18 @@ describe Blather::Stream::Client do
|
|
767
767
|
state = :started
|
768
768
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
769
769
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
770
|
-
val.
|
770
|
+
expect(val).to match(/stream:stream/)
|
771
771
|
|
772
772
|
when :started
|
773
773
|
state = :complete
|
774
774
|
val =~ %r{<iq[^>]+id="([^"]+)"}
|
775
775
|
server.send_data "<iq type='result' id='#{$1}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{jid}/server_resource</jid></bind></iq>"
|
776
776
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
777
|
-
val.
|
777
|
+
expect(val).to match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"\s?/>})
|
778
778
|
|
779
779
|
when :complete
|
780
780
|
EM.stop
|
781
|
-
@stream.jid.
|
781
|
+
expect(@stream.jid).to eq(Blather::JID.new('n@d/server_resource'))
|
782
782
|
|
783
783
|
else
|
784
784
|
EM.stop
|
@@ -797,14 +797,14 @@ describe Blather::Stream::Client do
|
|
797
797
|
state = :started
|
798
798
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
799
799
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
800
|
-
val.
|
800
|
+
expect(val).to match(/stream:stream/)
|
801
801
|
|
802
802
|
when :started
|
803
803
|
state = :complete
|
804
804
|
val =~ %r{<iq[^>]+id="([^"]+)"}
|
805
805
|
client.expects(:receive_data).with("BIND result ID mismatch. Expected: #{$1}. Received: #{$1}-bad")
|
806
806
|
server.send_data "<iq type='result' id='#{$1}-bad'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{jid}/server_resource</jid></bind></iq>"
|
807
|
-
val.
|
807
|
+
expect(val).to match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"\s?/>})
|
808
808
|
|
809
809
|
when :complete
|
810
810
|
EM.stop
|
@@ -826,12 +826,12 @@ describe Blather::Stream::Client do
|
|
826
826
|
when nil
|
827
827
|
state = :started
|
828
828
|
server.send_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>"
|
829
|
-
val.
|
829
|
+
expect(val).to match(/stream:stream/)
|
830
830
|
|
831
831
|
when :started
|
832
832
|
state = :complete
|
833
833
|
doc = parse_stanza val
|
834
|
-
doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).
|
834
|
+
expect(doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS)).not_to be_empty
|
835
835
|
|
836
836
|
server.send_data "<iq type='result' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{jid}</jid></bind></iq>"
|
837
837
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
@@ -839,7 +839,7 @@ describe Blather::Stream::Client do
|
|
839
839
|
|
840
840
|
when :complete
|
841
841
|
EM.stop
|
842
|
-
@stream.jid.
|
842
|
+
expect(@stream.jid).to eq(Blather::JID.new('n@d/r'))
|
843
843
|
|
844
844
|
else
|
845
845
|
EM.stop
|
@@ -851,7 +851,7 @@ describe Blather::Stream::Client do
|
|
851
851
|
|
852
852
|
it 'will return an error if resource binding errors out' do
|
853
853
|
client.expects(:receive_data).with do |n|
|
854
|
-
n.name.
|
854
|
+
expect(n.name).to eq(:bad_request)
|
855
855
|
end
|
856
856
|
|
857
857
|
state = nil
|
@@ -860,18 +860,18 @@ describe Blather::Stream::Client do
|
|
860
860
|
when nil
|
861
861
|
state = :started
|
862
862
|
server.send_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>"
|
863
|
-
val.
|
863
|
+
expect(val).to match(/stream:stream/)
|
864
864
|
|
865
865
|
when :started
|
866
866
|
state = :complete
|
867
867
|
doc = parse_stanza val
|
868
|
-
doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).
|
868
|
+
expect(doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS)).not_to be_empty
|
869
869
|
server.send_data "<iq type='error' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>r</resource></bind><error type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"
|
870
870
|
true
|
871
871
|
|
872
872
|
when :complete
|
873
873
|
EM.stop
|
874
|
-
val.
|
874
|
+
expect(val).to match(/\/stream:stream/)
|
875
875
|
|
876
876
|
else
|
877
877
|
EM.stop
|
@@ -883,8 +883,8 @@ describe Blather::Stream::Client do
|
|
883
883
|
|
884
884
|
it 'will return an error if an unknown node comes through during resouce binding' do
|
885
885
|
client.expects(:receive_data).with do |n|
|
886
|
-
n.
|
887
|
-
n.node.element_name.
|
886
|
+
expect(n).to be_instance_of Blather::UnknownResponse
|
887
|
+
expect(n.node.element_name).to eq('foo-bar')
|
888
888
|
end
|
889
889
|
|
890
890
|
state = nil
|
@@ -894,18 +894,18 @@ describe Blather::Stream::Client do
|
|
894
894
|
state = :started
|
895
895
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
896
896
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
897
|
-
val.
|
897
|
+
expect(val).to match(/stream:stream/)
|
898
898
|
|
899
899
|
when :started
|
900
900
|
state = :complete
|
901
901
|
doc = parse_stanza val
|
902
|
-
doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).
|
902
|
+
expect(doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS)).not_to be_empty
|
903
903
|
server.send_data "<foo-bar />"
|
904
904
|
true
|
905
905
|
|
906
906
|
when :complete
|
907
907
|
EM.stop
|
908
|
-
val.
|
908
|
+
expect(val).to match(/\/stream:stream/)
|
909
909
|
|
910
910
|
else
|
911
911
|
EM.stop
|
@@ -925,12 +925,12 @@ describe Blather::Stream::Client do
|
|
925
925
|
state = :started
|
926
926
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
927
927
|
server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
|
928
|
-
val.
|
928
|
+
expect(val).to match(/stream:stream/)
|
929
929
|
|
930
930
|
when :started
|
931
931
|
state = :completed
|
932
932
|
doc = parse_stanza val
|
933
|
-
doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).
|
933
|
+
expect(doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS)).not_to be_empty
|
934
934
|
server.send_data "<iq from='d' type='result' id='#{doc.find_first('iq')['id']}' />"
|
935
935
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
936
936
|
true
|
@@ -958,18 +958,18 @@ describe Blather::Stream::Client do
|
|
958
958
|
state = :started
|
959
959
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
960
960
|
server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></stream:features>"
|
961
|
-
val.
|
961
|
+
expect(val).to match(/stream:stream/)
|
962
962
|
|
963
963
|
when :started
|
964
964
|
state = :complete
|
965
965
|
doc = parse_stanza val
|
966
|
-
doc.find('/iq[@type="set"]/bind_ns:bind', :bind_ns => Blather::Stream::Resource::BIND_NS).
|
966
|
+
expect(doc.find('/iq[@type="set"]/bind_ns:bind', :bind_ns => Blather::Stream::Resource::BIND_NS)).not_to be_empty
|
967
967
|
server.send_data "<iq type='result' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{client.jid}</jid></bind></iq>"
|
968
968
|
true
|
969
969
|
|
970
970
|
when :complete
|
971
971
|
doc = parse_stanza val
|
972
|
-
doc.find('/iq[@type="set"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).
|
972
|
+
expect(doc.find('/iq[@type="set"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS)).not_to be_empty
|
973
973
|
EM.stop
|
974
974
|
true
|
975
975
|
|
@@ -989,18 +989,18 @@ describe Blather::Stream::Client do
|
|
989
989
|
state = :started
|
990
990
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
991
991
|
server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>"
|
992
|
-
val.
|
992
|
+
expect(val).to match(/stream:stream/)
|
993
993
|
|
994
994
|
when :started
|
995
995
|
state = :complete
|
996
996
|
doc = parse_stanza val
|
997
|
-
doc.find('/iq[@type="set"]/bind_ns:bind', :bind_ns => Blather::Stream::Resource::BIND_NS).
|
997
|
+
expect(doc.find('/iq[@type="set"]/bind_ns:bind', :bind_ns => Blather::Stream::Resource::BIND_NS)).not_to be_empty
|
998
998
|
server.send_data "<iq type='result' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{client.jid}</jid></bind></iq>"
|
999
999
|
true
|
1000
1000
|
|
1001
1001
|
when :complete
|
1002
1002
|
doc = parse_stanza val
|
1003
|
-
doc.find('/iq[@type="set"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).
|
1003
|
+
expect(doc.find('/iq[@type="set"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS)).not_to be_empty
|
1004
1004
|
EM.stop
|
1005
1005
|
true
|
1006
1006
|
|
@@ -1014,7 +1014,7 @@ describe Blather::Stream::Client do
|
|
1014
1014
|
|
1015
1015
|
it 'will return an error if session establishment errors out' do
|
1016
1016
|
client.expects(:receive_data).with do |n|
|
1017
|
-
n.name.
|
1017
|
+
expect(n.name).to eq(:internal_server_error)
|
1018
1018
|
end
|
1019
1019
|
|
1020
1020
|
state = nil
|
@@ -1024,18 +1024,18 @@ describe Blather::Stream::Client do
|
|
1024
1024
|
state = :started
|
1025
1025
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
1026
1026
|
server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
|
1027
|
-
val.
|
1027
|
+
expect(val).to match(/stream:stream/)
|
1028
1028
|
|
1029
1029
|
when :started
|
1030
1030
|
state = :completed
|
1031
1031
|
doc = parse_stanza val
|
1032
|
-
doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).
|
1032
|
+
expect(doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS)).not_to be_empty
|
1033
1033
|
server.send_data "<iq from='d' type='error' id='#{doc.find_first('iq')['id']}'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/><error type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"
|
1034
1034
|
true
|
1035
1035
|
|
1036
1036
|
when :completed
|
1037
1037
|
EM.stop
|
1038
|
-
val.
|
1038
|
+
expect(val).to match(/\/stream:stream/)
|
1039
1039
|
|
1040
1040
|
else
|
1041
1041
|
EM.stop
|
@@ -1047,8 +1047,8 @@ describe Blather::Stream::Client do
|
|
1047
1047
|
|
1048
1048
|
it 'will return an error if an unknown node come through during session establishment' do
|
1049
1049
|
client.expects(:receive_data).with do |n|
|
1050
|
-
n.
|
1051
|
-
n.node.element_name.
|
1050
|
+
expect(n).to be_instance_of Blather::UnknownResponse
|
1051
|
+
expect(n.node.element_name).to eq('foo-bar')
|
1052
1052
|
end
|
1053
1053
|
|
1054
1054
|
state = nil
|
@@ -1058,18 +1058,18 @@ describe Blather::Stream::Client do
|
|
1058
1058
|
state = :started
|
1059
1059
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
1060
1060
|
server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
|
1061
|
-
val.
|
1061
|
+
expect(val).to match(/stream:stream/)
|
1062
1062
|
|
1063
1063
|
when :started
|
1064
1064
|
state = :completed
|
1065
1065
|
doc = parse_stanza val
|
1066
|
-
doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).
|
1066
|
+
expect(doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS)).not_to be_empty
|
1067
1067
|
server.send_data '<foo-bar />'
|
1068
1068
|
true
|
1069
1069
|
|
1070
1070
|
when :completed
|
1071
1071
|
EM.stop
|
1072
|
-
val.
|
1072
|
+
expect(val).to match(/\/stream:stream/)
|
1073
1073
|
|
1074
1074
|
else
|
1075
1075
|
EM.stop
|
@@ -1081,8 +1081,8 @@ describe Blather::Stream::Client do
|
|
1081
1081
|
|
1082
1082
|
it 'sends client an error and reply to the server on parse error' do
|
1083
1083
|
client.expects(:receive_data).with do |v|
|
1084
|
-
v.
|
1085
|
-
v.message.
|
1084
|
+
expect(v).to be_kind_of Blather::ParseError
|
1085
|
+
expect(v.message).to match(/match/)
|
1086
1086
|
end
|
1087
1087
|
|
1088
1088
|
state = nil
|
@@ -1092,17 +1092,17 @@ describe Blather::Stream::Client do
|
|
1092
1092
|
state = :started
|
1093
1093
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"
|
1094
1094
|
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
|
1095
|
-
val.
|
1095
|
+
expect(val).to match(/stream:stream/)
|
1096
1096
|
|
1097
1097
|
when :started
|
1098
1098
|
state = :parse_error
|
1099
|
-
val.
|
1099
|
+
expect(val).to match(/bind/)
|
1100
1100
|
server.send_data "</generate-parse-error>"
|
1101
1101
|
true
|
1102
1102
|
|
1103
1103
|
when :parse_error
|
1104
1104
|
EM.stop
|
1105
|
-
val.
|
1105
|
+
expect(val).to eq("<stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>")
|
1106
1106
|
|
1107
1107
|
else
|
1108
1108
|
EM.stop
|
@@ -1116,14 +1116,14 @@ describe Blather::Stream::Client do
|
|
1116
1116
|
msg = Blather::Stanza::Message.new 'to@jid.com', 'body'
|
1117
1117
|
msg.from = 'node@jid.com'
|
1118
1118
|
comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
|
1119
|
-
comp.expects(:send_data).with { |s| s.
|
1119
|
+
comp.expects(:send_data).with { |s| expect(s).to match(/^<message[^>]*from="node@jid\.com\/resource"/) }
|
1120
1120
|
comp.send msg
|
1121
1121
|
end
|
1122
1122
|
|
1123
1123
|
it 'sends stanzas to the wire leaving "from" nil if not set' do
|
1124
1124
|
msg = Blather::Stanza::Message.new 'to@jid.com', 'body'
|
1125
1125
|
comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
|
1126
|
-
comp.expects(:send_data).with { |s| s.
|
1126
|
+
comp.expects(:send_data).with { |s| expect(s).not_to match(/^<message[^>]*from=/); true }
|
1127
1127
|
comp.send msg
|
1128
1128
|
end
|
1129
1129
|
|
@@ -1131,14 +1131,14 @@ describe Blather::Stream::Client do
|
|
1131
1131
|
stanza = Blather::Stanza::Iq.new :set, 'foo@bar.com', '123'
|
1132
1132
|
error = Blather::StanzaError.new(stanza, 'registration-required', :cancel)
|
1133
1133
|
comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
|
1134
|
-
comp.expects(:send_data).with { |s| s.
|
1134
|
+
comp.expects(:send_data).with { |s| expect(s).to match(/<error type=\"cancel\"><registration-required/); true }
|
1135
1135
|
comp.send error
|
1136
1136
|
end
|
1137
1137
|
|
1138
1138
|
it 'sends stream errors to the wire correctly' do
|
1139
1139
|
error = Blather::StreamError.new('foo-error')
|
1140
1140
|
comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
|
1141
|
-
comp.expects(:send_data).with { |s| s.
|
1141
|
+
comp.expects(:send_data).with { |s| expect(s).to match(/<stream:error xmlns:stream=\"http:\/\/etherx.jabber.org\/streams\"><foo-error/); true }
|
1142
1142
|
comp.send error
|
1143
1143
|
end
|
1144
1144
|
|
@@ -1147,7 +1147,7 @@ describe Blather::Stream::Client do
|
|
1147
1147
|
msg.xhtml = '<i>xhtml</i> body'
|
1148
1148
|
|
1149
1149
|
comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
|
1150
|
-
comp.expects(:send_data).with { |s| s.
|
1150
|
+
comp.expects(:send_data).with { |s| expect(s).not_to match(/\n/); true }
|
1151
1151
|
comp.send msg
|
1152
1152
|
end
|
1153
1153
|
|
@@ -1159,22 +1159,22 @@ describe Blather::Stream::Client do
|
|
1159
1159
|
state = :sasl_attempted
|
1160
1160
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
1161
1161
|
server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>"
|
1162
|
-
val.
|
1162
|
+
expect(val).to match(/stream:stream/)
|
1163
1163
|
when :sasl_attempted
|
1164
1164
|
state = :sasl_failed
|
1165
1165
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
1166
|
-
val.
|
1166
|
+
expect(val).to match(/auth/)
|
1167
1167
|
when :sasl_failed
|
1168
1168
|
state = :registered
|
1169
1169
|
server.send_data "<iq type='result'/>"
|
1170
|
-
val.
|
1170
|
+
expect(val).to match(/jabber:iq:register/)
|
1171
1171
|
when :registered
|
1172
1172
|
state = :authenticated
|
1173
1173
|
server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
|
1174
|
-
val.
|
1174
|
+
expect(val).to match(/mechanism="PLAIN"/)
|
1175
1175
|
when :authenticated
|
1176
1176
|
EM.stop
|
1177
|
-
val.
|
1177
|
+
expect(val).to match(/stream:stream/)
|
1178
1178
|
else
|
1179
1179
|
EM.stop
|
1180
1180
|
false
|
@@ -1183,7 +1183,7 @@ describe Blather::Stream::Client do
|
|
1183
1183
|
end
|
1184
1184
|
|
1185
1185
|
it 'fails when in-band registration failed' do
|
1186
|
-
client.expects(:receive_data).with { |n| n.
|
1186
|
+
client.expects(:receive_data).with { |n| expect(n).to be_instance_of Blather::BlatherError }
|
1187
1187
|
|
1188
1188
|
state = nil
|
1189
1189
|
mocked_server(4) do |val, server|
|
@@ -1192,18 +1192,18 @@ describe Blather::Stream::Client do
|
|
1192
1192
|
state = :sasl_attempted
|
1193
1193
|
server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
|
1194
1194
|
server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>"
|
1195
|
-
val.
|
1195
|
+
expect(val).to match(/stream:stream/)
|
1196
1196
|
when :sasl_attempted
|
1197
1197
|
state = :sasl_failed
|
1198
1198
|
server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
|
1199
|
-
val.
|
1199
|
+
expect(val).to match(/auth/)
|
1200
1200
|
when :sasl_failed
|
1201
1201
|
state = :registration_failed
|
1202
1202
|
server.send_data "<iq type='error'><query /><error code='409' type='cancel'><conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"
|
1203
|
-
val.
|
1203
|
+
expect(val).to match(/jabber:iq:register/)
|
1204
1204
|
when :registration_failed
|
1205
1205
|
EM.stop
|
1206
|
-
val.
|
1206
|
+
expect(val).to match(/\/stream:stream/)
|
1207
1207
|
else
|
1208
1208
|
EM.stop
|
1209
1209
|
false
|