141141 expect ( hash [ 'lis_person_name_family' ] ) . to eq 'last_name'
142142 expect ( hash [ 'lis_person_name_given' ] ) . to eq 'first_name'
143143 expect ( hash [ 'lis_person_sourcedid' ] ) . to eq '$Person.sourcedId'
144- expect ( hash [ 'launch_presentation_locale' ] ) . to eq 'en' #was I18n.default_locale.to_s
144+ expect ( hash [ 'launch_presentation_locale' ] ) . to eq :en #was I18n.default_locale.to_s
145145 expect ( hash [ 'launch_presentation_document_target' ] ) . to eq 'iframe'
146146 expect ( hash [ 'launch_presentation_return_url' ] ) . to eq 'http://www.google.com'
147147 expect ( hash [ 'tool_consumer_instance_guid' ] ) . to eq 'root_account_lti_guid'
196196 I18n . stub ( :localizer ) . and_return ( -> { :es } )
197197 hash = tool_launch . generate
198198
199- expect ( hash [ 'launch_presentation_locale' ] ) . to eq 'es'
199+ expect ( hash [ 'launch_presentation_locale' ] ) . to eq :es
200200 end
201201
202202 it 'adds account info in launch data for account navigation' do
230230 expect ( hash [ 'tool_consumer_instance_guid' ] ) . to eq 'root_account_lti_guid' #was hash['tool_consumer_instance_guid']).to eq sub_account.root_account.lti_guid
231231 end
232232
233- it 'includes URI query parameters' do
234- hash = LtiOutbound ::ToolLaunch . new ( :url => 'http://www.yahoo.com?paramater_a=value_a¶meter_b=value_b' ,
235- :tool => tool ,
236- :user => user ,
237- :account => account ,
238- :context => course ,
239- :link_code => '123456' ,
240- :return_url => 'http://www.google.com' ,
241- :variable_expander => variable_expander ) . generate
242- expect ( hash [ 'paramater_a' ] ) . to eq 'value_a'
243- expect ( hash [ 'parameter_b' ] ) . to eq 'value_b'
244- end
245-
246233 it 'does not allow overwriting other parameters from the URI query string' do
247234 hash = LtiOutbound ::ToolLaunch . new ( :url => 'http://www.yahoo.com?user_id=ATTEMPT_TO_SET_DATA&oauth_callback=ATTEMPT_TO_SET_DATA' ,
248235 :tool => tool ,
269256 expect ( hash [ 'custom_bob' ] ) . to eql ( 'bob' )
270257 expect ( hash [ 'custom_fred' ] ) . to eql ( 'fred' )
271258 expect ( hash [ 'custom_john' ] ) . to eql ( 'john' )
272- expect ( hash [ 'custom___taa____' ] ) . to eql ( ' 123' )
259+ expect ( hash [ 'custom___taa____' ] ) . to eql ( 123 )
273260 expect ( hash ) . to_not have_key '@$TAA$#$#'
274261 expect ( hash ) . to_not have_key 'john'
275262 end
321308 :return_url => 'http://www.yahoo.com' ,
322309 :resource_type => 'editor_button' ,
323310 :variable_expander => variable_expander ) . generate
324- expect ( hash [ 'launch_presentation_width' ] ) . to eq ' 1000'
325- expect ( hash [ 'launch_presentation_height' ] ) . to eq ' 300'
311+ expect ( hash [ 'launch_presentation_width' ] ) . to eq 1000
312+ expect ( hash [ 'launch_presentation_height' ] ) . to eq 300
326313 end
327314
328315 it 'does not copy query params to POST body if disable_lti_post_only feature flag is set' do
394381 end
395382 end
396383
397- #TODO: do not test private methods
398- describe '.generate_params' do
399- def explicit_signature_settings ( timestamp , nonce )
400- LtiOutbound ::ToolLaunch . instance_variable_set ( :'@timestamp' , timestamp )
401- LtiOutbound ::ToolLaunch . instance_variable_set ( :'@nonce' , nonce )
402- end
403-
404- it 'generate a correct signature' do
405- explicit_signature_settings ( '1251600739' , 'c8350c0e47782d16d2fa48b2090c1d8f' )
406-
407- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
408- :resource_link_id => '120988f929-274612' ,
409- :user_id => '292832126' ,
410- :roles => 'Instructor' ,
411- :lis_person_name_full => 'Jane Q. Public' ,
412- :lis_person_contact_email_primary => 'user@school.edu' ,
413- :lis_person_sourced_id => 'school.edu:user' ,
414- :context_id => '456434513' ,
415- :context_title => 'Design of Personal Environments' ,
416- :context_label => 'SI182' ,
417- :lti_version => 'LTI-1p0' ,
418- :lti_message_type => 'basic-lti-launch-request' ,
419- :tool_consumer_instance_guid => 'lmsng.school.edu' ,
420- :tool_consumer_instance_description => 'University of School (LMSng)' ,
421- :lti_submit => 'Launch Endpoint with LTI Data'
422- } , 'http://dr-chuck.com/ims/php-simple/tool.php' , '12345' , 'secret' )
423-
424- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'l1ZTsn1HjGXzqeaTQMPbjrqvjLU=' )
425- end
426-
427- it 'generate a correct signature with URL query parameters' do
428- explicit_signature_settings ( '1251600739' , 'c8350c0e47782d16d2fa48b2090c1d8f' )
429- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
430- :resource_link_id => '120988f929-274612' ,
431- :user_id => '292832126' ,
432- :roles => 'Instructor' ,
433- :lis_person_name_full => 'Jane Q. Public' ,
434- :lis_person_contact_email_primary => 'user@school.edu' ,
435- :lis_person_sourced_id => 'school.edu:user' ,
436- :context_id => '456434513' ,
437- :context_title => 'Design of Personal Environments' ,
438- :context_label => 'SI182' ,
439- :lti_version => 'LTI-1p0' ,
440- :lti_message_type => 'basic-lti-launch-request' ,
441- :tool_consumer_instance_guid => 'lmsng.school.edu' ,
442- :tool_consumer_instance_description => 'University of School (LMSng)' ,
443- :lti_submit => 'Launch Endpoint with LTI Data'
444- } , 'http://dr-chuck.com/ims/php-simple/tool.php?a=1&b=2&c=3%20%26a' , '12345' , 'secret' )
445- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'k/+aMdax1Jm5kuGF6DG/ptN5VfY=' )
446- expect ( hash [ 'c' ] ) . to eq '3 &a'
447- end
448-
449- it 'generate a correct signature with a non-standard port' do
450- #signatures generated using http://oauth.googlecode.com/svn/code/javascript/example/signature.html
451- explicit_signature_settings ( '1251600739' , 'c8350c0e47782d16d2fa48b2090c1d8f' )
452- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
453- } , 'http://dr-chuck.com:123/ims/php-simple/tool.php' , '12345' , 'secret' )
454- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'ghEdPHwN4iJmsM3Nr4AndDx2Kx8=' )
455-
456- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
457- } , 'http://dr-chuck.com/ims/php-simple/tool.php' , '12345' , 'secret' )
458- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'WoSpvCr2HEsLzao6Do0eukxwAsk=' )
459-
460- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
461- } , 'http://dr-chuck.com:80/ims/php-simple/tool.php' , '12345' , 'secret' )
462- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'WoSpvCr2HEsLzao6Do0eukxwAsk=' )
463-
464- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
465- } , 'http://dr-chuck.com:443/ims/php-simple/tool.php' , '12345' , 'secret' )
466- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'KqAV7eIS/+iWIDpvCyDfY8ZpmT4=' )
467-
468- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
469- } , 'https://dr-chuck.com/ims/php-simple/tool.php' , '12345' , 'secret' )
470- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'wFRB/1ZXi/91dop6GwahfboWPvQ=' )
471-
472- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
473- } , 'https://dr-chuck.com:443/ims/php-simple/tool.php' , '12345' , 'secret' )
474- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'wFRB/1ZXi/91dop6GwahfboWPvQ=' )
475-
476- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
477- } , 'https://dr-chuck.com:80/ims/php-simple/tool.php' , '12345' , 'secret' )
478- expect ( hash [ 'oauth_signature' ] ) . to eql ( 'X8Aq2HXSHnr6u/6z/G9zI5aDoR0=' )
479- end
480-
481- it 'does not copy query params to POST body if disable_lti_post_only feature flag is set' do
482- hash = LtiOutbound ::ToolLaunch . send ( :generate_params , {
483- :resource_link_id => '120988f929-274612' ,
484- :user_id => '292832126' ,
485- :roles => 'Instructor' ,
486- :lis_person_name_full => 'Jane Q. Public' ,
487- :lis_person_contact_email_primary => 'user@school.edu' ,
488- :lis_person_sourced_id => 'school.edu:user' ,
489- :context_id => '456434513' ,
490- :context_title => 'Design of Personal Environments' ,
491- :context_label => 'SI182' ,
492- :lti_version => 'LTI-1p0' ,
493- :lti_message_type => 'basic-lti-launch-request' ,
494- :tool_consumer_instance_guid => 'lmsng.school.edu' ,
495- :tool_consumer_instance_description => 'University of School (LMSng)' ,
496- :lti_submit => 'Launch Endpoint with LTI Data'
497- } , 'http://www.instructure.com?first=weston&last=dransfield' , 'key' , 'secret' ,
498- disable_lti_post_only : true )
499- expect ( hash . key? ( 'first' ) ) . to eq false
500- end
501- end
502384end
0 commit comments