Do not crash import on ResourceLinks w/o url

refs INTEROP-7258
flag=none

These can exist when exporting a course where there are
Lti::ResourceLinks whose current_external_tool is an LTI 1.1 tool
without a URL. A future commit will prevent ResourceLinks with no URL
from appearing in an export, but since people already have export files
with these LRLs without URLs, we should fix it to not crash the import.

Test plan:
- Have a course with some resource links (e.g. create an LTI 1.3
  assignmentor use deep linking in RCE in the syllabus, when editing an
  assignment body, etc.)
- Create an LTI 1.1 tool without a URL (but with a domain) in the course
  or account.
- In a Rails console, change the context_external_tool_id of the
  Lti::ResourceLink to point to the LTI 1.1 tool with no URL.
- Export the course. Check in the resulting imscc file (actually a zip
  file) that there is a file in lti_resource_links/ that does not have a
  launch_url or secure_launch_url.
- Import the course content in some course. The import should succeed.
- In a rails console lookup resource links with the same lookup_uuid as
  the one pointing to an LTI 1.1 tool to make sure no resource links
  were created by the import:
    Lti::ResourceLinks.where(lookup_uuid:
    lrl_pointing_to_11tool.lookup_uuid)

Change-Id: I420929b2d291d551f43bd2189a48cb911971e1cf
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/285477
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
This commit is contained in:
Evan Battaglia 2022-02-17 17:47:45 -07:00
parent b567f1f098
commit c856299406
4 changed files with 25 additions and 1 deletions

View File

@ -68,7 +68,9 @@ module CC::Importer::Canvas
lookup_uuid = el.content if el.attributes["name"].value == "lookup_uuid"
end
launch_url = (document.xpath("//blti:launch_url").first || document.xpath("//blti:secure_launch_url").first).content
launch_url = (document.xpath("//blti:launch_url").first || document.xpath("//blti:secure_launch_url").first)&.content
next unless launch_url
resource_links << {
custom: custom,

View File

@ -49,5 +49,8 @@
<resource identifier="1234facc599d2202cf67dce042ee34321" type="imsbasiclti_xmlv1p3">
<file href="lti_resource_links/1234facc599d2202cf67dce042ee34321.xml"/>
</resource>
<resource identifier="5678facc599d2202cf67dce042ee34321" type="imsbasiclti_xmlv1p3">
<file href="lti_resource_links/5678facc599d2202cf67dce042ee34321.xml"/>
</resource>
</resources>
</manifest>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<cartridge_basiclti_link xmlns="http://www.imsglobal.org/xsd/imslticc_v1p3" xmlns:blti="http://www.imsglobal.org/xsd/imsbasiclti_v1p0" xmlns:lticm="http://www.imsglobal.org/xsd/imslticm_v1p0" xmlns:lticp="http://www.imsglobal.org/xsd/imslticp_v1p0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imslticc_v1p3.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 imslticp_v1p0.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 imsbasiclti_v1p0p1.xsd">
<blti:title>LTI 1.3 a30691c6</blti:title>
<blti:description>1.3 Test Tool</blti:description>
<blti:custom>
<lticm:property name="param1">lrl-without-url</lticm:property>
</blti:custom>
<blti:extensions platform="canvas.instructure.com">
<lticm:property name="lookup_uuid">567812345c1e-c0a2-42dc-88b6-c029699a7c7a</lticm:property>
</blti:extensions>
</cartridge_basiclti_link>

View File

@ -76,4 +76,12 @@ describe CC::Importer::Canvas::LtiResourceLinkConverter do
end
end
end
it "ignores resource links without a URL" do
expect(lti_resource_links).not_to include(
a_hash_including(
lookup_uuid: "567812345c1e-c0a2-42dc-88b6-c029699a7c7a"
)
)
end
end