From 68e670d8ea7e637e5b1a4c0bef52543dbe1a594a Mon Sep 17 00:00:00 2001
From: Andrew Nicols
',
"outputregex" => '/UPDATE/',
- "expectedcontent" => '
',
+ "expectedcontent" => '
',
],
"Test object from another site should be replaced" => [
"content" => '
'
',
],
"Broken URL should not be changed" => [
@@ -113,11 +113,25 @@ class httpsreplace_test extends \advanced_testcase {
$this->getExternalTestFileUrl('/test.jpg', false) . '">',
"outputregex" => '/UPDATE/',
"expectedcontent" => '
',
+ $this->get_converted_http_link('/test.jpg') . '">',
],
];
}
+ /**
+ * Convert the HTTP external test file URL to use HTTPS.
+ *
+ * Note: We *must not* use getExternalTestFileUrl with the True option
+ * here, becase it is reasonable to have only one of these set due to
+ * issues with SSL certificates.
+ *
+ * @param string $path Path to be rewritten
+ * @return string
+ */
+ protected function get_converted_http_link($path) {
+ return preg_replace('/^http:/', 'https:', $this->getExternalTestFileUrl($path, false));
+ }
+
/**
* Test upgrade_http_links
* @param string $content Example content that we'll attempt to replace.
@@ -152,7 +166,7 @@ class httpsreplace_test extends \advanced_testcase {
// Get the http url, since the default test wwwroot is https.
$wwwrootdomain = 'www.example.com';
$wwwroothttp = preg_replace('/^https:/', 'http:', $CFG->wwwroot);
- $testdomain = 'download.moodle.org';
+ $testdomain = $this->get_converted_http_link('');
return [
"Test image from an available site so shouldn't be reported" => [
"content" => '
',