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

test_failproxy() fails if using local TEST_EXTERNAL_FILES_HTTP_URL

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5.12, 3.6.10, 3.7.6, 3.8.3, 3.9
    • 3.5.13, 3.7.7, 3.8.4
    • Unit tests
    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_35_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • Hide

      If using TEST_EXTERNAL_FILES_HTTP_URL, ensure they aren't server from 127.0.0.1 / localhost, but local IP instead, that way the proxy configured in the test is used and the expectations are correct.

      Show
      If using TEST_EXTERNAL_FILES_HTTP_URL, ensure they aren't server from 127.0.0.1 / localhost, but local IP instead, that way the proxy configured in the test is used and the expectations are correct.
    • Hide

      Preparations

      1. Open a terminal
      2. Start the exttests docker image:

        docker run -p 2080:80 moodlehq/moodle-exttests
        

      3. In config.php setup this:

        define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://localhost:2080');
        

      4. Go to the browser open http://localhost:2080/test.jpg
      5. Verify that you see a snowman picture (that means that "exttests" are being server correctly).
      6. Init phpunit

        php admin/tool/phpunit/cli/init.php
        

      7. Run "core_rsslib_testcase".

        vendor/bin/phpunit -v "core_rsslib_testcase" lib/tests/rsslib_test.php
        

      8. Verify that the test ends without errors (4 tests OK).
      Show
      Preparations Open a terminal Start the exttests docker image: docker run -p 2080:80 moodlehq/moodle-exttests In config.php setup this: define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://localhost:2080'); Go to the browser open http://localhost:2080/test.jpg Verify that you see a snowman picture (that means that "exttests" are being server correctly). Init phpunit php admin/tool/phpunit/cli/init.php Run "core_rsslib_testcase". vendor/bin/phpunit -v "core_rsslib_testcase" lib/tests/rsslib_test.php Verify that the test ends without errors (4 tests OK).

    Description

      Recently I started getting this failure in all my local phpunit tests:

      $ vendor/bin/phpunit -v "core_rsslib_testcase" lib/tests/rsslib_test.php
      Moodle 3.9dev+ (Build: 20200508), 7f725f8ed4ff345e5680f34f5608c6187a96d67c
      Php: 7.4.4, pgsql: 9.6.17, OS: Darwin 19.4.0 x86_64
      PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
       
      Runtime:       PHP 7.4.4
      Configuration: /Users/stronk7/git_moodle/moodle/phpunit.xml
       
      ..F.                                                                4 / 4 (100%)
       
      Time: 773 ms, Memory: 42.00 MB
       
      There was 1 failure:
       
      1) core_rsslib_testcase::test_failproxy
      Failed asserting that a NULL is not empty.
       
      /Users/stronk7/git_moodle/moodle/lib/tests/rsslib_test.php:123
      /Users/stronk7/git_moodle/moodle/lib/phpunit/classes/advanced_testcase.php:80
       
      To re-run:
       vendor/bin/phpunit -v "core_rsslib_testcase" lib/tests/rsslib_test.php
       
      FAILURES!
      Tests: 4, Assertions: 26, Failures: 1.
      

      Any database, any php version, all moodle branches... and 100% consistently.

      After looking a lot and confirming that there wasn't any change... I realised that, recently, I installed the exttests locally and I've them available under http://localhost... url.

      Problem is that such url matches the default CFG->proxybypass values, hence CURL operations don't use the proxy configuration when accessing to them.

      And the failing test is EXACTLY about to to use a wrong proxy configuration and detect that an error is returned. But that wrong proxy configuration isn't used (because of the reason explained above) and the rss feed is fetched without problem. Hence, the test fails.

      So this issue is about to ensure, in that exact test only, that the wrong proxy is used and not excluded because of CFG->proxybypass.

      Attachments

        Activity

          People

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Carlos Escobedo Carlos Escobedo
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              13/Jul/20

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 50 minutes
                2h 50m