canvas-lms/lib/lti/ims
Dan McCallum ecd0e98dea Launch LTI 1.3 tools with Assignment-derived resource link IDs
- Previously all LTI 1.3 launches set the context's identifier
  as the resource link ID. Now, when launching an `Assignment` bound
  to a LTI 1.3 tool, the `Assignment`s LTI identifier is set as the
  resource link ID. (Actually it's the LTI identifier associated with
  the `Assignment`'s `ResourceLink` for the launching tool.)
  - Any type of mismatch between the launching tool and the tool
  associated with the `Assignment` or its `ResourceLink` results in
  an error. As noted at bottom of the test plan, that the possibility
  for such errors even exists is rather likely to change in the
  future.

Closes LTIA-48

Test Plan:

  1. Create an LTI 1.3 `ContextExternalTool` and make it available to
  a `Course`. Be sure to include a course navigation placement config.
  2. Create an `Assignment` in that `Course` and bind it to the
  `ContextExternalTool` created in step 1.
  3. Launch the `Assignment`. Verify claim:

```
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
  "id": ${assignment.line_items.find(&:assignment_line_item?).resource_link.resource_link_id}
},
```

  4. Verify that the claim value in step 4 does _not_ match the
  `https://purl.imsglobal.org/spec/lti/claim/context` -> `id` claim
  (the latter should be the LTI ID for the `Course`).
  5. Launch the tool from course navigation.
  6. Verify that the
  `https://purl.imsglobal.org/spec/lti/claim/context` -> `id` claim
  has the same value it did in step 4.
  7. Verify that the
  `https://purl.imsglobal.org/spec/lti/claim/context` -> `id` and
  `https://purl.imsglobal.org/spec/lti/claim/resource_link` -> `id`
  claims match
  8. Re-bind the `Assignment` to a different LTI 1.3
  `ContextExternalTool`.
  9. Verify that launch attempts for the `Assignment` now fail
  with a `Lti::Ims::AdvantageErrors::InvalidLaunchError :: Mismatched
  assignment vs resource link tool configurations` message in error
  logs.

NB the last step is almost certainly incorrect long-term behavior, but
is consistent with the non-editability of `Assignment` `LineItem`s and
`ResourceLinks` from LTIA-47.

Change-Id: Ie5c63430082c4465a7d943343941f931c968ae11
Reviewed-on: https://gerrit.instructure.com/170818
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
2018-11-09 21:27:51 +00:00
..
advantage_errors.rb Launch LTI 1.3 tools with Assignment-derived resource link IDs 2018-11-09 21:27:51 +00:00