Fix scopes on creation of lti key

This was introduced in
https://gerrit.instructure.com/c/canvas-lms/+/219146
where the code to do customizations was removed. Turns
out that the customization page saved the scopes on the
developer key. This makes it save the scopes from the
tool_configuration settings.

closes PLAT-5285

Test Plan:
 - attempt to make a dev key in any manner
 - check in the console that the newly created dev key
   has scopes attached

Change-Id: I76cd42d15daf6f69bc04ad90768055254b5850b3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/222646
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
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 2020-01-09 14:09:40 -07:00
parent 9312726174
commit 5a1a8d8823
2 changed files with 11 additions and 1 deletions

View File

@ -66,7 +66,8 @@ module Lti
account: (account.site_admin? ? nil : account),
is_lti_key: true,
public_jwk_url: settings[:public_jwk_url],
public_jwk: settings[:public_jwk]
public_jwk: settings[:public_jwk],
scopes: settings[:scopes] || []
)
self.create!(
developer_key: dk,

View File

@ -383,11 +383,16 @@ module Lti
}
end
let(:tool_configuration) { described_class.create_tool_config_and_key!(account, params) }
let(:scopes) { ['https://purl.imsglobal.org/spec/lti-ags/scope/lineitem'] }
it 'creates a dev key' do
expect { described_class.create_tool_config_and_key! account, params }.to change(DeveloperKey, :count).by(1)
end
it 'adds scopes to dev key' do
expect(tool_configuration.developer_key.scopes).to eq(settings['scopes'])
end
it 'correctly sets custom_fields' do
expect(tool_configuration.settings['custom_fields']).to eq settings['custom_fields']
end
@ -434,6 +439,10 @@ module Lti
expect(tool_configuration.settings['target_link_uri']).to eq settings['target_link_uri']
end
it 'adds scopes to dev key' do
expect(tool_configuration.developer_key.scopes).to eq(settings['scopes'])
end
context 'when a timeout occurs' do
before { allow(CanvasHttp).to receive(:get).and_raise(Timeout::Error) }