gemify respondus_soap_endpoint
This turns the vendor/plugin into a rails engine, and establishes the convention of canvas-dependent rails engines/gems going into gems/plugins, and everything in that dir being auto-required and added to canvas spec runs. closes CNVS-14286 test plan: regression test on the respondus quiz builder client. no behavior should change. Change-Id: I51b548418bcb70af77e87c2c2d62cac27ed4ab44 Reviewed-on: https://gerrit.instructure.com/38394 Tested-by: Jenkins <jenkins@instructure.com> QA-Review: August Thornton <august@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
5e53eb3a33
commit
b55992e8ac
|
@ -0,0 +1,3 @@
|
|||
Dir["gems/plugins/*"].each do |plugin_dir|
|
||||
gem(File.basename(plugin_dir), path: plugin_dir)
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
# Declare your gem's dependencies in respondus_soap_endpoint.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
|
@ -0,0 +1,10 @@
|
|||
require 'soap4r-middleware'
|
||||
|
||||
require 'respondus_soap_endpoint/engine'
|
||||
require 'respondus_soap_endpoint/middleware'
|
||||
require 'respondus_soap_endpoint/api_port'
|
||||
require 'respondus_soap_endpoint/urn:RespondusAPIMappingRegistry.rb'
|
||||
require 'respondus_soap_endpoint/urn:RespondusAPIServant.rb'
|
||||
|
||||
module RespondusSoapEndpoint
|
||||
end
|
|
@ -1,6 +1,4 @@
|
|||
require_dependency 'urn:RespondusAPIServant.rb'
|
||||
require_dependency 'urn:RespondusAPIMappingRegistry.rb'
|
||||
|
||||
module RespondusSoapEndpoint
|
||||
class RespondusAPIPort
|
||||
NsRespondusAPI = "urn:RespondusAPI"
|
||||
|
||||
|
@ -210,3 +208,4 @@ class RespondusAPIPort
|
|||
]
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
module RespondusSoapEndpoint
|
||||
class Railtie < ::Rails::Engine
|
||||
initializer "respondus_soap_endpoint.canvas_plugin" do |app|
|
||||
require 'respondus_soap_endpoint/plugin_validator'
|
||||
Canvas::Plugin.register :respondus_soap_endpoint, nil, {
|
||||
name: ->{ t :name, 'Respondus SOAP Endpoint' },
|
||||
author: 'instructure',
|
||||
author_website: 'http://www.instructure.com',
|
||||
description: ->{ t :description, 'SOAP Endpoint for Respondus QTI uploads' },
|
||||
version: RespondusSoapEndpoint::VERSION,
|
||||
settings_partial: 'respondus_soap_endpoint/plugin_settings',
|
||||
settings: {
|
||||
enabled: false,
|
||||
worker: 'QtiWorker',
|
||||
},
|
||||
validator: 'RespondusSoapEndpointPluginValidator',
|
||||
}
|
||||
end
|
||||
|
||||
initializer "respondus_soap_endpoint.middleware" do |app|
|
||||
app.middleware.use 'RespondusSoapEndpoint::Middleware'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
class RespondusAPIMiddleware
|
||||
module RespondusSoapEndpoint
|
||||
class Middleware
|
||||
class_attribute :servant
|
||||
|
||||
Endpoint = %r{\A/api/respondus/soap}
|
||||
|
@ -31,7 +32,7 @@ class RespondusAPIMiddleware
|
|||
remove_method :call # we'll just use soap4r-middleware's
|
||||
Bundler.require 'respondus_soap_endpoint'
|
||||
include Soap4r::Middleware
|
||||
require_dependency 'respondus_soap_endpoint'
|
||||
require 'respondus_soap_endpoint'
|
||||
setup do
|
||||
self.endpoint = Endpoint
|
||||
self.servant = RespondusAPIPort.new
|
||||
|
@ -66,3 +67,4 @@ class RespondusAPIMiddleware
|
|||
super(env)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
require 'urn:RespondusAPI.rb'
|
||||
require 'respondus_soap_endpoint/urn:RespondusAPI.rb'
|
||||
require 'soap/mapping'
|
||||
|
||||
module UrnRespondusAPIMappingRegistry
|
|
@ -1,6 +1,7 @@
|
|||
require_dependency 'urn:RespondusAPI.rb'
|
||||
require 'respondus_soap_endpoint/urn:RespondusAPI.rb'
|
||||
require 'benchmark'
|
||||
|
||||
module RespondusSoapEndpoint
|
||||
class RespondusAPIPort
|
||||
attr_reader :session, :user
|
||||
attr_accessor :rack_env
|
||||
|
@ -48,7 +49,7 @@ class RespondusAPIPort
|
|||
def load_session(context)
|
||||
@verifier = ActiveSupport::MessageVerifier.new(
|
||||
Canvas::Security.encryption_key,
|
||||
'SHA1')
|
||||
digest: 'SHA1')
|
||||
if context.blank?
|
||||
@session = {}
|
||||
else
|
||||
|
@ -87,8 +88,6 @@ class RespondusAPIPort
|
|||
return load_user_with_oauth(password, domain_root_account)
|
||||
end
|
||||
|
||||
ip = rack_env['REMOTE_ADDR']
|
||||
|
||||
Authlogic::Session::Base.controller = AuthlogicAdapter.new(self)
|
||||
pseudonym_session = domain_root_account.pseudonym_sessions.new(:unique_id => userName, :password => password)
|
||||
pseudonym_session.remote_ip = request.remote_ip
|
||||
|
@ -592,3 +591,4 @@ Implemented for: Canvas LMS}]
|
|||
[ item_id ]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module RespondusSoapEndpoint
|
||||
VERSION = "1.1.0"
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
$:.push File.expand_path("../lib", __FILE__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "respondus_soap_endpoint/version"
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "respondus_soap_endpoint"
|
||||
s.version = RespondusSoapEndpoint::VERSION
|
||||
s.authors = ["Brian Palmer"]
|
||||
s.email = ["brianp@instructure.com"]
|
||||
s.homepage = "http://www.instructure.com"
|
||||
s.summary = "SOAP Endpoint for Respondus QTI uploads"
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*"]
|
||||
s.test_files = Dir["spec_canvas/**/*"]
|
||||
|
||||
s.add_dependency "rails", "~> 3.2.19"
|
||||
s.add_dependency "soap4r-middleware", "0.8.3"
|
||||
# in spite of the name, this fork of soap4r works with all rubies
|
||||
s.add_dependency "soap4r-ruby1.9", "2.0.0"
|
||||
end
|
|
@ -246,7 +246,7 @@ Implemented for: Canvas LMS}
|
|||
item_id.should == "xyz"
|
||||
|
||||
# import root folder should've been created and marked as hidden
|
||||
folder = Folder.assert_path(RespondusAPIPort::ATTACHMENT_FOLDER_NAME,
|
||||
folder = Folder.assert_path(RespondusSoapEndpoint::RespondusAPIPort::ATTACHMENT_FOLDER_NAME,
|
||||
@course)
|
||||
folder.hidden?.should == true
|
||||
end
|
|
@ -9,6 +9,6 @@ module ParallelExclude
|
|||
"spec/models/attachment_spec.rb"
|
||||
]
|
||||
|
||||
test_files = FileList['vendor/plugins/*/spec_canvas/**/*_spec.rb'].exclude('vendor/plugins/*/spec_canvas/selenium/*_spec.rb') + FileList['spec/**/*_spec.rb'].exclude('spec/selenium/**/*_spec.rb')
|
||||
test_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium')
|
||||
AVAILABLE_FILES = FILES.select{|file_name| test_files.include?(file_name) }
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
|
|||
require File.expand_path(File.dirname(__FILE__) + '/parallel_exclude')
|
||||
count = args[:count]
|
||||
single_thread_files = ParallelExclude::FILES
|
||||
test_files = FileList['vendor/plugins/*/spec_canvas/**/*_spec.rb'].exclude('vendor/plugins/*/spec_canvas/selenium/*_spec.rb') + FileList['spec/**/*_spec.rb'].exclude('spec/selenium/**/*_spec.rb')
|
||||
test_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium')
|
||||
single_thread_files.each { |filename| test_files.delete(filename) } #need to exclude these tests from running in parallel because they have dependencies that break the spces when run in parallel
|
||||
test_files.map! { |f| "#{Rails.root}/#{f}" }
|
||||
Rake::Task['parallel:spec'].invoke(count, '', '', test_files.join(' '))
|
||||
|
@ -28,7 +28,7 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
|
|||
task :nonseleniumallparallel, :count do |t, args|
|
||||
require "parallelized_specs"
|
||||
count = args[:count]
|
||||
test_files = FileList['vendor/plugins/*/spec_canvas/**/*_spec.rb'].exclude('vendor/plugins/*/spec_canvas/selenium/*_spec.rb') + FileList['spec/**/*_spec.rb'].exclude('spec/selenium/**/*_spec.rb')
|
||||
test_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium')
|
||||
test_files.map! { |f| "#{Rails.root}/#{f}" }
|
||||
Rake::Task['parallel:spec'].invoke(count, '', '', test_files.join(' '))
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ unless ARGV.any? { |a| a =~ /\Agems/ }
|
|||
task :selenium, :count, :build_section do |t, args|
|
||||
require "parallelized_specs"
|
||||
#used to split selenium builds when :build_section is set split it in two.
|
||||
test_files = FileList['spec/selenium/**/*_spec.rb'] + FileList['vendor/plugins/*/spec_canvas/selenium/*_spec.rb']
|
||||
test_files = FileList['spec/selenium/**/*_spec.rb'] + FileList['{gems,vendor}/plugins/*/spec_canvas/selenium/*_spec.rb']
|
||||
test_files = test_files.to_a.sort_by! { |file| File.size(file) }
|
||||
|
||||
args[:build_section].to_i == 0 ? section = nil : section = args[:build_section].to_i
|
||||
|
|
|
@ -45,7 +45,7 @@ unless Rails.env.production? || ARGV.any? { |a| a =~ /\Agems/ }
|
|||
if ENV['SINGLE_TEST']
|
||||
t.spec_opts += ['-e', %{"#{ENV['SINGLE_TEST']}"}]
|
||||
end
|
||||
spec_files = FileList['vendor/plugins/*/spec_canvas/**/*_spec.rb'].exclude('vendor/plugins/*/spec_canvas/selenium/*_spec.rb') + FileList['spec/**/*_spec.rb'].exclude('spec/selenium/**/*_spec.rb')
|
||||
spec_files = FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium')
|
||||
Gem.loaded_specs.values.each do |spec|
|
||||
path = spec.full_gem_path
|
||||
spec_canvas_path = File.expand_path(path+"/spec_canvas")
|
||||
|
@ -110,7 +110,7 @@ unless Rails.env.production? || ARGV.any? { |a| a =~ /\Agems/ }
|
|||
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
||||
klass.new(:coverage) do |t|
|
||||
t.spec_opts = ['--options', "\"#{Rails.root}/spec/spec.opts\""]
|
||||
t.send(spec_files_attr, FileList['vendor/plugins/*/spec_canvas/**/*_spec.rb'].exclude('vendor/plugins/*/spec_canvas/selenium/*_spec.rb') + FileList['spec/**/*_spec.rb'].exclude('spec/selenium/**/*_spec.rb'))
|
||||
t.send(spec_files_attr, FileList['{gems,vendor}/plugins/*/spec_canvas/**/*_spec.rb'].exclude(%r'spec_canvas/selenium') + FileList['spec/**/*_spec.rb'].exclude(%r'spec/selenium'))
|
||||
end
|
||||
|
||||
namespace :plugins do
|
||||
|
|
|
@ -1536,6 +1536,6 @@ class String
|
|||
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
|
||||
end
|
||||
|
||||
Dir[Rails.root+'vendor/plugins/*/spec_canvas/spec_helper.rb'].each do |f|
|
||||
Dir[Rails.root+'{gems,vendor}/plugins/*/spec_canvas/spec_helper.rb'].each do |f|
|
||||
require f
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'recaptcha/rails'
|
||||
require 'canvas/plugin'
|
||||
require_dependency 'canvas/plugin'
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
require_dependency 'users_controller_recaptcha'
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
group 'respondus_soap_endpoint' do
|
||||
# the soap4r gem is pulled in by soap4r-middleware
|
||||
gem 'soap4r-middleware', '0.8.3'
|
||||
gem 'soap4r-ruby1.9', '2.0.0'
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
Rails.configuration.to_prepare do
|
||||
require_dependency 'respondus_soap_endpoint_plugin_validator'
|
||||
plugin = Canvas::Plugin.register :respondus_soap_endpoint, nil, {
|
||||
:name => lambda{ t :name, 'Respondus SOAP Endpoint' },
|
||||
:author => 'instructure',
|
||||
:author_website => 'http://www.instructure.com',
|
||||
:description => lambda{ t :description, 'SOAP Endpoint for Respondus QTI uploads' },
|
||||
:version => '1.0.0',
|
||||
:settings_partial => 'plugins/respondus_soap_endpoint_settings',
|
||||
:settings => {
|
||||
:enabled => false,
|
||||
:worker => 'QtiWorker'
|
||||
},
|
||||
:validator => 'RespondusSoapEndpointPluginValidator'
|
||||
}
|
||||
end
|
||||
|
||||
class RespondusRailtie < Rails::Railtie
|
||||
config.app_middleware.insert_before 'ActionDispatch::ParamsParser', 'RespondusAPIMiddleware'
|
||||
end
|
Loading…
Reference in New Issue