Change NRPS service_version sub-claim to service_versions

- Per recent NRPS vs spec change, the `service_version` LTI 1.3
  launch sub-claim is renamed to `service_versions` and its type
  changed from a string to an array of strings. (The expressed
  version itself is still the same, i.e. it just appears as
  ["2.0"] instead of an unwrapped "2.0".)

Closes LTIA-35 WIP

Test Plan:

  - Verify LTI 1.3 launches to the IMS Reference Implementation include
  a https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice
  claim with a `"service_versions": ["2.0"]` sub-claim

Change-Id: I53801d633166a07c571e106cc60256729059fdcf
Reviewed-on: https://gerrit.instructure.com/167714
QA-Review: Samuel Barney <sbarney@instructure.com>
Tested-by: Jenkins
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
This commit is contained in:
Dan McCallum 2018-10-09 12:38:07 -07:00 committed by Marc Phillips
parent 9b89b6de75
commit 4f5b161072
3 changed files with 16 additions and 16 deletions

View File

@ -7,8 +7,8 @@ module LtiAdvantage::Claims
include ActiveModel::Model
attr_accessor :context_memberships_url,
:service_version
:service_versions
validates_presence_of :context_memberships_url, :service_version
validates_presence_of :context_memberships_url, :service_versions
end
end

View File

@ -137,7 +137,7 @@ module Lti::Messages
def add_names_and_roles_service_claims!
@message.names_and_roles_service.context_memberships_url =
@expander.controller.polymorphic_url([@context, :names_and_roles])
@message.names_and_roles_service.service_version = '2.0'
@message.names_and_roles_service.service_versions = ['2.0']
end
def expand_variable(variable)

View File

@ -248,6 +248,16 @@ describe Lti::Messages::JwtMessage do
end
end
shared_examples 'names and roles claim check' do
it 'sets the NRPS url' do
expect(message_names_and_roles_service['context_memberships_url']).to eq 'polymorphic_url'
end
it 'sets the NRPS version' do
expect(message_names_and_roles_service['service_versions']).to eq ['2.0']
end
end
describe 'names and roles' do
let(:message_names_and_roles_service) { decoded_jwt['https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice'] }
@ -285,12 +295,8 @@ describe Lti::Messages::JwtMessage do
course.root_account.save!
end
it 'sets the NRPS url' do
expect(message_names_and_roles_service['context_memberships_url']).to eq 'polymorphic_url'
end
it 'sets the NRPS version' do
expect(message_names_and_roles_service['service_version']).to eq '2.0'
context 'when context is a course' do
it_behaves_like 'names and roles claim check'
end
context 'when context is an account' do
@ -330,13 +336,7 @@ describe Lti::Messages::JwtMessage do
)
end
it 'sets the NRPS url' do
expect(message_names_and_roles_service['context_memberships_url']).to eq 'polymorphic_url'
end
it 'sets the NRPS version' do
expect(message_names_and_roles_service['service_version']).to eq '2.0'
end
it_behaves_like 'names and roles claim check'
end
end
end