add variable substitution for masquerading user's LTI id
fixes PLAT-976 test plan: - create an external app within a course - add MasqUserID=$Canvas.masqueradingUser.userId as a custom field - make sure the value of MasqUserID is set to the logged in user's LTI id - masquerade as a user who has access to the external app - make sure the value of MasqUserID is set to the lagged in user's LTI id, not the id of the user being impersonated Change-Id: I80bd6dbf38d66937b86e1f636db2fafc219c6ef7 Reviewed-on: https://gerrit.instructure.com/52929 Tested-by: Jenkins Reviewed-by: Nathan Mills <nathanm@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
parent
a12147fcda
commit
8d42c9bc8e
|
@ -233,6 +233,10 @@ module Lti
|
|||
-> { @current_pseudonym.id },
|
||||
-> { @current_pseudonym != @current_user }
|
||||
|
||||
register_expansion 'Canvas.masqueradingUser.userId', [],
|
||||
-> { @tool.opaque_identifier_for(@controller.logged_in_user) },
|
||||
USER_GUARD
|
||||
|
||||
register_expansion 'Canvas.xapi.url', [],
|
||||
-> { @controller.lti_xapi_url(Lti::AnalyticsService.create_token(@tool, @current_user, @context)) },
|
||||
-> { @current_user && @context.is_a?(Course) && @tool }
|
||||
|
|
|
@ -34,6 +34,7 @@ module Lti
|
|||
shard_mock = mock('shard')
|
||||
shard_mock.stubs(:settings).returns({encription_key: 'abc'})
|
||||
m.stubs(:shard).returns(shard_mock)
|
||||
m.stubs(:opaque_identifier_for).returns("6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f")
|
||||
m
|
||||
end
|
||||
let(:controller) do
|
||||
|
@ -546,6 +547,12 @@ module Lti
|
|||
expect(exp_hash[:test]).to eq 7878
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.masqueradingUser.userId' do
|
||||
exp_hash = {test: '$Canvas.masqueradingUser.userId'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq '6cd2e0d65bd5aef3b5ee56a64bdcd595e447bc8f'
|
||||
end
|
||||
|
||||
it 'has substitution for Canvas.module.id' do
|
||||
content_tag = mock('content_tag')
|
||||
content_tag.stubs(:context_module_id).returns('foo')
|
||||
|
|
Loading…
Reference in New Issue