adobe_connect_api 0.0.9.alpha → 0.0.9

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,9 +1,10 @@
1
- # A filter defeinition can be added to some actions to filter the results
1
+ # A filter definition can be added to some actions to filter the results
2
2
  # server-side. Example:
3
3
  # filter = AdobeConnectAPI::FilterDefinition.new
4
4
  # filter["sco-id"].greater_than 25
5
5
  # filter["date-created"] <= Time.now
6
6
 
7
+ # TODO KG: rename to AdobeConnectAPI since the class is also named API
7
8
  class AdobeConnectApi::FilterDefinition
8
9
  attr_accessor :rows
9
10
  attr_accessor :start
@@ -1,3 +1,3 @@
1
1
  module AdobeConnectApi
2
- VERSION = "0.0.9.alpha"
2
+ VERSION = "0.0.9"
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,8 +1,10 @@
1
+ # encoding: utf-8
1
2
 
2
- # Copyright (c) 2010 SWITCH - Serving Swiss Universities
3
+ # Copyright (c) 2010 - 2013 SWITCH - Serving Swiss Universities
3
4
  # Author: Mischael Schill <me@mschill.ch>
4
5
  # Martin Kos <martin@kos.li>
5
6
  # Christian Rohrer <christian.rohrer@switch.ch>
7
+ # Katja Gräfenhain <katja.graefenhain@switch.ch>
6
8
  # $Id$
7
9
 
8
10
  require 'rubygems'
@@ -14,10 +16,11 @@ require "cgi"
14
16
  require "yaml"
15
17
  #require 'logger'
16
18
 
17
- require "adobe_connect_api/version"
19
+ require 'adobe_connect_api/version'
18
20
  require 'adobe_connect_api/filter_definition'
19
21
  require 'adobe_connect_api/sort_definition'
20
22
  require 'adobe_connect_api/result'
23
+ require 'adobe_connect_api/xml_parser'
21
24
 
22
25
 
23
26
  # This class is a simple utility to acces the adobe connect api. Before
@@ -27,30 +30,43 @@ require 'adobe_connect_api/result'
27
30
  # All the actions are defined in the Adobe Connect Pro API documentation
28
31
  # some of the actions are accepting filter- and/or sorting-definitions.
29
32
 
30
- # 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
+
31
38
  class AdobeConnectAPI
39
+ include XMLParser
32
40
 
33
41
  attr :url
34
42
  attr :pointconfig
35
43
 
44
+ def self.version_string
45
+ "AdobeConnectAPI version #{AdobeConnectApi::VERSION}"
46
+ end
47
+
36
48
  # return BREEZESESSION id
37
49
  def sessionid
38
50
  @sessionid
39
51
  end
40
52
 
53
+ def pointconfig=(pointconfig)
54
+ if pointconfig == nil
55
+ pointconfig = YAML::load_file("#{root_directory}/config/config.breeze.yml")[environment]
56
+ else
57
+ @pointconfig = pointconfig
58
+ end
59
+ end
60
+
41
61
  #The URL is the base URL of the Connect-Server, without the trailing slash
42
62
  def initialize (url = nil, environment, root_directory)
43
- #TODO ChR: Get this from the application config/initializer/abobe_connect_api.rb
44
- # begin
45
- # environment = Rails.env
46
- # # KG: we need the rescue blog since belt does not know Rails, but instead uses Sinatra.env
47
- # rescue
48
- # environment = Sinatra.env
49
- # end
50
-
51
- @pointconfig = YAML::load_file("#{root_directory}/config/config.breeze.yml")[environment]
63
+ begin
64
+ @pointconfig = YAML::load_file("#{root_directory}/config/config.breeze.yml")[environment]
65
+ rescue
66
+ # should not occur except when running tests
67
+ end
52
68
  if (url == nil)
53
- @url = pointconfig["url"]
69
+ @url = @pointconfig["url"]
54
70
  else
55
71
  @url = url
56
72
  end
@@ -61,11 +77,11 @@ class AdobeConnectAPI
61
77
 
62
78
  if (login != nil && password == nil)
63
79
  # user given --> use generic user password
64
- # TODO KG: generate password
65
- password = pointconfig["generic_user_password"]
80
+ # TODO: generate password (see https://forge.switch.ch/redmine/issues/2355)
81
+ password = @pointconfig["generic_user_password"]
66
82
  elsif (login == nil) && (password == nil)
67
- login = pointconfig["username"]
68
- password = pointconfig["password"]
83
+ login = @pointconfig["username"]
84
+ password = @pointconfig["password"]
69
85
  end
70
86
 
71
87
  res = query("login",
@@ -75,9 +91,6 @@ class AdobeConnectAPI
75
91
  "external-auth" => external_auth,
76
92
  "domain" => domain)
77
93
 
78
- # TODO: debug
79
- puts res.body.inspect
80
-
81
94
  cookies = res.response["set-cookie"]
82
95
  puts cookies.inspect
83
96
  cookies.split(";").each{|s|
@@ -86,28 +99,22 @@ class AdobeConnectAPI
86
99
  @sessionid = array[1]
87
100
  end
88
101
  }
89
- #puts "ACS: Logged in"
102
+ puts "ACS: Logged in"
90
103
  return res.body
91
104
  end
92
105
 
93
106
  #makes a logout and removes the cookie
94
107
  def logout
95
- res = query("logout").body
108
+ res = query("logout")
96
109
  @sessionid = nil
97
110
  puts "ACS: Logged out"
98
- return res
111
+ return res.body
99
112
  end
100
113
 
101
114
  # creates a new user in Adobe Connect
102
115
  def create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil)
103
- # ?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
104
-
105
- # send-email: true
106
- # has-children: 0
107
- # type: user
108
-
109
116
  if password == nil
110
- password = pointconfig["generic_user_password"]
117
+ password = @pointconfig["generic_user_password"]
111
118
  end
112
119
 
113
120
  res = query("principal-update",
@@ -116,7 +123,7 @@ class AdobeConnectAPI
116
123
  "password" => password,
117
124
  "first-name" => first_name,
118
125
  "last-name" => last_name,
119
- "send-email" => true,
126
+ "send-email" => false,
120
127
  "has-children" => 0,
121
128
  "type" => "user")
122
129
 
@@ -124,6 +131,133 @@ class AdobeConnectAPI
124
131
  return res.body
125
132
  end
126
133
 
134
+ def delete_user(principal_id)
135
+ puts "ACS delete user with id: " + principal_id
136
+
137
+ res = query("principals-delete", "principal-id" => principal_id)
138
+
139
+ puts "ACS: user deleted"
140
+ return res.body
141
+ end
142
+
143
+ # create a new meeting in Adobe Connect
144
+ # 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"
145
+ def create_meeting(name, folder_id, url_path)
146
+ puts "ACS create meeting with name '#{name}', folder_id '#{folder_id.to_s}' and url_path '#{url_path}'"
147
+
148
+ res = query("sco-update",
149
+ "type" => "meeting",
150
+ "name" => name,
151
+ "folder-id" => folder_id,
152
+ "url-path" => url_path)
153
+
154
+ puts "ACS: meeting created"
155
+ return res.body
156
+ end
157
+
158
+ def delete_meeting(sco_id)
159
+ puts "ACS delete meeting with sco_id: " + sco_id
160
+
161
+ res = query("sco-delete",
162
+ "sco-id" => sco_id)
163
+
164
+ puts "ACS: meeting deleted"
165
+ return res.body
166
+ end
167
+
168
+ # searches the user with the given email address
169
+ # e.g. "https://collab-test.switch.ch/api/xml?action=principal-list&filter-email=rfurter@ethz.ch"
170
+ def get_principal(filter = nil, sort = nil)
171
+ puts "ACS: get_principal"
172
+ res = query("principal-list",
173
+ "filter" => filter,
174
+ "sort" => sort)
175
+
176
+ return res.body
177
+ end
178
+
179
+ def get_my_meetings_folder(email)
180
+ # NOTE: this id does not change unless we set up AC new
181
+ # tree_id = 14
182
+ # since we migrated to the new hardware, the tree_id changed
183
+ # i.e. sco-id of the user content folder, see: https://collab-test.switch.ch/api/xml?action=sco-shortcuts
184
+ tree_id = 11
185
+
186
+ filter = AdobeConnectApi::FilterDefinition.new
187
+ filter["name"] == email
188
+
189
+ res = query("sco-contents", "sco-id" => tree_id, "filter" => filter)
190
+ return res.body
191
+ end
192
+
193
+ # e.g. "https://collab-test.switch.ch/api/xml?action=permissions-update&principal-id=12578066&acl-id=13112626&permission-id=host"
194
+ def permissions_update(principal_id, acl_id, permission_id)
195
+ res = query("permissions-update",
196
+ "principal-id" => principal_id,
197
+ "acl-id" => acl_id,
198
+ "permission-id" => permission_id)
199
+
200
+ return res.body
201
+ end
202
+
203
+ #returns SCO information of sco-id
204
+ def sco_info(sco_id)
205
+ res = query("sco-info", "sco-id" => sco_id)
206
+ return res.body
207
+ end
208
+
209
+ # sco-search-by-field&query=TB_ac_test&field=name
210
+ def search_meeting(name)
211
+ filter = AdobeConnectApi::FilterDefinition.new
212
+ filter["type"] == "meeting"
213
+ res = query("sco-search-by-field",
214
+ "query" => name,
215
+ "field" => "name",
216
+ "filter" => filter)
217
+ # data = XmlSimple.xml_in(res.body)
218
+ # scos = []
219
+ # if data["sco-search-by-field-info"]
220
+ # results = data["sco-search-by-field-info"][0]
221
+ # scos = results["sco"]
222
+ # end
223
+ return res.body
224
+ end
225
+
226
+ #action=group-membership-update&group-id=integer&principal-id=integer&is-member=boolean
227
+ def group_membership_update(group_id, principal_id, is_member)
228
+ res = query("group-membership-update",
229
+ "group-id" => group_id,
230
+ "principal-id" => principal_id,
231
+ "is-member" => is_member)
232
+
233
+ return res.body
234
+ end
235
+
236
+
237
+ # TODO KG: test
238
+ def update_meeting(sco_id, description, language)
239
+ "action = sco-update&sco-id=&description=&lang="
240
+ res = query("sco-update",
241
+ "sco-id" => sco_id,
242
+ "description" => description,
243
+ "lang" => language)
244
+
245
+ return res.body
246
+ end
247
+
248
+
249
+ # TODO KG: test statistic functions
250
+ # e.g. acl-field-update&acl-id=13117741&field-id=meeting-passcode&value=12345
251
+ def set_passcode(acl_id, passcode)
252
+ res = query("acl-field-update",
253
+ "acl-id" => acl_id,
254
+ "field-id" => "meeting-passcode",
255
+ "value" => passcode)
256
+
257
+ data = XmlSimple.xml_in(res.body)
258
+ return AdobeConnectAPI::Result.new(data["status"][0]["code"], nil)
259
+ end
260
+
127
261
  #Returns all defined quotas (untested)
128
262
  def report_quotas
129
263
  res = query("report-quota")
@@ -180,36 +314,17 @@ class AdobeConnectAPI
180
314
 
181
315
  end
182
316
 
183
- #returns SCO contents of sco-id
184
- def sco_contents(sco_id, filter = nil, sort = nil)
185
- res = query("sco-contents", "sco-id" => sco_id, "filter" => filter, "sort" => sort)
186
- data = XmlSimple.xml_in(res.body)
187
- scos = []
188
- # puts YAML::dump(data)
189
- if data["scos"]
190
- data["scos"].each do |trans|
191
- # puts YAML::dump(trans)
192
- # puts "-------"
193
- scos = trans["sco"]
194
- end
195
- end
196
- return AdobeConnectAPI::Result.new(data["status"][0]["code"], scos)
197
- end
198
-
199
- #returns SCO information of sco-id
200
- def sco_info(sco_id)
201
- res = query("sco-info", "sco-id" => sco_id)
202
- data = XmlSimple.xml_in(res.body)
203
- if data["sco"][0]
204
- return data["sco"][0]
205
- end
206
- end
207
-
317
+ # TODO KG: refactor (return res.body) and test
208
318
  #returns permission information of an sco-id
209
319
  def permissions_info(sco_id, filter = nil)
210
320
  res = query("permissions-info", "acl-id" => sco_id, "filter" => filter)
321
+
322
+ return res.body
211
323
  data = XmlSimple.xml_in(res.body)
212
- puts YAML::dump(data)
324
+ if data['permissions'][0]
325
+ return data['permissions'][0]
326
+ end
327
+ #puts YAML::dump(data)
213
328
  # if data["sco"][0]
214
329
  # return data["sco"][0]
215
330
  # end
@@ -255,27 +370,6 @@ class AdobeConnectAPI
255
370
  return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows)
256
371
  end
257
372
 
258
- def search_meeting(name)
259
- action = "sco-search-by-field&query=" + name + "&field=name"
260
- uri = URI.parse(AC_HOST + "/api/xml?action=#{action}")
261
- http = Net::HTTP.new(uri.host, uri.port)
262
- if uri.scheme == "https"
263
- http.use_ssl=true
264
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
265
- end
266
- request = Net::HTTP::Get.new(uri.request_uri)
267
- if @sessionid
268
- request.add_field("Cookie", "BREEZESESSION="+@sessionid)
269
- end
270
- puts request.path
271
- response = http.request(request)
272
-
273
- puts response.body
274
- data = XmlSimple.xml_in(response.body)
275
- if data["sco-search-by-field-info"]
276
- results = data["sco-search-by-field-info"][0]
277
- return results["sco"]
278
- end
279
373
 
280
374
  #sends a query to the server and returns the http response. Parameters,
281
375
  #filter- and sort-definitions can be added. The filter as "filter" => ... and
@@ -313,9 +407,20 @@ class AdobeConnectAPI
313
407
  if @sessionid
314
408
  request.add_field("Cookie", "BREEZESESSION="+@sessionid)
315
409
  end
316
- puts request.path
410
+ puts "ACS query - request: " + request.path
317
411
  response = http.request(request)
412
+ puts "ACS query - response: " + response.body.inspect
318
413
  return response
319
414
  end
320
415
 
416
+
417
+
418
+ ### ADMIN FUNCTIONS (FOR STATISTICS) ###
419
+
420
+ # def report-active-meetings
421
+ # res = query("report-active-meetings")
422
+ # data = XmlSimple.xml_in(res.body)
423
+ # return AdobeConnectAPI::Result.new(data)
424
+ # end
425
+
321
426
  end
@@ -0,0 +1,206 @@
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
+ E_MAIL_2 = 'testuser2@switch.ch'
15
+
16
+ # API return values
17
+ STATUS_OK = 'ok'
18
+ NO_DATA = 'no-data'
19
+ STATUS_INVALID = 'invalid'
20
+ STATUS_NO_ACCESS = 'no-access'
21
+ CODE_DUPLICATE = 'duplicate'
22
+
23
+ describe AdobeConnectAPI do
24
+
25
+ before(:each) do
26
+ @interactconfig = YAML::load_file('./config/config.breeze.yml')[ENV["RAILS_ENV"]]
27
+ url = @interactconfig['url']
28
+
29
+ # open AdobeConnectAPI (use URL from config file)
30
+ @acs = AdobeConnectAPI.new(url, ENV['RAILS_ENV'], nil)
31
+ end
32
+
33
+ describe 'GemVersion' do
34
+ # standard test for gem version, see http://nithinbekal.com/2011/writing-ruby-gems-part-5-setting-up-rspec/
35
+ it 'should return correct version string' do
36
+ AdobeConnectAPI.version_string.should == "AdobeConnectAPI version #{AdobeConnectApi::VERSION}"
37
+ end
38
+ end
39
+
40
+ describe 'Login & logout' do
41
+ it 'should login admin' do
42
+ @acs.pointconfig=(@interactconfig)
43
+ # login to Adobe Connect
44
+ res = @acs.login()
45
+ @acs.get_status_code(res).should match STATUS_OK
46
+ end
47
+
48
+ it 'should logout' do
49
+ res = @acs.logout()
50
+ @acs.get_status_code(res).should include(STATUS_OK)
51
+ end
52
+
53
+ it 'should not login admin with wrong password' do
54
+ login = @interactconfig['username']
55
+ res = @acs.login(login, 'password')
56
+ @acs.get_status_code(res).should match NO_DATA
57
+ end
58
+ end
59
+
60
+ describe 'normal user' do
61
+ before(:each) do
62
+ # login normal user (no admin)
63
+ login = @interactconfig['test_user']
64
+ password = @interactconfig['generic_user_password']
65
+ @acs.login(login, password)
66
+
67
+ # delete the meeting if it already exists
68
+ res = @acs.search_meeting(MEETING_NAME)
69
+ sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
70
+ @acs.delete_meeting(sco_id) unless sco_id.nil?
71
+ end
72
+
73
+ it 'should return the id of my-meetings folder' do
74
+ folder = @acs.get_my_meetings_folder(@interactconfig['test_user'])
75
+ @acs.get_folder_id(folder).to_i.should_not be 0
76
+ end
77
+
78
+ it 'should be able to create a meeting' do
79
+ folder = @acs.get_my_meetings_folder(@interactconfig['test_user'])
80
+ folder_id = @acs.get_folder_id(folder)
81
+ res = @acs.create_meeting(MEETING_NAME, folder_id, URL_PATH)
82
+
83
+ puts res.inspect
84
+
85
+ @acs.get_status_code(res).should include(STATUS_OK)
86
+ @acs.get_sco_id(res).to_i.should_not be 0
87
+ end
88
+
89
+ it 'should not be able to create a user' do
90
+ password = @interactconfig['generic_user_password']
91
+ res = @acs.create_user(E_MAIL, E_MAIL, password, FIRST_NAME, LAST_NAME)
92
+ @acs.get_status_code(res).should include(STATUS_NO_ACCESS)
93
+ end
94
+ end
95
+
96
+
97
+ describe 'admin user' do
98
+ before(:each) do
99
+ # login normal admin user
100
+ login = @interactconfig['username']
101
+ password = @interactconfig['password']
102
+ @acs.login(login, password)
103
+
104
+ # delete the users if they already exist
105
+ filter = AdobeConnectApi::FilterDefinition.new
106
+ filter["email"] == E_MAIL
107
+ principal = @acs.get_principal(filter)
108
+ sco_id = @acs.get_principal_id(principal)
109
+ @acs.delete_user(sco_id) unless sco_id.nil?
110
+
111
+ filter2 = AdobeConnectApi::FilterDefinition.new
112
+ filter2["email"] == E_MAIL_2
113
+ principal2 = @acs.get_principal(filter2)
114
+ sco_id2 = @acs.get_principal_id(principal2)
115
+ @acs.delete_user(sco_id2) unless sco_id2.nil?
116
+ end
117
+
118
+ it 'should be able to create a user' do
119
+ password = @interactconfig['generic_user_password']
120
+ res = @acs.create_user(E_MAIL, E_MAIL, password, FIRST_NAME, LAST_NAME)
121
+
122
+ # should contain the status code OK
123
+ @acs.get_status_code(res).should include(STATUS_OK)
124
+
125
+ # should return the sco-id of the new user
126
+ @acs.get_principal_id(res).to_i.should_not be 0
127
+ end
128
+
129
+ it 'should be able to update the group membership' do
130
+ # get id of the authors group
131
+ filter_authors = AdobeConnectApi::FilterDefinition.new
132
+ filter_authors["type"] == "authors"
133
+ res = @acs.get_principal(filter_authors)
134
+ authors_group_id = @acs.get_principal_id(res)
135
+ authors_group_id.to_i.should_not be 0
136
+
137
+ # create user
138
+ password = @interactconfig['generic_user_password']
139
+ res = @acs.create_user(E_MAIL_2, E_MAIL_2, password, FIRST_NAME, LAST_NAME)
140
+ sco_id = @acs.get_principal_id(res)
141
+
142
+ @acs.group_membership_update(authors_group_id, sco_id, true).should include(STATUS_OK)
143
+ end
144
+
145
+ end
146
+
147
+
148
+ describe 'creation and deletion of meeting' do
149
+ before(:each) do
150
+ # login normal user
151
+ login = @interactconfig['test_user']
152
+ password = @interactconfig['generic_user_password']
153
+ @acs.login(login, password)
154
+
155
+ # get folder id
156
+ @folder_id = @acs.get_folder_id(@acs.get_my_meetings_folder(@interactconfig['test_user']))
157
+
158
+ # check if meeting already exists
159
+ res = @acs.search_meeting(MEETING_NAME)
160
+ @sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
161
+
162
+ if @sco_id.nil?
163
+ # create meeting
164
+ res = @acs.create_meeting(MEETING_NAME, @folder_id, URL_PATH)
165
+ @sco_id = @acs.get_sco_id(res)
166
+ end
167
+ end
168
+
169
+ it 'should not be able to create a meeting with the same url-path again' do
170
+ res = @acs.create_meeting(MEETING_NAME, @folder_id, URL_PATH)
171
+
172
+ status = @acs.get_status_code(res)
173
+ status.should include(STATUS_INVALID)
174
+
175
+ subcode = @acs.get_invalid_subcode(res)
176
+ subcode.should include(CODE_DUPLICATE)
177
+ end
178
+
179
+ it 'should delete the meeting' do
180
+ # delete meeting
181
+ res = @acs.delete_meeting(@sco_id)
182
+ @acs.get_status_code(res).should include(STATUS_OK)
183
+
184
+ # try to find meeting again
185
+ res = @acs.search_meeting(MEETING_NAME)
186
+ sco_id = @acs.get_sco_id_for_unique_name(res, MEETING_NAME)
187
+ sco_id.should be_nil
188
+ end
189
+
190
+ it 'should be able to add another host' do
191
+ filter = AdobeConnectApi::FilterDefinition.new
192
+ filter["email"] == @interactconfig['username']
193
+ principal = @acs.get_principal(filter)
194
+ principal_id = @acs.get_principal_id(principal)
195
+ res = @acs.permissions_update(principal_id, @sco_id, "host") unless (principal_id.nil? || @sco_id.nil?)
196
+ @acs.get_status_code(res).should include(STATUS_OK)
197
+ end
198
+
199
+ it 'should return the sco-info' do
200
+ res = @acs.sco_info(@sco_id)
201
+ @acs.get_sco_id(res).should eq @sco_id
202
+ end
203
+
204
+ end
205
+
206
+ 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,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adobe_connect_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.alpha
5
- prerelease: 6
4
+ version: 0.0.9
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Rohrer
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-24 00:00:00.000000000Z
12
+ date: 2013-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- requirement: &2153339500 !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: *2153339500
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:
@@ -56,13 +81,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
81
  required_rubygems_version: !ruby/object:Gem::Requirement
57
82
  none: false
58
83
  requirements:
59
- - - ! '>'
84
+ - - ! '>='
60
85
  - !ruby/object:Gem::Version
61
- version: 1.3.1
86
+ version: '0'
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