From 5d18db5aeae46ad0709927d1ece123eba0d53f9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jan 2026 18:15:51 +0100 Subject: [PATCH] Disable remote access in test --- test/phpunit/SecurityTest.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index fc719e8f1c1..8511ebbea73 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -469,15 +469,19 @@ class SecurityTest extends CommonClassTest $tmpvar = preg_match('/not supported/', $tmp['curl_error_msg']); $this->assertEquals(1, $tmpvar, "Did not find the /not supported/ in getURLContent error message. We should."); - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page - $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow - print __METHOD__." url=".$url."\n"; - $this->assertEquals(301, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 response'); + $DISABLEREMOTEACCESSTODOLIBARRFR = 1; - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page - $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 - print __METHOD__." url=".$url."\n"; - $this->assertEquals(200, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 with a follow -> 200 but we get '.(empty($tmp['http_code']) ? 0 : $tmp['http_code'])); + if (empty($DISABLEREMOTEACCESSTODOLIBARRFR)) { + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page + $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow + print __METHOD__." url=".$url."\n"; + $this->assertEquals(301, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 response'); + + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 + print __METHOD__." url=".$url."\n"; + $this->assertEquals(200, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 with a follow -> 200 but we get '.(empty($tmp['http_code']) ? 0 : $tmp['http_code'])); + } $url = 'http://localhost'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL