adobe_connect_api 0.0.9 → 0.0.10.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.3@adobe_connect_api
1
+ rvm 1.9.2@adobe_connect_api
@@ -9,7 +9,6 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = ""
10
10
 
11
11
  gem.add_dependency "xml-simple"
12
- gem.add_development_dependency "rspec"
13
12
 
14
13
  gem.files = `git ls-files`.split($\)
15
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,10 +1,9 @@
1
- # A filter definition can be added to some actions to filter the results
1
+ # A filter defeinition 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
8
7
  class AdobeConnectApi::FilterDefinition
9
8
  attr_accessor :rows
10
9
  attr_accessor :start
@@ -1,3 +1,3 @@
1
1
  module AdobeConnectApi
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10.alpha"
3
3
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
1
 
3
- # Copyright (c) 2010 - 2013 SWITCH - Serving Swiss Universities
2
+ # Copyright (c) 2010 SWITCH - Serving Swiss Universities
4
3
  # Author: Mischael Schill <me@mschill.ch>
5
4
  # Martin Kos <martin@kos.li>
6
5
  # Christian Rohrer <christian.rohrer@switch.ch>
7
- # Katja Gräfenhain <katja.graefenhain@switch.ch>
8
6
  # $Id$
9
7
 
10
8
  require 'rubygems'
@@ -16,11 +14,10 @@ require "cgi"
16
14
  require "yaml"
17
15
  #require 'logger'
18
16
 
19
- require 'adobe_connect_api/version'
17
+ require "adobe_connect_api/version"
20
18
  require 'adobe_connect_api/filter_definition'
21
19
  require 'adobe_connect_api/sort_definition'
22
20
  require 'adobe_connect_api/result'
23
- require 'adobe_connect_api/xml_parser'
24
21
 
25
22
 
26
23
  # This class is a simple utility to acces the adobe connect api. Before
@@ -30,43 +27,30 @@ require 'adobe_connect_api/xml_parser'
30
27
  # All the actions are defined in the Adobe Connect Pro API documentation
31
28
  # some of the actions are accepting filter- and/or sorting-definitions.
32
29
 
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
-
30
+ # module AdobeConnectApi
38
31
  class AdobeConnectAPI
39
- include XMLParser
40
32
 
41
33
  attr :url
42
34
  attr :pointconfig
43
35
 
44
- def self.version_string
45
- "AdobeConnectAPI version #{AdobeConnectApi::VERSION}"
46
- end
47
-
48
36
  # return BREEZESESSION id
49
37
  def sessionid
50
38
  @sessionid
51
39
  end
52
40
 
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
-
61
41
  #The URL is the base URL of the Connect-Server, without the trailing slash
62
42
  def initialize (url = nil, environment, root_directory)
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
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]
68
52
  if (url == nil)
69
- @url = @pointconfig["url"]
53
+ @url = pointconfig["url"]
70
54
  else
71
55
  @url = url
72
56
  end
@@ -77,11 +61,11 @@ class AdobeConnectAPI
77
61
 
78
62
  if (login != nil && password == nil)
79
63
  # user given --> use generic user password
80
- # TODO: generate password (see https://forge.switch.ch/redmine/issues/2355)
81
- password = @pointconfig["generic_user_password"]
64
+ # TODO KG: generate password
65
+ password = pointconfig["generic_user_password"]
82
66
  elsif (login == nil) && (password == nil)
83
- login = @pointconfig["username"]
84
- password = @pointconfig["password"]
67
+ login = pointconfig["username"]
68
+ password = pointconfig["password"]
85
69
  end
86
70
 
87
71
  res = query("login",
@@ -91,6 +75,9 @@ class AdobeConnectAPI
91
75
  "external-auth" => external_auth,
92
76
  "domain" => domain)
93
77
 
78
+ # TODO: debug
79
+ puts res.body.inspect
80
+
94
81
  cookies = res.response["set-cookie"]
95
82
  puts cookies.inspect
96
83
  cookies.split(";").each{|s|
@@ -99,22 +86,28 @@ class AdobeConnectAPI
99
86
  @sessionid = array[1]
100
87
  end
101
88
  }
102
- puts "ACS: Logged in"
89
+ #puts "ACS: Logged in"
103
90
  return res.body
104
91
  end
105
92
 
106
93
  #makes a logout and removes the cookie
107
94
  def logout
108
- res = query("logout")
95
+ res = query("logout").body
109
96
  @sessionid = nil
110
97
  puts "ACS: Logged out"
111
- return res.body
98
+ return res
112
99
  end
113
100
 
114
101
  # creates a new user in Adobe Connect
115
102
  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
+
116
109
  if password == nil
117
- password = @pointconfig["generic_user_password"]
110
+ password = pointconfig["generic_user_password"]
118
111
  end
119
112
 
120
113
  res = query("principal-update",
@@ -123,7 +116,7 @@ class AdobeConnectAPI
123
116
  "password" => password,
124
117
  "first-name" => first_name,
125
118
  "last-name" => last_name,
126
- "send-email" => false,
119
+ "send-email" => true,
127
120
  "has-children" => 0,
128
121
  "type" => "user")
129
122
 
@@ -131,133 +124,6 @@ class AdobeConnectAPI
131
124
  return res.body
132
125
  end
133
126
 
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
-
261
127
  #Returns all defined quotas (untested)
262
128
  def report_quotas
263
129
  res = query("report-quota")
@@ -314,17 +180,36 @@ class AdobeConnectAPI
314
180
 
315
181
  end
316
182
 
317
- # TODO KG: refactor (return res.body) and test
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
+
318
208
  #returns permission information of an sco-id
319
209
  def permissions_info(sco_id, filter = nil)
320
210
  res = query("permissions-info", "acl-id" => sco_id, "filter" => filter)
321
-
322
- return res.body
323
211
  data = XmlSimple.xml_in(res.body)
324
- if data['permissions'][0]
325
- return data['permissions'][0]
326
- end
327
- #puts YAML::dump(data)
212
+ puts YAML::dump(data)
328
213
  # if data["sco"][0]
329
214
  # return data["sco"][0]
330
215
  # end
@@ -370,6 +255,30 @@ class AdobeConnectAPI
370
255
  return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows)
371
256
  end
372
257
 
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
+ scos = []
276
+ if data["sco-search-by-field-info"]
277
+ results = data["sco-search-by-field-info"][0]
278
+ scos = results["sco"]
279
+ end
280
+ return AdobeConnectAPI::Result.new(data["status"][0]["code"], scos)
281
+ end
373
282
 
374
283
  #sends a query to the server and returns the http response. Parameters,
375
284
  #filter- and sort-definitions can be added. The filter as "filter" => ... and
@@ -407,20 +316,9 @@ class AdobeConnectAPI
407
316
  if @sessionid
408
317
  request.add_field("Cookie", "BREEZESESSION="+@sessionid)
409
318
  end
410
- puts "ACS query - request: " + request.path
319
+ puts request.path
411
320
  response = http.request(request)
412
- puts "ACS query - response: " + response.body.inspect
413
321
  return response
414
322
  end
415
323
 
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
-
426
324
  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
5
- prerelease:
4
+ version: 0.0.10.alpha
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Rohrer
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-02 00:00:00.000000000 Z
12
+ date: 2012-09-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &2153338220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,28 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
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'
24
+ version_requirements: *2153338220
46
25
  description: Wrapper to the Adobe Connect API
47
26
  email:
48
27
  - christian.rohrer@switch.ch
@@ -57,15 +36,11 @@ files:
57
36
  - README.md
58
37
  - Rakefile
59
38
  - adobe_connect_api.gemspec
60
- - config/config.breeze.yml
61
39
  - lib/adobe_connect_api.rb
62
40
  - lib/adobe_connect_api/filter_definition.rb
63
41
  - lib/adobe_connect_api/result.rb
64
42
  - lib/adobe_connect_api/sort_definition.rb
65
43
  - 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
69
44
  homepage: ''
70
45
  licenses: []
71
46
  post_install_message:
@@ -81,15 +56,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
56
  required_rubygems_version: !ruby/object:Gem::Requirement
82
57
  none: false
83
58
  requirements:
84
- - - ! '>='
59
+ - - ! '>'
85
60
  - !ruby/object:Gem::Version
86
- version: '0'
61
+ version: 1.3.1
87
62
  requirements: []
88
63
  rubyforge_project:
89
- rubygems_version: 1.8.25
64
+ rubygems_version: 1.8.17
90
65
  signing_key:
91
66
  specification_version: 3
92
67
  summary: Wrapper to the Adobe Connect API written in Ruby
93
- test_files:
94
- - spec/adobe_connect_api_spec.rb
95
- - spec/spec_helper.rb
68
+ test_files: []
@@ -1,30 +0,0 @@
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,77 +0,0 @@
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,206 +0,0 @@
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
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
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