Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85075

filelib unit test fails if additional curl security helper plugin is installed

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.4.8, 4.5.4, 5.0
    • Files API

      The mere presence of an additional curl security helper plugin causes a test failure, due to what seems like an incorrect test:

      1) core\filelib_test::test_curl_basics_with_security_helper
      Failed asserting that two strings are identical.
      --- Expected
      +++ Actual
      @@ @@
      -'You shall not pass'
      +'The URL is blocked.'/var/www/moodle/lib/tests/filelib_test.php:303

      A quick inspection seems to show this is because the tests use a mock helper, but this mock helper is not used when an additional helper is installed, so the tests fail.

      In lib/tests/filelib_test.php:3034 is checking the contents returned is 'You shall not pass', but because check_securityhelper_blocklist here:

      https://github.com/moodle/moodle/blob/b00c328d2dbbd49dcba8738c9da3ba4302e56c3a/lib/filelib.php#L3742

      is returning the curlmanager plugin, instead of the mocked security helper, which would return in the block below but is never reached:

      https://github.com/moodle/moodle/blob/b00c328d2dbbd49dcba8738c9da3ba4302e56c3a/lib/filelib.php#L3751 

      This can probably be fixed by just reordering these blocks so the mock helper is always executed first.

      Reproduce:

       

            matthewhilton Matthew Hilton
            matthewhilton Matthew Hilton
            Peter Burnett Peter Burnett
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.