kaltura-ruby-client 1.0
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.
- checksums.yaml +7 -0
- data/README +20 -0
- data/Rakefile +19 -0
- data/agpl.txt +674 -0
- data/kaltura.yml +7 -0
- data/lib/kaltura.rb +31 -0
- data/lib/kaltura_client.rb +14450 -0
- data/lib/kaltura_client_base.rb +432 -0
- data/lib/kaltura_plugins/kaltura_abc_screeners_watermark_access_control_client_plugin.rb +37 -0
- data/lib/kaltura_plugins/kaltura_ad_cue_point_client_plugin.rb +108 -0
- data/lib/kaltura_plugins/kaltura_annotation_client_plugin.rb +237 -0
- data/lib/kaltura_plugins/kaltura_aspera_client_plugin.rb +61 -0
- data/lib/kaltura_plugins/kaltura_attachment_client_plugin.rb +227 -0
- data/lib/kaltura_plugins/kaltura_audit_client_plugin.rb +349 -0
- data/lib/kaltura_plugins/kaltura_bulk_upload_client_plugin.rb +109 -0
- data/lib/kaltura_plugins/kaltura_bulk_upload_csv_client_plugin.rb +55 -0
- data/lib/kaltura_plugins/kaltura_bulk_upload_filter_client_plugin.rb +46 -0
- data/lib/kaltura_plugins/kaltura_bulk_upload_xml_client_plugin.rb +40 -0
- data/lib/kaltura_plugins/kaltura_caption_client_plugin.rb +406 -0
- data/lib/kaltura_plugins/kaltura_caption_search_client_plugin.rb +138 -0
- data/lib/kaltura_plugins/kaltura_code_cue_point_client_plugin.rb +97 -0
- data/lib/kaltura_plugins/kaltura_content_distribution_client_plugin.rb +1717 -0
- data/lib/kaltura_plugins/kaltura_cue_point_client_plugin.rb +290 -0
- data/lib/kaltura_plugins/kaltura_document_client_plugin.rb +522 -0
- data/lib/kaltura_plugins/kaltura_drm_client_plugin.rb +204 -0
- data/lib/kaltura_plugins/kaltura_drop_folder_client_plugin.rb +810 -0
- data/lib/kaltura_plugins/kaltura_drop_folder_xml_bulk_upload_client_plugin.rb +39 -0
- data/lib/kaltura_plugins/kaltura_email_notification_client_plugin.rb +276 -0
- data/lib/kaltura_plugins/kaltura_event_notification_client_plugin.rb +405 -0
- data/lib/kaltura_plugins/kaltura_external_media_client_plugin.rb +203 -0
- data/lib/kaltura_plugins/kaltura_file_sync_client_plugin.rb +151 -0
- data/lib/kaltura_plugins/kaltura_http_notification_client_plugin.rb +309 -0
- data/lib/kaltura_plugins/kaltura_kontiki_client_plugin.rb +72 -0
- data/lib/kaltura_plugins/kaltura_like_client_plugin.rb +82 -0
- data/lib/kaltura_plugins/kaltura_metadata_client_plugin.rb +788 -0
- data/lib/kaltura_plugins/kaltura_multi_centers_client_plugin.rb +45 -0
- data/lib/kaltura_plugins/kaltura_short_link_client_plugin.rb +231 -0
- data/lib/kaltura_plugins/kaltura_tag_search_client_plugin.rb +145 -0
- data/lib/kaltura_plugins/kaltura_var_console_client_plugin.rb +238 -0
- data/lib/kaltura_plugins/kaltura_velocix_client_plugin.rb +40 -0
- data/lib/kaltura_plugins/kaltura_virus_scan_client_plugin.rb +263 -0
- data/lib/kaltura_plugins/kaltura_webex_drop_folder_client_plugin.rb +121 -0
- data/lib/kaltura_plugins/kaltura_widevine_client_plugin.rb +195 -0
- data/license.txt +674 -0
- data/test/access_control_service_test.rb +75 -0
- data/test/base_entry_service_test.rb +267 -0
- data/test/configuration_test.rb +178 -0
- data/test/cue_point_service_test.rb +67 -0
- data/test/data_service_test.rb +76 -0
- data/test/document_service_test.rb +41 -0
- data/test/media/test.mov +0 -0
- data/test/media/test.pdf +0 -0
- data/test/media/test.png +0 -0
- data/test/media/test.swf +0 -0
- data/test/media/test.wmv +0 -0
- data/test/media_service_test.rb +294 -0
- data/test/metadata_profile_service_test.rb +63 -0
- data/test/test_helper.rb +59 -0
- metadata +127 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
# ===================================================================================================
|
2
|
+
# _ __ _ _
|
3
|
+
# | |/ /__ _| | |_ _ _ _ _ __ _
|
4
|
+
# | ' </ _` | | _| || | '_/ _` |
|
5
|
+
# |_|\_\__,_|_|\__|\_,_|_| \__,_|
|
6
|
+
#
|
7
|
+
# This file is part of the Kaltura Collaborative Media Suite which allows users
|
8
|
+
# to do with audio, video, and animation what Wiki platfroms allow them to do with
|
9
|
+
# text.
|
10
|
+
#
|
11
|
+
# Copyright (C) 2006-2011 Kaltura Inc.
|
12
|
+
#
|
13
|
+
# This program is free software: you can redistribute it and/or modify
|
14
|
+
# it under the terms of the GNU Affero General Public License as
|
15
|
+
# published by the Free Software Foundation, either version 3 of the
|
16
|
+
# License, or (at your option) any later version.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful,
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
# GNU Affero General Public License for more details.
|
22
|
+
#
|
23
|
+
# You should have received a copy of the GNU Affero General Public License
|
24
|
+
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
25
|
+
#
|
26
|
+
# @ignore
|
27
|
+
# ===================================================================================================
|
28
|
+
require 'test_helper'
|
29
|
+
require 'uri'
|
30
|
+
|
31
|
+
class AccessControlServiceTest < Test::Unit::TestCase
|
32
|
+
|
33
|
+
# this test create a access control object and reset the restrictions using and empty array.
|
34
|
+
should "be able to send empty array to the api and reset the values" do
|
35
|
+
|
36
|
+
# cleaning up the list
|
37
|
+
access_control_filter = Kaltura::KalturaAccessControlFilter.new
|
38
|
+
filter_pager = Kaltura::KalturaFilterPager.new
|
39
|
+
access_control_list = @client.access_control_service.list(access_control_filter, filter_pager)
|
40
|
+
access_control_list.objects.each do |obj|
|
41
|
+
@client.access_control_service.delete(obj.id) rescue nil
|
42
|
+
end if access_control_list.objects
|
43
|
+
|
44
|
+
access_control = Kaltura::KalturaAccessControl.new
|
45
|
+
access_control.name = "kaltura_test"
|
46
|
+
access_control.is_default = Kaltura::KalturaNullableBoolean::FALSE_VALUE
|
47
|
+
|
48
|
+
access_control.restrictions = []
|
49
|
+
|
50
|
+
restriction1 = Kaltura::KalturaCountryRestriction.new
|
51
|
+
restriction1.country_restriction_type = Kaltura::KalturaCountryRestrictionType::RESTRICT_COUNTRY_LIST
|
52
|
+
restriction1.country_list = 'UK,LK'
|
53
|
+
access_control.restrictions << restriction1
|
54
|
+
|
55
|
+
restriction2 = Kaltura::KalturaSiteRestriction.new
|
56
|
+
restriction2.site_restriction_type = Kaltura::KalturaSiteRestrictionType::RESTRICT_SITE_LIST
|
57
|
+
restriction2.site_list = 'http://www.kaltura.com'
|
58
|
+
access_control.restrictions << restriction2
|
59
|
+
|
60
|
+
created_access_control = @client.access_control_service.add(access_control)
|
61
|
+
|
62
|
+
assert_not_nil created_access_control.id
|
63
|
+
assert_equal created_access_control.restrictions.size, 2
|
64
|
+
|
65
|
+
# edited access control
|
66
|
+
edited_access_control = Kaltura::KalturaAccessControl.new
|
67
|
+
edited_access_control.name = access_control.name
|
68
|
+
edited_access_control.restrictions = []
|
69
|
+
|
70
|
+
updated_access_control = @client.access_control_service.update(created_access_control.id, edited_access_control)
|
71
|
+
|
72
|
+
assert_equal updated_access_control.restrictions, nil
|
73
|
+
assert_nil @client.access_control_service.delete(updated_access_control.id)
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
# ===================================================================================================
|
2
|
+
# _ __ _ _
|
3
|
+
# | |/ /__ _| | |_ _ _ _ _ __ _
|
4
|
+
# | ' </ _` | | _| || | '_/ _` |
|
5
|
+
# |_|\_\__,_|_|\__|\_,_|_| \__,_|
|
6
|
+
#
|
7
|
+
# This file is part of the Kaltura Collaborative Media Suite which allows users
|
8
|
+
# to do with audio, video, and animation what Wiki platfroms allow them to do with
|
9
|
+
# text.
|
10
|
+
#
|
11
|
+
# Copyright (C) 2006-2011 Kaltura Inc.
|
12
|
+
#
|
13
|
+
# This program is free software: you can redistribute it and/or modify
|
14
|
+
# it under the terms of the GNU Affero General Public License as
|
15
|
+
# published by the Free Software Foundation, either version 3 of the
|
16
|
+
# License, or (at your option) any later version.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful,
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
# GNU Affero General Public License for more details.
|
22
|
+
#
|
23
|
+
# You should have received a copy of the GNU Affero General Public License
|
24
|
+
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
25
|
+
#
|
26
|
+
# @ignore
|
27
|
+
# ===================================================================================================
|
28
|
+
require 'test_helper'
|
29
|
+
|
30
|
+
class BaseEntryServiceTest < Test::Unit::TestCase
|
31
|
+
|
32
|
+
# this test uploads a file to kaltura and creates an entry using the uploaded file.
|
33
|
+
should "upload a file and create an entry" do
|
34
|
+
|
35
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
36
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
37
|
+
base_entry.name = "kaltura_test"
|
38
|
+
pdf_file = File.open("test/media/test.pdf")
|
39
|
+
|
40
|
+
pdf_token = @client.base_entry_service.upload(pdf_file)
|
41
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
42
|
+
|
43
|
+
assert_not_nil created_entry.id
|
44
|
+
assert_nil @client.base_entry_service.delete(created_entry.id)
|
45
|
+
end
|
46
|
+
|
47
|
+
# this test uploads a file to kaltura and creates an entry using the uploaded file.
|
48
|
+
should "upload a file and create an entry" do
|
49
|
+
|
50
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
51
|
+
base_entry.type = Kaltura::KalturaEntryType::AUTOMATIC
|
52
|
+
base_entry.name = "kaltura_test"
|
53
|
+
swf_file = File.open("test/media/test.swf")
|
54
|
+
|
55
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
56
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
57
|
+
|
58
|
+
assert_not_nil created_entry.id
|
59
|
+
assert_nil @client.base_entry_service.delete(created_entry.id)
|
60
|
+
end
|
61
|
+
|
62
|
+
# this test simulates an api response with 'not supported' attributes and try to parse and generate an entry object out of it.
|
63
|
+
should "silently ignore any fields returned from the server that it does not recognize" do
|
64
|
+
|
65
|
+
response_body =
|
66
|
+
<<-XML
|
67
|
+
<?xml version='1.0' encoding='utf-8'?><xml><result><objectType>KalturaBaseEntry</objectType><id>0_npdg4rrs</id><not_supported_attr>not_supported_attr val</not_supported_attr><name>102_1321456940</name><description></description><partnerId>102</partnerId><userId></userId><tags></tags><adminTags></adminTags><categories></categories><status>2</status><moderationStatus>6</moderationStatus><moderationCount>0</moderationCount><type>10</type><createdAt>1321456940</createdAt><rank>0</rank><totalRank>0</totalRank><votes>0</votes><groupId></groupId><partnerData></partnerData><downloadUrl>http://ec2-174-129-124-16.compute-1.amazonaws.com/p/102/sp/10200/raw/entry_id/0_npdg4rrs/version/100000</downloadUrl><searchText> 102_1321456940 </searchText><licenseType>-1</licenseType><version>100000</version><thumbnailUrl>http://ec2-174-129-124-16.compute-1.amazonaws.com/p/102/sp/10200/thumbnail/entry_id/0_npdg4rrs/version/0</thumbnailUrl><accessControlId>4</accessControlId><startDate></startDate><endDate></endDate></result><executionTime>0.110525846481</executionTime></xml>
|
68
|
+
XML
|
69
|
+
created_entry = @client.parse_to_objects(response_body)
|
70
|
+
|
71
|
+
assert_instance_of Kaltura::KalturaBaseEntry, created_entry
|
72
|
+
assert_not_nil created_entry.id
|
73
|
+
end
|
74
|
+
|
75
|
+
# this test creates an entry and retrieves the list of entries and count from kaltura by setting a filter.
|
76
|
+
should "get the base entry list" do
|
77
|
+
|
78
|
+
# cleaning up the list
|
79
|
+
base_entry_filter = Kaltura::KalturaBaseEntryFilter.new
|
80
|
+
base_entry_filter.name_multi_like_or = "kaltura_test"
|
81
|
+
filter_pager = Kaltura::KalturaFilterPager.new
|
82
|
+
base_entry_list = @client.base_entry_service.list(base_entry_filter, filter_pager)
|
83
|
+
base_entry_list.objects.each do |obj|
|
84
|
+
@client.base_entry_service.delete(obj.id) rescue nil
|
85
|
+
end if base_entry_list.objects
|
86
|
+
|
87
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
88
|
+
base_entry.type = Kaltura::KalturaEntryType::AUTOMATIC
|
89
|
+
base_entry.name = "kaltura_test"
|
90
|
+
swf_file = File.open("test/media/test.swf")
|
91
|
+
|
92
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
93
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
94
|
+
|
95
|
+
assert_not_nil created_entry.id
|
96
|
+
|
97
|
+
base_entry_filter = Kaltura::KalturaBaseEntryFilter.new
|
98
|
+
base_entry_filter.name_multi_like_or = "kaltura_test"
|
99
|
+
filter_pager = Kaltura::KalturaFilterPager.new
|
100
|
+
base_entry_list = @client.base_entry_service.list(base_entry_filter, filter_pager)
|
101
|
+
|
102
|
+
assert_equal base_entry_list.total_count, 1
|
103
|
+
|
104
|
+
count = @client.base_entry_service.count(base_entry_filter)
|
105
|
+
|
106
|
+
assert_equal count.to_i, 1
|
107
|
+
|
108
|
+
assert_nil @client.base_entry_service.delete(created_entry.id)
|
109
|
+
end
|
110
|
+
|
111
|
+
# this test creates an entry and retrieves it back using the id.
|
112
|
+
should "get the base entry" do
|
113
|
+
|
114
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
115
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
116
|
+
base_entry.name = "kaltura_test"
|
117
|
+
swf_file = File.open("test/media/test.pdf")
|
118
|
+
|
119
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
120
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
121
|
+
|
122
|
+
assert_not_nil created_entry.id
|
123
|
+
|
124
|
+
base_entry = @client.base_entry_service.get(created_entry.id)
|
125
|
+
|
126
|
+
assert_not_nil base_entry
|
127
|
+
assert_instance_of Kaltura::KalturaDocumentEntry, base_entry
|
128
|
+
assert_equal base_entry.id, created_entry.id
|
129
|
+
assert_nil @client.base_entry_service.delete(base_entry.id)
|
130
|
+
end
|
131
|
+
|
132
|
+
# this test creates couple of entries and retrieves them back using the ids
|
133
|
+
should "get the base entries using the ids" do
|
134
|
+
|
135
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
136
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
137
|
+
base_entry.name = "kaltura_test"
|
138
|
+
swf_file = File.open("test/media/test.pdf")
|
139
|
+
|
140
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
141
|
+
created_entry1 = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
142
|
+
|
143
|
+
assert_not_nil created_entry1.id
|
144
|
+
|
145
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
146
|
+
base_entry.type = Kaltura::KalturaEntryType::AUTOMATIC
|
147
|
+
base_entry.name = "kaltura_test"
|
148
|
+
swf_file = File.open("test/media/test.swf")
|
149
|
+
|
150
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
151
|
+
created_entry2 = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
152
|
+
|
153
|
+
assert_not_nil created_entry2.id
|
154
|
+
|
155
|
+
base_entry_list = @client.base_entry_service.get_by_ids("#{created_entry1.id},#{created_entry2.id}")
|
156
|
+
|
157
|
+
assert_not_nil base_entry_list
|
158
|
+
assert_instance_of Array, base_entry_list
|
159
|
+
assert_equal base_entry_list.count, 2
|
160
|
+
assert_nil @client.base_entry_service.delete(created_entry1.id)
|
161
|
+
assert_nil @client.base_entry_service.delete(created_entry2.id)
|
162
|
+
end
|
163
|
+
|
164
|
+
# this test tries toretrieve an entry with invalid id.
|
165
|
+
should "throw an error for invalid base entry id" do
|
166
|
+
|
167
|
+
assert_raise Kaltura::KalturaAPIError do
|
168
|
+
@client.base_entry_service.get("invalid_base_entry_id")
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
# this test creates an entry and updates the metadata of it.
|
174
|
+
should "update the base entry metadata" do
|
175
|
+
|
176
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
177
|
+
base_entry.type = Kaltura::KalturaEntryType::AUTOMATIC
|
178
|
+
base_entry.name = "kaltura test"
|
179
|
+
swf_file = File.open("test/media/test.swf")
|
180
|
+
|
181
|
+
pdf_token = @client.base_entry_service.upload(swf_file)
|
182
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
183
|
+
|
184
|
+
assert_not_nil created_entry.id
|
185
|
+
|
186
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
187
|
+
base_entry.name = "kaltura test updated"
|
188
|
+
base_entry.description = "kaltura test description"
|
189
|
+
base_entry_updated = @client.base_entry_service.update(created_entry.id, base_entry)
|
190
|
+
|
191
|
+
assert_not_nil base_entry_updated
|
192
|
+
assert_instance_of Kaltura::KalturaBaseEntry, base_entry_updated
|
193
|
+
assert_equal base_entry_updated.name, "kaltura test updated"
|
194
|
+
assert_equal base_entry_updated.description, "kaltura test description"
|
195
|
+
|
196
|
+
assert_nil @client.base_entry_service.delete(base_entry_updated.id)
|
197
|
+
end
|
198
|
+
|
199
|
+
# this test creates an entry and updates it's thumbnail.
|
200
|
+
should "upload a thumbnail for the base entry " do
|
201
|
+
|
202
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
203
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
204
|
+
base_entry.name = "kaltura_test"
|
205
|
+
pdf_file = File.open("test/media/test.pdf")
|
206
|
+
|
207
|
+
pdf_token = @client.base_entry_service.upload(pdf_file)
|
208
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
209
|
+
|
210
|
+
assert_not_nil created_entry.id
|
211
|
+
|
212
|
+
img_file = File.open("test/media/test.png")
|
213
|
+
|
214
|
+
updated_entry = @client.base_entry_service.update_thumbnail_jpeg(created_entry.id, img_file)
|
215
|
+
|
216
|
+
assert_not_nil updated_entry.thumbnail_url
|
217
|
+
assert_not_equal updated_entry.thumbnail_url, created_entry.thumbnail_url
|
218
|
+
assert_nil @client.base_entry_service.delete(updated_entry.id)
|
219
|
+
end
|
220
|
+
|
221
|
+
# this test creates an entry and set it's moderation flags.
|
222
|
+
should "set the moderation flags" do
|
223
|
+
|
224
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
225
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
226
|
+
base_entry.name = "kaltura_test"
|
227
|
+
pdf_file = File.open("test/media/test.pdf")
|
228
|
+
|
229
|
+
pdf_token = @client.base_entry_service.upload(pdf_file)
|
230
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
231
|
+
|
232
|
+
assert_not_nil created_entry.id
|
233
|
+
|
234
|
+
# first list the flags. should be empty
|
235
|
+
moderation_flag_list = @client.base_entry_service.list_flags(created_entry.id)
|
236
|
+
|
237
|
+
assert_equal moderation_flag_list.total_count, 0
|
238
|
+
|
239
|
+
# add a new flag for moderate
|
240
|
+
flag = Kaltura::KalturaModerationFlag.new
|
241
|
+
flag.flagged_entry_id = created_entry.id
|
242
|
+
flag.flag_type = Kaltura::KalturaModerationFlagType::SEXUAL_CONTENT
|
243
|
+
flag = @client.base_entry_service.flag(flag)
|
244
|
+
|
245
|
+
# list the flags, should be 1
|
246
|
+
moderation_flag_list = @client.base_entry_service.list_flags(created_entry.id)
|
247
|
+
|
248
|
+
assert_equal moderation_flag_list.total_count, 1
|
249
|
+
assert_equal moderation_flag_list.objects[0].status, Kaltura::KalturaModerationFlagStatus::PENDING
|
250
|
+
|
251
|
+
# approve the flags
|
252
|
+
@client.base_entry_service.approve(created_entry.id)
|
253
|
+
|
254
|
+
# list the flags, should be empty
|
255
|
+
moderation_flag_list = @client.base_entry_service.list_flags(created_entry.id)
|
256
|
+
|
257
|
+
assert_equal moderation_flag_list.total_count, 0
|
258
|
+
|
259
|
+
# get the entry and check the moderation status
|
260
|
+
created_entry = @client.base_entry_service.get(created_entry.id)
|
261
|
+
|
262
|
+
assert_equal created_entry.moderation_status, Kaltura::KalturaEntryModerationStatus::APPROVED
|
263
|
+
|
264
|
+
assert_nil @client.base_entry_service.delete(created_entry.id)
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# ===================================================================================================
|
2
|
+
# _ __ _ _
|
3
|
+
# | |/ /__ _| | |_ _ _ _ _ __ _
|
4
|
+
# | ' </ _` | | _| || | '_/ _` |
|
5
|
+
# |_|\_\__,_|_|\__|\_,_|_| \__,_|
|
6
|
+
#
|
7
|
+
# This file is part of the Kaltura Collaborative Media Suite which allows users
|
8
|
+
# to do with audio, video, and animation what Wiki platfroms allow them to do with
|
9
|
+
# text.
|
10
|
+
#
|
11
|
+
# Copyright (C) 2006-2011 Kaltura Inc.
|
12
|
+
#
|
13
|
+
# This program is free software: you can redistribute it and/or modify
|
14
|
+
# it under the terms of the GNU Affero General Public License as
|
15
|
+
# published by the Free Software Foundation, either version 3 of the
|
16
|
+
# License, or (at your option) any later version.
|
17
|
+
#
|
18
|
+
# This program is distributed in the hope that it will be useful,
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
# GNU Affero General Public License for more details.
|
22
|
+
#
|
23
|
+
# You should have received a copy of the GNU Affero General Public License
|
24
|
+
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
25
|
+
#
|
26
|
+
# @ignore
|
27
|
+
# ===================================================================================================
|
28
|
+
require 'test_helper'
|
29
|
+
|
30
|
+
class ConfigurationTest < Test::Unit::TestCase
|
31
|
+
|
32
|
+
# this test validates the session id
|
33
|
+
should "not have a nil client session" do
|
34
|
+
assert_not_nil @client.ks
|
35
|
+
end
|
36
|
+
|
37
|
+
# this test generates a exception inside the client library code.
|
38
|
+
should "raise an error for invalid api calls" do
|
39
|
+
|
40
|
+
assert_raise NoMethodError do
|
41
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
42
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
43
|
+
base_entry.name = "kaltura_test"
|
44
|
+
pdf_file = File.open("test/media/test.pdf")
|
45
|
+
pdf_token = @client.invalid_service.upload(pdf_file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# this test invoke the api actions in https channel
|
50
|
+
should "support HTTPS" do
|
51
|
+
config = YAML.load_file("kaltura.yml")
|
52
|
+
|
53
|
+
partner_id = config["test"]["partner_id"]
|
54
|
+
service_url = config["test"]["service_url"]
|
55
|
+
administrator_secret = config["test"]["administrator_secret"]
|
56
|
+
timeout = config["test"]["timeout"]
|
57
|
+
|
58
|
+
service_url.gsub(/http:/, "https:/")
|
59
|
+
|
60
|
+
config = Kaltura::KalturaConfiguration.new(partner_id, service_url)
|
61
|
+
config.logger = Logger.new(STDOUT)
|
62
|
+
config.timeout = timeout
|
63
|
+
|
64
|
+
@client = Kaltura::KalturaClient.new( config )
|
65
|
+
assert_equal @client.ks, Kaltura::KalturaNotImplemented
|
66
|
+
|
67
|
+
session = @client.session_service.start( administrator_secret, '', Kaltura::KalturaSessionType::ADMIN )
|
68
|
+
@client.ks = session
|
69
|
+
|
70
|
+
assert_not_nil @client.ks
|
71
|
+
end
|
72
|
+
|
73
|
+
# this test generates a exception inside the client library code.
|
74
|
+
should "raise an error for invalid service url" do
|
75
|
+
|
76
|
+
config = YAML.load_file("kaltura.yml")
|
77
|
+
|
78
|
+
partner_id = config["test"]["partner_id"]
|
79
|
+
service_url = "http://invalid-service-url"
|
80
|
+
administrator_secret = config["test"]["administrator_secret"]
|
81
|
+
|
82
|
+
config = Kaltura::KalturaConfiguration.new(partner_id, service_url)
|
83
|
+
config.logger = Logger.new(STDOUT)
|
84
|
+
|
85
|
+
@client = Kaltura::KalturaClient.new( config )
|
86
|
+
|
87
|
+
assert_raise Kaltura::KalturaAPIError do
|
88
|
+
session = @client.session_service.start( administrator_secret, '', Kaltura::KalturaSessionType::ADMIN )
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# this test tries to retrieve a session key for a invalid configuration.
|
93
|
+
should "not create a valid client session for invalid credentials" do
|
94
|
+
|
95
|
+
config = YAML.load_file("kaltura.yml")
|
96
|
+
|
97
|
+
partner_id = config["test"]["partner_id"]
|
98
|
+
service_url = config["test"]["service_url"]
|
99
|
+
|
100
|
+
config = Kaltura::KalturaConfiguration.new(partner_id, service_url)
|
101
|
+
config.logger = Logger.new(STDOUT)
|
102
|
+
|
103
|
+
@client = Kaltura::KalturaClient.new( config )
|
104
|
+
|
105
|
+
assert_raise Kaltura::KalturaAPIError do
|
106
|
+
session = @client.session_service.start( "invalid_administrator_secret", '', Kaltura::KalturaSessionType::ADMIN )
|
107
|
+
@client.ks = session
|
108
|
+
end
|
109
|
+
|
110
|
+
assert_equal @client.ks, Kaltura::KalturaNotImplemented
|
111
|
+
end
|
112
|
+
|
113
|
+
# this test uses a session created in client side to comunicate with api.
|
114
|
+
should "upload a file and create an entry using the session created in client side" do
|
115
|
+
|
116
|
+
config = YAML.load_file("kaltura.yml")
|
117
|
+
|
118
|
+
partner_id = config["test"]["partner_id"]
|
119
|
+
service_url = config["test"]["service_url"]
|
120
|
+
administrator_secret = config["test"]["administrator_secret"]
|
121
|
+
timeout = config["test"]["timeout"]
|
122
|
+
|
123
|
+
config = Kaltura::KalturaConfiguration.new(partner_id, service_url)
|
124
|
+
config.logger = Logger.new(STDOUT)
|
125
|
+
config.timeout = timeout
|
126
|
+
|
127
|
+
@client = Kaltura::KalturaClient.new( config )
|
128
|
+
|
129
|
+
assert_equal @client.ks, Kaltura::KalturaNotImplemented
|
130
|
+
|
131
|
+
@client.generate_session(administrator_secret, '', Kaltura::KalturaSessionType::ADMIN, partner_id)
|
132
|
+
|
133
|
+
assert_not_nil @client.ks
|
134
|
+
|
135
|
+
base_entry = Kaltura::KalturaBaseEntry.new
|
136
|
+
base_entry.type = Kaltura::KalturaEntryType::DOCUMENT
|
137
|
+
base_entry.name = "kaltura_test"
|
138
|
+
pdf_file = File.open("test/media/test.pdf")
|
139
|
+
|
140
|
+
|
141
|
+
pdf_token = @client.base_entry_service.upload(pdf_file)
|
142
|
+
created_entry = @client.base_entry_service.add_from_uploaded_file(base_entry, pdf_token)
|
143
|
+
|
144
|
+
assert_not_nil created_entry.id
|
145
|
+
assert_nil @client.base_entry_service.delete(created_entry.id)
|
146
|
+
end
|
147
|
+
|
148
|
+
# this test is to validate the timeout configuration setting.
|
149
|
+
should "time out the request" do
|
150
|
+
|
151
|
+
config = YAML.load_file("kaltura.yml")
|
152
|
+
|
153
|
+
partner_id = config["test"]["partner_id"]
|
154
|
+
service_url = config["test"]["service_url"]
|
155
|
+
administrator_secret = config["test"]["administrator_secret"]
|
156
|
+
timeout = 0
|
157
|
+
|
158
|
+
config = Kaltura::KalturaConfiguration.new(partner_id, service_url)
|
159
|
+
config.logger = Logger.new(STDOUT)
|
160
|
+
config.timeout = timeout
|
161
|
+
|
162
|
+
exception = assert_raise Kaltura::KalturaAPIError do
|
163
|
+
@client = Kaltura::KalturaClient.new( config )
|
164
|
+
session = @client.session_service.start( administrator_secret, '', Kaltura::KalturaSessionType::ADMIN )
|
165
|
+
|
166
|
+
@client.ks = session
|
167
|
+
|
168
|
+
media_entry = Kaltura::KalturaMediaEntry.new
|
169
|
+
media_entry.name = "kaltura_test1"
|
170
|
+
media_entry.media_type = Kaltura::KalturaMediaType::VIDEO
|
171
|
+
video_file = File.open("test/media/test.wmv")
|
172
|
+
|
173
|
+
video_token = @client.media_service.upload(video_file)
|
174
|
+
end
|
175
|
+
|
176
|
+
assert_equal exception.message, 'Request Timeout'
|
177
|
+
end
|
178
|
+
end
|