jubjub 0.0.3 → 0.0.4

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.
@@ -0,0 +1,153 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jubjub::Connection::XmppGateway do
4
+
5
+ before do
6
+ @jid = Jubjub::Jid.new('theozaurus@theo-template.local')
7
+ @connection = Jubjub::Connection::XmppGateway.new(@jid, 'secret', {:host => '127.0.0.1', :port => '8000'})
8
+ end
9
+
10
+ describe "pubsub" do
11
+
12
+ describe "create" do
13
+ use_vcr_cassette 'pubsub create', :record => :new_episodes
14
+
15
+ it "return a Jubjub::Pubsub" do
16
+ @pubsub = @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
17
+
18
+ @pubsub.should be_a_kind_of Jubjub::Pubsub
19
+ @pubsub.jid.should == Jubjub::Jid.new('pubsub.theo-template.local')
20
+ @pubsub.node.should == 'node_1'
21
+ end
22
+
23
+ after do
24
+ # Clean up the node
25
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
26
+ end
27
+ end
28
+
29
+ describe "destroy" do
30
+ use_vcr_cassette 'pubsub destroy', :record => :new_episodes
31
+
32
+ before do
33
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
34
+ end
35
+
36
+ it "should send correct stanza" do
37
+ # will attempt to create new vcr cassette if the stanza is wrong
38
+ # relies on cassette being manually checked
39
+ @connection.pubsub.destroy('pubsub.theo-template.local', 'node_1').should be_true
40
+ end
41
+ end
42
+
43
+ describe "list" do
44
+
45
+ use_vcr_cassette 'pubsub list', :record => :new_episodes
46
+
47
+ before do
48
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
49
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_2'
50
+ end
51
+
52
+ it "return an array of Jubjub::Muc" do
53
+ list = @connection.pubsub.list 'pubsub.theo-template.local'
54
+ list.should be_a_kind_of Array
55
+
56
+ list.size.should eql(2)
57
+ list[0].should be_a_kind_of Jubjub::Pubsub
58
+ list[0].node.should == 'node_1'
59
+ list[1].should be_a_kind_of Jubjub::Pubsub
60
+ list[1].node.should == 'node_2'
61
+ end
62
+
63
+ after do
64
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
65
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_2'
66
+ end
67
+
68
+ end
69
+
70
+ describe "destroy with redirect" do
71
+ use_vcr_cassette 'pubsub destroy with redirect', :record => :new_episodes
72
+
73
+ before do
74
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
75
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_2'
76
+ end
77
+
78
+ it "should support redirects" do
79
+ @connection.pubsub.destroy('pubsub.theo-template.local', 'node_1', 'pubsub.theo-template.local', 'node_2').should be_true
80
+ end
81
+
82
+ after do
83
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_2'
84
+ end
85
+ end
86
+
87
+ describe "subscribe" do
88
+ use_vcr_cassette 'pubsub subscribe', :record => :new_episodes
89
+
90
+ before do
91
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
92
+ end
93
+
94
+ it "return a Jubjub::PubsubSubscription" do
95
+ @subscription = @connection.pubsub.subscribe( 'pubsub.theo-template.local', 'node_1' )
96
+
97
+ @subscription.should be_a_kind_of Jubjub::PubsubSubscription
98
+ @subscription.jid.should == Jubjub::Jid.new('pubsub.theo-template.local')
99
+ @subscription.node.should == 'node_1'
100
+ @subscription.subscriber.should == @jid
101
+ @subscription.subscription.should == "subscribed"
102
+ @subscription.subid.should be_kind_of(String)
103
+ end
104
+
105
+ after do
106
+ # Clean up the node
107
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
108
+ end
109
+
110
+ end
111
+
112
+ describe "unsubscribe" do
113
+
114
+ use_vcr_cassette 'pubsub unsubscribe', :record => :new_episodes
115
+
116
+ before do
117
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
118
+ @connection.pubsub.subscribe 'pubsub.theo-template.local', 'node_1'
119
+ end
120
+
121
+ it "return true" do
122
+ @connection.pubsub.unsubscribe( 'pubsub.theo-template.local', 'node_1' ).should be_true
123
+ end
124
+
125
+ after do
126
+ # Clean up the node
127
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
128
+ end
129
+
130
+ end
131
+
132
+ describe "unsubscribe with subid" do
133
+ use_vcr_cassette 'pubsub unsubscribe with subid', :record => :new_episodes
134
+
135
+ before do
136
+ @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
137
+ @subscription = @connection.pubsub.subscribe 'pubsub.theo-template.local', 'node_1'
138
+ end
139
+
140
+ it "return true" do
141
+ @connection.pubsub.unsubscribe( 'pubsub.theo-template.local', 'node_1', @subscription.subid ).should be_true
142
+ end
143
+
144
+ after do
145
+ # Clean up the node
146
+ @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
147
+ end
148
+
149
+ end
150
+
151
+ end
152
+
153
+ end
@@ -0,0 +1,47 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "230"
19
+ body: |
20
+ <iq type="result" id="blather003d" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/310086191298628414672003">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "132"
44
+ body: |
45
+ <iq type="result" id="blather003f" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/310086191298628414672003"/>
46
+
47
+ http_version: "1.1"
@@ -0,0 +1,47 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "232"
19
+ body: |
20
+ <iq type="result" id="blather0099" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "134"
44
+ body: |
45
+ <iq type="result" id="blather009b" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690"/>
46
+
47
+ http_version: "1.1"
@@ -0,0 +1,93 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "232"
19
+ body: |
20
+ <iq type="result" id="blather009d" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_2%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "232"
44
+ body: |
45
+ <iq type="result" id="blather009f" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690">
46
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
47
+ <create node="node_2"/>
48
+ </pubsub>
49
+ </iq>
50
+
51
+ http_version: "1.1"
52
+ - !ruby/struct:VCR::HTTPInteraction
53
+ request: !ruby/struct:VCR::Request
54
+ method: :post
55
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
56
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%3e%0a%20%20%20%20%20%20%3credirect%20uri%3d%22xmpp%3apubsub.theo-template.local%3f%3bnode%3dnode_2%22%2f%3e%0a%20%20%20%20%3c%2fdelete%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
57
+ headers:
58
+ content-type:
59
+ - application/x-www-form-urlencoded
60
+ response: !ruby/struct:VCR::Response
61
+ status: !ruby/struct:VCR::ResponseStatus
62
+ code: 200
63
+ message: ...
64
+ headers:
65
+ content-type:
66
+ - application/xml
67
+ content-length:
68
+ - "134"
69
+ body: |
70
+ <iq type="result" id="blather00a1" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690"/>
71
+
72
+ http_version: "1.1"
73
+ - !ruby/struct:VCR::HTTPInteraction
74
+ request: !ruby/struct:VCR::Request
75
+ method: :post
76
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
77
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_2%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
78
+ headers:
79
+ content-type:
80
+ - application/x-www-form-urlencoded
81
+ response: !ruby/struct:VCR::Response
82
+ status: !ruby/struct:VCR::ResponseStatus
83
+ code: 200
84
+ message: ...
85
+ headers:
86
+ content-type:
87
+ - application/xml
88
+ content-length:
89
+ - "134"
90
+ body: |
91
+ <iq type="result" id="blather00a3" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/42584528861298628855100690"/>
92
+
93
+ http_version: "1.1"
@@ -0,0 +1,119 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "231"
19
+ body: |
20
+ <iq type="result" id="blather00db" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/3334638571298641302447941">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_2%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "231"
44
+ body: |
45
+ <iq type="result" id="blather00dd" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/3334638571298641302447941">
46
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
47
+ <create node="node_2"/>
48
+ </pubsub>
49
+ </iq>
50
+
51
+ http_version: "1.1"
52
+ - !ruby/struct:VCR::HTTPInteraction
53
+ request: !ruby/struct:VCR::Request
54
+ method: :post
55
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
56
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22get%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cquery%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fdisco%23items%22%2f%3e%0a%3c%2fiq%3e%0a
57
+ headers:
58
+ content-type:
59
+ - application/x-www-form-urlencoded
60
+ response: !ruby/struct:VCR::Response
61
+ status: !ruby/struct:VCR::ResponseStatus
62
+ code: 200
63
+ message: ...
64
+ headers:
65
+ content-type:
66
+ - application/xml
67
+ content-length:
68
+ - "1502"
69
+ body: |
70
+ <iq type="result" id="blather00df" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/3334638571298641302447941">
71
+ <query xmlns="http://jabber.org/protocol/disco#items">
72
+ <item jid="pubsub.theo-template.local" name="node_1" node="node_1"/>
73
+ <item jid="pubsub.theo-template.local" name="node_2" node="node_2"/>
74
+ </query>
75
+ </iq>
76
+
77
+ http_version: "1.1"
78
+ - !ruby/struct:VCR::HTTPInteraction
79
+ request: !ruby/struct:VCR::Request
80
+ method: :post
81
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
82
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
83
+ headers:
84
+ content-type:
85
+ - application/x-www-form-urlencoded
86
+ response: !ruby/struct:VCR::Response
87
+ status: !ruby/struct:VCR::ResponseStatus
88
+ code: 200
89
+ message: ...
90
+ headers:
91
+ content-type:
92
+ - application/xml
93
+ content-length:
94
+ - "133"
95
+ body: |
96
+ <iq type="result" id="blather00e1" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/3334638571298641302447941"/>
97
+
98
+ http_version: "1.1"
99
+ - !ruby/struct:VCR::HTTPInteraction
100
+ request: !ruby/struct:VCR::Request
101
+ method: :post
102
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
103
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_2%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
104
+ headers:
105
+ content-type:
106
+ - application/x-www-form-urlencoded
107
+ response: !ruby/struct:VCR::Response
108
+ status: !ruby/struct:VCR::ResponseStatus
109
+ code: 200
110
+ message: ...
111
+ headers:
112
+ content-type:
113
+ - application/xml
114
+ content-length:
115
+ - "133"
116
+ body: |
117
+ <iq type="result" id="blather00e3" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/3334638571298641302447941"/>
118
+
119
+ http_version: "1.1"