Add asset_accessed to sessionless launch

closes PLAT-4753

Test Plan:
 - generate a sessionless launch, launch it, see that
   the event is generated on sessionless launch

Change-Id: Ic025da551286edea73e30e48e580b5f3d8d9fe38
Reviewed-on: https://gerrit.instructure.com/207982
Tested-by: Jenkins
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
This commit is contained in:
Marc Phillips 2019-09-03 15:26:28 -06:00
parent b2c3c62724
commit be6f7c7678
2 changed files with 26 additions and 0 deletions

View File

@ -254,6 +254,9 @@ class ExternalToolsController < ApplicationController
end
launch_settings = JSON.parse(launch_settings)
if tool = ContextExternalTool.find_external_tool(launch_settings['launch_url'], @context)
log_asset_access(tool, "external_tools", "external_tools", overwrite: false)
end
@lti_launch = Lti::Launch.new
@lti_launch.params = launch_settings['tool_settings']

View File

@ -1732,6 +1732,29 @@ describe ExternalToolsController do
end
end
describe '#sessionless_launch' do
before do
allow(BasicLTI::Sourcedid).to receive(:encryption_secret) {'encryption-secret-5T14NjaTbcYjc4'}
allow(BasicLTI::Sourcedid).to receive(:signing_secret) {'signing-secret-vp04BNqApwdwUYPUI'}
user_session(@user)
end
it "generates a sessionless launch" do
@tool = new_valid_tool(@course)
get :generate_sessionless_launch, params: {:course_id => @course.id, id: @tool.id}
expect(response).to be_successful
json = JSON.parse(response.body.sub(/^while\(1\)\;/, ''))
verifier = CGI.parse(URI.parse(json['url']).query)['verifier'].first
expect(controller).to receive(:log_asset_access).once
get :sessionless_launch, params: {:course_id => @course.id, verifier: verifier}
end
end
def opaque_id(asset)
if asset.respond_to?('lti_context_id')
Lti::Asset.global_context_id_for(asset)