Class: PubSub::ServiceHelperTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- PubSub::ServiceHelperTest
- Includes:
- ClientTester
- Defined in:
- lib/vendor/xmpp4r/test/pubsub/tc_helper.rb
Overview
Jabber.debug = true
Instance Method Summary collapse
-
#test_affiliations ⇒ Object
get affiliation example 184 and 185 from www.xmpp.org/extensions/xep-0060.html#owner-affiliations-retrieve-success1.
-
#test_create ⇒ Object
create node with default configuration example 119 and 121 from www.xmpp.org/extensions/xep-0060.html#owner-create-default.
-
#test_create_collection ⇒ Object
create node a collection node example 203 and 204 from www.xmpp.org/extensions/xep-0060.html#collections-createnode.
-
#test_create_configure ⇒ Object
create node with configuration example 123 and 124 from www.xmpp.org/extensions/xep-0060.html#owner-create-and-configure.
-
#test_delete ⇒ Object
delete node example 144 and 145 from www.xmpp.org/extensions/xep-0060.html#owner-delete-request.
-
#test_get_all_subscriptions ⇒ Object
get_all_subscriptions.
-
#test_get_all_subscriptions_with_no_subscriptions ⇒ Object
get all subscriptions with no subscriptions.
-
#test_get_node_config ⇒ Object
get configuration for a node example 125 and 126 from www.xmpp.org/extensions/xep-0060.html#owner-configure-request.
-
#test_get_subscription_options ⇒ Object
get subscription options examples 56 and 57 from www.xmpp.org/extensions/xep-0060.html#subscriber-configure-request.
-
#test_items ⇒ Object
retrieve all items examples 70 and 71 from www.xmpp.org/extensions/xep-0060.html#subscriber-retrieve-returnall.
-
#test_publish ⇒ Object
publish to a node example 88 and 89 from www.xmpp.org/extensions/xep-0060.html#publisher-publish.
-
#test_publish_pubsub_item_with_id ⇒ Object
publish item with id example 88 and 89 from www.xmpp.org/extensions/xep-0060.html#publisher-publish.
-
#test_publish_pubsub_item_with_id_and_produce_a_local_error ⇒ Object
publish item and trap client-side error examples 88 from www.xmpp.org/extensions/xep-0060.html#publisher-publish.
-
#test_publish_pubsub_item_with_id_and_produce_an_error ⇒ Object
publish item and trap server-side error examples 88 from www.xmpp.org/extensions/xep-0060.html#publisher-publish and 93 from www.xmpp.org/extensions/xep-0060.html#publisher-publish-error-forbidden.
-
#test_set_subscription_options ⇒ Object
set subscription options examples 65 and 66 from www.xmpp.org/extensions/xep-0060.html#subscriber-configure-submit.
-
#test_subscribe ⇒ Object
subscribe_to examples 30 and 31 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe.
-
#test_subscribe_approval_required ⇒ Object
subscribe error condition example 43 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe-approval.
-
#test_subscribe_configuration_required ⇒ Object
subscribe error condition example 44 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe-configure.
-
#test_subscribers ⇒ Object
get_subscribers example 171 and 172 from www.xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve.
-
#test_subscriptions ⇒ Object
get_subscriptions_from example 171 and 172 from www.xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve-request.
- #test_to_s ⇒ Object
-
#test_unsubscribe ⇒ Object
unsubscribe from examples 48 and 49 from www.xmpp.org/extensions/xep-0060.html#subscriber-unsubscribe-request.
Instance Method Details
#test_affiliations ⇒ Object
get affiliation example 184 and 185 from www.xmpp.org/extensions/xep-0060.html#owner-affiliations-retrieve-success1
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 460 def test_affiliations h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('affiliations', iq.pubsub.children.first.name) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <affiliations> <affiliation node='node1' affiliation='owner'/> <affiliation node='node2' affiliation='publisher'/> <affiliation node='node5' affiliation='outcast'/> <affiliation node='node6' affiliation='owner'/> </affiliations> </pubsub> </iq>") } a = h.get_affiliations assert_kind_of(Hash, a) assert_equal(4, a.size) assert_equal(:owner, a['node1']) assert_equal(:publisher, a['node2']) assert_equal(:outcast, a['node5']) assert_equal(:owner, a['node6']) wait_state end |
#test_create ⇒ Object
create node with default configuration example 119 and 121 from www.xmpp.org/extensions/xep-0060.html#owner-create-default
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 226 def test_create h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_kind_of(PubSub::ServiceHelper, h) state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(2, iq.pubsub.children.size) assert_equal('create', iq.pubsub.children.first.name) assert_equal('mynode', iq.pubsub.children.first.attributes['node']) assert_equal('configure', iq.pubsub.children[1].name) assert_equal({}, iq.pubsub.children[1].attributes) assert_equal([], iq.pubsub.children[1].children) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } assert_equal('mynode', h.create_node('mynode')) wait_state end |
#test_create_collection ⇒ Object
create node a collection node example 203 and 204 from www.xmpp.org/extensions/xep-0060.html#collections-createnode
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 280 def test_create_collection node = 'mynode' h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') = {'pubsub#node_type' => 'collection'} state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(2, iq.pubsub.children.size) assert_equal('create', iq.pubsub.children.first.name) assert_equal(node, iq.pubsub.children.first.attributes['node']) assert_kind_of(Jabber::PubSub::NodeConfig, iq.pubsub.children[1]) assert_equal(, iq.pubsub.children[1].) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } assert_equal('mynode', h.create_collection_node('mynode')) wait_state end |
#test_create_configure ⇒ Object
create node with configuration example 123 and 124 from www.xmpp.org/extensions/xep-0060.html#owner-create-and-configure
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 251 def test_create_configure node = 'mynode' = {'pubsub#access_model'=>'open'} h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(2, iq.pubsub.children.size) assert_equal('create', iq.pubsub.children.first.name) assert_equal(node, iq.pubsub.children.first.attributes['node']) assert_kind_of(Jabber::PubSub::NodeConfig, iq.pubsub.children[1]) assert_equal(, iq.pubsub.children[1].) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } assert_nothing_raised do assert_equal(node, h.create_node(node, Jabber::PubSub::NodeConfig.new(node, ))) end wait_state end |
#test_delete ⇒ Object
delete node example 144 and 145 from www.xmpp.org/extensions/xep-0060.html#owner-delete-request
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 304 def test_delete h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal(1, iq.pubsub.children.size) assert_equal('delete', iq.pubsub.children.first.name) assert_equal('mynode', iq.pubsub.children.first.attributes['node']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } h.delete_node('mynode') wait_state end |
#test_get_all_subscriptions ⇒ Object
get_all_subscriptions
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 562 def test_get_all_subscriptions h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('subscriptions', iq.pubsub.children.first.name) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscriptions> <subscription node='node1' jid='[email protected]' subscription='subscribed'/> <subscription node='node2' jid='[email protected]' subscription='subscribed'/> <subscription node='node5' jid='[email protected]' subscription='unconfigured'/> <subscription node='node6' jid='[email protected]' subscription='pending'/> </subscriptions> </pubsub> </iq>") } s = h.get_subscriptions_from_all_nodes assert_kind_of(Array,s) assert_equal(4,s.size) assert_kind_of(Jabber::PubSub::Subscription,s[0]) assert_kind_of(Jabber::PubSub::Subscription,s[1]) assert_kind_of(Jabber::PubSub::Subscription,s[2]) assert_kind_of(Jabber::PubSub::Subscription,s[3]) assert_equal(:subscribed,s[0].state) assert_equal(:unconfigured,s[2].state) assert_equal(:pending,s[3].state) assert_equal(JID.new("[email protected]"),s[0].jid) assert_equal("node1",s[0].node) wait_state end |
#test_get_all_subscriptions_with_no_subscriptions ⇒ Object
get all subscriptions with no subscriptions
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 600 def test_get_all_subscriptions_with_no_subscriptions h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('subscriptions', iq.pubsub.children.first.name) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscriptions /> </pubsub> </iq>") } s = h.get_subscriptions_from_all_nodes assert_kind_of(Array,s) assert_equal(0,s.size) wait_state end |
#test_get_node_config ⇒ Object
get configuration for a node example 125 and 126 from www.xmpp.org/extensions/xep-0060.html#owner-configure-request
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 625 def test_get_node_config pubsub = 'pubsub.example.org' h = PubSub::ServiceHelper.new(@client, pubsub) state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(pubsub, iq.to.to_s) assert_kind_of(Jabber::PubSub::OwnerNodeConfig, iq.pubsub.first_element('configure')) send( "<iq type='result' from='#{iq.to}' to='#{iq.from}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'> <configure node='princely_musings'> <x xmlns='jabber:x:data' type='form'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/pubsub#node_config</value> </field> <field var='pubsub#title' type='text-single' label='A friendly name for the node'/> </x> </configure> </pubsub> </iq>") } config = h.get_config_from('princelymusings') assert_kind_of(Jabber::PubSub::OwnerNodeConfig, config) wait_state end |
#test_get_subscription_options ⇒ Object
get subscription options examples 56 and 57 from www.xmpp.org/extensions/xep-0060.html#subscriber-configure-request
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 151 def pubsub = Jabber::JID.new('pubsub.example.org') node = 'princely_musings' jid = Jabber::JID.new('[email protected]/test') h = PubSub::ServiceHelper.new(@client, pubsub) state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(pubsub, iq.to) assert_kind_of(Jabber::PubSub::SubscriptionConfig, iq.pubsub.first_element('options')) assert_equal(node, iq.pubsub.first_element('options').node) assert_equal(jid.strip, iq.pubsub.first_element('options').jid) send( "<iq type='result' from='#{iq.to}' to='#{iq.from}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <options node='#{iq.pubsub.first_element('options').node}' jid='#{iq.pubsub.first_element('options').jid}'> <x xmlns='jabber:x:data' type='form'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/pubsub#subscribe_options</value> </field> <field var='pubsub#deliver' type='boolean' label='Enable delivery?'> <value>1</value> </field> </x> </options> </pubsub> </iq>") } = h.(node, jid) assert_kind_of(Jabber::PubSub::SubscriptionConfig, ) assert_equal({'pubsub#deliver'=>'1'}, .) wait_state end |
#test_items ⇒ Object
retrieve all items examples 70 and 71 from www.xmpp.org/extensions/xep-0060.html#subscriber-retrieve-returnall
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 423 def test_items item1 = Jabber::PubSub::Item.new("1") item1.text = 'foobar' item2 = Jabber::PubSub::Item.new("2") item2.text = 'barfoo' h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('items', iq.pubsub.children.first.name) assert_equal('mynode', iq.pubsub.children.first.attributes['node']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='mynode'> #{item1.to_s} #{item2.to_s} </items> </pubsub> </iq>") } items = h.get_items_from('mynode') assert_equal(2, items.size) assert_kind_of(REXML::Text, items['1']) assert_kind_of(REXML::Text, items['2']) assert_equal(item1.children.join, items['1'].to_s) assert_equal(item2.children.join, items['2'].to_s) wait_state end |
#test_publish ⇒ Object
publish to a node example 88 and 89 from www.xmpp.org/extensions/xep-0060.html#publisher-publish
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 324 def test_publish node = 'mynode' item1 = Jabber::PubSub::Item.new item1.text = 'foobar' h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal(1, iq.pubsub.children.size) assert_equal('publish', iq.pubsub.children[0].name) assert_equal(node, iq.pubsub.children[0].attributes['node']) assert_equal(1, iq.pubsub.children[0].children.size) assert_equal('item', iq.pubsub.children[0].children[0].name) assert_equal(1, iq.pubsub.children[0].children[0].children.size) assert_equal(item1.children.to_s, iq.pubsub.children[0].children[0].children[0].to_s) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } assert_nothing_raised { h.publish_item_to(node, item1) } wait_state end |
#test_publish_pubsub_item_with_id ⇒ Object
publish item with id example 88 and 89 from www.xmpp.org/extensions/xep-0060.html#publisher-publish
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 350 def test_publish_pubsub_item_with_id item1 = Jabber::PubSub::Item.new item1.text = 'foobar' h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal(1, iq.pubsub.children.size) assert_equal('publish', iq.pubsub.children[0].name) assert_equal(1, iq.pubsub.children[0].children.size) assert_equal('item', iq.pubsub.children[0].children[0].name) assert_equal('blubb', iq.pubsub.children[0].children[0].attributes['id'] ) assert_equal(1, iq.pubsub.children[0].children[0].children.size) assert_equal(item1.children.to_s, iq.pubsub.children[0].children[0].children[0].to_s) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } assert_nothing_raised { h.publish_item_with_id_to('mynode', item1,"blubb") } wait_state end |
#test_publish_pubsub_item_with_id_and_produce_a_local_error ⇒ Object
publish item and trap client-side error examples 88 from www.xmpp.org/extensions/xep-0060.html#publisher-publish
376 377 378 379 380 381 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 376 def test_publish_pubsub_item_with_id_and_produce_a_local_error item1 = 'foobarbaz' h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_raise RuntimeError do h.publish_item_with_id_to('mynode', item1,"blubb") end end |
#test_publish_pubsub_item_with_id_and_produce_an_error ⇒ Object
publish item and trap server-side error examples 88 from www.xmpp.org/extensions/xep-0060.html#publisher-publish and 93 from www.xmpp.org/extensions/xep-0060.html#publisher-publish-error-forbidden
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 389 def test_publish_pubsub_item_with_id_and_produce_an_error item1 = Jabber::PubSub::Item.new item1.text = "foobarbaz" h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(1, iq.children.size) assert_equal(1, iq.pubsub.children.size) assert_equal('publish', iq.pubsub.children[0].name) assert_equal(1, iq.pubsub.children[0].children.size) assert_equal('item', iq.pubsub.children[0].children[0].name) assert_equal('blubb', iq.pubsub.children[0].children[0].attributes['id'] ) assert_equal(1, iq.pubsub.children[0].children[0].children.size) assert_equal(item1.children.to_s, iq.pubsub.children[0].children[0].children[0].to_s) send("<iq type='error' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='#{iq.pubsub.children[0].attributes['node']}'> <item id='#{iq.pubsub.children[0].children[0].attributes['id']}'/> </publish> </pubsub> <error type='auth'> <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error>") } assert_raise Jabber::ServerError do h.publish_item_with_id_to('mynode', item1,"blubb") end wait_state end |
#test_set_subscription_options ⇒ Object
set subscription options examples 65 and 66 from www.xmpp.org/extensions/xep-0060.html#subscriber-configure-submit
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 195 def pubsub = Jabber::JID.new('pubsub.example.org') node = 'princely_musings' jid = Jabber::JID.new('[email protected]/test') = {'pubsub#deliver' => '0'} h = PubSub::ServiceHelper.new(@client, pubsub) state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:set, iq.type) assert_equal(pubsub, iq.to) assert_kind_of(Jabber::PubSub::SubscriptionConfig, iq.pubsub.first_element('options')) assert_equal(node, iq.pubsub.first_element('options').node) assert_equal(jid.strip, iq.pubsub.first_element('options').jid) send( "<iq type='result' from='#{iq.to}' to='#{iq.from}' id='#{iq.id}'/>") } assert_nothing_raised do assert_equal(true, h.(node, jid, ) ) end wait_state end |
#test_subscribe ⇒ Object
subscribe_to examples 30 and 31 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 21 def test_subscribe pubsub = 'pubsub.example.org' h = PubSub::ServiceHelper.new(@client,pubsub) assert_kind_of(Jabber::PubSub::ServiceHelper,h) state { |iq| assert_kind_of(Jabber::Iq,iq) assert_equal(:set,iq.type) assert_equal(pubsub, iq.to.to_s) assert_equal(@client.jid, iq.from) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(1, iq.pubsub.children.size) assert_equal('subscribe',iq.pubsub.children.first.name) assert_equal('princely_musings',iq.pubsub.children.first.attributes['node']) assert_equal(@client.jid.strip.to_s,iq.pubsub.children.first.attributes['jid']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscription node='#{iq.pubsub.children.first.attributes['node']}' jid='#{iq.from.strip}' subid='ba49252aaa4f5d320c24d3766f0bdcade78c78d3' subscription='subscribed'/> </pubsub> </iq>") } subscription = h.subscribe_to('princely_musings') assert_kind_of(Jabber::PubSub::Subscription,subscription) assert_equal(@client.jid.strip,subscription.jid) assert_equal('princely_musings',subscription.node) assert_equal('ba49252aaa4f5d320c24d3766f0bdcade78c78d3',subscription.subid) assert_equal(:subscribed,subscription.subscription) wait_state end |
#test_subscribe_approval_required ⇒ Object
subscribe error condition example 43 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe-approval
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 93 def test_subscribe_approval_required h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_kind_of(PubSub::ServiceHelper,h) state { |iq| assert_kind_of(Jabber::Iq,iq) assert_equal(:set,iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(1, iq.pubsub.children.size) assert_equal('subscribe',iq.pubsub.children.first.name) assert_equal('princely_musings',iq.pubsub.children.first.attributes['node']) assert_equal(@client.jid.strip.to_s,iq.pubsub.children.first.attributes['jid']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscription node='#{iq.pubsub.children.first.attributes['node']}' jid='#{iq.from.strip}' subid='ba49252aaa4f5d320c24d3766f0bdcade78c78d3' subscription='pending'/> </pubsub> </iq>") } subscription = h.subscribe_to('princely_musings') assert_kind_of(Jabber::PubSub::Subscription,subscription) assert_equal(@client.jid.strip,subscription.jid) assert_equal('princely_musings',subscription.node) assert_equal('ba49252aaa4f5d320c24d3766f0bdcade78c78d3',subscription.subid) assert_equal(:pending,subscription.subscription) assert_equal(true,subscription.need_approval?) wait_state end |
#test_subscribe_configuration_required ⇒ Object
subscribe error condition example 44 from www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe-configure
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 57 def test_subscribe_configuration_required h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_kind_of(PubSub::ServiceHelper,h) state { |iq| assert_kind_of(Jabber::Iq,iq) assert_equal(:set,iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(1, iq.pubsub.children.size) assert_equal('subscribe',iq.pubsub.children.first.name) assert_equal('princely_musings',iq.pubsub.children.first.attributes['node']) assert_equal(@client.jid.strip.to_s,iq.pubsub.children.first.attributes['jid']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscription node='#{iq.pubsub.children.first.attributes['node']}' jid='#{iq.from.strip}' subid='ba49252aaa4f5d320c24d3766f0bdcade78c78d3' subscription='unconfigured'/> <subscribe-options> <required/> </subscribe-options> </pubsub> </iq>") } subscription = h.subscribe_to('princely_musings') assert_kind_of(Jabber::PubSub::Subscription,subscription) assert_equal(@client.jid.strip,subscription.jid) assert_equal('princely_musings',subscription.node) assert_equal('ba49252aaa4f5d320c24d3766f0bdcade78c78d3',subscription.subid) assert_equal(:unconfigured,subscription.subscription) wait_state end |
#test_subscribers ⇒ Object
get_subscribers example 171 and 172 from www.xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 531 def test_subscribers h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('subscriptions', iq.pubsub.children.first.name) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscriptions node='princely_musings'> <subscription jid='[email protected]' subscription='subscribed'/> <subscription jid='[email protected]' subscription='subscribed'/> <subscription jid='[email protected]' subscription='unconfigured'/> <subscription jid='[email protected]' subscription='pending'/> </subscriptions> </pubsub> </iq>") } s = h.get_subscribers_from('princely_musings') assert_equal(4,s.size) assert_kind_of(Jabber::JID,s[0]) assert_kind_of(Jabber::JID,s[1]) assert_kind_of(Jabber::JID,s[2]) assert_kind_of(Jabber::JID,s[3]) wait_state end |
#test_subscriptions ⇒ Object
get_subscriptions_from example 171 and 172 from www.xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve-request
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 494 def test_subscriptions h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') state { |iq| assert_kind_of(Jabber::Iq, iq) assert_equal(:get, iq.type) assert_equal(1, iq.pubsub.children.size) assert_equal('subscriptions', iq.pubsub.children.first.name) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'> <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'> <subscriptions node='node1'> <subscription jid='[email protected]' subscription='subscribed'/> <subscription jid='[email protected]' subscription='unconfigured'/> <subscription jid='[email protected]' subscription='subscribed' subid='123-abc'/> <subscription jid='[email protected]' subscription='subscribed' subid='004-yyy'/> </subscriptions> </pubsub> </iq>") } s = h.get_subscriptions_from('node1') assert_kind_of(Array,s) assert_equal(4,s.size) assert_kind_of(Jabber::PubSub::Subscription,s[0]) assert_kind_of(Jabber::PubSub::Subscription,s[1]) assert_kind_of(Jabber::PubSub::Subscription,s[2]) assert_kind_of(Jabber::PubSub::Subscription,s[3]) assert_equal(:subscribed,s[0].state) assert_equal(:unconfigured,s[1].state) assert_equal(JID.new("[email protected]"),s[0].jid) assert_equal("123-abc",s[2].subid) wait_state end |
#test_to_s ⇒ Object
658 659 660 661 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 658 def test_to_s h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_equal('pubsub.example.org',h.to_s) end |
#test_unsubscribe ⇒ Object
unsubscribe from examples 48 and 49 from www.xmpp.org/extensions/xep-0060.html#subscriber-unsubscribe-request
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/vendor/xmpp4r/test/pubsub/tc_helper.rb', line 128 def test_unsubscribe h = PubSub::ServiceHelper.new(@client,'pubsub.example.org') assert_kind_of(PubSub::ServiceHelper,h) state { |iq| assert_kind_of(Jabber::Iq,iq) assert_equal(:set,iq.type) assert_equal(1, iq.children.size) assert_equal('http://jabber.org/protocol/pubsub', iq.pubsub.namespace) assert_equal(1, iq.pubsub.children.size) assert_equal('unsubscribe',iq.pubsub.children.first.name) assert_equal('princely_musings',iq.pubsub.children.first.attributes['node']) assert_equal(@client.jid.strip.to_s,iq.pubsub.children.first.attributes['jid']) send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>") } unsubscribe = h.unsubscribe_from('princely_musings') assert_equal(true, unsubscribe) wait_state end |