adobe_connect 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/adobe_connect.gemspec +1 -1
  3. data/lib/adobe_connect.rb +5 -0
  4. data/lib/adobe_connect/acl_field.rb +60 -0
  5. data/lib/adobe_connect/base.rb +128 -0
  6. data/lib/adobe_connect/group.rb +91 -0
  7. data/lib/adobe_connect/meeting.rb +99 -0
  8. data/lib/adobe_connect/meeting_folder.rb +12 -0
  9. data/lib/adobe_connect/param_formatter.rb +6 -0
  10. data/lib/adobe_connect/response.rb +5 -19
  11. data/lib/adobe_connect/service.rb +1 -1
  12. data/lib/adobe_connect/telephony_profile.rb +87 -0
  13. data/lib/adobe_connect/user.rb +21 -55
  14. data/lib/adobe_connect/version.rb +1 -1
  15. data/test/fixtures/acl_field_save_error.xml +6 -0
  16. data/test/fixtures/acl_field_save_success.xml +7 -0
  17. data/test/fixtures/acl_field_update_success.xml +7 -0
  18. data/test/fixtures/{log_in_success.xml → generic_success.xml} +0 -0
  19. data/test/fixtures/group_is_member.xml +13 -0
  20. data/test/fixtures/group_is_not_member.xml +5 -0
  21. data/test/fixtures/group_save_error.xml +6 -0
  22. data/test/fixtures/group_save_success.xml +9 -0
  23. data/test/fixtures/group_update_success.xml +9 -0
  24. data/test/fixtures/meeting_find_by_id_error.xml +4 -0
  25. data/test/fixtures/meeting_find_by_id_success.xml +16 -0
  26. data/test/fixtures/meeting_save_error.xml +6 -0
  27. data/test/fixtures/meeting_save_success.xml +11 -0
  28. data/test/fixtures/meeting_update_success.xml +11 -0
  29. data/test/fixtures/telephony_profile_info_success.xml +13 -0
  30. data/test/fixtures/telephony_profile_list_success.xml +16 -0
  31. data/test/fixtures/telephony_profile_save_error.xml +6 -0
  32. data/test/fixtures/telephony_profile_save_success.xml +7 -0
  33. data/test/fixtures/telephony_profile_update_success.xml +7 -0
  34. data/test/fixtures/user_update_success.xml +4 -0
  35. data/test/lib/adobe_connect/acl_field_test.rb +39 -0
  36. data/test/lib/adobe_connect/adobe_connect_base_tests.rb +121 -0
  37. data/test/lib/adobe_connect/config_test.rb +1 -1
  38. data/test/lib/adobe_connect/group_test.rb +77 -0
  39. data/test/lib/adobe_connect/meeting_folder_test.rb +3 -7
  40. data/test/lib/adobe_connect/meeting_test.rb +117 -0
  41. data/test/lib/adobe_connect/param_formatter_test.rb +1 -1
  42. data/test/lib/adobe_connect/response_test.rb +1 -1
  43. data/test/lib/adobe_connect/service_test.rb +5 -8
  44. data/test/lib/adobe_connect/telephony_profile_test.rb +41 -0
  45. data/test/lib/adobe_connect/user_test.rb +29 -84
  46. data/test/test_helper.rb +16 -0
  47. metadata +87 -28
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ </results>
@@ -0,0 +1,39 @@
1
+ require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ class AdobeConnectAclFieldTest < AdobeConnectTestCase
4
+
5
+ include AdobeConnectBaseTests
6
+
7
+ AdobeConnect::Config.declare do
8
+ username 'test@example.com'
9
+ password 'pwd'
10
+ domain 'http://example.com'
11
+ end
12
+
13
+ def test_attrs_does_not_contain_field_id_when_unpersisted
14
+ attrs = @connect_acl_field.attrs
15
+
16
+ assert !attrs.has_key?(:field_id)
17
+ end
18
+
19
+ def test_attrs_contain_field_id_when_persisted
20
+ @connect_acl_field.instance_variable_set(:@id, '54321')
21
+
22
+ attrs = @connect_acl_field.attrs
23
+
24
+ assert attrs.has_key?(:field_id)
25
+ assert_equal '54321', attrs[:field_id]
26
+ end
27
+
28
+ private
29
+ def obj_attrs
30
+ { name: 'Phone', obj_type: 'principal' }
31
+ end
32
+
33
+ def obj_attrs_posted
34
+ { :object_type => 'object-type-principal', :permission_id => 'manage',
35
+ :name => 'Phone', :field_type => 'text', :is_required => false,
36
+ :is_primary => true
37
+ }
38
+ end
39
+ end
@@ -0,0 +1,121 @@
1
+ module AdobeConnectBaseTests
2
+
3
+ def setup
4
+ super
5
+ @ac_class = self.class.to_s.gsub(/^AdobeConnect/, '').gsub(/Test$/,'')
6
+ @obj_class = "AdobeConnect::#{@ac_class}".constantize
7
+ @connect_obj = @obj_class.new(obj_attrs)
8
+ self.instance_variable_set(:"@connect_#{@ac_class.underscore.downcase}", @connect_obj)
9
+ @method_prefix = @obj_class.config[:ac_method_prefix] || @obj_class.config[:ac_obj_type]
10
+ end
11
+
12
+ def test_initialize_takes_a_hash_with_appropriate_keys
13
+ obj_attrs.each do |key, value|
14
+ assert_equal @connect_obj.send(key), value
15
+ end
16
+ end
17
+
18
+ def test_save_persists_obj_to_connect_server
19
+ ac_response = mock_ac_response(responses[:save_success])
20
+
21
+ @connect_obj.service.expects(:"#{@method_prefix}_update").
22
+ with(obj_attrs_posted).
23
+ returns(ac_response)
24
+
25
+ assert @connect_obj.save
26
+ end
27
+
28
+ def test_save_stores_the_obj_id_on_the_obj
29
+ ac_response = mock_ac_response(responses[:save_success])
30
+
31
+ @connect_obj.service.expects(:"#{@method_prefix}_update").
32
+ with(obj_attrs_posted).
33
+ returns(ac_response)
34
+
35
+ @connect_obj.save
36
+
37
+ assert_equal "26243", @connect_obj.id
38
+ end
39
+
40
+ def test_save_returns_false_on_failure
41
+ response = mock_ac_response(responses[:save_error])
42
+
43
+ @connect_obj.service.
44
+ expects(:"#{@method_prefix}_update").
45
+ returns(response)
46
+ refute @connect_obj.save
47
+ end
48
+
49
+ def test_save_stores_errors_on_failure
50
+ response = mock_ac_response(responses[:save_error])
51
+
52
+ @connect_obj.service.
53
+ expects(:"#{@method_prefix}_update").
54
+ returns(response)
55
+ @connect_obj.save
56
+ refute_equal 0, @connect_obj.errors.length
57
+ end
58
+
59
+ def test_create_should_return_a_new_obj
60
+ @obj_class.any_instance.expects(:save).returns(true)
61
+
62
+ connect_obj = @obj_class.create(obj_attrs)
63
+ assert_instance_of @obj_class, connect_obj
64
+ end
65
+
66
+ def test_should_update_obj
67
+ response = mock_ac_response(responses[:update_success])
68
+
69
+ @connect_obj.instance_variable_set(:@id, 26243)
70
+
71
+ @connect_obj.service.
72
+ expects(:"#{@method_prefix}_update").
73
+ returns(response)
74
+
75
+ assert @connect_obj.save
76
+ end
77
+
78
+ def test_should_delete_obj
79
+ response = mock_ac_response(responses[:generic_success])
80
+
81
+ @connect_obj.service.
82
+ expects(:"#{@connect_obj.send(:delete_method_prefix)}_delete").
83
+ returns(response)
84
+
85
+ assert @connect_obj.delete
86
+ end
87
+
88
+ def test_should_update_permissions_on_obj
89
+ response = mock_ac_response(responses[:generic_success])
90
+
91
+ @connect_obj.service.
92
+ expects(:permissions_update).
93
+ with(:acl_id => @connect_obj.id,
94
+ :principal_id => 123,
95
+ :permission_id =>'view').
96
+ returns(response)
97
+
98
+ assert @connect_obj.permissions_update(123, 'view')
99
+ end
100
+
101
+ private
102
+ def load_responses(responses)
103
+ responses.reduce({}) {|rsps, rsp|
104
+ rsps.merge(rsp => response_file(rsp.to_s))
105
+ }
106
+ end
107
+
108
+ def response_file(resp_name, prefix = nil)
109
+ prefix ||= @ac_class.underscore.downcase
110
+ File.read(
111
+ File.expand_path("../../fixtures/#{prefix}_#{resp_name}.xml",
112
+ File.dirname(__FILE__))
113
+ ).gsub(/\n\s+/, '') #Strip indentation and new lines, they cause issues
114
+ end
115
+
116
+ def responses
117
+ @rsps ||= load_responses([:save_success, :save_error, :update_success]).
118
+ merge(:generic_success => response_file('success', 'generic'))
119
+ end
120
+
121
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
- class ConfigTest < MiniTest::Unit::TestCase
3
+ class ConfigTest < AdobeConnectTestCase
4
4
  def setup
5
5
  @config = AdobeConnect::Config
6
6
  end
@@ -0,0 +1,77 @@
1
+ require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ class AdobeConnectGroupTest < AdobeConnectTestCase
4
+
5
+ include AdobeConnectBaseTests
6
+
7
+ AdobeConnect::Config.declare do
8
+ username 'test@example.com'
9
+ password 'pwd'
10
+ domain 'http://example.com'
11
+ end
12
+
13
+ def test_attrs_does_not_contain_principal_id_when_unpersisted
14
+ attrs = @connect_group.attrs
15
+
16
+ assert !attrs.has_key?(:principal_id)
17
+ end
18
+
19
+ def test_attrs_contain_principal_id_when_persisted
20
+ @connect_group.instance_variable_set(:@id, '54321')
21
+
22
+ attrs = @connect_group.attrs
23
+
24
+ assert attrs.has_key?(:principal_id)
25
+ assert_equal '54321', attrs[:principal_id]
26
+ end
27
+
28
+ def test_add_member_to_group
29
+ response = mock_ac_response(responses[:generic_success])
30
+
31
+ @connect_group.service.
32
+ expects(:group_membership_update).
33
+ returns(response)
34
+
35
+ user_stub = mock
36
+ user_stub.expects(:id).returns(12345)
37
+
38
+ assert @connect_group.add_member(user_stub)
39
+ end
40
+
41
+ def test_user_is_member_of_group
42
+ response = mock_ac_response(responses[:is_member])
43
+
44
+ @connect_group.id = 12345
45
+
46
+ @connect_group.service.
47
+ expects(:principal_list).
48
+ returns(response)
49
+
50
+ assert @connect_group.is_member?('testuser@example.com')
51
+ end
52
+
53
+ def test_user_is_not_member_of_group
54
+ response = mock_ac_response(responses[:is_not_member])
55
+
56
+ @connect_group.id = 12345
57
+
58
+ @connect_group.service.
59
+ expects(:principal_list).
60
+ returns(response)
61
+
62
+ refute @connect_group.is_member?('testuser@example.com')
63
+ end
64
+
65
+ private
66
+ def obj_attrs
67
+ { name: 'Test group', description: 'This is for testing' }
68
+ end
69
+
70
+ def obj_attrs_posted
71
+ { name: 'Test group', description: 'This is for testing', :type => 'group', :has_children => 1 }
72
+ end
73
+
74
+ def responses
75
+ super.merge(load_responses([:is_member, :is_not_member]))
76
+ end
77
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
- class AdobeConnectMeetingFolderTest < MiniTest::Unit::TestCase
3
+ class AdobeConnectMeetingFolderTest < AdobeConnectTestCase
4
4
 
5
5
  AdobeConnect::Config.declare do
6
6
  username 'test@example.com'
@@ -32,9 +32,7 @@ class AdobeConnectMeetingFolderTest < MiniTest::Unit::TestCase
32
32
  end
33
33
 
34
34
  def test_find_returns_a_new_folder
35
- response = mock(:code => '200')
36
- response.expects(:body).returns(FOLDER_SUCCESS)
37
- ac_response = AdobeConnect::Response.new(response)
35
+ ac_response = mock_ac_response(FOLDER_SUCCESS)
38
36
 
39
37
  AdobeConnect::Service.any_instance.
40
38
  expects(:request).
@@ -51,9 +49,7 @@ class AdobeConnectMeetingFolderTest < MiniTest::Unit::TestCase
51
49
  end
52
50
 
53
51
  def test_contents_returns_folder_contents
54
- response = mock(:code => '200')
55
- response.expects(:body).returns(FOLDER_CONTENTS)
56
- ac_response = AdobeConnect::Response.new(response)
52
+ ac_response = mock_ac_response(FOLDER_CONTENTS)
57
53
  @folder.service.expects(:sco_contents).returns(ac_response)
58
54
 
59
55
  assert_equal @folder.contents.xpath('//sco').length, 10
@@ -0,0 +1,117 @@
1
+ require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ class AdobeConnectMeetingTest < AdobeConnectTestCase
4
+
5
+ include AdobeConnectBaseTests
6
+
7
+ AdobeConnect::Config.declare do
8
+ username 'test@example.com'
9
+ password 'pwd'
10
+ domain 'http://example.com'
11
+ end
12
+
13
+ def test_attrs_contain_type_and_folder_id_when_unpersisted
14
+ attrs = @connect_meeting.attrs
15
+
16
+ assert attrs.has_key?(:type)
17
+ assert attrs.has_key?(:folder_id)
18
+ assert !attrs.has_key?(:sco_id)
19
+ end
20
+
21
+ def test_attrs_contain_sco_id_when_persisted
22
+ @connect_meeting.instance_variable_set(:@id, '54321')
23
+
24
+ attrs = @connect_meeting.attrs
25
+
26
+ assert !attrs.has_key?(:folder_id)
27
+ assert attrs.has_key?(:sco_id)
28
+ assert_equal '54321', attrs[:sco_id]
29
+ end
30
+
31
+ def test_find_by_id_should_return_existing_meeting
32
+ response = mock_ac_response(responses[:find_by_id_success])
33
+ AdobeConnect::Service.any_instance.expects(:sco_info).
34
+ with(:sco_id => '98765').
35
+ returns(response)
36
+
37
+ connect_meeting = AdobeConnect::Meeting.find_by_id('98765')
38
+ assert_instance_of AdobeConnect::Meeting, connect_meeting
39
+ end
40
+
41
+ def test_find_by_id_should_return_nil_if_not_found
42
+ response = mock_ac_response(responses[:find_by_id_error])
43
+ AdobeConnect::Service.any_instance.expects(:sco_info).
44
+ with(:sco_id => '98765').
45
+ returns(response)
46
+
47
+ connect_meeting = AdobeConnect::Meeting.find_by_id('98765')
48
+ assert_nil connect_meeting
49
+ end
50
+
51
+ def test_add_participant_to_meeting
52
+ response = mock_ac_response(responses[:generic_success])
53
+
54
+ AdobeConnect::Service.any_instance.
55
+ expects(:permissions_update).
56
+ with(:acl_id => @connect_meeting.id,
57
+ :principal_id => 123,
58
+ :permission_id =>'view').
59
+ returns(response)
60
+
61
+ assert @connect_meeting.add_participant(123)
62
+ end
63
+
64
+ def test_add_presenter_to_meeting
65
+ response = mock_ac_response(responses[:generic_success])
66
+
67
+ AdobeConnect::Service.any_instance.
68
+ expects(:permissions_update).
69
+ with(:acl_id => @connect_meeting.id,
70
+ :principal_id => 123,
71
+ :permission_id =>'mini-host').
72
+ returns(response)
73
+
74
+ assert @connect_meeting.add_presenter(123)
75
+ end
76
+
77
+ def test_add_host_to_meeting
78
+ response = mock_ac_response(responses[:generic_success])
79
+
80
+ AdobeConnect::Service.any_instance.
81
+ expects(:permissions_update).
82
+ with(:acl_id => @connect_meeting.id,
83
+ :principal_id => 123,
84
+ :permission_id =>'host').
85
+ returns(response)
86
+
87
+ assert @connect_meeting.add_host(123)
88
+ end
89
+
90
+ def test_remove_user_from_meeting
91
+ response = mock_ac_response(responses[:generic_success])
92
+
93
+ AdobeConnect::Service.any_instance.
94
+ expects(:permissions_update).
95
+ with(:acl_id => @connect_meeting.id,
96
+ :principal_id => 123,
97
+ :permission_id =>'remove').
98
+ returns(response)
99
+
100
+ assert @connect_meeting.remove_user(123)
101
+ end
102
+
103
+ private
104
+ def obj_attrs
105
+ { description: 'This is an important meeting',
106
+ name: 'Important Meeting', folder_id: '12345' }
107
+ end
108
+
109
+ def obj_attrs_posted
110
+ { date_end: nil, date_begin: nil, description: 'This is an important meeting',
111
+ name: 'Important Meeting', url_path: nil, type: 'meeting', folder_id: '12345' }
112
+ end
113
+
114
+ def responses
115
+ super.merge(load_responses([:find_by_id_success, :find_by_id_error]))
116
+ end
117
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
- class AdobeConnectParamFormatterTest < MiniTest::Unit::TestCase
3
+ class AdobeConnectParamFormatterTest < AdobeConnectTestCase
4
4
  def setup
5
5
  params = { :a => 1, :b => 'param value', 'dashed_value' => 3 }
6
6
  @formatter = AdobeConnect::ParamFormatter.new(params)
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
- class AdobeConnectResponseTest < MiniTest::Unit::TestCase
3
+ class AdobeConnectResponseTest < AdobeConnectTestCase
4
4
 
5
5
  TEST_HEADERS = { 'Accept' => 'application/json' }
6
6
  TEST_BODY = <<-END
@@ -1,8 +1,8 @@
1
1
  require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
- class AdobeConnectServiceTest < MiniTest::Unit::TestCase
3
+ class AdobeConnectServiceTest < AdobeConnectTestCase
4
4
 
5
- LOGIN_SUCCESS = File.read(File.expand_path('../../fixtures/log_in_success.xml', File.dirname(__FILE__)))
5
+ LOGIN_SUCCESS = File.read(File.expand_path('../../fixtures/generic_success.xml', File.dirname(__FILE__)))
6
6
  LOGIN_FAIL = File.read(File.expand_path('../../fixtures/log_in_fail.xml', File.dirname(__FILE__)))
7
7
 
8
8
  def setup
@@ -24,9 +24,8 @@ class AdobeConnectServiceTest < MiniTest::Unit::TestCase
24
24
  end
25
25
 
26
26
  def test_log_in_authenticates
27
- response = mock(:code => '200')
27
+ response = mock_response(LOGIN_SUCCESS)
28
28
  response.expects(:fetch).with('set-cookie').returns('BREEZESESSION=12345')
29
- response.expects(:body).returns(LOGIN_SUCCESS)
30
29
  @service.client.stubs(:get).returns(response)
31
30
 
32
31
  @service.log_in
@@ -34,9 +33,8 @@ class AdobeConnectServiceTest < MiniTest::Unit::TestCase
34
33
  end
35
34
 
36
35
  def test_log_in_creates_a_session
37
- response = mock(:code => '200')
36
+ response = mock_response(LOGIN_SUCCESS)
38
37
  response.expects(:fetch).with('set-cookie').returns('BREEZESESSION=12345;HttpOnly;path=/')
39
- response.expects(:body).returns(LOGIN_SUCCESS)
40
38
  @service.client.stubs(:get).
41
39
  with("/api/xml?action=login&login=name&password=password").
42
40
  returns(response)
@@ -46,8 +44,7 @@ class AdobeConnectServiceTest < MiniTest::Unit::TestCase
46
44
  end
47
45
 
48
46
  def test_log_in_returns_false_on_failure
49
- response = mock(:code => '200')
50
- response.expects(:body).returns(LOGIN_FAIL)
47
+ response = mock_response(LOGIN_FAIL)
51
48
  @service.client.stubs(:get).returns(response)
52
49
 
53
50
  refute @service.log_in