Support User Placement for LTI 1.3 Launch

Closes PLAT-3636

Test Plan:
- Verify the LTI 1.3 Launch for `User Navigation` works

Change-Id: Idc1924269632f7d6e16f5c2e56d45d1fa47e27b0
Reviewed-on: https://gerrit.instructure.com/161216
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
Tested-by: Jenkins
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
Han Ngo 2018-08-17 14:22:04 -06:00 committed by Weston Dransfield
parent 13807f58b0
commit 7704e5d6a5
2 changed files with 41 additions and 14 deletions

View File

@ -1253,7 +1253,18 @@ class UsersController < ApplicationController
current_user: @current_user,
current_pseudonym: @current_pseudonym,
tool: @tool})
adapter = Lti::LtiOutboundAdapter.new(@tool, @current_user, @domain_root_account).prepare_tool_launch(@return_url, variable_expander, opts)
adapter = if @tool.settings.fetch('use_1_3', false)
Lti::LtiAdvantageAdapter.new(
tool: @tool,
user: @current_user,
context: @domain_root_account,
return_url: @return_url,
expander: variable_expander,
opts: opts
)
else
Lti::LtiOutboundAdapter.new(@tool, @current_user, @domain_root_account).prepare_tool_launch(@return_url, variable_expander, opts)
end
@lti_launch.params = adapter.generate_post_payload
@lti_launch.resource_url = @tool.user_navigation(:url)

View File

@ -17,6 +17,7 @@
#
require_relative '../sharding_spec_helper'
require File.expand_path(File.dirname(__FILE__) + '/../lti_1_3_spec_helper')
describe UsersController do
let(:group_helper) { Factories::GradingPeriodGroupHelper.new }
@ -50,37 +51,52 @@ describe UsersController do
tool
end
let_once(:user) { user_factory(active_all: true) }
before do
account.account_users.create!(user: user)
user_session(user)
end
it "removes query string when post_only = true" do
u = user_factory(active_all: true)
account.account_users.create!(user: u)
user_session(@user)
tool.user_navigation = { text: "example" }
tool.settings['post_only'] = 'true'
tool.save!
get :external_tool, params: {id:tool.id, user_id:u.id}
get :external_tool, params: {id:tool.id, user_id:user.id}
expect(assigns[:lti_launch].resource_url).to eq 'http://www.example.com/basic_lti'
end
it "does not remove query string from url" do
u = user_factory(active_all: true)
account.account_users.create!(user: u)
user_session(@user)
tool.user_navigation = { text: "example" }
tool.save!
get :external_tool, params: {id:tool.id, user_id:u.id}
get :external_tool, params: {id:tool.id, user_id:user.id}
expect(assigns[:lti_launch].resource_url).to eq 'http://www.example.com/basic_lti?first=john&last=smith'
end
it "uses localized labels" do
u = user_factory(active_all: true)
account.account_users.create!(user: u)
user_session(@user)
get :external_tool, params: {id:tool.id, user_id:u.id}
get :external_tool, params: {id:tool.id, user_id:user.id}
expect(tool.label_for(:user_navigation, :en)).to eq 'English Label'
end
context 'using LTI 1.3 when specified' do
include_context 'lti_1_3_spec_helper'
subject do
get :external_tool, params: {id:tool.id, user_id:user.id}
JSON::JWT.decode(assigns[:lti_launch].params[:id_token], :skip_verification)
end
before do
tool.settings['use_1_3'] = true
tool.developer_key = DeveloperKey.create!
tool.save!
end
it 'does LTI 1.3 launch' do
expect(subject["https://purl.imsglobal.org/spec/lti/claim/message_type"]).to eq "LtiResourceLinkRequest"
end
end
end
describe "GET oauth" do