bigbluebutton-api-ruby 1.3.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +7 -3
- data/CHANGELOG.md +197 -0
- data/Dockerfile +13 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +26 -13
- data/LICENSE +1 -1
- data/README.md +96 -0
- data/Rakefile +8 -4
- data/bigbluebutton-api-ruby.gemspec +19 -12
- data/docker-compose.yml +10 -0
- data/examples/get_version_example.rb +1 -3
- data/examples/join_example.rb +0 -1
- data/examples/prepare.rb +1 -1
- data/features/config.yml.example +5 -9
- data/features/step_definitions/common_steps.rb +3 -4
- data/lib/bigbluebutton_api.rb +111 -32
- data/lib/bigbluebutton_config_layout.rb +3 -1
- data/lib/bigbluebutton_config_xml.rb +8 -5
- data/lib/bigbluebutton_exception.rb +1 -1
- data/lib/bigbluebutton_formatter.rb +4 -2
- data/lib/bigbluebutton_hash_to_xml.rb +3 -1
- data/spec/bigbluebutton_api_0.81_spec.rb +2 -3
- data/spec/bigbluebutton_api_0.9_spec.rb +32 -0
- data/spec/bigbluebutton_api_spec.rb +665 -599
- data/spec/bigbluebutton_config_xml_spec.rb +30 -4
- data/spec/bigbluebutton_formatter_spec.rb +36 -7
- metadata +113 -35
- data/CHANGELOG.rdoc +0 -90
- data/README.rdoc +0 -62
@@ -4,728 +4,794 @@ require 'spec_helper'
|
|
4
4
|
# there are separate files with more tests.
|
5
5
|
describe BigBlueButton::BigBlueButtonApi do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
7
|
+
shared_examples_for "BigBlueButtonApi" do |version|
|
8
|
+
|
9
|
+
# default variables and API object for all tests
|
10
|
+
let(:url) { "http://server.com" }
|
11
|
+
let(:secret) { "1234567890abcdefghijkl" }
|
12
|
+
let(:logger) { Logger.new(STDOUT) }
|
13
|
+
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
|
14
|
+
before { logger.level = Logger::INFO }
|
15
|
+
|
16
|
+
describe "#initialize" do
|
17
|
+
context "standard initialization" do
|
18
|
+
subject { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
|
19
|
+
it { subject.url.should == url }
|
20
|
+
it { subject.secret.should == secret }
|
21
|
+
it { subject.version.should == version }
|
22
|
+
it { subject.logger.should == logger }
|
23
|
+
it { subject.timeout.should == 10 }
|
24
|
+
it { subject.supported_versions.should include("0.8") }
|
25
|
+
it { subject.supported_versions.should include("0.81") }
|
26
|
+
it { subject.supported_versions.should include("0.9") }
|
27
|
+
it { subject.request_headers.should == {} }
|
28
|
+
end
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
context "when the version is not informed, get it from the BBB server" do
|
31
|
+
before { BigBlueButton::BigBlueButtonApi.any_instance.should_receive(:get_api_version).and_return("0.8") }
|
32
|
+
subject { BigBlueButton::BigBlueButtonApi.new(url, secret, nil) }
|
33
|
+
it { subject.version.should == "0.8" }
|
34
|
+
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
BigBlueButton::BigBlueButtonApi.new(url,
|
36
|
-
|
37
|
-
|
36
|
+
context "when the version informed is empty, get it from the BBB server" do
|
37
|
+
before { BigBlueButton::BigBlueButtonApi.any_instance.should_receive(:get_api_version).and_return("0.8") }
|
38
|
+
subject { BigBlueButton::BigBlueButtonApi.new(url, secret, " ") }
|
39
|
+
it { subject.version.should == "0.8" }
|
40
|
+
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
it "when the version is lower than the lowest supported, raise exception" do
|
43
|
+
expect {
|
44
|
+
BigBlueButton::BigBlueButtonApi.new(url, secret, "0.1", nil)
|
45
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
46
|
+
end
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
{ :name => "name", :meetingID => "meeting-id", :moderatorPW => "mp", :attendeePW => "ap",
|
49
|
-
:welcome => "Welcome!", :dialNumber => 12345678, :logoutURL => "http://example.com",
|
50
|
-
:maxParticipants => 25, :voiceBridge => 12345, :webVoice => "12345abc", :record => "true" }
|
51
|
-
}
|
52
|
-
let(:req_response) {
|
53
|
-
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222, :hasBeenForciblyEnded => "FALSE" }
|
54
|
-
}
|
55
|
-
let(:final_response) {
|
56
|
-
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false }
|
57
|
-
}
|
48
|
+
it "when the version is higher than thew highest supported, use the highest supported" do
|
49
|
+
BigBlueButton::BigBlueButtonApi.new(url, secret, "5.0", nil).version.should eql('1.0')
|
50
|
+
end
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
it { subject.should == final_response }
|
68
|
-
end
|
52
|
+
it "compares versions in the format 'x.xx' properly" do
|
53
|
+
expect {
|
54
|
+
# if not comparing properly, 0.61 would be bigger than 0.9, for example
|
55
|
+
# comparing the way BBB does, it is lower, so will raise an exception
|
56
|
+
BigBlueButton::BigBlueButtonApi.new(url, secret, "0.61", nil)
|
57
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
58
|
+
end
|
69
59
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
60
|
+
context "current supported versions" do
|
61
|
+
before {
|
62
|
+
BigBlueButton::BigBlueButtonApi.any_instance.should_receive(:get_api_version).and_return("0.9")
|
63
|
+
}
|
64
|
+
subject { BigBlueButton::BigBlueButtonApi.new(url, secret) }
|
65
|
+
it { subject.supported_versions.should == ["0.8", "0.81", "0.9", "1.0"] }
|
66
|
+
end
|
77
67
|
end
|
78
68
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
:
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
:moderatorPW =>
|
88
|
-
|
89
|
-
|
90
|
-
|
69
|
+
describe "#create_meeting" do
|
70
|
+
context "standard case" do
|
71
|
+
let(:req_params) {
|
72
|
+
{ :name => "name", :meetingID => "meeting-id", :moderatorPW => "mp", :attendeePW => "ap",
|
73
|
+
:welcome => "Welcome!", :dialNumber => 12345678, :logoutURL => "http://example.com",
|
74
|
+
:maxParticipants => 25, :voiceBridge => 12345, :webVoice => "12345abc", :record => "true" }
|
75
|
+
}
|
76
|
+
let(:req_response) {
|
77
|
+
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222, :hasBeenForciblyEnded => "FALSE" }
|
78
|
+
}
|
79
|
+
let(:final_response) {
|
80
|
+
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false }
|
81
|
+
}
|
91
82
|
|
92
|
-
|
93
|
-
|
94
|
-
{
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
{
|
101
|
-
|
102
|
-
let(:modules) {
|
103
|
-
m = BigBlueButton::BigBlueButtonModules.new
|
104
|
-
m.add_presentation(:url, "http://www.samplepdf.com/sample.pdf")
|
105
|
-
m.add_presentation(:url, "http://www.samplepdf.com/sample2.pdf")
|
106
|
-
m.add_presentation(:base64, "JVBERi0xLjQKJ....[clipped here]....0CiUlRU9GCg==", "first-class.pdf")
|
107
|
-
m
|
108
|
-
}
|
83
|
+
# ps: not mocking the formatter here because it's easier to just check the results (final_response)
|
84
|
+
before { api.should_receive(:send_api_request).with(:create, req_params).and_return(req_response) }
|
85
|
+
subject {
|
86
|
+
options = { :moderatorPW => "mp", :attendeePW => "ap", :welcome => "Welcome!",
|
87
|
+
:dialNumber => 12345678, :logoutURL => "http://example.com", :maxParticipants => 25,
|
88
|
+
:voiceBridge => 12345, :webVoice => "12345abc", :record => "true" }
|
89
|
+
api.create_meeting("name", "meeting-id", options)
|
90
|
+
}
|
91
|
+
it { subject.should == final_response }
|
92
|
+
end
|
109
93
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
api.create_meeting("name", "meeting-id",
|
117
|
-
|
118
|
-
it { subject.should == final_response }
|
119
|
-
end
|
94
|
+
context "accepts non standard options" do
|
95
|
+
let(:params) {
|
96
|
+
{ :name => "name", :meetingID => "meeting-id",
|
97
|
+
:moderatorPW => "mp", :attendeePW => "ap", :nonStandard => 1 }
|
98
|
+
}
|
99
|
+
before { api.should_receive(:send_api_request).with(:create, params) }
|
100
|
+
it { api.create_meeting("name", "meeting-id", params) }
|
101
|
+
end
|
120
102
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
}
|
103
|
+
context "accepts :record as boolean" do
|
104
|
+
let(:req_params) {
|
105
|
+
{ :name => "name", :meetingID => "meeting-id",
|
106
|
+
:moderatorPW => "mp", :attendeePW => "ap", :record => "true" }
|
107
|
+
}
|
108
|
+
before { api.should_receive(:send_api_request).with(:create, req_params) }
|
109
|
+
it {
|
110
|
+
params = { :name => "name", :meetingID => "meeting-id",
|
111
|
+
:moderatorPW => "mp", :attendeePW => "ap", :record => true }
|
112
|
+
api.create_meeting("name", "meeting-id", params)
|
113
|
+
}
|
114
|
+
end
|
134
115
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
116
|
+
context "with modules" do
|
117
|
+
let(:req_params) {
|
118
|
+
{ :name => "name", :meetingID => "meeting-id", :moderatorPW => "mp", :attendeePW => "ap" }
|
119
|
+
}
|
120
|
+
let(:req_response) {
|
121
|
+
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222, :hasBeenForciblyEnded => "FALSE", :createTime => "123123123" }
|
122
|
+
}
|
123
|
+
let(:final_response) {
|
124
|
+
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false, :createTime => 123123123 }
|
125
|
+
}
|
126
|
+
let(:modules) {
|
127
|
+
m = BigBlueButton::BigBlueButtonModules.new
|
128
|
+
m.add_presentation(:url, "http://www.samplepdf.com/sample.pdf")
|
129
|
+
m.add_presentation(:url, "http://www.samplepdf.com/sample2.pdf")
|
130
|
+
m.add_presentation(:base64, "JVBERi0xLjQKJ....[clipped here]....0CiUlRU9GCg==", "first-class.pdf")
|
131
|
+
m
|
132
|
+
}
|
145
133
|
|
146
|
-
|
147
|
-
|
148
|
-
|
134
|
+
before {
|
135
|
+
api.should_receive(:send_api_request).with(:create, req_params, modules.to_xml).
|
136
|
+
and_return(req_response)
|
137
|
+
}
|
138
|
+
subject {
|
139
|
+
options = { :moderatorPW => "mp", :attendeePW => "ap" }
|
140
|
+
api.create_meeting("name", "meeting-id", options, modules)
|
141
|
+
}
|
142
|
+
it { subject.should == final_response }
|
143
|
+
end
|
149
144
|
|
150
|
-
|
151
|
-
|
152
|
-
|
145
|
+
context "without modules" do
|
146
|
+
let(:req_params) {
|
147
|
+
{ :name => "name", :meetingID => "meeting-id", :moderatorPW => "mp", :attendeePW => "ap",
|
148
|
+
:welcome => "Welcome!", :dialNumber => 12345678, :logoutURL => "http://example.com",
|
149
|
+
:maxParticipants => 25, :voiceBridge => 12345, :record => "true", :duration => 20,
|
150
|
+
:meta_1 => "meta1", :meta_2 => "meta2" }
|
151
|
+
}
|
152
|
+
let(:req_response) {
|
153
|
+
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222, :hasBeenForciblyEnded => "FALSE", :createTime => "123123123" }
|
154
|
+
}
|
155
|
+
let(:final_response) {
|
156
|
+
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false, :createTime => 123123123 }
|
157
|
+
}
|
153
158
|
|
154
|
-
|
155
|
-
|
159
|
+
before { api.should_receive(:send_api_request).with(:create, req_params).and_return(req_response) }
|
160
|
+
subject {
|
161
|
+
options = { :moderatorPW => "mp", :attendeePW => "ap", :welcome => "Welcome!", :dialNumber => 12345678,
|
162
|
+
:logoutURL => "http://example.com", :maxParticipants => 25, :voiceBridge => 12345, :record => true,
|
163
|
+
:duration => 20, :meta_1 => "meta1", :meta_2 => "meta2" }
|
164
|
+
api.create_meeting("name", "meeting-id", options)
|
165
|
+
}
|
166
|
+
it { subject.should == final_response }
|
167
|
+
end
|
156
168
|
end
|
157
169
|
|
158
|
-
|
159
|
-
let(:
|
160
|
-
|
161
|
-
}
|
162
|
-
let(:params_out) {
|
163
|
-
{ :meetingID => meeting_id, :password => moderator_password,
|
164
|
-
:anything1 => "anything-1", :anything2 => 2 }
|
165
|
-
}
|
166
|
-
before { api.should_receive(:send_api_request).with(:end, params_out) }
|
167
|
-
it { api.end_meeting(meeting_id, moderator_password, params_in) }
|
168
|
-
end
|
169
|
-
end
|
170
|
+
describe "#end_meeting" do
|
171
|
+
let(:meeting_id) { "meeting-id" }
|
172
|
+
let(:moderator_password) { "password" }
|
170
173
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
+
context "standard case" do
|
175
|
+
let(:params) { { :meetingID => meeting_id, :password => moderator_password } }
|
176
|
+
let(:response) { "anything" }
|
174
177
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
it { api.is_meeting_running?(meeting_id).should == true }
|
179
|
-
end
|
178
|
+
before { api.should_receive(:send_api_request).with(:end, params).and_return(response) }
|
179
|
+
it { api.end_meeting(meeting_id, moderator_password).should == response }
|
180
|
+
end
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
182
|
+
context "accepts non standard options" do
|
183
|
+
let(:params_in) {
|
184
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
185
|
+
}
|
186
|
+
let(:params_out) {
|
187
|
+
{ :meetingID => meeting_id, :password => moderator_password,
|
188
|
+
:anything1 => "anything-1", :anything2 => 2 }
|
189
|
+
}
|
190
|
+
before { api.should_receive(:send_api_request).with(:end, params_out) }
|
191
|
+
it { api.end_meeting(meeting_id, moderator_password, params_in) }
|
192
|
+
end
|
185
193
|
end
|
186
194
|
|
187
|
-
|
188
|
-
let(:
|
189
|
-
|
190
|
-
}
|
191
|
-
let(:params_out) {
|
192
|
-
{ :meetingID => meeting_id, :anything1 => "anything-1", :anything2 => 2 }
|
193
|
-
}
|
194
|
-
before { api.should_receive(:send_api_request).with(:isMeetingRunning, params_out) }
|
195
|
-
it { api.is_meeting_running?(meeting_id, params_in) }
|
196
|
-
end
|
197
|
-
end
|
195
|
+
describe "#is_meeting_running?" do
|
196
|
+
let(:meeting_id) { "meeting-id" }
|
197
|
+
let(:params) { { :meetingID => meeting_id } }
|
198
198
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
{
|
203
|
-
|
204
|
-
}
|
199
|
+
context "when the meeting is running" do
|
200
|
+
let(:response) { { :running => "TRUE" } }
|
201
|
+
before { api.should_receive(:send_api_request).with(:isMeetingRunning, params).and_return(response) }
|
202
|
+
it { api.is_meeting_running?(meeting_id).should == true }
|
203
|
+
end
|
205
204
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
api.
|
210
|
-
|
211
|
-
end
|
205
|
+
context "when the meeting is not running" do
|
206
|
+
let(:response) { { :running => "FALSE" } }
|
207
|
+
before { api.should_receive(:send_api_request).with(:isMeetingRunning, params).and_return(response) }
|
208
|
+
it { api.is_meeting_running?(meeting_id).should == false }
|
209
|
+
end
|
212
210
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
211
|
+
context "accepts non standard options" do
|
212
|
+
let(:params_in) {
|
213
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
214
|
+
}
|
215
|
+
let(:params_out) {
|
216
|
+
{ :meetingID => meeting_id, :anything1 => "anything-1", :anything2 => 2 }
|
217
|
+
}
|
218
|
+
before { api.should_receive(:send_api_request).with(:isMeetingRunning, params_out) }
|
219
|
+
it { api.is_meeting_running?(meeting_id, params_in) }
|
220
|
+
end
|
220
221
|
end
|
221
|
-
end
|
222
222
|
|
223
|
-
|
224
|
-
|
225
|
-
|
223
|
+
describe "#join_meeting_url" do
|
224
|
+
context "standard case" do
|
225
|
+
let(:params) {
|
226
|
+
{ :meetingID => "meeting-id", :password => "pw", :fullName => "Name",
|
227
|
+
:userID => "id123", :webVoiceConf => 12345678, :createTime => 9876543 }
|
228
|
+
}
|
226
229
|
|
227
|
-
|
228
|
-
|
230
|
+
before { api.should_receive(:get_url).with(:join, params).and_return(["test-url", nil]) }
|
231
|
+
it {
|
232
|
+
options = { :userID => "id123", :webVoiceConf => 12345678, :createTime => 9876543 }
|
233
|
+
api.join_meeting_url("meeting-id", "Name", "pw", options).should == "test-url"
|
234
|
+
}
|
235
|
+
end
|
229
236
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
:recording => "false", :meta_1 => "abc", :meta_2 => "2" }
|
239
|
-
} # hash after the send_api_request call, before the formatting
|
240
|
-
|
241
|
-
let(:expected_attendee1) { { :userID => "123", :fullName => "Dexter Morgan", :role => :moderator } }
|
242
|
-
let(:expected_attendee2) { { :userID => "id2", :fullName => "Cameron", :role => :viewer } }
|
243
|
-
let(:final_response) {
|
244
|
-
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false,
|
245
|
-
:running => true, :startTime => DateTime.parse("Thu Sep 01 17:51:42 UTC 2011"), :endTime => nil,
|
246
|
-
:returncode => true, :attendees => [ expected_attendee1, expected_attendee2 ],
|
247
|
-
:messageKey => "mkey", :message => "m", :participantCount => 50, :moderatorCount => 3,
|
248
|
-
:meetingName => "meeting-name", :maxUsers => 100, :voiceBridge => 12341234, :createTime => 123123123,
|
249
|
-
:recording => false, :meta_1 => "abc", :meta_2 => "2" }
|
250
|
-
} # expected return hash after all the formatting
|
251
|
-
|
252
|
-
# ps: not mocking the formatter here because it's easier to just check the results (final_response)
|
253
|
-
before { api.should_receive(:send_api_request).with(:getMeetingInfo, params).and_return(response) }
|
254
|
-
it { api.get_meeting_info(meeting_id, password).should == final_response }
|
237
|
+
context "accepts non standard options" do
|
238
|
+
let(:params) {
|
239
|
+
{ :meetingID => "meeting-id", :password => "pw",
|
240
|
+
:fullName => "Name", :userID => "id123", :nonStandard => 1 }
|
241
|
+
}
|
242
|
+
before { api.should_receive(:get_url).with(:join, params) }
|
243
|
+
it { api.join_meeting_url("meeting-id", "Name", "pw", params) }
|
244
|
+
end
|
255
245
|
end
|
256
246
|
|
257
|
-
|
258
|
-
let(:
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
{ :meetingID => meeting_id, :password => password
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
247
|
+
describe "#get_meeting_info" do
|
248
|
+
let(:meeting_id) { "meeting-id" }
|
249
|
+
let(:password) { "password" }
|
250
|
+
|
251
|
+
context "standard case" do
|
252
|
+
let(:params) { { :meetingID => meeting_id, :password => password } }
|
253
|
+
|
254
|
+
let(:attendee1) { { :userID => 123, :fullName => "Dexter Morgan", :role => "MODERATOR" } }
|
255
|
+
let(:attendee2) { { :userID => "id2", :fullName => "Cameron", :role => "VIEWER" } }
|
256
|
+
let(:response) {
|
257
|
+
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222, :hasBeenForciblyEnded => "FALSE",
|
258
|
+
:running => "TRUE", :startTime => "Thu Sep 01 17:51:42 UTC 2011", :endTime => "null",
|
259
|
+
:returncode => true, :attendees => { :attendee => [ attendee1, attendee2 ] },
|
260
|
+
:messageKey => "mkey", :message => "m", :participantCount => "50", :moderatorCount => "3",
|
261
|
+
:meetingName => "meeting-name", :maxUsers => "100", :voiceBridge => "12341234", :createTime => "123123123",
|
262
|
+
:recording => "false", :meta_1 => "abc", :meta_2 => "2" }
|
263
|
+
} # hash after the send_api_request call, before the formatting
|
264
|
+
|
265
|
+
let(:expected_attendee1) { { :userID => "123", :fullName => "Dexter Morgan", :role => :moderator } }
|
266
|
+
let(:expected_attendee2) { { :userID => "id2", :fullName => "Cameron", :role => :viewer } }
|
267
|
+
let(:final_response) {
|
268
|
+
{ :meetingID => "123", :moderatorPW => "111", :attendeePW => "222", :hasBeenForciblyEnded => false,
|
269
|
+
:running => true, :startTime => DateTime.parse("Thu Sep 01 17:51:42 UTC 2011"), :endTime => nil,
|
270
|
+
:returncode => true, :attendees => [ expected_attendee1, expected_attendee2 ],
|
271
|
+
:messageKey => "mkey", :message => "m", :participantCount => 50, :moderatorCount => 3,
|
272
|
+
:meetingName => "meeting-name", :maxUsers => 100, :voiceBridge => 12341234, :createTime => 123123123,
|
273
|
+
:recording => false, :meta_1 => "abc", :meta_2 => "2" }
|
274
|
+
} # expected return hash after all the formatting
|
275
|
+
|
276
|
+
# ps: not mocking the formatter here because it's easier to just check the results (final_response)
|
277
|
+
before { api.should_receive(:send_api_request).with(:getMeetingInfo, params).and_return(response) }
|
278
|
+
it { api.get_meeting_info(meeting_id, password).should == final_response }
|
279
|
+
end
|
280
|
+
|
281
|
+
context "accepts non standard options" do
|
282
|
+
let(:params_in) {
|
283
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
284
|
+
}
|
285
|
+
let(:params_out) {
|
286
|
+
{ :meetingID => meeting_id, :password => password,
|
287
|
+
:anything1 => "anything-1", :anything2 => 2 }
|
288
|
+
}
|
289
|
+
before { api.should_receive(:send_api_request).with(:getMeetingInfo, params_out).and_return({}) }
|
290
|
+
it { api.get_meeting_info(meeting_id, password, params_in) }
|
291
|
+
end
|
267
292
|
end
|
268
|
-
end
|
269
293
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
294
|
+
describe "#get_meetings" do
|
295
|
+
context "standard case" do
|
296
|
+
let(:meeting_hash1) { { :meetingID => "Demo Meeting", :attendeePW => "ap", :moderatorPW => "mp", :hasBeenForciblyEnded => false, :running => true } }
|
297
|
+
let(:meeting_hash2) { { :meetingID => "Ended Meeting", :attendeePW => "pass", :moderatorPW => "pass", :hasBeenForciblyEnded => true, :running => false } }
|
298
|
+
let(:flattened_response) {
|
299
|
+
{ :returncode => true, :meetings => [ meeting_hash1, meeting_hash2 ], :messageKey => "mkey", :message => "m" }
|
300
|
+
} # hash *after* the flatten_objects call
|
301
|
+
|
302
|
+
before {
|
303
|
+
api.should_receive(:send_api_request).with(:getMeetings, {}).
|
304
|
+
and_return(flattened_response)
|
305
|
+
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
306
|
+
formatter_mock.should_receive(:flatten_objects).with(:meetings, :meeting)
|
307
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
|
308
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash1)
|
309
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash2)
|
310
|
+
}
|
311
|
+
it { api.get_meetings }
|
312
|
+
end
|
277
313
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash2)
|
286
|
-
}
|
287
|
-
it { api.get_meetings }
|
314
|
+
context "accepts non standard options" do
|
315
|
+
let(:params) {
|
316
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
317
|
+
}
|
318
|
+
before { api.should_receive(:send_api_request).with(:getMeetings, params).and_return({}) }
|
319
|
+
it { api.get_meetings(params) }
|
320
|
+
end
|
288
321
|
end
|
289
322
|
|
290
|
-
|
291
|
-
|
292
|
-
{ :
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
end
|
297
|
-
end
|
323
|
+
describe "#get_api_version" do
|
324
|
+
context "returns the version returned by the server" do
|
325
|
+
let(:hash) { { :returncode => true, :version => "0.8" } }
|
326
|
+
before { api.should_receive(:send_api_request).with(:index).and_return(hash) }
|
327
|
+
it { api.get_api_version.should == "0.8" }
|
328
|
+
end
|
298
329
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
it { api.get_api_version.should == "0.8" }
|
330
|
+
context "returns an empty string when the server responds with an empty hash" do
|
331
|
+
before { api.should_receive(:send_api_request).with(:index).and_return({}) }
|
332
|
+
it { api.get_api_version.should == "" }
|
333
|
+
end
|
304
334
|
end
|
305
335
|
|
306
|
-
|
307
|
-
|
308
|
-
|
336
|
+
describe "#test_connection" do
|
337
|
+
context "returns the returncode returned by the server" do
|
338
|
+
let(:hash) { { :returncode => "any-value" } }
|
339
|
+
before { api.should_receive(:send_api_request).with(:index).and_return(hash) }
|
340
|
+
it { api.test_connection.should == "any-value" }
|
341
|
+
end
|
309
342
|
end
|
310
|
-
end
|
311
343
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
344
|
+
describe "#check_url" do
|
345
|
+
context "when method = :check" do
|
346
|
+
it {
|
347
|
+
api.url = 'http://my-test-server.com/bigbluebutton/api'
|
348
|
+
api.check_url.should == 'http://my-test-server.com/check'
|
349
|
+
}
|
350
|
+
end
|
317
351
|
end
|
318
|
-
end
|
319
352
|
|
320
|
-
|
321
|
-
|
353
|
+
describe "#==" do
|
354
|
+
let(:api2) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
|
322
355
|
|
323
|
-
|
324
|
-
|
325
|
-
|
356
|
+
context "compares attributes" do
|
357
|
+
it { api.should == api2 }
|
358
|
+
end
|
326
359
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
360
|
+
context "differs #logger" do
|
361
|
+
before { api2.logger = !api.logger }
|
362
|
+
it { api.should_not == api2 }
|
363
|
+
end
|
364
|
+
|
365
|
+
context "differs #secret" do
|
366
|
+
before { api2.secret = api.secret + "x" }
|
367
|
+
it { api.should_not == api2 }
|
368
|
+
end
|
369
|
+
|
370
|
+
context "differs #version" do
|
371
|
+
before { api2.version = api.version + "x" }
|
372
|
+
it { api.should_not == api2 }
|
373
|
+
end
|
331
374
|
|
332
|
-
|
333
|
-
|
334
|
-
|
375
|
+
context "differs #supported_versions" do
|
376
|
+
before { api2.supported_versions << "x" }
|
377
|
+
it { api.should_not == api2 }
|
378
|
+
end
|
335
379
|
end
|
336
380
|
|
337
|
-
|
338
|
-
|
339
|
-
|
381
|
+
describe "#last_http_response" do
|
382
|
+
# we test this through a #test_connection call
|
383
|
+
|
384
|
+
let(:request_mock) { mock }
|
385
|
+
before {
|
386
|
+
api.should_receive(:get_url)
|
387
|
+
# this return value will be stored in @http_response
|
388
|
+
api.should_receive(:send_request).and_return(request_mock)
|
389
|
+
# to return fast from #send_api_request
|
390
|
+
request_mock.should_receive(:body).and_return("")
|
391
|
+
api.test_connection
|
392
|
+
}
|
393
|
+
it { api.last_http_response.should == request_mock }
|
340
394
|
end
|
341
395
|
|
342
|
-
|
343
|
-
|
344
|
-
|
396
|
+
describe "#last_xml_response" do
|
397
|
+
# we test this through a #test_connection call
|
398
|
+
|
399
|
+
let(:request_mock) { mock }
|
400
|
+
let(:expected_xml) { "<response><returncode>SUCCESS</returncode></response>" }
|
401
|
+
before {
|
402
|
+
api.should_receive(:get_url)
|
403
|
+
api.should_receive(:send_request).and_return(request_mock)
|
404
|
+
request_mock.should_receive(:body).at_least(1).and_return(expected_xml)
|
405
|
+
api.test_connection
|
406
|
+
}
|
407
|
+
it { api.last_xml_response.should == expected_xml }
|
345
408
|
end
|
346
|
-
end
|
347
409
|
|
348
|
-
|
349
|
-
# we test this through a #test_connection call
|
350
|
-
|
351
|
-
let(:request_mock) { mock }
|
352
|
-
before {
|
353
|
-
api.should_receive(:get_url)
|
354
|
-
# this return value will be stored in @http_response
|
355
|
-
api.should_receive(:send_request).and_return(request_mock)
|
356
|
-
# to return fast from #send_api_request
|
357
|
-
request_mock.should_receive(:body).and_return("")
|
358
|
-
api.test_connection
|
359
|
-
}
|
360
|
-
it { api.last_http_response.should == request_mock }
|
361
|
-
end
|
410
|
+
describe "#get_url" do
|
362
411
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
let(:request_mock) { mock }
|
367
|
-
let(:expected_xml) { "<response><returncode>SUCCESS</returncode></response>" }
|
368
|
-
before {
|
369
|
-
api.should_receive(:get_url)
|
370
|
-
api.should_receive(:send_request).and_return(request_mock)
|
371
|
-
request_mock.should_receive(:body).at_least(1).and_return(expected_xml)
|
372
|
-
api.test_connection
|
373
|
-
}
|
374
|
-
it { api.last_xml_response.should == expected_xml }
|
375
|
-
end
|
412
|
+
context "when method = :index" do
|
413
|
+
it { api.get_url(:index).should == [api.url, nil] }
|
414
|
+
end
|
376
415
|
|
377
|
-
|
416
|
+
context "when method = :check" do
|
417
|
+
it {
|
418
|
+
api.url = 'http://my-test-server.com/bigbluebutton/api'
|
419
|
+
api.get_url(:check).should == ['http://my-test-server.com/check', nil]
|
420
|
+
}
|
421
|
+
end
|
378
422
|
|
379
|
-
|
380
|
-
|
381
|
-
|
423
|
+
context "when method != :index" do
|
424
|
+
context "validates the entire url" do
|
425
|
+
context "with params" do
|
426
|
+
let(:params) { { :param1 => "value1", :param2 => "value2" } }
|
427
|
+
subject { api.get_url(:join, params)[0] }
|
428
|
+
it {
|
429
|
+
# the hash can be sorted differently depending on the ruby version
|
430
|
+
if params.map{ |k,v| "#{k}" }.join =~ /^param1/
|
431
|
+
subject.should match(/#{url}\/join\?param1=value1¶m2=value2/)
|
432
|
+
else
|
433
|
+
subject.should match(/#{url}\/join\?param2=value2¶m1=value1/)
|
434
|
+
end
|
435
|
+
}
|
436
|
+
end
|
382
437
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
438
|
+
context "without params" do
|
439
|
+
subject { api.get_url(:join)[0] }
|
440
|
+
it { subject.should match(/#{url}\/join\?[^&]/) }
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
context "when method = :setConfigXML" do
|
388
445
|
it {
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
subject.should match(/#{url}\/join\?param2=value2¶m1=value1/)
|
394
|
-
end
|
446
|
+
api.url = 'http://my-test-server.com/bigbluebutton/api'
|
447
|
+
response = api.get_url(:setConfigXML, { param1: 1, param2: 2 })
|
448
|
+
response[0].should eql('http://my-test-server.com/bigbluebutton/api/setConfigXML')
|
449
|
+
response[1].should match(/checksum=.*¶m1=1¶m2=2/)
|
395
450
|
}
|
396
451
|
end
|
397
452
|
|
398
|
-
context "
|
399
|
-
|
400
|
-
|
453
|
+
context "discards params with nil value" do
|
454
|
+
let(:params) { { :param1 => "value1", :param2 => nil } }
|
455
|
+
subject { api.get_url(:join, params)[0] }
|
456
|
+
it { subject.should_not match(/param2=/) }
|
401
457
|
end
|
402
|
-
end
|
403
458
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
context "escapes all params" do
|
411
|
-
let(:params) { { :param1 => "value with spaces", :param2 => "@$" } }
|
412
|
-
subject { api.get_url(:join, params) }
|
413
|
-
it { subject.should match(/param1=value\+with\+spaces/) }
|
414
|
-
it { subject.should match(/param2=%40%24/) }
|
415
|
-
end
|
459
|
+
context "escapes all params" do
|
460
|
+
let(:params) { { :param1 => "value with spaces", :param2 => "@$" } }
|
461
|
+
subject { api.get_url(:join, params)[0] }
|
462
|
+
it { subject.should match(/param1=value\+with\+spaces/) }
|
463
|
+
it { subject.should match(/param2=%40%24/) }
|
464
|
+
end
|
416
465
|
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
"85a54e28e4ec18bfdcb214a73f74d35b09a84176"
|
466
|
+
[ [' ', '+'],
|
467
|
+
['*', '*']
|
468
|
+
].each do |values|
|
469
|
+
context "escapes #{values[0].inspect} as #{values[1].inspect}" do
|
470
|
+
let(:params) { { param1: "before#{values[0]}after" } }
|
471
|
+
subject { api.get_url(:join, params)[0] }
|
472
|
+
it { subject.should match(/param1=before#{Regexp.quote(values[1])}after/) }
|
425
473
|
end
|
426
|
-
|
427
|
-
|
428
|
-
|
474
|
+
end
|
475
|
+
|
476
|
+
context "includes the checksum" do
|
477
|
+
let(:params) { { :param1 => "value1", :param2 => "value2" } }
|
478
|
+
let(:checksum) {
|
479
|
+
# the hash can be sorted differently depending on the ruby version
|
480
|
+
if params.map{ |k,v| k }.join =~ /^param1/
|
481
|
+
"67882ae54f49600f56f358c10d24697ef7d8c6b2"
|
482
|
+
else
|
483
|
+
"85a54e28e4ec18bfdcb214a73f74d35b09a84176"
|
484
|
+
end
|
485
|
+
}
|
486
|
+
subject { api.get_url(:join, params)[0] }
|
487
|
+
it { subject.should match(/checksum=#{checksum}$/) }
|
488
|
+
end
|
429
489
|
end
|
430
490
|
end
|
431
|
-
end
|
432
491
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
492
|
+
describe "#send_api_request" do
|
493
|
+
let(:method) { :join }
|
494
|
+
let(:params) { { :param1 => "value1" } }
|
495
|
+
let(:data) { "any data" }
|
496
|
+
let(:url) { "http://test-server:8080?param1=value1&checksum=12345" }
|
497
|
+
let(:make_request) { api.send_api_request(method, params, data) }
|
498
|
+
let(:response_mock) { mock() } # mock of what send_request() would return
|
440
499
|
|
441
|
-
|
500
|
+
before { api.should_receive(:get_url).with(method, params).and_return([url, nil]) }
|
442
501
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
502
|
+
context "returns an empty hash if the response body is empty" do
|
503
|
+
before do
|
504
|
+
api.should_receive(:send_request).with(url, data).and_return(response_mock)
|
505
|
+
response_mock.should_receive(:body).and_return("")
|
506
|
+
end
|
507
|
+
it { make_request.should == { } }
|
447
508
|
end
|
448
|
-
it { make_request.should == { } }
|
449
|
-
end
|
450
509
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
510
|
+
context "hashfies and validates the response body" do
|
511
|
+
before do
|
512
|
+
api.should_receive(:send_request).with(url, data).and_return(response_mock)
|
513
|
+
response_mock.should_receive(:body).twice.and_return("response-body")
|
514
|
+
end
|
515
|
+
|
516
|
+
context "checking if it has a :response key" do
|
517
|
+
before { BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return({ }) }
|
518
|
+
it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
519
|
+
end
|
520
|
+
|
521
|
+
context "checking if it the :response key has a :returncode key" do
|
522
|
+
before { BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return({ :response => { } }) }
|
523
|
+
it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
524
|
+
end
|
455
525
|
end
|
456
526
|
|
457
|
-
context "
|
458
|
-
|
459
|
-
|
527
|
+
context "formats the response hash" do
|
528
|
+
let(:response) { { :returncode => "SUCCESS" } }
|
529
|
+
let(:formatted_response) { { :returncode => true, :messageKey => "", :message => "" } }
|
530
|
+
before do
|
531
|
+
api.should_receive(:send_request).with(url, data).and_return(response_mock)
|
532
|
+
response_mock.should_receive(:body).twice.and_return("response-body")
|
533
|
+
BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
|
534
|
+
|
535
|
+
# here starts the validation
|
536
|
+
# doesn't test the resulting format, only that the formatter was called
|
537
|
+
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
538
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
|
539
|
+
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
|
540
|
+
end
|
541
|
+
it { make_request }
|
460
542
|
end
|
461
543
|
|
462
|
-
context "
|
463
|
-
|
544
|
+
context "raise an error if the formatted response has no :returncode" do
|
545
|
+
let(:response) { { :returncode => true } }
|
546
|
+
let(:formatted_response) { { } }
|
547
|
+
before do
|
548
|
+
api.should_receive(:send_request).with(url, data).and_return(response_mock)
|
549
|
+
response_mock.should_receive(:body).twice.and_return("response-body")
|
550
|
+
BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
|
551
|
+
|
552
|
+
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
553
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
|
554
|
+
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
|
555
|
+
end
|
464
556
|
it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
465
557
|
end
|
466
558
|
end
|
467
559
|
|
468
|
-
|
469
|
-
let(:
|
470
|
-
let(:
|
471
|
-
|
472
|
-
api.should_receive(:send_request).with(url, data).and_return(response_mock)
|
473
|
-
response_mock.should_receive(:body).twice.and_return("response-body")
|
474
|
-
BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
|
475
|
-
|
476
|
-
# here starts the validation
|
477
|
-
# doesn't test the resulting format, only that the formatter was called
|
478
|
-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
479
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
|
480
|
-
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
|
481
|
-
end
|
482
|
-
it { make_request }
|
483
|
-
end
|
560
|
+
describe "#send_request" do
|
561
|
+
let(:url) { "http://test-server:8080/res?param1=value1&checksum=12345" }
|
562
|
+
let(:url_parsed) { URI.parse(url) }
|
563
|
+
let(:res) { Net::HTTPResponse.new(1.0, '200', 'OK') }
|
484
564
|
|
485
|
-
context "raise an error if the formatted response has no :returncode" do
|
486
|
-
let(:response) { { :returncode => true } }
|
487
|
-
let(:formatted_response) { { } }
|
488
565
|
before do
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
|
495
|
-
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
|
566
|
+
@http_mock = mock(Net::HTTP)
|
567
|
+
@http_mock.should_receive(:"open_timeout=").with(api.timeout)
|
568
|
+
@http_mock.should_receive(:"read_timeout=").with(api.timeout)
|
569
|
+
Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_mock)
|
570
|
+
res.stub(:body) { "ok" }
|
496
571
|
end
|
497
|
-
it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
498
|
-
end
|
499
|
-
end
|
500
572
|
|
501
|
-
|
502
|
-
|
503
|
-
|
573
|
+
context "standard case" do
|
574
|
+
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
|
575
|
+
it { api.send(:send_request, url).should == res }
|
576
|
+
end
|
504
577
|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_mock)
|
510
|
-
end
|
578
|
+
context "handles a TimeoutError" do
|
579
|
+
before { @http_mock.should_receive(:get) { raise TimeoutError } }
|
580
|
+
it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
581
|
+
end
|
511
582
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
583
|
+
context "handles general Exceptions" do
|
584
|
+
before { @http_mock.should_receive(:get) { raise Exception } }
|
585
|
+
it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
|
586
|
+
end
|
516
587
|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
588
|
+
context "post with data" do
|
589
|
+
let(:data) { "any data" }
|
590
|
+
before {
|
591
|
+
path = "/res?param1=value1&checksum=12345"
|
592
|
+
opts = { 'Content-Type' => 'application/xml' }
|
593
|
+
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
|
594
|
+
}
|
595
|
+
it {
|
596
|
+
api.send(:send_request, url, data).should == res
|
597
|
+
}
|
598
|
+
end
|
521
599
|
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
600
|
+
context "get with headers" do
|
601
|
+
let(:headers_hash) { { :anything => "anything" } }
|
602
|
+
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
|
603
|
+
it {
|
604
|
+
api.request_headers = headers_hash
|
605
|
+
api.send(:send_request, url).should == res
|
606
|
+
}
|
607
|
+
end
|
526
608
|
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
609
|
+
context "get with headers" do
|
610
|
+
let(:headers_hash) { { :anything => "anything" } }
|
611
|
+
let(:data) { "any data" }
|
612
|
+
before {
|
613
|
+
path = "/res?param1=value1&checksum=12345"
|
614
|
+
opts = { 'Content-Type' => 'application/xml', :anything => "anything" }
|
615
|
+
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
|
616
|
+
}
|
617
|
+
it {
|
618
|
+
api.request_headers = headers_hash
|
619
|
+
api.send(:send_request, url, data).should == res
|
620
|
+
}
|
621
|
+
end
|
537
622
|
end
|
538
623
|
|
539
|
-
|
540
|
-
let(:
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
api.send(:send_request, url).should == "ok"
|
624
|
+
describe "#get_recordings" do
|
625
|
+
let(:recording1) { { :recordID => "id1", :meetindID => "meeting-id" } } # simplified "recording" node in the response
|
626
|
+
let(:recording2) { { :recordID => "id2", :meetindID => "meeting-id" } }
|
627
|
+
let(:response) {
|
628
|
+
{ :returncode => true, :recordings => { :recording => [ recording1, recording2 ] }, :messageKey => "mkey", :message => "m" }
|
545
629
|
}
|
546
|
-
|
630
|
+
let(:flattened_response) {
|
631
|
+
{ :returncode => true, :recordings => [ recording1, recording2 ], :messageKey => "mkey", :message => "m" }
|
632
|
+
} # hash *after* the flatten_objects call
|
547
633
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
opts = { 'Content-Type' => 'text/xml', :anything => "anything" }
|
554
|
-
@http_mock.should_receive(:post).with(path, data, opts).and_return("ok")
|
555
|
-
}
|
556
|
-
it {
|
557
|
-
api.request_headers = headers_hash
|
558
|
-
api.send(:send_request, url, data).should == "ok"
|
559
|
-
}
|
560
|
-
end
|
561
|
-
end
|
634
|
+
context "accepts non standard options" do
|
635
|
+
let(:params) { { :meetingID => "meeting-id", :nonStandard => 1 } }
|
636
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, params).and_return(response) }
|
637
|
+
it { api.get_recordings(params) }
|
638
|
+
end
|
562
639
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
{ :returncode => true, :recordings => { :recording => [ recording1, recording2 ] }, :messageKey => "mkey", :message => "m" }
|
568
|
-
}
|
569
|
-
let(:flattened_response) {
|
570
|
-
{ :returncode => true, :recordings => [ recording1, recording2 ], :messageKey => "mkey", :message => "m" }
|
571
|
-
} # hash *after* the flatten_objects call
|
572
|
-
|
573
|
-
context "accepts non standard options" do
|
574
|
-
let(:params) { { :meetingID => "meeting-id", :nonStandard => 1 } }
|
575
|
-
before { api.should_receive(:send_api_request).with(:getRecordings, params).and_return(response) }
|
576
|
-
it { api.get_recordings(params) }
|
577
|
-
end
|
640
|
+
context "without meeting ID" do
|
641
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, {}).and_return(response) }
|
642
|
+
it { api.get_recordings.should == response }
|
643
|
+
end
|
578
644
|
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
645
|
+
context "with one meeting ID" do
|
646
|
+
context "in an array" do
|
647
|
+
let(:options) { { :meetingID => ["meeting-id"] } }
|
648
|
+
let(:req_params) { { :meetingID => "meeting-id" } }
|
649
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, req_params).and_return(response) }
|
650
|
+
it { api.get_recordings(options).should == response }
|
651
|
+
end
|
583
652
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
653
|
+
context "in a string" do
|
654
|
+
let(:options) { { :meetingID => "meeting-id" } }
|
655
|
+
let(:req_params) { { :meetingID => "meeting-id" } }
|
656
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, req_params).and_return(response) }
|
657
|
+
it { api.get_recordings(options).should == response }
|
658
|
+
end
|
590
659
|
end
|
591
660
|
|
592
|
-
context "
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
661
|
+
context "with several meeting IDs" do
|
662
|
+
context "in an array" do
|
663
|
+
let(:options) { { :meetingID => ["meeting-id-1", "meeting-id-2"] } }
|
664
|
+
let(:req_params) { { :meetingID => "meeting-id-1,meeting-id-2" } }
|
665
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, req_params).and_return(response) }
|
666
|
+
it { api.get_recordings(options).should == response }
|
667
|
+
end
|
599
668
|
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
669
|
+
context "in a string" do
|
670
|
+
let(:options) { { :meetingID => "meeting-id-1,meeting-id-2" } }
|
671
|
+
let(:req_params) { { :meetingID => "meeting-id-1,meeting-id-2" } }
|
672
|
+
before { api.should_receive(:send_api_request).with(:getRecordings, req_params).and_return(response) }
|
673
|
+
it { api.get_recordings(options).should == response }
|
674
|
+
end
|
606
675
|
end
|
607
676
|
|
608
|
-
context "
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
677
|
+
context "formats the response" do
|
678
|
+
before {
|
679
|
+
api.should_receive(:send_api_request).with(:getRecordings, anything).and_return(flattened_response)
|
680
|
+
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
681
|
+
formatter_mock.should_receive(:flatten_objects).with(:recordings, :recording)
|
682
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording1)
|
683
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording2)
|
684
|
+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
|
685
|
+
}
|
686
|
+
it { api.get_recordings }
|
613
687
|
end
|
614
688
|
end
|
615
689
|
|
616
|
-
|
617
|
-
before {
|
618
|
-
api.should_receive(:send_api_request).with(:getRecordings, anything).and_return(flattened_response)
|
619
|
-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
|
620
|
-
formatter_mock.should_receive(:flatten_objects).with(:recordings, :recording)
|
621
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording1)
|
622
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording2)
|
623
|
-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
|
624
|
-
}
|
625
|
-
it { api.get_recordings }
|
626
|
-
end
|
627
|
-
end
|
628
|
-
|
629
|
-
describe "#publish_recordings" do
|
630
|
-
|
631
|
-
context "publish is converted to string" do
|
632
|
-
let(:recordIDs) { "any" }
|
633
|
-
let(:req_params) { { :publish => "false", :recordID => "any" } }
|
634
|
-
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
635
|
-
it { api.publish_recordings(recordIDs, false) }
|
636
|
-
end
|
690
|
+
describe "#publish_recordings" do
|
637
691
|
|
638
|
-
|
639
|
-
|
640
|
-
let(:
|
641
|
-
let(:req_params) { { :publish => "true", :recordID => "id-1" } }
|
692
|
+
context "publish is converted to string" do
|
693
|
+
let(:recordIDs) { "any" }
|
694
|
+
let(:req_params) { { :publish => "false", :recordID => "any" } }
|
642
695
|
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
643
|
-
it { api.publish_recordings(recordIDs,
|
696
|
+
it { api.publish_recordings(recordIDs, false) }
|
644
697
|
end
|
645
698
|
|
646
|
-
context "
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
699
|
+
context "with one recording ID" do
|
700
|
+
context "in an array" do
|
701
|
+
let(:recordIDs) { ["id-1"] }
|
702
|
+
let(:req_params) { { :publish => "true", :recordID => "id-1" } }
|
703
|
+
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
704
|
+
it { api.publish_recordings(recordIDs, true) }
|
705
|
+
end
|
706
|
+
|
707
|
+
context "in a string" do
|
708
|
+
let(:recordIDs) { "id-1" }
|
709
|
+
let(:req_params) { { :publish => "true", :recordID => "id-1" } }
|
710
|
+
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
711
|
+
it { api.publish_recordings(recordIDs, true) }
|
712
|
+
end
|
651
713
|
end
|
652
|
-
end
|
653
714
|
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
715
|
+
context "with several recording IDs" do
|
716
|
+
context "in an array" do
|
717
|
+
let(:recordIDs) { ["id-1", "id-2"] }
|
718
|
+
let(:req_params) { { :publish => "true", :recordID => "id-1,id-2" } }
|
719
|
+
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
720
|
+
it { api.publish_recordings(recordIDs, true) }
|
721
|
+
end
|
722
|
+
|
723
|
+
context "in a string" do
|
724
|
+
let(:recordIDs) { "id-1,id-2,id-3" }
|
725
|
+
let(:req_params) { { :publish => "true", :recordID => "id-1,id-2,id-3" } }
|
726
|
+
before { api.should_receive(:send_api_request).with(:publishRecordings, req_params) }
|
727
|
+
it { api.publish_recordings(recordIDs, true) }
|
728
|
+
end
|
660
729
|
end
|
661
730
|
|
662
|
-
context "
|
663
|
-
let(:recordIDs) { "id-1
|
664
|
-
let(:
|
665
|
-
|
666
|
-
|
731
|
+
context "accepts non standard options" do
|
732
|
+
let(:recordIDs) { ["id-1"] }
|
733
|
+
let(:params_in) {
|
734
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
735
|
+
}
|
736
|
+
let(:params_out) {
|
737
|
+
{ :publish => "true", :recordID => "id-1",
|
738
|
+
:anything1 => "anything-1", :anything2 => 2 }
|
739
|
+
}
|
740
|
+
before { api.should_receive(:send_api_request).with(:publishRecordings, params_out) }
|
741
|
+
it { api.publish_recordings(recordIDs, true, params_in) }
|
667
742
|
end
|
668
743
|
end
|
669
744
|
|
670
|
-
|
671
|
-
let(:recordIDs) { ["id-1"] }
|
672
|
-
let(:params_in) {
|
673
|
-
{ :anything1 => "anything-1", :anything2 => 2 }
|
674
|
-
}
|
675
|
-
let(:params_out) {
|
676
|
-
{ :publish => "true", :recordID => "id-1",
|
677
|
-
:anything1 => "anything-1", :anything2 => 2 }
|
678
|
-
}
|
679
|
-
before { api.should_receive(:send_api_request).with(:publishRecordings, params_out) }
|
680
|
-
it { api.publish_recordings(recordIDs, true, params_in) }
|
681
|
-
end
|
682
|
-
end
|
745
|
+
describe "#delete_recordings" do
|
683
746
|
|
684
|
-
|
747
|
+
context "with one recording ID" do
|
748
|
+
context "in an array" do
|
749
|
+
let(:recordIDs) { ["id-1"] }
|
750
|
+
let(:req_params) { { :recordID => "id-1" } }
|
751
|
+
before { api.should_receive(:send_api_request).with(:deleteRecordings, req_params) }
|
752
|
+
it { api.delete_recordings(recordIDs) }
|
753
|
+
end
|
685
754
|
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
755
|
+
context "in a string" do
|
756
|
+
let(:recordIDs) { "id-1" }
|
757
|
+
let(:req_params) { { :recordID => "id-1" } }
|
758
|
+
before { api.should_receive(:send_api_request).with(:deleteRecordings, req_params) }
|
759
|
+
it { api.delete_recordings(recordIDs) }
|
760
|
+
end
|
692
761
|
end
|
693
762
|
|
694
|
-
context "
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
763
|
+
context "with several recording IDs" do
|
764
|
+
context "in an array" do
|
765
|
+
let(:recordIDs) { ["id-1", "id-2"] }
|
766
|
+
let(:req_params) { { :recordID => "id-1,id-2" } }
|
767
|
+
before { api.should_receive(:send_api_request).with(:deleteRecordings, req_params) }
|
768
|
+
it { api.delete_recordings(recordIDs) }
|
769
|
+
end
|
701
770
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
771
|
+
context "in a string" do
|
772
|
+
let(:recordIDs) { "id-1,id-2,id-3" }
|
773
|
+
let(:req_params) { { :recordID => "id-1,id-2,id-3" } }
|
774
|
+
before { api.should_receive(:send_api_request).with(:deleteRecordings, req_params) }
|
775
|
+
it { api.delete_recordings(recordIDs) }
|
776
|
+
end
|
708
777
|
end
|
709
778
|
|
710
|
-
context "
|
711
|
-
let(:recordIDs) { "id-1
|
712
|
-
let(:
|
713
|
-
|
714
|
-
|
779
|
+
context "accepts non standard options" do
|
780
|
+
let(:recordIDs) { ["id-1"] }
|
781
|
+
let(:params_in) {
|
782
|
+
{ :anything1 => "anything-1", :anything2 => 2 }
|
783
|
+
}
|
784
|
+
let(:params_out) {
|
785
|
+
{ :recordID => "id-1", :anything1 => "anything-1", :anything2 => 2 }
|
786
|
+
}
|
787
|
+
before { api.should_receive(:send_api_request).with(:deleteRecordings, params_out) }
|
788
|
+
it { api.delete_recordings(recordIDs, params_in) }
|
715
789
|
end
|
716
790
|
end
|
717
|
-
|
718
|
-
context "accepts non standard options" do
|
719
|
-
let(:recordIDs) { ["id-1"] }
|
720
|
-
let(:params_in) {
|
721
|
-
{ :anything1 => "anything-1", :anything2 => 2 }
|
722
|
-
}
|
723
|
-
let(:params_out) {
|
724
|
-
{ :recordID => "id-1", :anything1 => "anything-1", :anything2 => 2 }
|
725
|
-
}
|
726
|
-
before { api.should_receive(:send_api_request).with(:deleteRecordings, params_out) }
|
727
|
-
it { api.delete_recordings(recordIDs, params_in) }
|
728
|
-
end
|
729
791
|
end
|
730
792
|
|
793
|
+
it_should_behave_like "BigBlueButtonApi", "0.8"
|
794
|
+
it_should_behave_like "BigBlueButtonApi", "0.81"
|
795
|
+
it_should_behave_like "BigBlueButtonApi", "0.9"
|
796
|
+
it_should_behave_like "BigBlueButtonApi", "1.0"
|
731
797
|
end
|