Exemplo n.º 1
0
    def test_it_returns_None_if_all_schemas_fail(
        self,
        launch_params_auth_schema,
        bearer_token_schema,
        canvas_oauth_callback_schema,
        pyramid_request,
    ):
        launch_params_auth_schema.lti_user.side_effect = ValidationError(
            ["TEST_ERROR_MESSAGE"])
        bearer_token_schema.lti_user.side_effect = ValidationError(
            ["TEST_ERROR_MESSAGE"])
        canvas_oauth_callback_schema.lti_user.side_effect = ValidationError(
            ["TEST_ERROR_MESSAGE"])

        assert get_lti_user(pyramid_request) is None
Exemplo n.º 2
0
    def test_it_returns_the_LTIUser_from_LaunchParamsAuthSchema(
        self,
        bearer_token_schema,
        LaunchParamsAuthSchema,
        launch_params_auth_schema,
        pyramid_request,
    ):
        bearer_token_schema.lti_user.side_effect = ValidationError(
            ["TEST_ERROR_MESSAGE"])

        lti_user = get_lti_user(pyramid_request)

        LaunchParamsAuthSchema.assert_called_once_with(pyramid_request)
        launch_params_auth_schema.lti_user.assert_called_once_with()
        assert lti_user == launch_params_auth_schema.lti_user.return_value
Exemplo n.º 3
0
    def test_if_LaunchParamsAuthSchema_fails_it_falls_back_on_BearerTokenSchema(
        self,
        launch_params_auth_schema,
        BearerTokenSchema,
        bearer_token_schema,
        pyramid_request,
    ):
        launch_params_auth_schema.lti_user.side_effect = ValidationError(
            ["TEST_ERROR_MESSAGE"])

        lti_user = get_lti_user(pyramid_request)

        BearerTokenSchema.assert_called_once_with(pyramid_request)
        bearer_token_schema.lti_user.assert_called_once_with()
        assert lti_user == bearer_token_schema.lti_user.return_value
Exemplo n.º 4
0
 def test_LaunchParamsAuthSchema_overrides_BearerTokenSchema(
         self, launch_params_auth_schema, pyramid_request):
     assert (get_lti_user(pyramid_request) ==
             launch_params_auth_schema.lti_user.return_value)