diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf32ddb --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +spec/test_app/db/*.sqlite3 +spec/test_app/db/*.sqlite3-journal +spec/test_app/log/*.log +spec/test_app/tmp/ +spec/test_app/.sass-cache diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..0d786ba --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--warnings +--require spec_helper diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9841566 --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in rails_lti2_provider.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..22dc2c9 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,116 @@ +PATH + remote: . + specs: + rails_lti2_provider (0.0.1) + ims-lti (~> 2.0.0.beta.11) + rails (~> 4.1.6) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.6) + actionpack (= 4.1.6) + actionview (= 4.1.6) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.6) + actionview (= 4.1.6) + activesupport (= 4.1.6) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.6) + activesupport (= 4.1.6) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.6) + activesupport (= 4.1.6) + builder (~> 3.1) + activerecord (4.1.6) + activemodel (= 4.1.6) + activesupport (= 4.1.6) + arel (~> 5.0.0) + activesupport (4.1.6) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + builder (3.2.2) + diff-lcs (1.2.5) + erubis (2.7.0) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.9.1) + faraday (>= 0.7.4, < 0.10) + hike (1.2.3) + i18n (0.6.11) + ims-lti (2.0.0.beta.11) + faraday (~> 0.8) + faraday_middleware (~> 0.8) + simple_oauth (= 0.2) + json (1.8.1) + mail (2.6.1) + mime-types (>= 1.16, < 3) + mime-types (2.4.2) + minitest (5.4.2) + multi_json (1.10.1) + multipart-post (2.0.0) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.6) + actionmailer (= 4.1.6) + actionpack (= 4.1.6) + actionview (= 4.1.6) + activemodel (= 4.1.6) + activerecord (= 4.1.6) + activesupport (= 4.1.6) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.6) + sprockets-rails (~> 2.0) + railties (4.1.6) + actionpack (= 4.1.6) + activesupport (= 4.1.6) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) + rspec-core (3.0.4) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.4) + rspec-support (~> 3.0.0) + rspec-rails (3.0.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.4) + simple_oauth (0.2.0) + sprockets (2.12.2) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.2.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.9) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + tzinfo (1.2.2) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + rails_lti2_provider! + rspec-rails + sqlite3 diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..ea966ec --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2014 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..8ce2926 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += RailsLti2Provider + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bc2f14d --- /dev/null +++ b/Rakefile @@ -0,0 +1,23 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'RailsLti2Provider' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + + +Bundler::GemHelper.install_tasks + diff --git a/app/assets/images/rails_lti2_provider/.keep b/app/assets/images/rails_lti2_provider/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/rails_lti2_provider/application.js b/app/assets/javascripts/rails_lti2_provider/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/app/assets/javascripts/rails_lti2_provider/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/app/assets/javascripts/rails_lti2_provider/tool_proxy.js b/app/assets/javascripts/rails_lti2_provider/tool_proxy.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/rails_lti2_provider/tool_proxy.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/rails_lti2_provider/application.css b/app/assets/stylesheets/rails_lti2_provider/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/assets/stylesheets/rails_lti2_provider/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/assets/stylesheets/rails_lti2_provider/tool_proxy.css b/app/assets/stylesheets/rails_lti2_provider/tool_proxy.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/rails_lti2_provider/tool_proxy.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/rails_lti2_provider/application_controller.rb b/app/controllers/rails_lti2_provider/application_controller.rb new file mode 100644 index 0000000..9780fe3 --- /dev/null +++ b/app/controllers/rails_lti2_provider/application_controller.rb @@ -0,0 +1,4 @@ +module RailsLti2Provider + class ApplicationController < ActionController::Base + end +end diff --git a/app/controllers/rails_lti2_provider/tool_proxy_controller.rb b/app/controllers/rails_lti2_provider/tool_proxy_controller.rb new file mode 100644 index 0000000..6d1cd42 --- /dev/null +++ b/app/controllers/rails_lti2_provider/tool_proxy_controller.rb @@ -0,0 +1,5 @@ +module RailsLti2Provider + class ToolProxyController < ApplicationController + include RailsLti2Provider::Concerns::Controllers::ToolProxyController + end +end diff --git a/app/helpers/rails_lti2_provider/application_helper.rb b/app/helpers/rails_lti2_provider/application_helper.rb new file mode 100644 index 0000000..b36f85f --- /dev/null +++ b/app/helpers/rails_lti2_provider/application_helper.rb @@ -0,0 +1,4 @@ +module RailsLti2Provider + module ApplicationHelper + end +end diff --git a/app/helpers/rails_lti2_provider/tool_proxy_helper.rb b/app/helpers/rails_lti2_provider/tool_proxy_helper.rb new file mode 100644 index 0000000..be13120 --- /dev/null +++ b/app/helpers/rails_lti2_provider/tool_proxy_helper.rb @@ -0,0 +1,4 @@ +module RailsLti2Provider + module ToolProxyHelper + end +end diff --git a/app/models/rails_lti2_provider/lti_launch.rb b/app/models/rails_lti2_provider/lti_launch.rb new file mode 100644 index 0000000..d8d019f --- /dev/null +++ b/app/models/rails_lti2_provider/lti_launch.rb @@ -0,0 +1,23 @@ +module RailsLti2Provider + class LtiLaunch < ActiveRecord::Base + validates_presence_of :tool_proxy_id, :nonce + has_one :tool_proxy + serialize :message + + def self.check_launch(lti_message) + tool_proxy = ToolProxy.find_by_uuid(lti_message.oauth_consumer_key) + valid_launch = lti_message.valid_signature?(tool_proxy.shared_secret) && + tool_proxy.lti_launches.where(nonce: lti_message.oauth_nonce).count == 0 && + DateTime.strptime(lti_message.oauth_timestamp,'%s') > 5.minutes.ago + raise Unauthorized unless valid_launch + tool_proxy.lti_launches.where('created_at > ?', 1.day.ago).delete_all + tool_proxy.lti_launches.create(nonce: lti_message.oauth_nonce, message: lti_message.post_params) + lti_message + end + + class Unauthorized < StandardError; + end + + + end +end diff --git a/app/models/rails_lti2_provider/tool_proxy.rb b/app/models/rails_lti2_provider/tool_proxy.rb new file mode 100644 index 0000000..d945174 --- /dev/null +++ b/app/models/rails_lti2_provider/tool_proxy.rb @@ -0,0 +1,7 @@ +module RailsLti2Provider + class ToolProxy < ActiveRecord::Base + validates_presence_of :shared_secret, :uuid, :proxy_json + serialize :proxy_json, JSON + has_many :lti_launches + end +end diff --git a/app/views/layouts/rails_lti2_provider/application.html.erb b/app/views/layouts/rails_lti2_provider/application.html.erb new file mode 100644 index 0000000..e0c1afe --- /dev/null +++ b/app/views/layouts/rails_lti2_provider/application.html.erb @@ -0,0 +1,14 @@ + + + + RailsLti2Provider + <%= stylesheet_link_tag "rails_lti2_provider/application", media: "all" %> + <%= javascript_include_tag "rails_lti2_provider/application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/app/views/rails_lti2_provider/tool_proxy/register.html.erb b/app/views/rails_lti2_provider/tool_proxy/register.html.erb new file mode 100644 index 0000000..a85595f --- /dev/null +++ b/app/views/rails_lti2_provider/tool_proxy/register.html.erb @@ -0,0 +1,2 @@ +

ToolProxy#register

+

Find me in app/views/rails_lti2_provider/tool_proxy/register.html.erb

diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..3f8a9be --- /dev/null +++ b/bin/rails @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/rails_lti2_provider/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..0c86b5c --- /dev/null +++ b/bin/rspec @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rspec-core', 'rspec') diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..786b9cb --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,18 @@ +RailsLti2Provider::Engine.routes.draw do + + Rails.application.routes.draw do + RailsLti2Provider::RESOURCE_HANDLERS.each do |config| + config[:messages].each do |message| + route = message[:route].symbolize_keys + path = route.delete(:path) || ':controller/:action' + post path, route + end + end + end + + post 'tool_proxy/register', to: 'tool_proxy#register', as: :tool_proxy_registrar + + get 'tool_proxy/:tool_proxy_id', to: 'tool_proxy#show', as: :show_tool_proxy + + +end diff --git a/db/migrate/20141014213753_create_rails_lti2_provider_tool_proxies.rb b/db/migrate/20141014213753_create_rails_lti2_provider_tool_proxies.rb new file mode 100644 index 0000000..0cb5f09 --- /dev/null +++ b/db/migrate/20141014213753_create_rails_lti2_provider_tool_proxies.rb @@ -0,0 +1,11 @@ +class CreateRailsLti2ProviderToolProxies < ActiveRecord::Migration + def change + create_table :rails_lti2_provider_tool_proxies do |t| + t.string :uuid + t.string :shared_secret + t.text :proxy_json + + t.timestamps + end + end +end diff --git a/db/migrate/20141015204601_create_rails_lti2_provider_lti_launches.rb b/db/migrate/20141015204601_create_rails_lti2_provider_lti_launches.rb new file mode 100644 index 0000000..3df0104 --- /dev/null +++ b/db/migrate/20141015204601_create_rails_lti2_provider_lti_launches.rb @@ -0,0 +1,11 @@ +class CreateRailsLti2ProviderLtiLaunches < ActiveRecord::Migration + def change + create_table :rails_lti2_provider_lti_launches do |t| + t.string :tool_proxy_id + t.string :nonce + t.text :message + + t.timestamps + end + end +end diff --git a/lib/rails_lti2_provider.rb b/lib/rails_lti2_provider.rb new file mode 100644 index 0000000..8247ceb --- /dev/null +++ b/lib/rails_lti2_provider.rb @@ -0,0 +1,9 @@ +require "ims/lti" + +module RailsLti2Provider + require "rails_lti2_provider/engine" + require "rails_lti2_provider/concerns" + require "rails_lti2_provider/tool_proxy_registration" + require "rails_lti2_provider/controller_helpers" + +end diff --git a/lib/rails_lti2_provider/concerns.rb b/lib/rails_lti2_provider/concerns.rb new file mode 100644 index 0000000..95b57a4 --- /dev/null +++ b/lib/rails_lti2_provider/concerns.rb @@ -0,0 +1,3 @@ +module RailsLti2Provider::Concerns + require_relative 'concerns/controllers' +end \ No newline at end of file diff --git a/lib/rails_lti2_provider/concerns/controllers.rb b/lib/rails_lti2_provider/concerns/controllers.rb new file mode 100644 index 0000000..b268ebb --- /dev/null +++ b/lib/rails_lti2_provider/concerns/controllers.rb @@ -0,0 +1,3 @@ +module RailsLti2Provider::Concerns::Controllers + require_relative "controllers/tool_proxy_controller" +end \ No newline at end of file diff --git a/lib/rails_lti2_provider/concerns/controllers/tool_proxy_controller.rb b/lib/rails_lti2_provider/concerns/controllers/tool_proxy_controller.rb new file mode 100644 index 0000000..479d02f --- /dev/null +++ b/lib/rails_lti2_provider/concerns/controllers/tool_proxy_controller.rb @@ -0,0 +1,23 @@ +module RailsLti2Provider::Concerns::Controllers::ToolProxyController + extend ActiveSupport::Concern + + included do + def register + registration_request = IMS::LTI::Models::Messages::RegistrationRequest.new(params) + registrar = RailsLti2Provider::ToolProxyRegistration.new(registration_request, self) + result = registrar.register + if result.has_key?(:success) + redirect_to result[:return_url], {status: 'success', tool_proxy_guid: result[:tool_proxy_uuid]} + else + redirect_to result[:return_url], {status: 'error', tool_proxy_guid: result[:tool_proxy_uuid]} + end + end + + def show + + end + + + end + +end \ No newline at end of file diff --git a/lib/rails_lti2_provider/controller_helpers.rb b/lib/rails_lti2_provider/controller_helpers.rb new file mode 100644 index 0000000..e736cf9 --- /dev/null +++ b/lib/rails_lti2_provider/controller_helpers.rb @@ -0,0 +1,15 @@ +module RailsLti2Provider + module ControllerHelpers + + def lti2_authentication + @lti_message = IMS::LTI::Models::Messages::BasicLTILaunchRequest.new(params) + @lti_message.launch_url = request.url + RailsLti2Provider::LtiLaunch.check_launch(@lti_message) + end + + def disable_xframe_header + response.headers.except! 'X-Frame-Options' + end + + end +end \ No newline at end of file diff --git a/lib/rails_lti2_provider/engine.rb b/lib/rails_lti2_provider/engine.rb new file mode 100644 index 0000000..7e860b0 --- /dev/null +++ b/lib/rails_lti2_provider/engine.rb @@ -0,0 +1,16 @@ +module RailsLti2Provider + RESOURCE_HANDLERS = [] + + class Engine < ::Rails::Engine + isolate_namespace RailsLti2Provider + + initializer 'resource_handlers' do |app| + controllers = {} + Dir[Rails.root.join('config', 'resource_handlers', '*.yml')].each do |yml| + config = YAML.load(File.read(yml)).with_indifferent_access + RESOURCE_HANDLERS << config + end + end + + end +end diff --git a/lib/rails_lti2_provider/tool_proxy_registration.rb b/lib/rails_lti2_provider/tool_proxy_registration.rb new file mode 100644 index 0000000..3816ddb --- /dev/null +++ b/lib/rails_lti2_provider/tool_proxy_registration.rb @@ -0,0 +1,105 @@ +module RailsLti2Provider + class ToolProxyRegistration + + attr_reader :tool_consumer_profile, :registration_state, :return_url + + attr_writer :shared_secret, :tool_proxy, :tool_profile, :security_contract, :product_instance + + def initialize(registration_request, controller) + @controller = controller + @return_url = registration_request.launch_presentation_return_url + @registration_service = IMS::LTI::Services::ToolProxyRegistrationService.new(registration_request) + @tool_consumer_profile = @registration_service.tool_consumer_profile + @registration_state = :not_registered + end + + def shared_secret + @shared_secret ||= SecureRandom.hex(64) + end + + def tool_proxy + @tool_proxy ||= IMS::LTI::Models::ToolProxy.new( + id: 'defined_by_tool_consumer', + lti_version: 'LTI-2p0', + security_contract: security_contract, + tool_consumer_profile: tool_consumer_profile.id, + tool_profile: tool_profile, + ) + end + + def tool_profile + @tool_profile ||= IMS::LTI::Models::ToolProfile.new( + lti_version: 'LTI-2p0', + product_instance: product_instance, + resource_handler: resource_handlers + ) + end + + def product_instance + unless @product_instance + product_instance_config = Rails.root.join('config', 'product_instance.json') + raise 'MissingProductInstaceConfig' unless File.exist? product_instance_config + @product_instance = IMS::LTI::Models::ProductInstance.new.from_json(File.read(product_instance_config)) + end + end + + def security_contract + @security_contract ||= IMS::LTI::Models::SecurityContract.new(shared_secret: shared_secret) + end + + def register + raise 'ToolProxyAlreadyRegisteredException' if registration_state == :registered + if registered_proxy = @registration_service.register_tool_proxy(tool_proxy) + tool_proxy.tool_proxy_guid = registered_proxy.tool_proxy_guid + tool_proxy.id = @controller.show_tool_proxy_url(registered_proxy.tool_proxy_guid) + ToolProxy.create!(shared_secret: shared_secret, uuid:registered_proxy.tool_proxy_guid, proxy_json:tool_proxy.as_json) + @registration_state = :registered + { + tool_proxy_uuid: tool_proxy.tool_proxy_guid, + return_url: @return_url, + status: 'success' + } + else + { + tool_proxy_uuid: tool_proxy.tool_proxy_guid, + return_url: @return_url, + status: 'error', + message: "Failed to create a tool proxy in #{tool_consumer_profile.product_instance.product_info.product_name.default_value}" + } + end + end + + private + + def resource_handlers + RailsLti2Provider::RESOURCE_HANDLERS.map do |handler| + IMS::LTI::Models::ResourceHandler.from_json( + { + resource_type: {code: handler['code']}, + resource_name: handler['name'], + message: messages(handler['messages']) + } + ) + end + end + + def messages(messages) + messages.map do |m| + host = @controller.request.port == 80 || @controller.request.port == 443 ? @controller.request.host : "#{@controller.request.host}:#{@controller.request.port}" + { + message_type: m['type'], + path: Rails.application.routes.url_for(host: host, controller: m['route']['controller'], action: m['route']['action']), + parameter: parameters(m['parameters']) + } + end + end + + def parameters(params) + (params || []).map do |p| + #TODO: check if variable parameters are in the capabilities offered + IMS::LTI::Models::Parameter.new(p.symbolize_keys) + end + end + + end +end diff --git a/lib/rails_lti2_provider/version.rb b/lib/rails_lti2_provider/version.rb new file mode 100644 index 0000000..3febcd6 --- /dev/null +++ b/lib/rails_lti2_provider/version.rb @@ -0,0 +1,3 @@ +module RailsLti2Provider + VERSION = "0.0.1" +end diff --git a/lib/tasks/rails_lti2_provider_tasks.rake b/lib/tasks/rails_lti2_provider_tasks.rake new file mode 100644 index 0000000..353f935 --- /dev/null +++ b/lib/tasks/rails_lti2_provider_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :rails_lti2_provider do +# # Task goes here +# end diff --git a/rails_lti2_provider.gemspec b/rails_lti2_provider.gemspec new file mode 100644 index 0000000..cb42e28 --- /dev/null +++ b/rails_lti2_provider.gemspec @@ -0,0 +1,22 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "rails_lti2_provider/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "rails_lti2_provider" + s.version = RailsLti2Provider::VERSION + s.authors = ["Instructure"] + s.homepage = %q{http://github.com/instructure/ims-lti} + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + + s.add_dependency "rails", "~> 4.1.6" + s.add_dependency "ims-lti", "~> 2.0.0.beta.11" + + s.add_development_dependency "sqlite3" + s.add_development_dependency "rspec-rails" + +end diff --git a/spec/lib/rails_lti2_provider/tool_proxy_registration_spec.rb b/spec/lib/rails_lti2_provider/tool_proxy_registration_spec.rb new file mode 100644 index 0000000..3d5088e --- /dev/null +++ b/spec/lib/rails_lti2_provider/tool_proxy_registration_spec.rb @@ -0,0 +1,7 @@ +require "rails_helper" + +describe RailsLti2Provider::ToolProxyRegistration do + + + +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..28d6499 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,45 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../test_app/config/environment", __FILE__) +require 'rspec/rails' + +ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../') + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f } + +# Checks for pending migrations before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..cfb18dc --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,78 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause this +# file to always be loaded, without a need to explicitly require it in any files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, make a +# separate helper file that requires this one and then use it only in the specs +# that actually need it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed + + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + expectations.syntax = :expect + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + mocks.syntax = :expect + + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended. + mocks.verify_partial_doubles = true + end +=end +end diff --git a/spec/test_app/README.rdoc b/spec/test_app/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/spec/test_app/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/spec/test_app/Rakefile b/spec/test_app/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/spec/test_app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/spec/test_app/app/assets/images/.keep b/spec/test_app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/app/assets/javascripts/application.js b/spec/test_app/app/assets/javascripts/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/spec/test_app/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/spec/test_app/app/assets/stylesheets/application.css b/spec/test_app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/spec/test_app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/spec/test_app/app/controllers/application_controller.rb b/spec/test_app/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/spec/test_app/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/spec/test_app/app/controllers/concerns/.keep b/spec/test_app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/app/controllers/sample_controller.rb b/spec/test_app/app/controllers/sample_controller.rb new file mode 100644 index 0000000..081df27 --- /dev/null +++ b/spec/test_app/app/controllers/sample_controller.rb @@ -0,0 +1,13 @@ +class SampleController < ApplicationController + include RailsLti2Provider::ControllerHelpers + + protect_from_forgery except: :launch + before_filter :lti2_authentication, only: :launch + after_filter :disable_xframe_header, only: :launch + + def launch + + render text: 'Hello World' + end + +end \ No newline at end of file diff --git a/spec/test_app/app/helpers/application_helper.rb b/spec/test_app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/spec/test_app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/spec/test_app/app/mailers/.keep b/spec/test_app/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/app/models/.keep b/spec/test_app/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/app/models/concerns/.keep b/spec/test_app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/app/views/layouts/application.html.erb b/spec/test_app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..797902d --- /dev/null +++ b/spec/test_app/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + TestApp + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/spec/test_app/bin/bundle b/spec/test_app/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/spec/test_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/spec/test_app/bin/rails b/spec/test_app/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/spec/test_app/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/spec/test_app/bin/rake b/spec/test_app/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/spec/test_app/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/spec/test_app/config.ru b/spec/test_app/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/spec/test_app/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/spec/test_app/config/application.rb b/spec/test_app/config/application.rb new file mode 100644 index 0000000..78902c6 --- /dev/null +++ b/spec/test_app/config/application.rb @@ -0,0 +1,29 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +Bundler.require(*Rails.groups) +require "rails_lti2_provider" + +module TestApp + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/spec/test_app/config/boot.rb b/spec/test_app/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/spec/test_app/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/spec/test_app/config/database.yml b/spec/test_app/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/spec/test_app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/spec/test_app/config/environment.rb b/spec/test_app/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/spec/test_app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/spec/test_app/config/environments/development.rb b/spec/test_app/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/spec/test_app/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/test_app/config/environments/production.rb b/spec/test_app/config/environments/production.rb new file mode 100644 index 0000000..b93a877 --- /dev/null +++ b/spec/test_app/config/environments/production.rb @@ -0,0 +1,78 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/spec/test_app/config/environments/test.rb b/spec/test_app/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/spec/test_app/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/test_app/config/initializers/assets.rb b/spec/test_app/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/spec/test_app/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/spec/test_app/config/initializers/backtrace_silencers.rb b/spec/test_app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/spec/test_app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/spec/test_app/config/initializers/cookies_serializer.rb b/spec/test_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/spec/test_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/spec/test_app/config/initializers/filter_parameter_logging.rb b/spec/test_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/spec/test_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/spec/test_app/config/initializers/inflections.rb b/spec/test_app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/spec/test_app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/spec/test_app/config/initializers/mime_types.rb b/spec/test_app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/spec/test_app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/spec/test_app/config/initializers/session_store.rb b/spec/test_app/config/initializers/session_store.rb new file mode 100644 index 0000000..438994f --- /dev/null +++ b/spec/test_app/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_test_app_session' diff --git a/spec/test_app/config/initializers/wrap_parameters.rb b/spec/test_app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/spec/test_app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/spec/test_app/config/locales/en.yml b/spec/test_app/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/spec/test_app/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/spec/test_app/config/product_instance.json b/spec/test_app/config/product_instance.json new file mode 100644 index 0000000..f463746 --- /dev/null +++ b/spec/test_app/config/product_instance.json @@ -0,0 +1,21 @@ +{ + "guid": "baf196ff-2707-4ea3-9ad7-713db8e6f740", + "product_info": { + "product_version": "1.0", + "product_name": { + "default_value": "Sample Provider", + "key": "tool.name" + }, + "product_family": { + "code": "Test Provider", + "vendor": { + "code": "rails_lti_provider", + "vendor_name": { + "default_value": "RailsLti2Provider", + "key": "tool.vendor.name" + }, + "timestamp": "2014-07-22T10:59:55-06:00l" + } + } + } +} \ No newline at end of file diff --git a/spec/test_app/config/resource_handlers/sample.yml b/spec/test_app/config/resource_handlers/sample.yml new file mode 100644 index 0000000..1a5ae5a --- /dev/null +++ b/spec/test_app/config/resource_handlers/sample.yml @@ -0,0 +1,30 @@ +code: 'asmt' +name: + default_value: sample + key: assignemnt_name + +description: + default_value: sample description + key: assignemnt_description + +messages: + - type: basic-lti-launch-request + route: + path: sample + controller: sample + action: launch + +parameters: + - name: course_id + variable: Course.id + - name: first_name + variable: Person.name + required: true + - name: xyzzy + fixed: yzzyx + +required_capabilities: + - Result.autocreate + +optional_capabilites: + - Result.lineitem \ No newline at end of file diff --git a/spec/test_app/config/routes.rb b/spec/test_app/config/routes.rb new file mode 100644 index 0000000..296d623 --- /dev/null +++ b/spec/test_app/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + mount RailsLti2Provider::Engine => "/rails_lti2_provider" +end diff --git a/spec/test_app/config/secrets.yml b/spec/test_app/config/secrets.yml new file mode 100644 index 0000000..a928da6 --- /dev/null +++ b/spec/test_app/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a5c5696659e72d6ddc2ea69cbe3f2f747ac3b28b7fb6cc88e94553ab8755eb9120ad06292f65cb99eac73708959faf740d54d94426db97da332cc79f34580a8c + +test: + secret_key_base: 8ea1fa89812fd143db3a291ae8761655b08ffdd8e834266dd3e427e9720879cdc902a145eadc77694e859fae4544d24a46aa0035dd7a5bee72a0899ed70733dd + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/spec/test_app/db/schema.rb b/spec/test_app/db/schema.rb new file mode 100644 index 0000000..fd72029 --- /dev/null +++ b/spec/test_app/db/schema.rb @@ -0,0 +1,32 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20141015204601) do + + create_table "rails_lti2_provider_lti_launches", force: true do |t| + t.string "tool_proxy_id" + t.string "nonce" + t.text "message" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "rails_lti2_provider_tool_proxies", force: true do |t| + t.string "uuid" + t.string "shared_secret" + t.text "proxy_json" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/spec/test_app/lib/assets/.keep b/spec/test_app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/log/.keep b/spec/test_app/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/test_app/public/404.html b/spec/test_app/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/spec/test_app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/test_app/public/422.html b/spec/test_app/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/spec/test_app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/test_app/public/500.html b/spec/test_app/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/spec/test_app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/test_app/public/favicon.ico b/spec/test_app/public/favicon.ico new file mode 100644 index 0000000..e69de29