def test_models_lti_consumer_auth_parameters_edit_mode_manual( self, _mock_rl, _mock_ts, _mock_nonce ): """ Verify that instructor LTI authentication parameters are correctly built with edit mode when credentials are setup manually. """ instance = LTIConsumerFactory( lti_provider_id=None, url="http://localhost:8060/lti/videos/3cd0bcc4-0", oauth_consumer_key="ManualTestOauthConsumerKey", shared_secret="ManualTestSharedSecret", ) expected_content_parameters = { "lti_message_type": "basic-lti-launch-request", "lti_version": "LTI-1p0", "resource_link_id": "1234", "context_id": "example.com", "user_id": "richie", "lis_person_contact_email_primary": "", "roles": "instructor", "oauth_consumer_key": "ManualTestOauthConsumerKey", "oauth_nonce": "59474787080480293391616018589", "oauth_signature": "CCnCQtLjPlb+Yr2C0FjYmoVO6Gk=", "oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": "1616018589", "oauth_version": "1.0", } self.assertDictEqual( expected_content_parameters, instance.get_content_parameters(edit=True) )
def test_models_lti_consumer_auth_parameters_no_edit_mode_predefined( self, _mock_rl, _mock_ts, _mock_nonce ): """ Verify that student LTI authentication parameters are correctly built without edit mode when credentials come from the settings. """ instance = LTIConsumerFactory( lti_provider_id="lti_provider_test", url="http://localhost:8060/lti/videos/3cd0bcc4-0", # Add credentials on the model to check that they have no influence oauth_consumer_key="IgnoredOauthConsumerKey", shared_secret="IgnoredSharedSecret", ) expected_content_parameters = { "lti_message_type": "basic-lti-launch-request", "lti_version": "LTI-1p0", "resource_link_id": "1234", "context_id": "example.com", "user_id": "richie", "lis_person_contact_email_primary": "", "roles": "student", "oauth_consumer_key": "TestOauthConsumerKey", "oauth_nonce": "59474787080480293391616018589", "oauth_signature": "PkxLai53gItjVvgbccU7AW4HwuY=", "oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": "1616018589", "oauth_version": "1.0", } self.assertDictEqual( expected_content_parameters, instance.get_content_parameters() )
def test_models_lti_consumer_auth_parameters_edit_mode_predefined( self, _mock_rl, _mock_ts, _mock_nonce ): """ Verify that instructor LTI authentication parameters are correctly built with edit mode """ instance = LTIConsumerFactory( lti_provider_id="lti_provider_test", url="http://localhost:8060/lti/videos/3cd0bcc4-0", ) expected_content_parameters = { "lti_message_type": "basic-lti-launch-request", "lti_version": "LTI-1p0", "resource_link_id": "1234", "context_id": "example.com", "user_id": "richie", "lis_person_contact_email_primary": "", "roles": "instructor", "oauth_consumer_key": "TestOauthConsumerKey", "oauth_nonce": "59474787080480293391616018589", "oauth_signature": "Y3d9qVSe+W7kA5E9+7JB/NeF2OA=", "oauth_signature_method": "HMAC-SHA1", "oauth_timestamp": "1616018589", "oauth_version": "1.0", } self.assertDictEqual( expected_content_parameters, instance.get_content_parameters(edit=True) )