bigbluebutton-api-ruby 1.9.0 → 2.0.0.pre.rc.1

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.
@@ -1,153 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Tests for BBB API version 0.81
4
- describe BigBlueButton::BigBlueButtonApi do
5
-
6
- # default variables and API object for all tests
7
- let(:url) { "http://server.com" }
8
- let(:secret) { "1234567890abcdefghijkl" }
9
- let(:version) { "0.81" }
10
- let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version) }
11
-
12
- describe "#get_default_config_xml" do
13
- let(:response) { "<response><returncode>1</returncode></response>" }
14
- let(:response_asObject) { {"response" => {"returncode" => "1" } } }
15
-
16
- context "with response as a string" do
17
- context "and without non standard options" do
18
- before { api.should_receive(:send_api_request).with(:getDefaultConfigXML, {}, nil, true).and_return(response) }
19
- it { api.get_default_config_xml() }
20
- it { api.get_default_config_xml().should == response }
21
- it { api.get_default_config_xml(false).should_not == response_asObject }
22
- end
23
-
24
- context "and with non standard options" do
25
- let(:params_in) {
26
- { :anything1 => "anything-1", :anything2 => 2 }
27
- }
28
- before { api.should_receive(:send_api_request).with(:getDefaultConfigXML, params_in, nil, true).and_return(response) }
29
- it { api.get_default_config_xml(false, params_in) }
30
- it { api.get_default_config_xml(false, params_in).should == response }
31
- it { api.get_default_config_xml(false, params_in).should_not == response_asObject }
32
- end
33
- end
34
-
35
- context "with response as a object" do
36
- context "and without non standard options" do
37
- before { api.should_receive(:send_api_request).with(:getDefaultConfigXML, {}, nil, true).and_return(response) }
38
- it { api.get_default_config_xml(true) }
39
- it { api.get_default_config_xml(true).should == response_asObject }
40
- it { api.get_default_config_xml(true).should_not == response }
41
- end
42
-
43
- context "and with non standard options" do
44
- let(:params_in) {
45
- { :anything1 => "anything-1", :anything2 => 2 }
46
- }
47
- before { api.should_receive(:send_api_request).with(:getDefaultConfigXML, params_in, nil, true).and_return(response) }
48
- it { api.get_default_config_xml(true, params_in) }
49
- it { api.get_default_config_xml(true, params_in).should == response_asObject }
50
- it { api.get_default_config_xml(true, params_in).should_not == response }
51
- end
52
- end
53
- end
54
-
55
- describe "#set_config_xml" do
56
- let(:configToken) { "asdfl234kjasdfsadfy" }
57
- let(:meeting_id) { "meeting-id" }
58
- let(:xml) { "<response><returncode>SUCCESS</returncode><configToken>asdfl234kjasdfsadfy</configToken></response>" }
59
- let(:response) {
60
- { :returncode => "SUCCESS", :configToken => configToken }
61
- }
62
-
63
- context "without non standard options" do
64
- let(:params) {
65
- { :meetingID => meeting_id, :configXML => xml }
66
- }
67
-
68
- before { api.should_receive(:send_api_request).with(:setConfigXML, params, xml).and_return(response) }
69
- it { api.set_config_xml(meeting_id, xml) }
70
- it { api.set_config_xml(meeting_id, xml).should == configToken }
71
- end
72
-
73
- context "with non standard options" do
74
- let(:params_in) {
75
- { :anything1 => "anything-1", :anything2 => 2 }
76
- }
77
- let(:params_out) {
78
- { :meetingID => meeting_id, :configXML => xml, :anything1 => "anything-1", :anything2 => 2 }
79
- }
80
-
81
- before { api.should_receive(:send_api_request).with(:setConfigXML, params_out, xml).and_return(response) }
82
- it { api.set_config_xml(meeting_id, xml, params_in) }
83
- it { api.set_config_xml(meeting_id, xml, params_in).should == configToken }
84
- end
85
- end
86
-
87
- describe "#get_available_layouts" do
88
- let(:config_xml) { # a simplified config.xml file
89
- "<config>
90
- <modules>
91
- <module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\"
92
- uri=\"rtmp://test-server.org/bigbluebutton\"
93
- layoutConfig=\"http://test-server.org/client/conf/layout.xml\"
94
- enableEdit=\"false\"/>
95
- </modules>
96
- </config>"
97
- }
98
- let(:layouts_xml) { # a simplified layouts.xml file
99
- "<layouts>
100
- <layout name=\"Default\" default=\"true\">
101
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
102
- </layout>
103
- <layout name=\"Video Chat\">
104
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
105
- </layout>
106
- </layouts>"
107
- }
108
-
109
- context "when an XML is passed" do
110
- before {
111
- response = double("Net::HTTPResponse")
112
- response.stub(:body).and_return(layouts_xml)
113
- api.should_receive(:send_request)
114
- .with("http://test-server.org/client/conf/layout.xml")
115
- .and_return(response)
116
- }
117
- subject { api.get_available_layouts(config_xml) }
118
- it { should be_instance_of(Array) }
119
- it { subject.count.should be(2) }
120
- it { should include("Default") }
121
- it { should include("Video Chat") }
122
- end
123
-
124
- context "when no XML is passed" do
125
- before {
126
- api.should_receive(:get_default_config_xml)
127
- .and_return(config_xml)
128
- response = double("Net::HTTPResponse")
129
- response.stub(:body).and_return(layouts_xml)
130
- api.should_receive(:send_request)
131
- .with("http://test-server.org/client/conf/layout.xml")
132
- .and_return(response)
133
- }
134
- subject { api.get_available_layouts }
135
- it { should be_instance_of(Array) }
136
- it { subject.count.should be(2) }
137
- it { should include("Default") }
138
- it { should include("Video Chat") }
139
- end
140
- end
141
-
142
- describe "#get_default_layouts" do
143
- subject { api.get_default_layouts }
144
- it { should be_instance_of(Array) }
145
- it { should include("Default") }
146
- it { should include("Video Chat") }
147
- it { should include("Meeting") }
148
- it { should include("Webinar") }
149
- it { should include("Lecture assistant") }
150
- it { should include("Lecture") }
151
- end
152
-
153
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BigBlueButton::BigBlueButtonConfigLayout do
4
-
5
- let(:default_xml) { # a simplified layouts.xml file
6
- "<layouts>
7
- <layout name=\"Default\" default=\"true\">
8
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
9
- </layout>
10
- <layout name=\"Video Chat\">
11
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
12
- </layout>
13
- </layouts>"
14
- }
15
-
16
- describe "#initialize" do
17
- context "with a valid xml" do
18
- before {
19
- XmlSimple.should_receive(:xml_in)
20
- .with(default_xml, { 'ForceArray' => false, 'KeepRoot' => true })
21
- .and_return("internal_xml")
22
- }
23
- subject { BigBlueButton::BigBlueButtonConfigLayout.new(default_xml) }
24
- it("creates and stores a correct internal xml") { subject.xml.should eql("internal_xml") }
25
- end
26
-
27
- context "with an empty string as xml" do
28
- it "throws an exception" do
29
- expect {
30
- BigBlueButton::BigBlueButtonConfigLayout.new("")
31
- }.to raise_error(BigBlueButton::BigBlueButtonException)
32
- end
33
- end
34
-
35
- context "throws any exception thrown by XmlSimple" do
36
- before {
37
- XmlSimple.should_receive(:xml_in) { raise Exception }
38
- }
39
- it {
40
- expect {
41
- BigBlueButton::BigBlueButtonConfigLayout.new(default_xml)
42
- }.to raise_error(BigBlueButton::BigBlueButtonException)
43
- }
44
- end
45
- end
46
-
47
- describe "#get_available_layouts" do
48
- subject { target.get_available_layouts }
49
-
50
- context "returns nil if the xml has no <layouts>" do
51
- let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new("<test></test>") }
52
- it { should be_nil }
53
- end
54
-
55
- context "returns nil if the xml has no <layouts><layout>" do
56
- let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new("<layouts></layouts>") }
57
- it { should be_nil }
58
- end
59
-
60
- context "returns the correct available layout names" do
61
- let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new(default_xml) }
62
- it { should be_instance_of(Array) }
63
- it { subject.count.should be(2) }
64
- it { should include("Default") }
65
- it { should include("Video Chat") }
66
- end
67
-
68
- context "doesn't return duplicated layouts" do
69
- let(:layouts_xml) {
70
- "<layouts>
71
- <layout name=\"Default\" default=\"true\">
72
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
73
- </layout>
74
- <layout name=\"Default\">
75
- <window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
76
- </layout>
77
- </layouts>"
78
- }
79
- let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new(layouts_xml) }
80
- it { should be_instance_of(Array) }
81
- it { subject.count.should be(1) }
82
- it { should include("Default") }
83
- end
84
- end
85
-
86
- end
@@ -1,302 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BigBlueButton::BigBlueButtonConfigXml do
4
-
5
- let(:default_xml) { # a simplified config.xml file
6
- "<config>
7
- <help url=\"http://test-server.org/help.html\"/>
8
- <modules>
9
- <module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\"
10
- uri=\"rtmp://test-server.org/bigbluebutton\"
11
- layoutConfig=\"http://test-server.org/client/conf/layout.xml\"
12
- enableEdit=\"false\"/>
13
- </modules>
14
- </config>"
15
- }
16
-
17
- let(:complex_xml) {
18
- "<config>\
19
- <localeversion suppressWarning=\"false\">0.8</localeversion>\
20
- <version>4357-2014-02-06</version>\
21
- <help url=\"http://test-server.org/help.html\"/>\
22
- <javaTest url=\"http://test-server.org/testjava.html\"/>\
23
- <modules>
24
- <module name=\"ChatModule\" url=\"http://test-server.org/client/ChatModule.swf\"
25
- uri=\"rtmp://test-server.org/bigbluebutton\"
26
- dependsOn=\"UsersModule\" translationOn=\"false\"
27
- translationEnabled=\"false\" privateEnabled=\"true\"
28
- position=\"top-right\" baseTabIndex=\"701\"/>
29
- <module name=\"UsersModule\" url=\"http://test-server.org/client/UsersModule.swf\"
30
- uri=\"rtmp://test-server.org/bigbluebutton\"
31
- allowKickUser=\"true\" enableRaiseHand=\"true\"
32
- enableSettingsButton=\"true\" baseTabIndex=\"301\"/>
33
- <module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\"
34
- uri=\"rtmp://test-server.org/bigbluebutton\"
35
- layoutConfig=\"http://test-server.org/client/conf/layout.xml\"
36
- enableEdit=\"false\"/>
37
- </modules>
38
- </config>"
39
- }
40
-
41
- describe "#initialize" do
42
- context "with a valid xml" do
43
- before {
44
- XmlSimple.should_receive(:xml_in)
45
- .with(default_xml, { 'ForceArray' => false, 'KeepRoot' => true })
46
- .and_return("response")
47
- }
48
- subject { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
49
- it("creates and stores a correct internal xml") { subject.xml.should eql("response") }
50
- end
51
-
52
- context "with an empty string as xml" do
53
- it "throws an exception" do
54
- expect {
55
- BigBlueButton::BigBlueButtonConfigXml.new("")
56
- }.to raise_error(BigBlueButton::BigBlueButtonException)
57
- end
58
- end
59
-
60
- context "throws any exception thrown by XmlSimple" do
61
- before {
62
- XmlSimple.should_receive(:xml_in) { raise Exception }
63
- }
64
- it {
65
- expect {
66
- BigBlueButton::BigBlueButtonConfigXml.new(default_xml)
67
- }.to raise_error(BigBlueButton::BigBlueButtonException)
68
- }
69
- end
70
- end
71
-
72
- describe "#get_attribute" do
73
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
74
-
75
- context "searching inside a module" do
76
- context "if the xml has no <config>" do
77
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
78
- subject { target.get_attribute("LayoutModule", "layoutConfig") }
79
- it { should be_nil }
80
- end
81
-
82
- context "if the xml has no <config><modules>" do
83
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config></config>") }
84
- subject { target.get_attribute("LayoutModule", "layoutConfig") }
85
- it { should be_nil }
86
- end
87
-
88
- context "if the xml has no <config><modules><module>" do
89
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config><modules></modules></config>") }
90
- subject { target.get_attribute("LayoutModule", "layoutConfig") }
91
- it { should be_nil }
92
- end
93
-
94
- context "if the module and attribute are found" do
95
- subject { target.get_attribute("LayoutModule", "layoutConfig") }
96
- it { should eql("http://test-server.org/client/conf/layout.xml") }
97
- end
98
-
99
- context "if the module is not found" do
100
- subject { target.get_attribute("InexistentModule", "layoutConfig") }
101
- it { should be_nil }
102
- end
103
-
104
- context "if the attribute is not found" do
105
- subject { target.get_attribute("LayoutModule", "inexistentAttribute") }
106
- it { should be_nil }
107
- end
108
-
109
- # just to make sure it won't break in a more complete config.xml
110
- context "works with a complex xml" do
111
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
112
- subject { target.get_attribute("LayoutModule", "layoutConfig") }
113
- it { should eql("http://test-server.org/client/conf/layout.xml") }
114
- end
115
- end
116
-
117
- context "searching outside a module" do
118
- context "if the xml has no <config>" do
119
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
120
- subject { target.get_attribute("help", "url", false) }
121
- it { should be_nil }
122
- end
123
-
124
- context "if the tag and attribute are found" do
125
- subject { target.get_attribute("help", "url", false) }
126
- it { should eql("http://test-server.org/help.html") }
127
- end
128
-
129
- context "if the tag is not found" do
130
- subject { target.get_attribute("inexistent", "url", false) }
131
- it { should be_nil }
132
- end
133
-
134
- context "if the attribute is not found" do
135
- subject { target.get_attribute("help", "inexistent", false) }
136
- it { should be_nil }
137
- end
138
-
139
- # just to make sure it won't break in a more complete config.xml
140
- context "works with a complex xml" do
141
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
142
- subject { target.get_attribute("help", "url", false) }
143
- it { should eql("http://test-server.org/help.html") }
144
- end
145
- end
146
- end
147
-
148
- describe "#set_attribute" do
149
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
150
-
151
- context "setting an attribute inside a module" do
152
- context "if the xml has no <config>" do
153
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
154
- subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
155
- it { should be_nil }
156
- end
157
-
158
- context "if the xml has no <config><modules>" do
159
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config></config>") }
160
- subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
161
- it { should be_nil }
162
- end
163
-
164
- context "if the xml has no <config><modules><module>" do
165
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config><modules></modules></config>") }
166
- subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
167
- it { should be_nil }
168
- end
169
-
170
- context "if the module and attribute are found" do
171
- context "setting an attribute as string" do
172
- before(:each) {
173
- target.set_attribute("LayoutModule", "layoutConfig", "value").should eql("value")
174
- }
175
- it { target.get_attribute("LayoutModule", "layoutConfig").should eql("value") }
176
- end
177
-
178
- context "sets values always as string" do
179
- context "boolean" do
180
- before(:each) {
181
- target.set_attribute("LayoutModule", "layoutConfig", true).should eql("true")
182
- }
183
- it { target.get_attribute("LayoutModule", "layoutConfig").should eql("true") }
184
- end
185
-
186
- context "Hash" do
187
- before(:each) {
188
- target.set_attribute("LayoutModule", "layoutConfig", {}).should eql("{}")
189
- }
190
- it { target.get_attribute("LayoutModule", "layoutConfig").should eql("{}") }
191
- end
192
- end
193
- end
194
-
195
- context "if the module is not found" do
196
- subject { target.set_attribute("InexistentModule", "layoutConfig", "value") }
197
- it { should be_nil }
198
- end
199
-
200
- context "if the attribute is not found" do
201
- subject { target.set_attribute("LayoutModule", "inexistentAttribute", "value") }
202
- it { should be_nil }
203
- end
204
-
205
- # just to make sure it won't break in a more complete config.xml
206
- context "works with a complex xml" do
207
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
208
- before(:each) {
209
- target.set_attribute("LayoutModule", "layoutConfig", "value").should eql("value")
210
- }
211
- it { target.get_attribute("LayoutModule", "layoutConfig").should eql("value") }
212
- end
213
- end
214
-
215
- context "setting an attribute outside of a module" do
216
- context "if the xml has no <config>" do
217
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
218
- subject { target.set_attribute("help", "url", "value", false) }
219
- it { should be_nil }
220
- end
221
-
222
- context "if the module and attribute are found" do
223
- before(:each) {
224
- target.set_attribute("help", "url", "value", false).should eql("value")
225
- }
226
- it { target.get_attribute("help", "url", false).should eql("value") }
227
- end
228
-
229
- context "if the module is not found" do
230
- subject { target.set_attribute("InexistentModule", "url", "value", false) }
231
- it { should be_nil }
232
- end
233
-
234
- context "if the attribute is not found" do
235
- subject { target.set_attribute("help", "inexistentAttribute", "value", false) }
236
- it { should be_nil }
237
- end
238
-
239
- # just to make sure it won't break in a more complete config.xml
240
- context "works with a complex xml" do
241
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
242
- before(:each) {
243
- target.set_attribute("help", "url", "value", false).should eql("value")
244
- }
245
- it { target.get_attribute("help", "url", false).should eql("value") }
246
- end
247
- end
248
-
249
- end
250
-
251
- describe "#as_string" do
252
- context "for a simple xml" do
253
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
254
- subject { target.as_string }
255
- it {
256
- # it is the same XML as `default_xml`, just formatted slightly differently
257
- expected = "<config><help url=\"http://test-server.org/help.html\" /><modules><module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\" uri=\"rtmp://test-server.org/bigbluebutton\" layoutConfig=\"http://test-server.org/client/conf/layout.xml\" enableEdit=\"false\" /></modules></config>"
258
- should eql(expected)
259
- }
260
- end
261
-
262
- context "for a complex xml" do
263
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
264
- subject { target.as_string }
265
- it {
266
- # it is the same XML as `default_xml`, just formatted slightly differently
267
- expected = "<config version=\"4357-2014-02-06\"><localeversion suppressWarning=\"false\">0.8</localeversion><help url=\"http://test-server.org/help.html\" /><javaTest url=\"http://test-server.org/testjava.html\" /><modules><module name=\"ChatModule\" url=\"http://test-server.org/client/ChatModule.swf\" uri=\"rtmp://test-server.org/bigbluebutton\" dependsOn=\"UsersModule\" translationOn=\"false\" translationEnabled=\"false\" privateEnabled=\"true\" position=\"top-right\" baseTabIndex=\"701\" /><module name=\"UsersModule\" url=\"http://test-server.org/client/UsersModule.swf\" uri=\"rtmp://test-server.org/bigbluebutton\" allowKickUser=\"true\" enableRaiseHand=\"true\" enableSettingsButton=\"true\" baseTabIndex=\"301\" /><module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\" uri=\"rtmp://test-server.org/bigbluebutton\" layoutConfig=\"http://test-server.org/client/conf/layout.xml\" enableEdit=\"false\" /></modules></config>"
268
- should eql(expected)
269
- }
270
- end
271
- end
272
-
273
- describe "#is_modified?" do
274
- let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
275
-
276
- context "before any attribute is set" do
277
- it { target.is_modified?.should be_false }
278
- end
279
-
280
- context "after setting an attribute" do
281
- before(:each) { target.set_attribute("LayoutModule", "layoutConfig", "value") }
282
- it { target.is_modified?.should be_true }
283
- end
284
-
285
- context "if an attribute is set to the same value it already had" do
286
- before(:each) {
287
- value = target.get_attribute("LayoutModule", "layoutConfig")
288
- target.set_attribute("LayoutModule", "layoutConfig", value)
289
- }
290
- it { target.is_modified?.should be_false }
291
- end
292
-
293
- context "if an attribute is set to the same value it already had, but with a different type" do
294
- before(:each) {
295
- # it's already false in the original XML, but as a string, not boolean
296
- target.set_attribute("LayoutModule", "enableEdit", false)
297
- }
298
- it { target.is_modified?.should be_false }
299
- end
300
- end
301
-
302
- end