MDL-68658 phpunit: Ensure that the configured proxy is applied always
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 10 May 2020 14:54:14 +0000 (16:54 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 22 May 2020 15:07:05 +0000 (17:07 +0200)
Previously, if the RSS feed (extests) was being served locally,
CFG->proxybypass was applied and causing the test to fail (proxy
ignored).

In that exact test we need the configured proxy to be applied
always, because the test is exaclty about detecting the problem
when a wrong proxy is used.

lib/tests/rsslib_test.php

index 51648c9..c724f6a 100644 (file)
@@ -118,11 +118,15 @@ EOD;
         $oldproxy = $CFG->proxyhost;
         $CFG->proxyhost = 'xxxxxxxxxxxxxxx.moodle.org';
 
+        $oldproxybypass = $CFG->proxybypass; // Ensure we don't get locally served extests bypassing the proxy.
+        $CFG->proxybypass = '';
+
         $feed = new moodle_simplepie($this->getExternalTestFileUrl('/rsstest.xml'));
 
         $this->assertNotEmpty($feed->error());
         $this->assertEmpty($feed->get_title());
         $CFG->proxyhost = $oldproxy;
+        $CFG->proxybypass = $oldproxybypass;
     }
 
     /*