adobe_connect_api 0.0.69.alpha → 0.0.70.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.2@adobe_connect_api
1
+ rvm 1.9.3@adobe_connect_api
@@ -9,6 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = ""
10
10
 
11
11
  gem.add_dependency "xml-simple"
12
+ gem.add_development_dependency "rspec"
12
13
 
13
14
  gem.files = `git ls-files`.split($\)
14
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2010 SWITCH - Serving Swiss Universities
2
+ # Author: Christian Rohrer <christian.rohrer@switch.ch>
3
+ # $Id$
4
+
5
+ # Configuration of the breeze / adobe connect connection
6
+
7
+ development:
8
+ url : https://collab-test.switch.ch
9
+ username: interactAdmin@switch.ch
10
+ password: CqxV4pi0WUyqAq5G
11
+
12
+ test_user: interact-support@switch.ch
13
+ generic_user_password: gu4nolico
14
+
15
+ test:
16
+ url : https://collab-test.switch.ch
17
+ username: interactAdmin@switch.ch
18
+ password: CqxV4pi0WUyqAq5G
19
+
20
+ test_user: interact-support@switch.ch
21
+ generic_user_password: gu4nolico
22
+
23
+ production:
24
+ url : https://collab.switch.ch
25
+ username: interactAdmin@switch.ch
26
+ password: CqxV4pi0WUyqAq5G
27
+
28
+ generic_user_password: gu4nolico
29
+
30
+
@@ -1,3 +1,3 @@
1
1
  module AdobeConnectApi
2
- VERSION = "0.0.69.alpha"
2
+ VERSION = "0.0.70.alpha"
3
3
  end
@@ -0,0 +1,77 @@
1
+ # Copyright (c) 2010 - 2013 SWITCH - Serving Swiss Universities
2
+ # Author: Katja Gräfenhain <katja.graefenhain@switch.ch>
3
+
4
+ # This class is a simple utility to parse the result from querying the
5
+ # adobe connect api. All methods accept a String containing XML, that is
6
+ # returned from the AdobeConnectAPI methods.
7
+ # For queries and returned results see the API documentation:
8
+ # http://help.adobe.com/en_US/connect/8.0/webservices/connect_8_webservices.pdf
9
+ module XMLParser
10
+
11
+ # used for all actions, e.g. 'login' and 'logout'
12
+ def get_status_code(xml)
13
+ data = XmlSimple.xml_in(xml)
14
+ data['status'].first['code']
15
+ end
16
+
17
+ # used if the returned status contains an invalid value
18
+ def get_invalid_subcode(xml)
19
+ data = XmlSimple.xml_in(xml)
20
+ data['status'].first['invalid'].first['subcode']
21
+ end
22
+
23
+ # supported actions: 'principal-update' or 'principal-list'
24
+ # NOTE: does not handle more than one result, so use only for 'principal-list' that returns a unique result e.g. when querying users by e-mail
25
+ def get_principal_id(xml)
26
+ data = XmlSimple.xml_in(xml)
27
+ if data.keys.include?('principal-list')
28
+ return data['principal-list'].first['principal'].first['principal-id'] unless data['principal-list'].first.empty?
29
+ elsif data.keys.include?('principal')
30
+ return data['principal'].first['principal-id']
31
+ else
32
+ raise "XMLParser does not support result of this format. No principal information found."
33
+ end
34
+ return nil
35
+ end
36
+
37
+ # supported actions: 'sco-update', 'sco-info'
38
+ def get_sco_id(xml)
39
+ data = XmlSimple.xml_in(xml)
40
+ if data['sco']
41
+ return data['sco'].first['sco-id']
42
+ else
43
+ raise "XMLParser does not support result of this format. No sco information found."
44
+ end
45
+ return nil
46
+ end
47
+
48
+ # supported action: 'sco-search-by-field'
49
+ # gets the first result that name EXACTLY matches the given name
50
+ def get_sco_id_for_unique_name(xml, name)
51
+ data = XmlSimple.xml_in(xml)
52
+ if data['sco-search-by-field-info'] && !data['sco-search-by-field-info'].first.empty?
53
+ data['sco-search-by-field-info'].first['sco'].each do |sco|
54
+ if sco['name'].first == name
55
+ return sco['sco-id']
56
+ else
57
+ raise "No correct match for name #{name} found"
58
+ end
59
+ end
60
+ end
61
+ return nil
62
+ end
63
+
64
+ # supported actions: 'sco-contents' but only with filter-name and the user's e-mail-address (does not consider multiple sco results)
65
+ # e.g. action=sco-contents&sco-id=11&filter-name=interact-support%40switch.ch
66
+ def get_folder_id(xml)
67
+ data = XmlSimple.xml_in(xml)
68
+
69
+ if data['scos']
70
+ return data['scos'].first['sco'].first['sco-id'] unless data['scos'].first.empty?
71
+ else
72
+ raise "XMLParser does not support result of this format. No sco information found."
73
+ end
74
+ return nil
75
+ end
76
+
77
+ end
@@ -1,9 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (c) 2010 SWITCH - Serving Swiss Universities
3
+ # Copyright (c) 2010 - 2013 SWITCH - Serving Swiss Universities
4
4
  # Author: Mischael Schill <me@mschill.ch>
5
5
  # Martin Kos <martin@kos.li>
6
6
  # Christian Rohrer <christian.rohrer@switch.ch>
7
+ # Katja Gräfenhain <katja.graefenhain@switch.ch>
7
8
  # $Id$
8
9
 
9
10
  require 'rubygems'
@@ -15,10 +16,11 @@ require "cgi"
15
16
  require "yaml"
16
17
  #require 'logger'
17
18
 
18
- require "adobe_connect_api/version"
19
+ require 'adobe_connect_api/version'
19
20
  require 'adobe_connect_api/filter_definition'
20
21
  require 'adobe_connect_api/sort_definition'
21
22
  require 'adobe_connect_api/result'
23
+ require 'adobe_connect_api/xml_parser'
22
24
 
23
25
 
24
26
  # This class is a simple utility to acces the adobe connect api. Before
@@ -28,12 +30,21 @@ require 'adobe_connect_api/result'
28
30
  # All the actions are defined in the Adobe Connect Pro API documentation
29
31
  # some of the actions are accepting filter- and/or sorting-definitions.
30
32
 
31
- # module AdobeConnectApi
33
+ # NOTE KG: refactored so that all methods return the body of the query result, e.g.
34
+ # "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<results><status code=\"ok\"/><sco account-id=\"7\" disabled=\"\" display-seq=\"0\" folder-id=\"14152063\"
35
+ # icon=\"meeting\" lang=\"en\" max-retries=\"\" sco-id=\"14153596\" source-sco-id=\"\" type=\"meeting\" version=\"0\"><date-created>2013-03-27T17:55:36.403+01:00</date-created><
36
+ # date-modified>2013-03-27T17:55:36.403+01:00</date-modified><name>Testmeeting from RSpec</name><url-path>/rspec_testmeeting/</url-path></sco></results>"
37
+
32
38
  class AdobeConnectAPI
39
+ include XMLParser
33
40
 
34
41
  attr :url
35
42
  attr :pointconfig
36
43
 
44
+ def self.version_string
45
+ "AdobeConnectAPI version #{AdobeConnectApi::VERSION}"
46
+ end
47
+
37
48
  # return BREEZESESSION id
38
49
  def sessionid
39
50
  @sessionid
@@ -41,17 +52,9 @@ class AdobeConnectAPI
41
52
 
42
53
  #The URL is the base URL of the Connect-Server, without the trailing slash
43
54
  def initialize (url = nil, environment, root_directory)
44
- #TODO ChR: Get this from the application config/initializer/abobe_connect_api.rb
45
- # begin
46
- # environment = Rails.env
47
- # # KG: we need the rescue blog since belt does not know Rails, but instead uses Sinatra.env
48
- # rescue
49
- # environment = Sinatra.env
50
- # end
51
-
52
55
  @pointconfig = YAML::load_file("#{root_directory}/config/config.breeze.yml")[environment]
53
56
  if (url == nil)
54
- @url = pointconfig["url"]
57
+ @url = @pointconfig["url"]
55
58
  else
56
59
  @url = url
57
60
  end
@@ -62,11 +65,11 @@ class AdobeConnectAPI
62
65
 
63
66
  if (login != nil && password == nil)
64
67
  # user given --> use generic user password
65
- # TODO KG: generate password
66
- password = pointconfig["generic_user_password"]
68
+ # TODO: generate password (see https://forge.switch.ch/redmine/issues/2355)
69
+ password = @pointconfig["generic_user_password"]
67
70
  elsif (login == nil) && (password == nil)
68
- login = pointconfig["username"]
69
- password = pointconfig["password"]
71
+ login = @pointconfig["username"]
72
+ password = @pointconfig["password"]
70
73
  end
71
74
 
72
75
  res = query("login",
@@ -76,9 +79,6 @@ class AdobeConnectAPI
76
79
  "external-auth" => external_auth,
77
80
  "domain" => domain)
78
81
 
79
- # TODO: debug
80
- puts res.body.inspect
81
-
82
82
  cookies = res.response["set-cookie"]
83
83
  puts cookies.inspect
84
84
  cookies.split(";").each{|s|
@@ -87,28 +87,22 @@ class AdobeConnectAPI
87
87
  @sessionid = array[1]
88
88
  end
89
89
  }
90
- #puts "ACS: Logged in"
90
+ puts "ACS: Logged in"
91
91
  return res.body
92
92
  end
93
93
 
94
94
  #makes a logout and removes the cookie
95
95
  def logout
96
- res = query("logout").body
96
+ res = query("logout")
97
97
  @sessionid = nil
98
98
  puts "ACS: Logged out"
99
- return res
99
+ return res.body
100
100
  end
101
101
 
102
102
  # creates a new user in Adobe Connect
103
103
  def create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil)
104
- # ?action=principal-update&email=string&first-name=string&has-children=boolean&last-name=string&login=string&password=string&send-email=boolean&type=allowedValue&session=BreezeSessionCookieValue
105
-
106
- # send-email: true
107
- # has-children: 0
108
- # type: user
109
-
110
104
  if password == nil
111
- password = pointconfig["generic_user_password"]
105
+ password = @pointconfig["generic_user_password"]
112
106
  end
113
107
 
114
108
  res = query("principal-update",
@@ -117,21 +111,27 @@ class AdobeConnectAPI
117
111
  "password" => password,
118
112
  "first-name" => first_name,
119
113
  "last-name" => last_name,
120
- "send-email" => true,
114
+ "send-email" => false,
121
115
  "has-children" => 0,
122
116
  "type" => "user")
123
117
 
124
118
  puts "ACS: user created"
125
- puts res.body
126
- data = XmlSimple.xml_in(res.body)
127
-
128
- data["principal"].first["principal-id"]
119
+ return res.body
120
+ end
121
+
122
+ def delete_user(principal_id)
123
+ puts "ACS delete user with id: " + principal_id
124
+
125
+ res = query("principals-delete", "principal-id" => principal_id)
126
+
127
+ puts "ACS: user deleted"
128
+ return res.body
129
129
  end
130
130
 
131
131
  # create a new meeting in Adobe Connect
132
132
  # e.g. "https://collab-test.switch.ch/api/xml?action=sco-update&type=meeting&name=API-Test&folder-id=12578070&date-begin=2012-06-15T17:00&date-end=2012-06-15T23:00&url-path=apitest"
133
133
  def create_meeting(name, folder_id, url_path)
134
- puts "ACS create meeting with name, folder_id and url_path: " + name + folder_id.to_s + url_path
134
+ puts "ACS create meeting with name '#{name}', folder_id '#{folder_id.to_s}' and url_path '#{url_path}'"
135
135
 
136
136
  res = query("sco-update",
137
137
  "type" => "meeting",
@@ -140,9 +140,7 @@ class AdobeConnectAPI
140
140
  "url-path" => url_path)
141
141
 
142
142
  puts "ACS: meeting created"
143
- puts res.body
144
- data = XmlSimple.xml_in(res.body)
145
- data["sco"].first['sco-id']
143
+ return res.body
146
144
  end
147
145
 
148
146
  def delete_meeting(sco_id)
@@ -155,51 +153,29 @@ class AdobeConnectAPI
155
153
  return res.body
156
154
  end
157
155
 
158
- # searches the user with the given email address and returns the principal id
156
+ # searches the user with the given email address
159
157
  # e.g. "https://collab-test.switch.ch/api/xml?action=principal-list&filter-email=rfurter@ethz.ch"
160
- def get_principal_id(filter = nil, sort = nil)
161
- puts "ACS: get_principal_id"
158
+ def get_principal(filter = nil, sort = nil)
159
+ puts "ACS: get_principal"
162
160
  res = query("principal-list",
163
161
  "filter" => filter,
164
162
  "sort" => sort)
165
163
 
166
- puts res.body
167
- data = XmlSimple.xml_in(res.body)
168
- rows = []
169
- if data["principal-list"]
170
- data["principal-list"].each do |trans|
171
- rows = trans["principal"]
172
- end
173
- end
174
-
175
- # can only contain one result, since each email adress is used only once in AC
176
- rows.first["principal-id"] unless rows.nil?
164
+ return res.body
177
165
  end
178
166
 
179
- def get_my_meetings_folder_id(email)
180
- # res = query("sco-shortcuts")
181
- # data = XmlSimple.xml_in(res.body)
182
- # if data["shortcuts"]
183
- # data["shortcuts"].each do |trans|
184
- # if trans["sco"]["type"] == "user-meetings"
185
- # tree_id = trans["sco"]["sco-id"]
186
- # break
187
- # end
188
- # end
189
-
167
+ def get_my_meetings_folder(email)
190
168
  # NOTE: this id does not change unless we set up AC new
191
- tree_id = 14
169
+ # tree_id = 14
170
+ # since we migrated to the new hardware, the tree_id changed
171
+ # i.e. sco-id of the user content folder, see: https://collab-test.switch.ch/api/xml?action=sco-shortcuts
172
+ tree_id = 11
192
173
 
193
174
  filter = AdobeConnectApi::FilterDefinition.new
194
175
  filter["name"] == email
195
176
 
196
- res = sco_contents(tree_id, filter)
197
- if res.rows.empty?
198
- return nil
199
- else
200
- # should not contain more than 1 result
201
- return res.rows.first["sco-id"]
202
- end
177
+ res = query("sco-contents", "sco-id" => tree_id, "filter" => filter)
178
+ return res.body
203
179
  end
204
180
 
205
181
  # e.g. "https://collab-test.switch.ch/api/xml?action=permissions-update&principal-id=12578066&acl-id=13112626&permission-id=host"
@@ -209,16 +185,54 @@ class AdobeConnectAPI
209
185
  "acl-id" => acl_id,
210
186
  "permission-id" => permission_id)
211
187
 
212
- data = XmlSimple.xml_in(res.body)
213
- return AdobeConnectAPI::Result.new(data["status"][0]["code"], nil)
188
+ return res.body
189
+ end
190
+
191
+ #returns SCO information of sco-id
192
+ def sco_info(sco_id)
193
+ res = query("sco-info", "sco-id" => sco_id)
194
+ return res.body
195
+ end
196
+
197
+ # sco-search-by-field&query=TB_ac_test&field=name
198
+ def search_meeting(name)
199
+ filter = AdobeConnectApi::FilterDefinition.new
200
+ filter["type"] == "meeting"
201
+ res = query("sco-search-by-field",
202
+ "query" => name,
203
+ "field" => "name",
204
+ "filter" => filter)
205
+ # data = XmlSimple.xml_in(res.body)
206
+ # scos = []
207
+ # if data["sco-search-by-field-info"]
208
+ # results = data["sco-search-by-field-info"][0]
209
+ # scos = results["sco"]
210
+ # end
211
+ return res.body
212
+ end
213
+
214
+ # TODO KG: test
215
+ def update_meeting(sco_id, description, language)
216
+ "action = sco-update&sco-id=&description=&lang="
217
+ res = query("sco-update",
218
+ "sco-id" => sco_id,
219
+ "description" => description,
220
+ "lang" => language)
221
+
222
+ return res.body
214
223
  end
215
224
 
225
+
226
+ # TODO KG: test statistic functions
227
+
216
228
  #action=group-membership-update&group-id=integer&principal-id=integer&is-member=boolean
217
229
  def group_membership_update(group_id, principal_id, is_member)
218
230
  res = query("group-membership-update",
219
231
  "group-id" => group_id,
220
232
  "principal-id" => principal_id,
221
233
  "is-member" => is_member)
234
+
235
+ return res.body
222
236
  end
223
237
 
224
238
  # e.g. acl-field-update&acl-id=13117741&field-id=meeting-passcode&value=12345
@@ -288,34 +302,12 @@ class AdobeConnectAPI
288
302
 
289
303
  end
290
304
 
291
- #returns SCO contents of sco-id
292
- def sco_contents(sco_id, filter = nil, sort = nil)
293
- res = query("sco-contents", "sco-id" => sco_id, "filter" => filter, "sort" => sort)
294
- data = XmlSimple.xml_in(res.body)
295
- scos = []
296
- # puts YAML::dump(data)
297
- if data["scos"]
298
- data["scos"].each do |trans|
299
- # puts YAML::dump(trans)
300
- # puts "-------"
301
- scos = trans["sco"]
302
- end
303
- end
304
- return AdobeConnectAPI::Result.new(data["status"][0]["code"], scos)
305
- end
306
-
307
- #returns SCO information of sco-id
308
- def sco_info(sco_id)
309
- res = query("sco-info", "sco-id" => sco_id)
310
- data = XmlSimple.xml_in(res.body)
311
- if data["sco"][0]
312
- return data["sco"][0]
313
- end
314
- end
315
-
305
+ # TODO KG: refactor (return res.body) and test
316
306
  #returns permission information of an sco-id
317
307
  def permissions_info(sco_id, filter = nil)
318
308
  res = query("permissions-info", "acl-id" => sco_id, "filter" => filter)
309
+
310
+ return res.body
319
311
  data = XmlSimple.xml_in(res.body)
320
312
  if data['permissions'][0]
321
313
  return data['permissions'][0]
@@ -366,54 +358,6 @@ class AdobeConnectAPI
366
358
  return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows)
367
359
  end
368
360
 
369
- # sco-search-by-field&query=TB_ac_test&field=name
370
- def search_meeting(name)
371
- res = query("sco-search-by-field",
372
- "query" => name,
373
- "field" => "name")
374
- data = XmlSimple.xml_in(res.body)
375
- scos = []
376
- if data["sco-search-by-field-info"]
377
- results = data["sco-search-by-field-info"][0]
378
- scos = results["sco"]
379
- end
380
- return AdobeConnectAPI::Result.new(data["status"][0]["code"], scos)
381
- end
382
-
383
- # sco-search-by-field&query=TB_ac_test&field=name and additionally check that the name is exactly the same (what is not done in Adobe Connect)
384
- def search_unique_name(name)
385
- res = query("sco-search-by-field",
386
- "query" => name,
387
- "field" => "name")
388
- data = XmlSimple.xml_in(res.body)
389
- scos = []
390
- if data["sco-search-by-field-info"]
391
- results = data["sco-search-by-field-info"][0]
392
- scos = results["sco"]
393
- end
394
- result = AdobeConnectAPI::Result.new(data["status"][0]["code"], scos)
395
-
396
- if result.rows.empty?
397
- nil
398
- else
399
- result.rows.each do |sco|
400
- if sco["name"] == name
401
- return sco["sco-id"]
402
- end
403
- end
404
- end
405
- return nil
406
- end
407
-
408
- def update_meeting(sco_id, description, language)
409
- "action = sco-update&sco-id=&description=&lang="
410
- res = query("sco-update",
411
- "sco-id" => sco_id,
412
- "description" => description,
413
- "lang" => language)
414
- data = XmlSimple.xml_in(res.body)
415
- return AdobeConnectAPI::Result.new(data["status"][0]["code"], nil)
416
- end
417
361
 
418
362
  #sends a query to the server and returns the http response. Parameters,
419
363
  #filter- and sort-definitions can be added. The filter as "filter" => ... and
@@ -0,0 +1,181 @@
1
+ # Copyright (c) 2010 - 2013 SWITCH - Serving Swiss Universities
2
+ # Author: Katja Gräfenhain <katja.graefenhain@switch.ch>
3
+
4
+ require 'spec_helper'
5
+ #include '../lib/adobe_connect_api/xml_parser'
6
+
7
+ # testdata:
8
+ MEETING_NAME = 'Testmeeting from RSpec'
9
+ URL_PATH = 'rspec_testmeeting'
10
+ E_MAIL = 'testuser@switch.ch'
11
+ FIRST_NAME = 'Test'
12
+ LAST_NAME = 'User'
13
+
14
+ # API return values
15
+ STATUS_OK = 'ok'
16
+ NO_DATA = 'no-data'
17
+ STATUS_INVALID = 'invalid'
18
+ STATUS_NO_ACCESS = 'no-access'
19
+ CODE_DUPLICATE = 'duplicate'
20
+
21
+ describe AdobeConnectAPI do
22
+
23
+ before(:each) do
24
+ @interactconfig = YAML::load_file("./config/config.breeze.yml")[ENV["RAILS_ENV"]]
25
+ url = @interactconfig['url']
26
+
27
+ # open AdobeConnectAPI (use URL from config file)
28
+ @acs = AdobeConnectAPI.new(url, ENV['RAILS_ENV'], nil)
29
+ end
30
+
31
+ describe 'GemVersion' do
32
+ # standard test for gem version, see http://nithinbekal.com/2011/writing-ruby-gems-part-5-setting-up-rspec/
33
+ it 'should return correct version string' do
34
+ AdobeConnectAPI.version_string.should == "AdobeConnectAPI version #{AdobeConnectApi::VERSION}"
35
+ end
36
+ end
37
+
38
+ describe 'Login & logout' do
39
+ it 'should login admin' do
40
+ @acs.pointconfig=(@interactconfig)
41
+ # login to Adobe Connect
42
+ res = @acs.login()
43
+ @acs.get_status_code(res).should match STATUS_OK
44
+ end
45
+
46
+ it 'should logout' do
47
+ res = @acs.logout()
48
+ @acs.get_status_code(res).should include(STATUS_OK)
49
+ end
50
+
51
+ it 'should not login admin with wrong password' do
52
+ login = @interactconfig['username']
53
+ res = @acs.login(login, 'password')
54
+ @acs.get_status_code(res).should match NO_DATA
55
+ end
56
+ end
57
+
58
+ describe 'normal user' do
59
+ before(:each) do
60
+ # login normal user (no admin)
61
+ login = @interactconfig['test_user']
62
+ password = @interactconfig['generic_user_password']
63
+ @acs.login(login, password)
64
+
65
+ # delete the meeting if it already exists
66
+ res = @acs.search_meeting(MEETING_NAME)
67
+ sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
68
+ @acs.delete_meeting(sco_id) unless sco_id.nil?
69
+ end
70
+
71
+ it 'should return the id of my-meetings folder' do
72
+ folder = @acs.get_my_meetings_folder(@interactconfig['test_user'])
73
+ @acs.get_folder_id(folder).to_i.should_not be 0
74
+ end
75
+
76
+ it 'should be able to create a meeting' do
77
+ folder = @acs.get_my_meetings_folder(@interactconfig['test_user'])
78
+ folder_id = @acs.get_folder_id(folder)
79
+ res = @acs.create_meeting(MEETING_NAME, folder_id, URL_PATH)
80
+
81
+ puts res.inspect
82
+
83
+ @acs.get_status_code(res).should include(STATUS_OK)
84
+ @acs.get_sco_id(res).to_i.should_not be 0
85
+ end
86
+
87
+ it 'should not be able to create a user' do
88
+ password = @interactconfig['generic_user_password']
89
+ res = @acs.create_user(E_MAIL, E_MAIL, password, FIRST_NAME, LAST_NAME)
90
+ @acs.get_status_code(res).should include(STATUS_NO_ACCESS)
91
+ end
92
+ end
93
+
94
+
95
+ describe 'admin user' do
96
+ before(:each) do
97
+ # login normal admin user
98
+ login = @interactconfig['username']
99
+ password = @interactconfig['password']
100
+ @acs.login(login, password)
101
+
102
+ # delete the user if it already exists
103
+ filter = AdobeConnectApi::FilterDefinition.new
104
+ filter["email"] == E_MAIL
105
+ principal = @acs.get_principal(filter)
106
+ sco_id = @acs.get_principal_id(principal)
107
+ @acs.delete_user(sco_id) unless sco_id.nil?
108
+ end
109
+
110
+ it 'should be able to create a user' do
111
+ password = @interactconfig['generic_user_password']
112
+ res = @acs.create_user(E_MAIL, E_MAIL, password, FIRST_NAME, LAST_NAME)
113
+
114
+ # should contain the status code OK
115
+ @acs.get_status_code(res).should include(STATUS_OK)
116
+
117
+ # should return the sco-id of the new user
118
+ @acs.get_principal_id(res).to_i.should_not be 0
119
+ end
120
+ end
121
+
122
+
123
+ describe 'creation and deletion of meeting' do
124
+ before(:each) do
125
+ # login normal user
126
+ login = @interactconfig['test_user']
127
+ password = @interactconfig['generic_user_password']
128
+ @acs.login(login, password)
129
+
130
+ # get folder id
131
+ @folder_id = @acs.get_folder_id(@acs.get_my_meetings_folder(@interactconfig['test_user']))
132
+
133
+ # check if meeting already exists
134
+ res = @acs.search_meeting(MEETING_NAME)
135
+ @sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
136
+
137
+ if @sco_id.nil?
138
+ # create meeting
139
+ res = @acs.create_meeting(MEETING_NAME, @folder_id, URL_PATH)
140
+ @sco_id = @acs.get_sco_id(res)
141
+ end
142
+ end
143
+
144
+ it 'should not be able to create a meeting with the same url-path again' do
145
+ res = @acs.create_meeting(MEETING_NAME, @folder_id, URL_PATH)
146
+
147
+ status = @acs.get_status_code(res)
148
+ status.should include(STATUS_INVALID)
149
+
150
+ subcode = @acs.get_invalid_subcode(res)
151
+ subcode.should include(CODE_DUPLICATE)
152
+ end
153
+
154
+ it 'should delete the meeting' do
155
+ # delete meeting
156
+ res = @acs.delete_meeting(@sco_id)
157
+ @acs.get_status_code(res).should include(STATUS_OK)
158
+
159
+ # try to find meeting again
160
+ res = @acs.search_meeting(MEETING_NAME)
161
+ sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
162
+ sco_id.should be_nil
163
+ end
164
+
165
+ it 'should be able to add another host' do
166
+ filter = AdobeConnectApi::FilterDefinition.new
167
+ filter["email"] == @interactconfig['username']
168
+ principal = @acs.get_principal(filter)
169
+ principal_id = @acs.get_principal_id(principal)
170
+ res = @acs.permissions_update(principal_id, @sco_id, "host") unless (principal_id.nil? || @sco_id.nil?)
171
+ @acs.get_status_code(res).should include(STATUS_OK)
172
+ end
173
+
174
+ it 'should return the sco-info' do
175
+ res = @acs.sco_info(@sco_id)
176
+ @acs.get_sco_id(res).should eq @sco_id
177
+ end
178
+
179
+ end
180
+
181
+ end
@@ -0,0 +1,8 @@
1
+ require 'rspec'
2
+ require 'adobe_connect_api'
3
+
4
+ RSpec.configure do |config|
5
+ ENV["RAILS_ENV"] = 'test'
6
+ config.color_enabled = true
7
+ config.formatter = 'documentation'
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adobe_connect_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.69.alpha
4
+ version: 0.0.70.alpha
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-31 00:00:00.000000000Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- requirement: &2161409200 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,28 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2161409200
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
25
46
  description: Wrapper to the Adobe Connect API
26
47
  email:
27
48
  - christian.rohrer@switch.ch
@@ -36,11 +57,15 @@ files:
36
57
  - README.md
37
58
  - Rakefile
38
59
  - adobe_connect_api.gemspec
60
+ - config/config.breeze.yml
39
61
  - lib/adobe_connect_api.rb
40
62
  - lib/adobe_connect_api/filter_definition.rb
41
63
  - lib/adobe_connect_api/result.rb
42
64
  - lib/adobe_connect_api/sort_definition.rb
43
65
  - lib/adobe_connect_api/version.rb
66
+ - lib/adobe_connect_api/xml_parser.rb
67
+ - spec/adobe_connect_api_spec.rb
68
+ - spec/spec_helper.rb
44
69
  homepage: ''
45
70
  licenses: []
46
71
  post_install_message:
@@ -61,8 +86,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
86
  version: 1.3.1
62
87
  requirements: []
63
88
  rubyforge_project:
64
- rubygems_version: 1.8.17
89
+ rubygems_version: 1.8.25
65
90
  signing_key:
66
91
  specification_version: 3
67
92
  summary: Wrapper to the Adobe Connect API written in Ruby
68
- test_files: []
93
+ test_files:
94
+ - spec/adobe_connect_api_spec.rb
95
+ - spec/spec_helper.rb