canvas kaltura gem
fixes CNVS-10479 test plan: - in a course with kaltura enabled - go to a discussion and add media - upload a video (use right tab, not the webcam) - save the video/discussion post - the video should be saved properly and viewable (this sometimes takes a minute of two) Change-Id: I40b9174807707dd1fb41125e04705422a8711d5d Reviewed-on: https://gerrit.instructure.com/32024 Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Nathan Rogowski <nathan@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
306f1583d8
commit
f1009a38fe
|
@ -120,6 +120,7 @@ gem 'canvas_breach_mitigation', :path => 'gems/canvas_breach_mitigation'
|
|||
gem 'canvas_color', :path => 'gems/canvas_color'
|
||||
gem 'canvas_crummy', :path => 'gems/canvas_crummy'
|
||||
gem 'canvas_http', :path => 'gems/canvas_http'
|
||||
gem 'canvas_kaltura', :path => 'gems/canvas_kaltura'
|
||||
gem 'canvas_mimetype_fu', :path => 'gems/canvas_mimetype_fu'
|
||||
gem 'canvas_sanitize', :path => 'gems/canvas_sanitize'
|
||||
gem 'canvas_sort', :path => 'gems/canvas_sort'
|
||||
|
@ -134,3 +135,4 @@ gem 'multipart', :path => 'gems/multipart'
|
|||
gem 'paginated_collection', :path => 'gems/paginated_collection'
|
||||
gem 'utf8_cleaner', :path => 'gems/utf8_cleaner'
|
||||
gem 'workflow', :path => 'gems/workflow'
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ define [
|
|||
@uploader.removeEventListener 'K5.uiconfError', @showConfigError
|
||||
@uploader.removeEventListener 'K5.error', @showConfigError
|
||||
@uploader.removeEventListener 'K5.fileError', @onFileTypeError
|
||||
@uploader.removeEventListener 'K5.progress', @updatdProgBar
|
||||
@uploader.removeEventListener 'K5.progress', @updateProgBar
|
||||
|
||||
onFileTypeError: (error) =>
|
||||
if (error.maxFileSize > error.file.size)
|
||||
|
|
|
@ -1272,7 +1272,7 @@ class ApplicationController < ActionController::Base
|
|||
elsif feature == :etherpad
|
||||
!!EtherpadCollaboration.config
|
||||
elsif feature == :kaltura
|
||||
!!Kaltura::ClientV3.config
|
||||
!!CanvasKaltura::ClientV3.config
|
||||
elsif feature == :web_conferences
|
||||
!!WebConference.config
|
||||
elsif feature == :scribd
|
||||
|
|
|
@ -54,9 +54,9 @@ class ContextController < ApplicationController
|
|||
def media_object_redirect
|
||||
mo = MediaObject.by_media_id(params[:id]).first
|
||||
mo.viewed! if mo
|
||||
config = Kaltura::ClientV3.config
|
||||
config = CanvasKaltura::ClientV3.config
|
||||
if config
|
||||
redirect_to Kaltura::ClientV3.new.assetSwfUrl(params[:id])
|
||||
redirect_to CanvasKaltura::ClientV3.new.assetSwfUrl(params[:id])
|
||||
else
|
||||
render :text => t(:media_objects_not_configured, "Media Objects not configured")
|
||||
end
|
||||
|
@ -72,9 +72,9 @@ class ContextController < ApplicationController
|
|||
width = params[:width]
|
||||
height = params[:height]
|
||||
type = (params[:type].presence || 2).to_i
|
||||
config = Kaltura::ClientV3.config
|
||||
config = CanvasKaltura::ClientV3.config
|
||||
if config
|
||||
redirect_to Kaltura::ClientV3.new.thumbnail_url(mo.try(:media_id) || media_id,
|
||||
redirect_to CanvasKaltura::ClientV3.new.thumbnail_url(mo.try(:media_id) || media_id,
|
||||
:width => width,
|
||||
:height => height,
|
||||
:type => type),
|
||||
|
@ -96,7 +96,7 @@ class ContextController < ApplicationController
|
|||
request_params.each do |k, v|
|
||||
str += k.to_s + v.to_s
|
||||
end
|
||||
hash = Digest::MD5.hexdigest(Kaltura::ClientV3.config['secret_key'] + str)
|
||||
hash = Digest::MD5.hexdigest(CanvasKaltura::ClientV3.config['secret_key'] + str)
|
||||
if hash == params[:sig]
|
||||
notifications = {}
|
||||
if params[:multi_notification] != 'true'
|
||||
|
|
|
@ -44,7 +44,7 @@ class ServicesApiController < ApplicationController
|
|||
# }
|
||||
def show_kaltura_config
|
||||
if @current_user
|
||||
@kal = Kaltura::ClientV3.config
|
||||
@kal = CanvasKaltura::ClientV3.config
|
||||
response = { 'enabled' => !@kal.nil? }
|
||||
|
||||
if @kal
|
||||
|
@ -77,14 +77,14 @@ class ServicesApiController < ApplicationController
|
|||
if !@current_user
|
||||
render :json => {:errors => {:base => t('must_be_logged_in', "You must be logged in to use Kaltura")}, :logged_in => false}
|
||||
end
|
||||
client = Kaltura::ClientV3.new
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
uid = "#{@user.id}_#{@domain_root_account.id}"
|
||||
res = client.startSession(Kaltura::SessionType::USER, uid)
|
||||
res = client.startSession(CanvasKaltura::SessionType::USER, uid)
|
||||
raise "Kaltura session failed to generate" if res.match(/START_SESSION_ERROR/)
|
||||
render :json => {
|
||||
:ks => res,
|
||||
:subp_id => Kaltura::ClientV3.config['subpartner_id'],
|
||||
:partner_id => Kaltura::ClientV3.config['partner_id'],
|
||||
:subp_id => CanvasKaltura::ClientV3.config['subpartner_id'],
|
||||
:partner_id => CanvasKaltura::ClientV3.config['partner_id'],
|
||||
:uid => uid,
|
||||
:serverTime => Time.now.to_i
|
||||
}
|
||||
|
|
|
@ -1178,7 +1178,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def media_download
|
||||
asset = Kaltura::ClientV3.new.media_sources(params[:entryId]).find{|a| a[:fileExt] == params[:type] }
|
||||
asset = CanvasKaltura::ClientV3.new.media_sources(params[:entryId]).find{|a| a[:fileExt] == params[:type] }
|
||||
url = asset && asset[:url]
|
||||
if url
|
||||
if params[:redirect] == '1'
|
||||
|
|
|
@ -494,8 +494,8 @@ module ApplicationHelper
|
|||
def inst_env
|
||||
global_inst_object = { :environment => Rails.env }
|
||||
{
|
||||
:allowMediaComments => Kaltura::ClientV3.config && @context.try_rescue(:allow_media_comments?),
|
||||
:kalturaSettings => Kaltura::ClientV3.config.try(:slice, 'domain', 'resource_domain', 'rtmp_domain', 'partner_id', 'subpartner_id', 'player_ui_conf', 'player_cache_st', 'kcw_ui_conf', 'upload_ui_conf', 'max_file_size_bytes', 'do_analytics', 'use_alt_record_widget', 'hide_rte_button', 'js_uploader'),
|
||||
:allowMediaComments => CanvasKaltura::ClientV3.config && @context.try_rescue(:allow_media_comments?),
|
||||
:kalturaSettings => CanvasKaltura::ClientV3.config.try(:slice, 'domain', 'resource_domain', 'rtmp_domain', 'partner_id', 'subpartner_id', 'player_ui_conf', 'player_cache_st', 'kcw_ui_conf', 'upload_ui_conf', 'max_file_size_bytes', 'do_analytics', 'use_alt_record_widget', 'hide_rte_button', 'js_uploader'),
|
||||
:equellaEnabled => !!equella_enabled?,
|
||||
:googleAnalyticsAccount => Setting.get('google_analytics_key', nil),
|
||||
:http_status => @status,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
module KalturaHelper
|
||||
|
||||
def append_sis_data(js_hash)
|
||||
if Kaltura::ClientV3.config && Kaltura::ClientV3.config['kaltura_sis'].present? && Kaltura::ClientV3.config['kaltura_sis'] == "1" && @current_user
|
||||
if CanvasKaltura::ClientV3.config && CanvasKaltura::ClientV3.config['kaltura_sis'].present? && CanvasKaltura::ClientV3.config['kaltura_sis'] == "1" && @current_user
|
||||
pseudonym = @context ? @current_user.sis_pseudonym_for(@context) : @current_user.primary_pseudonym
|
||||
js_hash[:SIS_SOURCE_ID] = @context.sis_source_id if (@context && @context.sis_source_id)
|
||||
js_hash[:SIS_USER_ID] = pseudonym.sis_user_id if (pseudonym && pseudonym.sis_user_id)
|
||||
|
|
|
@ -835,7 +835,7 @@ class Attachment < ActiveRecord::Base
|
|||
to_use = thumbnail_for_size(geometry) || self.thumbnail
|
||||
to_use.cached_s3_url
|
||||
elsif self.media_object && self.media_object.media_id
|
||||
Kaltura::ClientV3.new.thumbnail_url(self.media_object.media_id,
|
||||
CanvasKaltura::ClientV3.new.thumbnail_url(self.media_object.media_id,
|
||||
:width => options[:width] || 140,
|
||||
:height => options[:height] || 100,
|
||||
:vid_sec => options[:video_seconds] || 5)
|
||||
|
|
|
@ -61,16 +61,16 @@ class MediaObject < ActiveRecord::Base
|
|||
# upload to complete. Wrap it in a timeout if you ever want it to give up
|
||||
# waiting.
|
||||
def self.add_media_files(attachments, wait_for_completion)
|
||||
return unless Kaltura::ClientV3.config
|
||||
return unless CanvasKaltura::ClientV3.config
|
||||
attachments = Array(attachments)
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
files = []
|
||||
root_account_id = attachments.map{|a| a.root_account_id }.compact.first
|
||||
attachments.select{|a| !a.media_object }.each do |attachment|
|
||||
pseudonym = attachment.user.sis_pseudonym_for(attachment.context) if attachment.user && attachment.context.respond_to?(:root_account)
|
||||
sis_source_id, sis_user_id = "", ""
|
||||
if Kaltura::ClientV3.config['kaltura_sis'].present? && Kaltura::ClientV3.config['kaltura_sis'] == "1"
|
||||
if CanvasKaltura::ClientV3.config['kaltura_sis'].present? && CanvasKaltura::ClientV3.config['kaltura_sis'] == "1"
|
||||
sis_source_id = %Q[,"sis_source_id":"#{attachment.context.sis_source_id}"] if attachment.context.respond_to?('sis_source_id') && attachment.context.sis_source_id
|
||||
sis_user_id = %Q[,"sis_user_id":"#{pseudonym ? pseudonym.sis_user_id : ''}"] if pseudonym
|
||||
context_code = %Q[,"context_code":"#{[attachment.context_type, attachment.context_id].join('_').underscore}"]
|
||||
|
@ -110,8 +110,8 @@ class MediaObject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.bulk_migration(csv, root_account_id)
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
res = client.bulkUploadCsv(csv)
|
||||
if !res[:ready]
|
||||
MediaObject.send_later_enqueue_args(:refresh_media_files, {:run_at => 1.minute.from_now, :priority => Delayed::LOW_PRIORITY}, res[:id], [], root_account_id)
|
||||
|
@ -173,8 +173,8 @@ class MediaObject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.refresh_media_files(bulk_upload_id, attachment_ids, root_account_id, attempt=0)
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
res = client.bulkUploadGet(bulk_upload_id)
|
||||
if !res[:ready]
|
||||
if attempt < Setting.get('media_object_bulk_refresh_max_attempts', '5').to_i
|
||||
|
@ -191,8 +191,8 @@ class MediaObject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.media_id_exists?(media_id)
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
info = client.mediaGet(media_id)
|
||||
return !!info[:id]
|
||||
end
|
||||
|
@ -211,8 +211,8 @@ class MediaObject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_title_on_kaltura
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
res = client.mediaUpdate(self.media_id, :name => self.user_entered_title)
|
||||
if !res[:error]
|
||||
self.title = self.user_entered_title
|
||||
|
@ -226,7 +226,7 @@ class MediaObject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def media_sources
|
||||
Kaltura::ClientV3.new.media_sources(self.media_id)
|
||||
CanvasKaltura::ClientV3.new.media_sources(self.media_id)
|
||||
end
|
||||
|
||||
def retrieve_details_ensure_codecs(attempt=0)
|
||||
|
@ -252,8 +252,8 @@ class MediaObject < ActiveRecord::Base
|
|||
# From Kaltura, retrieve the title (if it's not already set)
|
||||
# and the list of valid flavors along with their id's.
|
||||
# Might as well confirm the media type while you're at it.
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
self.data ||= {}
|
||||
entry = client.mediaGet(self.media_id)
|
||||
if entry
|
||||
|
@ -294,8 +294,8 @@ class MediaObject < ActiveRecord::Base
|
|||
def delete_from_remote
|
||||
return unless self.media_id
|
||||
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
client.mediaDelete(self.media_id)
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</span>
|
||||
<div style="border-bottom: 1px dotted #aaa;">
|
||||
<% if comment && comment.media_comment? %>
|
||||
<% kaltura_thumbnail_url = Kaltura::ClientV3.new.thumbnail_url(comment.media_comment_id, :width => 50, :height => 35, :bgcolor => "F3F4F5") %>
|
||||
<% kaltura_thumbnail_url = CanvasKaltura::ClientV3.new.thumbnail_url(comment.media_comment_id, :width => 50, :height => 35, :bgcolor => "F3F4F5") %>
|
||||
<img src="<%= kaltura_thumbnail_url %>" style="float: right; padding-left: 3px;" alt=""/>
|
||||
<% end %>
|
||||
<b class="ellipsis"><%= recent_feedback.assignment.title %></b>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
Rails.configuration.to_prepare do
|
||||
CanvasKaltura.timeout_protector_proc = Proc.new() do |options, &block|
|
||||
Canvas.timeout_protection("kaltura", options, &block)
|
||||
end
|
||||
CanvasKaltura.logger = Rails.logger
|
||||
CanvasKaltura.cache = Rails.cache
|
||||
CanvasKaltura.plugin_settings = -> { Canvas::Plugin.find(:kaltura) }
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'canvas_sort', :path => '../canvas_sort'
|
||||
gem 'canvas_http', :path => '../canvas_http'
|
||||
gem 'canvas_uuid', :path => '../canvas_uuid'
|
||||
gem 'multipart', :path => '../multipart'
|
||||
|
||||
gemspec
|
|
@ -0,0 +1 @@
|
|||
require "bundler/gem_tasks"
|
|
@ -0,0 +1,29 @@
|
|||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "canvas_kaltura"
|
||||
spec.version = "1.0.0"
|
||||
spec.authors = ["Nick Cloward"]
|
||||
spec.email = ["ncloward@instructure.com"]
|
||||
spec.summary = %q{Canvas Kaltura}
|
||||
|
||||
spec.files = Dir.glob("{lib,spec}/**/*") + %w(test.sh)
|
||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||
spec.require_paths = ["lib"]
|
||||
|
||||
|
||||
spec.add_dependency "nokogiri", "1.5.6"
|
||||
spec.add_dependency "libxml-ruby", "2.6.0"
|
||||
spec.add_dependency "canvas_http"
|
||||
spec.add_dependency "canvas_sort"
|
||||
spec.add_dependency "multipart"
|
||||
spec.add_dependency "canvas_uuid"
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.5"
|
||||
spec.add_development_dependency "rake"
|
||||
spec.add_development_dependency "rspec"
|
||||
spec.add_development_dependency "webmock", "1.16.1"
|
||||
end
|
|
@ -0,0 +1,42 @@
|
|||
require 'canvas_http'
|
||||
require 'canvas_sort'
|
||||
|
||||
module CanvasKaltura
|
||||
require "canvas_kaltura/kaltura_client_v3"
|
||||
require "canvas_kaltura/kaltura_string_io"
|
||||
|
||||
def self.logger=(logger)
|
||||
@logger = logger
|
||||
end
|
||||
|
||||
def self.logger
|
||||
@logger
|
||||
end
|
||||
|
||||
def self.cache=(cache)
|
||||
@cache = cache
|
||||
end
|
||||
|
||||
def self.cache
|
||||
@cache
|
||||
end
|
||||
|
||||
def self.with_timeout_protector(options = {}, &block)
|
||||
@timeout_protector_proc ||= Proc.new do
|
||||
block.call
|
||||
end
|
||||
@timeout_protector_proc.call(options, &block)
|
||||
end
|
||||
|
||||
def self.timeout_protector_proc=(callable)
|
||||
@timeout_protector_proc = callable
|
||||
end
|
||||
|
||||
def self.plugin_settings=(kaltura_settings)
|
||||
@plugin_settings = kaltura_settings
|
||||
end
|
||||
|
||||
def self.plugin_settings
|
||||
@plugin_settings.call
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2011 - 2013 Instructure, Inc.
|
||||
# Copyright (C) 2011 - 2014 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
|
@ -22,10 +22,12 @@ require 'net/http'
|
|||
require 'uri'
|
||||
require 'nokogiri'
|
||||
require 'libxml'
|
||||
require 'multipart'
|
||||
|
||||
|
||||
# Test Console and API Documentation at:
|
||||
# http://www.kaltura.com/api_v3/testmeDoc/index.php
|
||||
module Kaltura
|
||||
module CanvasKaltura
|
||||
|
||||
class SessionType
|
||||
USER = 0;
|
||||
|
@ -36,7 +38,7 @@ module Kaltura
|
|||
attr_accessor :endpoint, :ks
|
||||
|
||||
def initialize
|
||||
config = Kaltura::ClientV3.config
|
||||
config = CanvasKaltura::ClientV3.config
|
||||
@host = config['domain']
|
||||
@resource_domain = config['resource_domain']
|
||||
@endpoint = config['endpoint']
|
||||
|
@ -52,7 +54,7 @@ module Kaltura
|
|||
end
|
||||
|
||||
def self.config
|
||||
res = Canvas::Plugin.find(:kaltura).try(:settings)
|
||||
res = CanvasKaltura.plugin_settings.try(:settings)
|
||||
return nil unless res && res['partner_id'] && res['subpartner_id']
|
||||
|
||||
# default settings
|
||||
|
@ -89,23 +91,26 @@ module Kaltura
|
|||
}
|
||||
|
||||
def media_sources(entryId)
|
||||
cache_key = ['media_sources2', entryId, @cache_play_list_seconds].cache_key
|
||||
sources = Rails.cache.read(cache_key)
|
||||
cache_key = ['media_sources2', entryId, @cache_play_list_seconds].join('/')
|
||||
sources = CanvasKaltura.cache.read(cache_key)
|
||||
|
||||
unless sources
|
||||
startSession(Kaltura::SessionType::ADMIN)
|
||||
startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
assets = flavorAssetGetByEntryId(entryId)
|
||||
sources = []
|
||||
all_assets_are_done_converting = true
|
||||
assets.each do |asset|
|
||||
if ASSET_STATUSES[asset[:status]] == :READY
|
||||
hash = asset.slice :containerFormat, :width, :fileExt, :size, :bitrate, :height, :isOriginal
|
||||
keys = [:containerFormat, :width, :fileExt, :size, :bitrate, :height, :isOriginal]
|
||||
hash = asset.select{|k| keys.member?(k)}
|
||||
|
||||
hash[:url] = flavorAssetGetPlaylistUrl(entryId, asset[:id])
|
||||
if hash[:content_type] = CONTENT_TYPES[asset[:fileExt]]
|
||||
hash[:url] ||= flavorAssetGetDownloadUrl(asset[:id])
|
||||
end
|
||||
|
||||
if hash[:url].blank? || hash[:content_type].blank?
|
||||
Rails.logger.warn "kaltura entry (#{entryId}) has an invalid asset (#{asset[:id]})"
|
||||
if hash[:url].nil? || hash[:url].strip.empty? || hash[:content_type].nil? || hash[:content_type].strip.empty?
|
||||
CanvasKaltura.logger.warn "kaltura entry (#{entryId}) has an invalid asset (#{asset[:id]})"
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -124,11 +129,11 @@ module Kaltura
|
|||
# only cache if all the sources are done converting
|
||||
# @cache_play_list_seconds of 0 means don't cache
|
||||
# @cache_play_list_seconds of nil means cache indefinitely
|
||||
if @cache_play_list_seconds != 0 && sources.present? && all_assets_are_done_converting
|
||||
if @cache_play_list_seconds != 0 && !sources.empty? && all_assets_are_done_converting
|
||||
if @cache_play_list_seconds
|
||||
Rails.cache.write(cache_key, sources, :expires_in => @cache_play_list_seconds)
|
||||
CanvasKaltura.cache.write(cache_key, sources, :expires_in => @cache_play_list_seconds)
|
||||
else
|
||||
Rails.cache.write(cache_key, sources)
|
||||
CanvasKaltura.cache.write(cache_key, sources)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -338,7 +343,7 @@ module Kaltura
|
|||
end
|
||||
|
||||
def assetSwfUrl(assetId)
|
||||
config = Kaltura::ClientV3.config
|
||||
config = CanvasKaltura::ClientV3.config
|
||||
return nil unless config
|
||||
"https://#{config['domain']}/kwidget/wid/_#{config['partner_id']}/uiconf_id/#{config['player_ui_conf']}/entry_id/#{assetId}"
|
||||
end
|
||||
|
@ -370,7 +375,7 @@ module Kaltura
|
|||
# the first pass
|
||||
def sendRequest(request, body=nil)
|
||||
response = nil
|
||||
Canvas.timeout_protection("kaltura", fallback_timeout_length: 30) do
|
||||
CanvasKaltura.with_timeout_protector(fallback_timeout_length: 30) do
|
||||
http = Net::HTTP.new(@host, Net::HTTP.https_default_port)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
|
@ -381,4 +386,3 @@ module Kaltura
|
|||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module Kaltura
|
||||
module CanvasKaltura
|
||||
class KalturaStringIO < StringIO
|
||||
attr_accessor :path
|
||||
|
|
@ -16,12 +16,12 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
||||
require_webmock
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Kaltura::ClientV3" do
|
||||
describe CanvasKaltura::ClientV3 do
|
||||
def create_config(opts={})
|
||||
Kaltura::ClientV3.stubs(:config).returns({
|
||||
CanvasKaltura::ClientV3.stub(:config) {
|
||||
{
|
||||
'domain' => 'www.instructuremedia.com',
|
||||
'resource_domain' => 'www.instructuremedia.com',
|
||||
'partner_id' => '100',
|
||||
|
@ -30,10 +30,10 @@ describe "Kaltura::ClientV3" do
|
|||
'user_secret_key' => '1234821hrj3k21hjk4j3kl21j4kl321j4kl3j21kl4j3k2l1',
|
||||
'player_ui_conf' => '1',
|
||||
'kcw_ui_conf' => '1',
|
||||
'upload_ui_conf' => '1'
|
||||
}.merge(opts))
|
||||
'upload_ui_conf' => '1'}.merge(opts)
|
||||
}
|
||||
|
||||
@kaltura = Kaltura::ClientV3.new
|
||||
@kaltura = CanvasKaltura::ClientV3.new
|
||||
end
|
||||
|
||||
include WebMock::API
|
||||
|
@ -49,117 +49,79 @@ describe "Kaltura::ClientV3" do
|
|||
end
|
||||
|
||||
before(:each) do
|
||||
CanvasKaltura.cache = double(read: nil)
|
||||
CanvasKaltura.logger = double.as_null_object
|
||||
CanvasKaltura.timeout_protector_proc = lambda { |options, &block| block.call }
|
||||
create_config
|
||||
WebMock.enable!
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
WebMock.reset!
|
||||
WebMock.disable!
|
||||
end
|
||||
|
||||
describe 'thumbnail_url' do
|
||||
it "should properly sanitize thumbnail parameters" do
|
||||
@kaltura.thumbnail_url('0_123<evil>', :width => 'evilwidth',
|
||||
:height => 'evilheight', :type => 'eviltype', :bgcolor => 'evilcolor',
|
||||
:vid_sec => 'evilsec').should ==
|
||||
"https://www.instructuremedia.com/p/100/thumbnail/entry_id/0_123evil/width/0/height/0/bgcolor/ec/type/0/vid_sec/0"
|
||||
url = @kaltura.thumbnail_url('0_123<evil>', {
|
||||
:width => 'evilwidth',
|
||||
:height => 'evilheight',
|
||||
:type => 'eviltype',
|
||||
:bgcolor => 'evilcolor',
|
||||
:vid_sec => 'evilsec'
|
||||
})
|
||||
expect(url).to eq "https://www.instructuremedia.com/p/100/thumbnail/entry_id/0_123evil/width/0/height/0/bgcolor/ec/type/0/vid_sec/0"
|
||||
end
|
||||
end
|
||||
|
||||
describe "sort_source_list" do
|
||||
it "should work on an empty array" do
|
||||
@kaltura.sort_source_list([]).should == []
|
||||
expect(@kaltura.sort_source_list([])).to be_empty
|
||||
end
|
||||
|
||||
it "should work with an empty file extension" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => '', :bitrate => '128'}
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => '', :bitrate => '128'}
|
||||
]
|
||||
file_info = [{:fileExt => '', :bitrate => '128'}]
|
||||
expect(@kaltura.sort_source_list(file_info)).to eq file_info
|
||||
end
|
||||
|
||||
it "should sort bitrates properly as numbers, and not as strings" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '2'},
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
{:fileExt => 'mp4', :bitrate => '2'},
|
||||
]
|
||||
file_info1 = {:fileExt => 'mp4', :bitrate => '2'}
|
||||
file_info2 = {:fileExt => 'mp4', :bitrate => '100'}
|
||||
expect(@kaltura.sort_source_list([file_info1, file_info2])).to eq [file_info2, file_info1]
|
||||
end
|
||||
|
||||
it "should work with unknown file types, and sort them last" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'unknown', :bitrate => '100'},
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
{:fileExt => 'unknown', :bitrate => '100'},
|
||||
]
|
||||
file_info1 = {:fileExt => 'unknown', :bitrate => '100'}
|
||||
file_info2 = {:fileExt => 'mp4', :bitrate => '100'}
|
||||
expect(@kaltura.sort_source_list([file_info1, file_info2])).to eq [file_info2, file_info1]
|
||||
end
|
||||
|
||||
it "should sort by preferred file types" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'flv', :bitrate => '100'},
|
||||
{:fileExt => 'mp3', :bitrate => '100'},
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '100'},
|
||||
{:fileExt => 'mp3', :bitrate => '100'},
|
||||
{:fileExt => 'flv', :bitrate => '100'},
|
||||
]
|
||||
file_info1 = {:fileExt => 'flv', :bitrate => '100'}
|
||||
file_info2 = {:fileExt => 'mp3', :bitrate => '100'}
|
||||
file_info3 = {:fileExt => 'mp4', :bitrate => '100'}
|
||||
expect(@kaltura.sort_source_list([file_info1, file_info2, file_info3])).to eq [file_info3, file_info2, file_info1]
|
||||
end
|
||||
|
||||
it "should prefer converted assets to the original" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
]
|
||||
file_info1 = {:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'}
|
||||
file_info2 = {:fileExt => 'flv', :bitrate => '100', :isOriginal => '0'}
|
||||
file_info3 = {:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'}
|
||||
file_info4 = {:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'}
|
||||
expect(@kaltura.sort_source_list([file_info1, file_info2, file_info3, file_info4])).to eq [file_info4, file_info3, file_info2, file_info1]
|
||||
end
|
||||
|
||||
it "should prefer assets without conversion warnings" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
]
|
||||
file_info1 = {:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'}
|
||||
file_info2 = {:fileExt => 'flv', :bitrate => '100', :isOriginal => '0', :hasWarnings => true}
|
||||
file_info3 = {:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0'}
|
||||
file_info4 = {:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0'}
|
||||
expect(@kaltura.sort_source_list([file_info1, file_info2, file_info3, file_info4])).to eq [file_info4, file_info3, file_info2.delete_if{|k| k == :hasWarnings}, file_info1]
|
||||
end
|
||||
|
||||
it "should prefer assets with conversion warnings over original" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
]).first[:isOriginal].should_not == '1'
|
||||
file_list = [
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '1'},
|
||||
{:fileExt => 'flv', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
{:fileExt => 'mp3', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
]
|
||||
expect(@kaltura.sort_source_list(file_list).first[:isOriginal]).to_not eq '1'
|
||||
end
|
||||
|
||||
it "should sort by descending bitrate but deprioritize sources with suspiciously high bitrates" do
|
||||
|
@ -188,66 +150,65 @@ describe "Kaltura::ClientV3" do
|
|||
def create_config_with_mock(seconds)
|
||||
create_config('cache_play_list_seconds' => seconds)
|
||||
@source = {:content_type => "video/mp4", :containerFormat => "isom", :url => "https://kaltura.example.com/url", :fileExt=>"mp4"}
|
||||
@kaltura.expects(:flavorAssetGetByEntryId).returns([@source.merge({:status => '2'})])
|
||||
@kaltura.expects(:flavorAssetGetPlaylistUrl).returns("https://kaltura.example.com/url")
|
||||
expect(@kaltura).to receive(:flavorAssetGetByEntryId) { [@source.merge({:status => '2'})] }
|
||||
expect(@kaltura).to receive(:flavorAssetGetPlaylistUrl) { "https://kaltura.example.com/url" }
|
||||
end
|
||||
|
||||
it "should not cache" do
|
||||
enable_cache do
|
||||
create_config_with_mock(0)
|
||||
@kaltura.media_sources('hi')
|
||||
Rails.cache.read(['media_sources2', 'hi', 0].cache_key).should be_nil
|
||||
end
|
||||
create_config_with_mock(0)
|
||||
expect(CanvasKaltura.cache).to_not receive(:write)
|
||||
@kaltura.media_sources('hi')
|
||||
end
|
||||
|
||||
it "should cache for set length" do
|
||||
create_config_with_mock(2)
|
||||
m = mock()
|
||||
m.expects(:write).with(['media_sources2', 'hi', 2].cache_key, [@source], {:expires_in => 2})
|
||||
m.expects(:read)
|
||||
Rails.stubs(:cache).returns(m)
|
||||
m = double()
|
||||
expect(m).to receive(:write).with(['media_sources2', 'hi', 2].join('/'), [@source], {:expires_in => 2})
|
||||
expect(m).to receive(:read)
|
||||
allow(CanvasKaltura).to receive(:cache) { m }
|
||||
@kaltura.media_sources('hi')
|
||||
end
|
||||
|
||||
it "should cache indefinitely" do
|
||||
create_config_with_mock(nil)
|
||||
m = mock()
|
||||
m.expects(:write).with(['media_sources2', 'hi', nil].cache_key, [@source])
|
||||
m.expects(:read)
|
||||
Rails.stubs(:cache).returns(m)
|
||||
@kaltura.media_sources('hi') end
|
||||
m = double()
|
||||
expect(m).to receive(:write).with(['media_sources2', 'hi', nil].join('/'), [@source])
|
||||
expect(m).to receive(:read)
|
||||
allow(CanvasKaltura).to receive(:cache) { m }
|
||||
@kaltura.media_sources('hi')
|
||||
end
|
||||
end
|
||||
|
||||
it "should skip empty urls" do
|
||||
create_config
|
||||
@source = {:content_type => "video/mp4", :containerFormat => "isom", :url => nil, :fileExt => "mp4", :status => '2', :id => "1"}
|
||||
@kaltura.expects(:flavorAssetGetByEntryId).returns([@source, @source.merge({:fileExt => "wav", :id => '2'})])
|
||||
@kaltura.stubs(:flavorAssetGetPlaylistUrl)
|
||||
@kaltura.stubs(:flavorAssetGetDownloadUrl)
|
||||
expect(@kaltura).to receive(:flavorAssetGetByEntryId) {[@source, @source.merge({:fileExt => "wav", :id => '2'})]}
|
||||
allow(@kaltura).to receive(:flavorAssetGetPlaylistUrl)
|
||||
allow(@kaltura).to receive(:flavorAssetGetDownloadUrl)
|
||||
|
||||
res = @kaltura.media_sources('hi')
|
||||
res.should == []
|
||||
expect(res).to be_empty
|
||||
end
|
||||
|
||||
it "should skip unknown types" do
|
||||
create_config
|
||||
@source = {:content_type => "video/mp4", :containerFormat => "isom", :url => nil, :fileExt => "wav", :status => '2', :id => "1"}
|
||||
@kaltura.expects(:flavorAssetGetByEntryId).returns([@source])
|
||||
@kaltura.stubs(:flavorAssetGetPlaylistUrl)
|
||||
expect(@kaltura).to receive(:flavorAssetGetByEntryId) { [@source] }
|
||||
allow(@kaltura).to receive(:flavorAssetGetPlaylistUrl)
|
||||
|
||||
res = @kaltura.media_sources('hi')
|
||||
res.should == []
|
||||
expect(res).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "startSession" do
|
||||
it "should send Kaltura a request with proper parameters for a user" do
|
||||
user_id = 12345
|
||||
session_type = Kaltura::SessionType::USER
|
||||
session_type = CanvasKaltura::SessionType::USER
|
||||
|
||||
kaltura_stub = stub_kaltura_session(
|
||||
:params => {
|
||||
:secret => Kaltura::ClientV3.config['user_secret_key'],
|
||||
:secret => CanvasKaltura::ClientV3.config['user_secret_key'],
|
||||
:partnerId => '100',
|
||||
:userId => user_id.to_s,
|
||||
:type => session_type.to_s
|
||||
|
@ -256,15 +217,15 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
@kaltura.startSession(session_type, user_id)
|
||||
|
||||
kaltura_stub.should have_been_requested
|
||||
expect(kaltura_stub).to have_been_requested
|
||||
end
|
||||
|
||||
it "should send Kaltura a request with proper parameters for an admin" do
|
||||
session_type = Kaltura::SessionType::ADMIN
|
||||
session_type = CanvasKaltura::SessionType::ADMIN
|
||||
|
||||
kaltura_stub = stub_kaltura_session(
|
||||
:params => {
|
||||
:secret => Kaltura::ClientV3.config['secret_key'],
|
||||
:secret => CanvasKaltura::ClientV3.config['secret_key'],
|
||||
:partnerId => '100',
|
||||
:type => session_type.to_s
|
||||
}
|
||||
|
@ -272,16 +233,16 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
@kaltura.startSession(session_type)
|
||||
|
||||
kaltura_stub.should have_been_requested
|
||||
expect(kaltura_stub).to have_been_requested
|
||||
end
|
||||
|
||||
it "should set ks properly" do
|
||||
session_type = Kaltura::SessionType::USER
|
||||
session_type = CanvasKaltura::SessionType::USER
|
||||
|
||||
stub_kaltura_session(
|
||||
:ks => 'ks_from_kaltura',
|
||||
:params => {
|
||||
:secret => Kaltura::ClientV3.config['user_secret_key'],
|
||||
:secret => CanvasKaltura::ClientV3.config['user_secret_key'],
|
||||
:partnerId => '100',
|
||||
:type => session_type.to_s
|
||||
}
|
||||
|
@ -289,7 +250,7 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
@kaltura.startSession
|
||||
|
||||
@kaltura.ks.should == 'ks_from_kaltura'
|
||||
expect(@kaltura.ks).to eq 'ks_from_kaltura'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -297,16 +258,16 @@ describe "Kaltura::ClientV3" do
|
|||
it "should call getRequest with proper parameters" do
|
||||
entry_id = 12345
|
||||
|
||||
@kaltura.expects(:getRequest).with(
|
||||
expect(@kaltura).to receive(:getRequest).with(
|
||||
:media, :get, {:ks => nil, :entryId => entry_id}
|
||||
).returns(stub(:children => []))
|
||||
).and_return(double(:children => []))
|
||||
|
||||
@kaltura.mediaGet(entry_id)
|
||||
end
|
||||
|
||||
it "should properly create an items hash" do
|
||||
media_name = "Movie on 1-31-13 at 7.27 PM.mov"
|
||||
@kaltura.stubs(:getRequest).returns(Nokogiri::XML("<name>#{media_name}</name>"))
|
||||
allow(@kaltura).to receive(:getRequest) { Nokogiri::XML("<name>#{media_name}</name>") }
|
||||
|
||||
media_info = @kaltura.mediaGet(0)
|
||||
|
||||
|
@ -317,19 +278,19 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
describe "mediaUpdate" do
|
||||
it "should call getRequest with proper parameters" do
|
||||
@kaltura.expects(:getRequest).with(
|
||||
expect(@kaltura).to receive(:getRequest).with(
|
||||
:media, :update, {
|
||||
:ks => nil,
|
||||
:entryId => 12345,
|
||||
'mediaEntry:key' => 'value'
|
||||
}).returns(stub(:children => []))
|
||||
}).and_return(double(:children => []))
|
||||
|
||||
@kaltura.mediaUpdate(12345, {"key" => "value"})
|
||||
end
|
||||
|
||||
it "should return a properly formatted item" do
|
||||
media_name = "Movie on 2-31-13 at 7.27 PM.mov"
|
||||
@kaltura.stubs(:getRequest).returns(Nokogiri::XML("<name>#{media_name}</name>"))
|
||||
allow(@kaltura).to receive(:getRequest) { Nokogiri::XML("<name>#{media_name}</name>") }
|
||||
|
||||
media_info = @kaltura.mediaUpdate(0,{})
|
||||
|
||||
|
@ -339,7 +300,7 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
describe "mediaDelete" do
|
||||
it "should call getRequest with proper parameters" do
|
||||
@kaltura.expects(:getRequest).with(
|
||||
expect(@kaltura).to receive(:getRequest).with(
|
||||
:media, :delete, {:ks => nil, :entryId => 12345}
|
||||
)
|
||||
|
||||
|
@ -353,11 +314,11 @@ describe "Kaltura::ClientV3" do
|
|||
img = @kaltura.mediaTypeToSymbol(2)
|
||||
aud = @kaltura.mediaTypeToSymbol(5)
|
||||
|
||||
[vid,img,aud].should == [:video,:image,:audio]
|
||||
expect([vid,img,aud]).to eq [:video,:image,:audio]
|
||||
end
|
||||
|
||||
it "should default to video" do
|
||||
@kaltura.mediaTypeToSymbol(rand(10)+6).should == :video
|
||||
expect(@kaltura.mediaTypeToSymbol(rand(10)+6)).to eq :video
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -385,9 +346,9 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
bulk_upload_result = @kaltura.bulkUploadGet(bulk_upload_id)
|
||||
|
||||
bulk_upload_result[:id].should == bulk_upload_id.to_s
|
||||
bulk_upload_result[:status].should == status.to_s
|
||||
bulk_upload_result[:entries].should == [{
|
||||
expect(bulk_upload_result[:id]).to eq bulk_upload_id.to_s
|
||||
expect(bulk_upload_result[:status]).to eq status.to_s
|
||||
expect(bulk_upload_result[:entries]).to eq [{
|
||||
:name => name,
|
||||
:entryId => entryId,
|
||||
:originalId => originalId
|
||||
|
@ -414,13 +375,13 @@ describe "Kaltura::ClientV3" do
|
|||
|
||||
parsed_bulk_upload = @kaltura.bulkUploadCsv("csv,data,with,bulk,upload,info")
|
||||
|
||||
bulk_upload_add_stub.should have_been_requested
|
||||
log_file_stub.should have_been_requested
|
||||
expect(bulk_upload_add_stub).to have_been_requested
|
||||
expect(log_file_stub).to have_been_requested
|
||||
|
||||
parsed_bulk_upload[:id ].should == 'batch_job_12345'
|
||||
parsed_bulk_upload[:status ].should == 'ready'
|
||||
parsed_bulk_upload[:ready ].should == true
|
||||
parsed_bulk_upload[:entries ].should == [{:name => 'aName', :entryId => 'anEntryId', :originalId => 'anOriginalId'} ]
|
||||
expect(parsed_bulk_upload[:id]).to eq 'batch_job_12345'
|
||||
expect(parsed_bulk_upload[:status]).to eq 'ready'
|
||||
expect(parsed_bulk_upload[:ready]).to eq true
|
||||
expect(parsed_bulk_upload[:entries]).to eq [{:name => 'aName', :entryId => 'anEntryId', :originalId => 'anOriginalId'}]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -435,7 +396,7 @@ describe "Kaltura::ClientV3" do
|
|||
:url => "the_url"
|
||||
}]
|
||||
|
||||
@kaltura.expects(:bulkUploadCsv).with(
|
||||
expect(@kaltura).to receive(:bulkUploadCsv).with(
|
||||
%Q[the_name,the_desc,the_tags,the_url,the_media_type,"","","","","","",the_partner_data\n]
|
||||
)
|
||||
|
||||
|
@ -450,10 +411,10 @@ describe "Kaltura::ClientV3" do
|
|||
"partner_id" => "partner_id",
|
||||
"player_ui_conf" => "player_ui_conf"
|
||||
}
|
||||
Kaltura::ClientV3.stubs(:config).returns(config_result)
|
||||
allow(CanvasKaltura::ClientV3).to receive(:config) { config_result }
|
||||
|
||||
entry_id = "f_73gebd8"
|
||||
@kaltura.assetSwfUrl(entry_id).should == "https://domain/kwidget/wid/_partner_id/uiconf_id/player_ui_conf/entry_id/#{entry_id}"
|
||||
expect(@kaltura.assetSwfUrl(entry_id)).to eq "https://domain/kwidget/wid/_partner_id/uiconf_id/player_ui_conf/entry_id/#{entry_id}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -472,7 +433,7 @@ describe "Kaltura::ClientV3" do
|
|||
</manifest>
|
||||
XML
|
||||
|
||||
@kaltura.flavorAssetGetPlaylistUrl(entry_id, flavor_id).should == media_url
|
||||
expect(@kaltura.flavorAssetGetPlaylistUrl(entry_id, flavor_id)).to eq media_url
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,11 +16,11 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
||||
require 'spec_helper'
|
||||
|
||||
describe Kaltura::KalturaStringIO do
|
||||
describe CanvasKaltura::KalturaStringIO do
|
||||
it "should set path" do
|
||||
io = Kaltura::KalturaStringIO.new("hey there", "custom_path.csv")
|
||||
io = CanvasKaltura::KalturaStringIO.new("hey there", "custom_path.csv")
|
||||
io.path.should == "custom_path.csv"
|
||||
end
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe CanvasKaltura do
|
||||
context ".timeout_protector" do
|
||||
it "call block if not set" do
|
||||
CanvasKaltura.timeout_protector_proc = nil
|
||||
expect(CanvasKaltura.with_timeout_protector { 2 }).to be 2
|
||||
end
|
||||
|
||||
it "call timeout protector if set" do
|
||||
CanvasKaltura.timeout_protector_proc = lambda { |options, &block| 27 }
|
||||
expect(CanvasKaltura.with_timeout_protector).to be 27
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
require 'canvas_kaltura'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.treat_symbols_as_metadata_keys_with_true_values = true
|
||||
config.run_all_when_everything_filtered = true
|
||||
config.filter_run :focus
|
||||
config.color_enabled = true
|
||||
config.order = 'random'
|
||||
end
|
||||
|
||||
require 'webmock/rspec'
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
result=0
|
||||
|
||||
bundle install
|
||||
bundle exec rspec spec
|
||||
let result=$result+$?
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
echo "SUCCESS"
|
||||
else
|
||||
echo "FAILURE"
|
||||
fi
|
||||
|
||||
exit $result
|
|
@ -289,8 +289,8 @@ module CCHelper
|
|||
|
||||
def self.media_object_info(obj, client = nil, flavor = nil)
|
||||
unless client
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
end
|
||||
if flavor
|
||||
assets = client.flavorAssetGetByEntryId(obj.media_id)
|
||||
|
|
|
@ -160,7 +160,7 @@ module CC
|
|||
MAX_MEDIA_OBJECT_SIZE = 4.gigabytes
|
||||
def add_media_objects(html_content_exporter)
|
||||
return if for_course_copy
|
||||
return unless Kaltura::ClientV3.config
|
||||
return unless CanvasKaltura::ClientV3.config
|
||||
|
||||
# check to make sure we don't export more than 4 gigabytes of media objects
|
||||
total_size = 0
|
||||
|
@ -178,8 +178,8 @@ module CC
|
|||
return
|
||||
end
|
||||
|
||||
client = Kaltura::ClientV3.new
|
||||
client.startSession(Kaltura::SessionType::ADMIN)
|
||||
client = CanvasKaltura::ClientV3.new
|
||||
client.startSession(CanvasKaltura::SessionType::ADMIN)
|
||||
|
||||
tracks = {}
|
||||
html_content_exporter.used_media_objects.each do |obj|
|
||||
|
@ -189,8 +189,8 @@ module CC
|
|||
info = html_content_exporter.media_object_infos[obj.id]
|
||||
next unless info && info[:asset]
|
||||
|
||||
unless Kaltura::ClientV3::ASSET_STATUSES[info[:asset][:status]] == :READY &&
|
||||
url = (client.flavorAssetGetPlaylistUrl(obj.media_id, info[:asset][:id]) || client.flavorAssetGetDownloadUrl(info[:asset][:id]))
|
||||
unless CanvasKaltura::ClientV3::ASSET_STATUSES[info[:asset][:status]] == :READY &&
|
||||
url = (client.flavorAssetGetPlaylistUrl(obj.media_id, info[:asset][:id]) || client.flavorAssetGetDownloadUrl(info[:asset][:id]))
|
||||
add_error(I18n.t('course_exports.errors.media_file', "A media file failed to export"))
|
||||
next
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../api_spec_helper')
|
|||
describe "Services API", type: :request do
|
||||
before do
|
||||
user_with_pseudonym(:active_all => true)
|
||||
@kal = mock('Kaltura::ClientV3')
|
||||
Kaltura::ClientV3.stubs(:config).returns({
|
||||
@kal = mock('CanvasKaltura::ClientV3')
|
||||
CanvasKaltura::ClientV3.stubs(:config).returns({
|
||||
'domain' => 'kaltura.fake.local',
|
||||
'resource_domain' => 'cdn.kaltura.fake.local',
|
||||
'rtmp_domain' => 'rtmp-kaltura.fake.local',
|
||||
|
@ -48,7 +48,7 @@ describe "Services API", type: :request do
|
|||
end
|
||||
|
||||
it "should degrade gracefully if kaltura is disabled or not configured" do
|
||||
Kaltura::ClientV3.stubs(:config).returns(nil)
|
||||
CanvasKaltura::ClientV3.stubs(:config).returns(nil)
|
||||
json = api_call(:get, "/api/v1/services/kaltura",
|
||||
:controller => "services_api", :action => "show_kaltura_config", :format => "json")
|
||||
json.should == {
|
||||
|
@ -58,9 +58,9 @@ describe "Services API", type: :request do
|
|||
|
||||
it "should return a new kaltura session" do
|
||||
stub_kaltura
|
||||
kal = mock('Kaltura::ClientV3')
|
||||
kal = mock('CanvasKaltura::ClientV3')
|
||||
kal.expects(:startSession).returns "new_session_id_here"
|
||||
Kaltura::ClientV3.stubs(:new).returns(kal)
|
||||
CanvasKaltura::ClientV3.stubs(:new).returns(kal)
|
||||
json = api_call(:post, "/api/v1/services/kaltura_session",
|
||||
:controller => "services_api", :action => "start_kaltura_session", :format => "json")
|
||||
json.delete_if { |k,v| %w(serverTime).include?(k) }.should == {
|
||||
|
|
|
@ -619,8 +619,8 @@ describe 'Submissions API', type: :request do
|
|||
@course.enroll_student(student1).accept!
|
||||
a1 = @course.assignments.create!(:title => 'assignment1', :grading_type => 'letter_grade', :points_possible => 15)
|
||||
media_object(:media_id => "54321", :context => student1, :user => student1)
|
||||
mock_kaltura = mock('Kaltura::ClientV3')
|
||||
Kaltura::ClientV3.stubs(:new).returns(mock_kaltura)
|
||||
mock_kaltura = mock('CanvasKaltura::ClientV3')
|
||||
CanvasKaltura::ClientV3.stubs(:new).returns(mock_kaltura)
|
||||
mock_kaltura.expects(:media_sources).returns([{:height => "240", :bitrate => "382", :isOriginal => "0", :width => "336", :content_type => "video/mp4",
|
||||
:containerFormat => "isom", :url => "https://kaltura.example.com/some/url", :size =>"204", :fileExt=>"mp4"}])
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ describe ContextController do
|
|||
|
||||
describe "GET '/media_objects/:id/thumbnail" do
|
||||
it "should redirect to kaltura even if the MediaObject does not exist" do
|
||||
Kaltura::ClientV3.stubs(:config).returns({})
|
||||
Kaltura::ClientV3.any_instance.expects(:thumbnail_url).returns("http://example.com/thumbnail_redirect")
|
||||
CanvasKaltura::ClientV3.stubs(:config).returns({})
|
||||
CanvasKaltura::ClientV3.any_instance.expects(:thumbnail_url).returns("http://example.com/thumbnail_redirect")
|
||||
get :media_object_thumbnail,
|
||||
:id => '0_notexist',
|
||||
:width => 100,
|
||||
|
|
|
@ -407,8 +407,8 @@ describe "Common Cartridge exporting" do
|
|||
|
||||
it "should export media tracks" do
|
||||
stub_kaltura
|
||||
Kaltura::ClientV3.any_instance.stubs(:startSession)
|
||||
Kaltura::ClientV3.any_instance.stubs(:flavorAssetGetPlaylistUrl).returns(Tempfile.new('blah.flv'))
|
||||
CanvasKaltura::ClientV3.any_instance.stubs(:startSession)
|
||||
CanvasKaltura::ClientV3.any_instance.stubs(:flavorAssetGetPlaylistUrl).returns(Tempfile.new('blah.flv'))
|
||||
CC::CCHelper.stubs(:media_object_info).returns({asset: {id: 1, status: '2'}, filename: 'blah.flv'})
|
||||
obj = @course.media_objects.create! media_id: '0_deadbeef'
|
||||
track = obj.media_tracks.create! kind: 'subtitles', locale: 'tlh', content: "Hab SoSlI' Quch!"
|
||||
|
|
|
@ -4,8 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/cc_spec_helper')
|
|||
describe CC::CCHelper do
|
||||
describe CC::CCHelper::HtmlContentExporter do
|
||||
before do
|
||||
@kaltura = mock('Kaltura::ClientV3')
|
||||
Kaltura::ClientV3.stubs(:new).returns(@kaltura)
|
||||
@kaltura = mock('CanvasKaltura::ClientV3')
|
||||
CanvasKaltura::ClientV3.stubs(:new).returns(@kaltura)
|
||||
@kaltura.stubs(:startSession)
|
||||
@kaltura.stubs(:flavorAssetGetByEntryId).with('abcde').returns([
|
||||
{
|
||||
|
|
|
@ -156,8 +156,8 @@ describe MediaObject do
|
|||
stub_kaltura
|
||||
user
|
||||
attachment_obj_with_context(@user, user: @user)
|
||||
Kaltura::ClientV3.any_instance.stubs(:startSession).returns(nil)
|
||||
Kaltura::ClientV3.any_instance.stubs(:bulkUploadAdd).returns({})
|
||||
CanvasKaltura::ClientV3.any_instance.stubs(:startSession).returns(nil)
|
||||
CanvasKaltura::ClientV3.any_instance.stubs(:bulkUploadAdd).returns({})
|
||||
MediaObject.add_media_files(@attachment, false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -695,7 +695,7 @@ shared_examples_for "all selenium tests" do
|
|||
|
||||
def stub_kaltura
|
||||
# trick kaltura into being activated
|
||||
Kaltura::ClientV3.stubs(:config).returns({
|
||||
CanvasKaltura::ClientV3.stubs(:config).returns({
|
||||
'domain' => 'www.instructuremedia.com',
|
||||
'resource_domain' => 'www.instructuremedia.com',
|
||||
'partner_id' => '100',
|
||||
|
@ -706,9 +706,9 @@ shared_examples_for "all selenium tests" do
|
|||
'kcw_ui_conf' => '1',
|
||||
'upload_ui_conf' => '1'
|
||||
})
|
||||
kal = mock('Kaltura::ClientV3')
|
||||
kal = mock('CanvasKaltura::ClientV3')
|
||||
kal.stubs(:startSession).returns "new_session_id_here"
|
||||
Kaltura::ClientV3.stubs(:new).returns(kal)
|
||||
CanvasKaltura::ClientV3.stubs(:new).returns(kal)
|
||||
end
|
||||
|
||||
def page_view(opts={})
|
||||
|
|
|
@ -221,7 +221,7 @@ describe "conversations" do
|
|||
context "media comments" do
|
||||
it "should add audio and video comments to the message form" do
|
||||
# don't have a good way to test kaltura here, so we just fake it up
|
||||
Kaltura::ClientV3.expects(:config).at_least(1).returns({})
|
||||
CanvasKaltura::ClientV3.expects(:config).at_least(1).returns({})
|
||||
|
||||
['audio', 'video'].each_with_index do |media_comment_type, index|
|
||||
mo = MediaObject.new
|
||||
|
|
|
@ -1108,7 +1108,7 @@ end
|
|||
|
||||
def stub_kaltura
|
||||
# trick kaltura into being activated
|
||||
Kaltura::ClientV3.stubs(:config).returns({
|
||||
CanvasKaltura::ClientV3.stubs(:config).returns({
|
||||
'domain' => 'kaltura.example.com',
|
||||
'resource_domain' => 'kaltura.example.com',
|
||||
'partner_id' => '100',
|
||||
|
|
Loading…
Reference in New Issue