create attribute for lti_guid on accounts
This allows us to make changes with how we generate that
id without breaking tool providers who depend on the old
way
This also sets the lti_quid to the value it was before the
1c6ae6979e
change
Test Plan:
* Exiting root accounts lti_guid attribute should have the domain name in it
* New accounts will use the accounts UUID and thus have no domain name
refs CNVS-3829
Change-Id: Ib5b10cb097d3f0e5c562d1af70f5770217418e63
Reviewed-on: https://gerrit.instructure.com/18481
Reviewed-by: Zach Wily <zach@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Bryan Madsen <bryan@instructure.com>
Reviewed-by: Stanley Stuart <stanley@instructure.com>
This commit is contained in:
parent
540f97d453
commit
a97298c99b
|
@ -248,8 +248,9 @@ class Account < ActiveRecord::Base
|
|||
|
||||
def ensure_defaults
|
||||
self.uuid ||= AutoHandle.generate_securish_uuid
|
||||
self.lti_guid ||= self.uuid if self.respond_to?(:lti_guid)
|
||||
end
|
||||
|
||||
|
||||
def verify_unique_sis_source_id
|
||||
return true unless self.sis_source_id
|
||||
if self.root_account?
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class AddLtiAccountGuid < ActiveRecord::Migration
|
||||
tag :predeploy
|
||||
|
||||
def self.up
|
||||
add_column :accounts, :lti_guid, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :accounts, :lti_guid, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class GenerateOldAccountOpaqueIDs < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
|
||||
def self.up
|
||||
# Set all the root account opaque ids to their old value so that LTI
|
||||
# integrations won't break
|
||||
DataFixup::SetAccountLtiOpaqueIds.send_later_if_production(:run)
|
||||
end
|
||||
end
|
|
@ -127,7 +127,7 @@ module BasicLTI
|
|||
hash['launch_presentation_height'] = 400
|
||||
hash['launch_presentation_return_url'] = return_url
|
||||
root_context = (context.respond_to?(:root_account) && context.root_account) || context
|
||||
hash['tool_consumer_instance_guid'] = root_context.uuid
|
||||
hash['tool_consumer_instance_guid'] = root_context.respond_to?(:lti_guid) ? root_context.lti_guid : root_context.uuid
|
||||
hash['tool_consumer_instance_name'] = root_context.name
|
||||
hash['tool_consumer_instance_contact_email'] = HostUrl.outgoing_email_address # TODO: find a better email address to use here
|
||||
hash['tool_consumer_info_product_family_code'] = 'canvas'
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
module DataFixup::SetAccountLtiOpaqueIds
|
||||
|
||||
def self.run
|
||||
Account.root_accounts.each do |root|
|
||||
root.lti_guid = "#{root.opaque_identifier(:asset_string)}.#{HostUrl.context_host(root)}"
|
||||
root.save!
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# Copyright (C) 2012 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
||||
require 'lib/data_fixup/set_account_lti_opaque_ids.rb'
|
||||
|
||||
describe 'DataFixup::SetAccountLtiOpaqueIds' do
|
||||
describe "up" do
|
||||
it "should work" do
|
||||
root_account = Account.default
|
||||
root_account.lti_guid.should == root_account.uuid
|
||||
|
||||
DataFixup::SetAccountLtiOpaqueIds.run
|
||||
|
||||
root_account.reload
|
||||
root_account.lti_guid.should_not == root_account.uuid
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue