tp-blather 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +13 -0
- data/.gemtest +0 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +249 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE +22 -0
- data/README.md +413 -0
- data/Rakefile +20 -0
- data/TODO.md +2 -0
- data/blather.gemspec +51 -0
- data/examples/certs/README +20 -0
- data/examples/certs/ca-bundle.crt +3987 -0
- data/examples/echo.rb +19 -0
- data/examples/execute.rb +17 -0
- data/examples/ping_pong.rb +38 -0
- data/examples/print_hierarchy.rb +77 -0
- data/examples/rosterprint.rb +15 -0
- data/examples/stream_only.rb +28 -0
- data/examples/trusted_echo.rb +21 -0
- data/examples/xmpp4r/echo.rb +36 -0
- data/lib/blather.rb +112 -0
- data/lib/blather/cert_store.rb +53 -0
- data/lib/blather/client.rb +95 -0
- data/lib/blather/client/client.rb +345 -0
- data/lib/blather/client/dsl.rb +320 -0
- data/lib/blather/client/dsl/pubsub.rb +174 -0
- data/lib/blather/core_ext/eventmachine.rb +125 -0
- data/lib/blather/core_ext/ipaddr.rb +20 -0
- data/lib/blather/errors.rb +69 -0
- data/lib/blather/errors/sasl_error.rb +44 -0
- data/lib/blather/errors/stanza_error.rb +110 -0
- data/lib/blather/errors/stream_error.rb +84 -0
- data/lib/blather/file_transfer.rb +107 -0
- data/lib/blather/file_transfer/ibb.rb +68 -0
- data/lib/blather/file_transfer/s5b.rb +114 -0
- data/lib/blather/jid.rb +141 -0
- data/lib/blather/roster.rb +118 -0
- data/lib/blather/roster_item.rb +146 -0
- data/lib/blather/stanza.rb +167 -0
- data/lib/blather/stanza/disco.rb +32 -0
- data/lib/blather/stanza/disco/capabilities.rb +161 -0
- data/lib/blather/stanza/disco/disco_info.rb +205 -0
- data/lib/blather/stanza/disco/disco_items.rb +134 -0
- data/lib/blather/stanza/iq.rb +144 -0
- data/lib/blather/stanza/iq/command.rb +339 -0
- data/lib/blather/stanza/iq/ibb.rb +86 -0
- data/lib/blather/stanza/iq/ping.rb +50 -0
- data/lib/blather/stanza/iq/query.rb +53 -0
- data/lib/blather/stanza/iq/roster.rb +185 -0
- data/lib/blather/stanza/iq/s5b.rb +208 -0
- data/lib/blather/stanza/iq/si.rb +415 -0
- data/lib/blather/stanza/iq/vcard.rb +149 -0
- data/lib/blather/stanza/message.rb +428 -0
- data/lib/blather/stanza/message/muc_user.rb +119 -0
- data/lib/blather/stanza/muc/muc_user_base.rb +54 -0
- data/lib/blather/stanza/presence.rb +172 -0
- data/lib/blather/stanza/presence/c.rb +100 -0
- data/lib/blather/stanza/presence/muc.rb +35 -0
- data/lib/blather/stanza/presence/muc_user.rb +147 -0
- data/lib/blather/stanza/presence/status.rb +218 -0
- data/lib/blather/stanza/presence/subscription.rb +100 -0
- data/lib/blather/stanza/pubsub.rb +119 -0
- data/lib/blather/stanza/pubsub/affiliations.rb +79 -0
- data/lib/blather/stanza/pubsub/create.rb +65 -0
- data/lib/blather/stanza/pubsub/errors.rb +18 -0
- data/lib/blather/stanza/pubsub/event.rb +139 -0
- data/lib/blather/stanza/pubsub/items.rb +103 -0
- data/lib/blather/stanza/pubsub/publish.rb +103 -0
- data/lib/blather/stanza/pubsub/retract.rb +92 -0
- data/lib/blather/stanza/pubsub/subscribe.rb +68 -0
- data/lib/blather/stanza/pubsub/subscription.rb +135 -0
- data/lib/blather/stanza/pubsub/subscriptions.rb +83 -0
- data/lib/blather/stanza/pubsub/unsubscribe.rb +84 -0
- data/lib/blather/stanza/pubsub_owner.rb +51 -0
- data/lib/blather/stanza/pubsub_owner/delete.rb +52 -0
- data/lib/blather/stanza/pubsub_owner/purge.rb +52 -0
- data/lib/blather/stanza/x.rb +416 -0
- data/lib/blather/stream.rb +266 -0
- data/lib/blather/stream/client.rb +32 -0
- data/lib/blather/stream/component.rb +39 -0
- data/lib/blather/stream/features.rb +70 -0
- data/lib/blather/stream/features/register.rb +38 -0
- data/lib/blather/stream/features/resource.rb +63 -0
- data/lib/blather/stream/features/sasl.rb +190 -0
- data/lib/blather/stream/features/session.rb +45 -0
- data/lib/blather/stream/features/tls.rb +29 -0
- data/lib/blather/stream/parser.rb +102 -0
- data/lib/blather/version.rb +3 -0
- data/lib/blather/xmpp_node.rb +94 -0
- data/spec/blather/client/client_spec.rb +687 -0
- data/spec/blather/client/dsl/pubsub_spec.rb +492 -0
- data/spec/blather/client/dsl_spec.rb +266 -0
- data/spec/blather/errors/sasl_error_spec.rb +33 -0
- data/spec/blather/errors/stanza_error_spec.rb +129 -0
- data/spec/blather/errors/stream_error_spec.rb +108 -0
- data/spec/blather/errors_spec.rb +33 -0
- data/spec/blather/file_transfer_spec.rb +135 -0
- data/spec/blather/jid_spec.rb +87 -0
- data/spec/blather/roster_item_spec.rb +134 -0
- data/spec/blather/roster_spec.rb +107 -0
- data/spec/blather/stanza/discos/disco_info_spec.rb +247 -0
- data/spec/blather/stanza/discos/disco_items_spec.rb +154 -0
- data/spec/blather/stanza/iq/command_spec.rb +206 -0
- data/spec/blather/stanza/iq/ibb_spec.rb +124 -0
- data/spec/blather/stanza/iq/ping_spec.rb +45 -0
- data/spec/blather/stanza/iq/query_spec.rb +64 -0
- data/spec/blather/stanza/iq/roster_spec.rb +139 -0
- data/spec/blather/stanza/iq/s5b_spec.rb +57 -0
- data/spec/blather/stanza/iq/si_spec.rb +98 -0
- data/spec/blather/stanza/iq/vcard_spec.rb +93 -0
- data/spec/blather/stanza/iq_spec.rb +61 -0
- data/spec/blather/stanza/message/muc_user_spec.rb +152 -0
- data/spec/blather/stanza/message_spec.rb +282 -0
- data/spec/blather/stanza/presence/c_spec.rb +56 -0
- data/spec/blather/stanza/presence/muc_spec.rb +37 -0
- data/spec/blather/stanza/presence/muc_user_spec.rb +83 -0
- data/spec/blather/stanza/presence/status_spec.rb +144 -0
- data/spec/blather/stanza/presence/subscription_spec.rb +102 -0
- data/spec/blather/stanza/presence_spec.rb +125 -0
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +57 -0
- data/spec/blather/stanza/pubsub/create_spec.rb +56 -0
- data/spec/blather/stanza/pubsub/event_spec.rb +98 -0
- data/spec/blather/stanza/pubsub/items_spec.rb +79 -0
- data/spec/blather/stanza/pubsub/publish_spec.rb +83 -0
- data/spec/blather/stanza/pubsub/retract_spec.rb +75 -0
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +61 -0
- data/spec/blather/stanza/pubsub/subscription_spec.rb +97 -0
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +59 -0
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +74 -0
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +50 -0
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +50 -0
- data/spec/blather/stanza/pubsub_owner_spec.rb +27 -0
- data/spec/blather/stanza/pubsub_spec.rb +68 -0
- data/spec/blather/stanza/x_spec.rb +231 -0
- data/spec/blather/stanza_spec.rb +134 -0
- data/spec/blather/stream/client_spec.rb +1090 -0
- data/spec/blather/stream/component_spec.rb +108 -0
- data/spec/blather/stream/parser_spec.rb +152 -0
- data/spec/blather/stream/ssl_spec.rb +32 -0
- data/spec/blather/xmpp_node_spec.rb +47 -0
- data/spec/blather_spec.rb +34 -0
- data/spec/fixtures/pubsub.rb +311 -0
- data/spec/spec_helper.rb +17 -0
- data/yard/templates/default/class/html/handlers.erb +18 -0
- data/yard/templates/default/class/setup.rb +10 -0
- data/yard/templates/default/class/text/handlers.erb +1 -0
- metadata +459 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSub::Subscribe do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:subscribe, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscribe
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can be imported' do
|
10
|
+
Blather::XMPPNode.parse(subscribe_xml).should be_instance_of Blather::Stanza::PubSub::Subscribe
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'ensures an subscribe node is present on create' do
|
14
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
15
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'ensures an subscribe node exists when calling #subscribe' do
|
19
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
20
|
+
subscribe.pubsub.remove_children :subscribe
|
21
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
|
+
|
23
|
+
subscribe.subscribe.should_not be_nil
|
24
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'defaults to a set node' do
|
28
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
29
|
+
subscribe.type.should == :set
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'sets the host if requested' do
|
33
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'pubsub.jabber.local', 'node', 'jid'
|
34
|
+
subscribe.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'sets the node' do
|
38
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
39
|
+
subscribe.node.should == 'node-name'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has a node attribute' do
|
43
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
44
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
subscribe.node.should == 'node-name'
|
46
|
+
|
47
|
+
subscribe.node = 'new-node'
|
48
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
subscribe.node.should == 'new-node'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a jid attribute' do
|
53
|
+
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
54
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
subscribe.jid.should == Blather::JID.new('jid')
|
56
|
+
|
57
|
+
subscribe.jid = Blather::JID.new('n@d/r')
|
58
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
subscribe.jid.should == Blather::JID.new('n@d/r')
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSub::Subscription do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:subscription, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscription
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can be imported' do
|
10
|
+
Blather::XMPPNode.parse(subscription_xml).should be_instance_of Blather::Stanza::PubSub::Subscription
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'ensures an subscription node is present on create' do
|
14
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
15
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'ensures an subscription node exists when calling #subscription_node' do
|
19
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
20
|
+
subscription.pubsub.remove_children :subscription
|
21
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
|
+
|
23
|
+
subscription.subscription_node.should_not be_nil
|
24
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'defaults to a set node' do
|
28
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
29
|
+
subscription.type.should == :set
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'sets the host if requested' do
|
33
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'pubsub.jabber.local', 'node', 'jid', 'subid', :none
|
34
|
+
subscription.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'sets the node' do
|
38
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
39
|
+
subscription.node.should == 'node-name'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has a node attribute' do
|
43
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
44
|
+
subscription.find('//ns:pubsub/ns:subscription[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
subscription.node.should == 'node-name'
|
46
|
+
|
47
|
+
subscription.node = 'new-node'
|
48
|
+
subscription.find('//ns:pubsub/ns:subscription[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
subscription.node.should == 'new-node'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a jid attribute' do
|
53
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
54
|
+
subscription.find('//ns:pubsub/ns:subscription[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
subscription.jid.should == Blather::JID.new('jid')
|
56
|
+
|
57
|
+
subscription.jid = Blather::JID.new('n@d/r')
|
58
|
+
subscription.find('//ns:pubsub/ns:subscription[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
subscription.jid.should == Blather::JID.new('n@d/r')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'has a subid attribute' do
|
63
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
64
|
+
subscription.find('//ns:pubsub/ns:subscription[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
65
|
+
subscription.subid.should == 'subid'
|
66
|
+
|
67
|
+
subscription.subid = 'new-subid'
|
68
|
+
subscription.find('//ns:pubsub/ns:subscription[@subid="new-subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
69
|
+
subscription.subid.should == 'new-subid'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'has a subscription attribute' do
|
73
|
+
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
74
|
+
subscription.find('//ns:pubsub/ns:subscription[@subscription="none"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
75
|
+
subscription.subscription.should == :none
|
76
|
+
|
77
|
+
subscription.subscription = :pending
|
78
|
+
subscription.find('//ns:pubsub/ns:subscription[@subscription="pending"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
79
|
+
subscription.subscription.should == :pending
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'ensures subscription is one of Stanza::PubSub::Subscription::VALID_TYPES' do
|
83
|
+
lambda { Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :invalid_type_name }.should raise_error(Blather::ArgumentError)
|
84
|
+
|
85
|
+
Blather::Stanza::PubSub::Subscription::VALID_TYPES.each do |valid_type|
|
86
|
+
n = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', valid_type
|
87
|
+
n.subscription.should == valid_type
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Blather::Stanza::PubSub::Subscription::VALID_TYPES.each do |valid_type|
|
92
|
+
it "provides a helper (#{valid_type}?) for type #{valid_type}" do
|
93
|
+
Blather::Stanza::PubSub::Subscription.new.should respond_to :"#{valid_type}?"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
def control_subscriptions
|
5
|
+
{ :subscribed => [{:node => 'node1', :jid => 'francisco@denmark.lit', :subid => 'fd8237yr872h3f289j2'}, {:node => 'node2', :jid => 'francisco@denmark.lit', :subid => 'h8394hf8923ju'}],
|
6
|
+
:unconfigured => [{:node => 'node3', :jid => 'francisco@denmark.lit'}],
|
7
|
+
:pending => [{:node => 'node4', :jid => 'francisco@denmark.lit'}],
|
8
|
+
:none => [{:node => 'node5', :jid => 'francisco@denmark.lit'}] }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Blather::Stanza::PubSub::Subscriptions do
|
12
|
+
it 'registers itself' do
|
13
|
+
Blather::XMPPNode.class_from_registration(:subscriptions, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscriptions
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'can be imported' do
|
17
|
+
Blather::XMPPNode.parse(subscriptions_xml).should be_instance_of Blather::Stanza::PubSub::Subscriptions
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'ensures an subscriptions node is present on create' do
|
21
|
+
subscriptions = Blather::Stanza::PubSub::Subscriptions.new
|
22
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'ensures an subscriptions node exists when calling #subscriptions' do
|
26
|
+
subscriptions = Blather::Stanza::PubSub::Subscriptions.new
|
27
|
+
subscriptions.pubsub.remove_children :subscriptions
|
28
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
29
|
+
|
30
|
+
subscriptions.subscriptions.should_not be_nil
|
31
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'defaults to a get node' do
|
35
|
+
aff = Blather::Stanza::PubSub::Subscriptions.new
|
36
|
+
aff.type.should == :get
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'sets the host if requested' do
|
40
|
+
aff = Blather::Stanza::PubSub::Subscriptions.new :get, 'pubsub.jabber.local'
|
41
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'can import a subscriptions result node' do
|
45
|
+
node = parse_stanza(subscriptions_xml).root
|
46
|
+
|
47
|
+
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
48
|
+
subscriptions.size.should == 4
|
49
|
+
subscriptions.list.should == control_subscriptions
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'will iterate over each subscription' do
|
53
|
+
node = parse_stanza(subscriptions_xml).root
|
54
|
+
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
55
|
+
subscriptions.each do |type, nodes|
|
56
|
+
nodes.should == control_subscriptions[type]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSub::Unsubscribe do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:unsubscribe, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Unsubscribe
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can be imported' do
|
10
|
+
Blather::XMPPNode.parse(unsubscribe_xml).should be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'ensures an unsubscribe node is present on create' do
|
14
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
15
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'ensures an unsubscribe node exists when calling #unsubscribe' do
|
19
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
20
|
+
unsubscribe.pubsub.remove_children :unsubscribe
|
21
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
|
+
|
23
|
+
unsubscribe.unsubscribe.should_not be_nil
|
24
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'defaults to a set node' do
|
28
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
29
|
+
unsubscribe.type.should == :set
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'sets the host if requested' do
|
33
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'pubsub.jabber.local', 'node', 'jid'
|
34
|
+
unsubscribe.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'sets the node' do
|
38
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
39
|
+
unsubscribe.node.should == 'node-name'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has a node attribute' do
|
43
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
44
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
unsubscribe.node.should == 'node-name'
|
46
|
+
|
47
|
+
unsubscribe.node = 'new-node'
|
48
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
unsubscribe.node.should == 'new-node'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has a jid attribute' do
|
53
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
54
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
unsubscribe.jid.should == Blather::JID.new('jid')
|
56
|
+
|
57
|
+
unsubscribe.jid = Blather::JID.new('n@d/r')
|
58
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
unsubscribe.jid.should == Blather::JID.new('n@d/r')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'has a subid attribute' do
|
63
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
64
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
65
|
+
|
66
|
+
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid', 'subid'
|
67
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
68
|
+
unsubscribe.subid.should == 'subid'
|
69
|
+
|
70
|
+
unsubscribe.subid = 'newsubid'
|
71
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="newsubid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
72
|
+
unsubscribe.subid.should == 'newsubid'
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSubOwner::Delete do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:delete, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Delete
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can be imported' do
|
10
|
+
Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Delete
|
11
|
+
<iq type='set'
|
12
|
+
from='hamlet@denmark.lit/elsinore'
|
13
|
+
to='pubsub.shakespeare.lit'
|
14
|
+
id='delete1'>
|
15
|
+
<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
|
16
|
+
<delete node='princely_musings'/>
|
17
|
+
</pubsub>
|
18
|
+
</iq>
|
19
|
+
NODE
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'ensures an delete node is present on delete' do
|
23
|
+
delete = Blather::Stanza::PubSubOwner::Delete.new
|
24
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'ensures an delete node exists when calling #delete_node' do
|
28
|
+
delete = Blather::Stanza::PubSubOwner::Delete.new
|
29
|
+
delete.pubsub.remove_children :delete
|
30
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
|
31
|
+
|
32
|
+
delete.delete_node.should_not be_nil
|
33
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'defaults to a set node' do
|
37
|
+
delete = Blather::Stanza::PubSubOwner::Delete.new
|
38
|
+
delete.type.should == :set
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'sets the host if requested' do
|
42
|
+
delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'pubsub.jabber.local'
|
43
|
+
delete.to.should == Blather::JID.new('pubsub.jabber.local')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'sets the node' do
|
47
|
+
delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'host', 'node-name'
|
48
|
+
delete.node.should == 'node-name'
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSubOwner::Purge do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:purge, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Purge
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'can be imported' do
|
10
|
+
Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Purge
|
11
|
+
<iq type='set'
|
12
|
+
from='hamlet@denmark.lit/elsinore'
|
13
|
+
to='pubsub.shakespeare.lit'
|
14
|
+
id='purge1'>
|
15
|
+
<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
|
16
|
+
<purge node='princely_musings'/>
|
17
|
+
</pubsub>
|
18
|
+
</iq>
|
19
|
+
NODE
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'ensures an purge node is present on create' do
|
23
|
+
purge = Blather::Stanza::PubSubOwner::Purge.new
|
24
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'ensures an purge node exists when calling #purge_node' do
|
28
|
+
purge = Blather::Stanza::PubSubOwner::Purge.new
|
29
|
+
purge.pubsub.remove_children :purge
|
30
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
|
31
|
+
|
32
|
+
purge.purge_node.should_not be_nil
|
33
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'defaults to a set node' do
|
37
|
+
purge = Blather::Stanza::PubSubOwner::Purge.new
|
38
|
+
purge.type.should == :set
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'sets the host if requested' do
|
42
|
+
purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'pubsub.jabber.local'
|
43
|
+
purge.to.should == Blather::JID.new('pubsub.jabber.local')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'sets the node' do
|
47
|
+
purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'host', 'node-name'
|
48
|
+
purge.node.should == 'node-name'
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSubOwner do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'ensures a pubusb node is present on create' do
|
10
|
+
pubsub = Blather::Stanza::PubSubOwner.new
|
11
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'ensures a pubsub node exists when calling #pubsub' do
|
15
|
+
pubsub = Blather::Stanza::PubSubOwner.new
|
16
|
+
pubsub.remove_children :pubsub
|
17
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_nil
|
18
|
+
|
19
|
+
pubsub.pubsub.should_not be_nil
|
20
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets the host if requested' do
|
24
|
+
aff = Blather::Stanza::PubSubOwner.new :get, 'pubsub.jabber.local'
|
25
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/pubsub'
|
3
|
+
|
4
|
+
describe Blather::Stanza::PubSub do
|
5
|
+
it 'registers itself' do
|
6
|
+
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'ensures a pubusb node is present on create' do
|
10
|
+
pubsub = Blather::Stanza::PubSub.new
|
11
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'ensures a pubsub node exists when calling #pubsub' do
|
15
|
+
pubsub = Blather::Stanza::PubSub.new
|
16
|
+
pubsub.remove_children :pubsub
|
17
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should be_nil
|
18
|
+
|
19
|
+
pubsub.pubsub.should_not be_nil
|
20
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'sets the host if requested' do
|
24
|
+
aff = Blather::Stanza::PubSub.new :get, 'pubsub.jabber.local'
|
25
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'ensures newly inherited items are PubSubItem objects' do
|
29
|
+
pubsub = Blather::XMPPNode.parse(items_all_nodes_xml)
|
30
|
+
pubsub.items.map { |i| i.class }.uniq.should == [Blather::Stanza::PubSub::PubSubItem]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe Blather::Stanza::PubSub::PubSubItem do
|
35
|
+
it 'can be initialized with just an ID' do
|
36
|
+
id = 'foobarbaz'
|
37
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new id
|
38
|
+
item.id.should == id
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can be initialized with a payload' do
|
42
|
+
payload = 'foobarbaz'
|
43
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
|
44
|
+
item.payload.should == payload
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'allows the payload to be set' do
|
48
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new
|
49
|
+
item.payload.should be_nil
|
50
|
+
item.payload = 'testing'
|
51
|
+
item.payload.should == 'testing'
|
52
|
+
item.content.should == 'testing'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'allows the payload to be unset' do
|
56
|
+
payload = 'foobarbaz'
|
57
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
|
58
|
+
item.payload.should == payload
|
59
|
+
item.payload = nil
|
60
|
+
item.payload.should be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'makes payloads readable as string' do
|
64
|
+
payload = Blather::XMPPNode.new 'foo'
|
65
|
+
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'bar', payload
|
66
|
+
item.payload.should == payload.to_s
|
67
|
+
end
|
68
|
+
end
|