MDL-66166 core_useragent: Update MoodleBot UA and treat as web crawler

This commit is contained in:
Brendan Heywood
2019-09-30 23:30:20 +10:00
parent 9528b1ff5b
commit 3bc082dd07
4 changed files with 31 additions and 6 deletions
+5 -3
View File
@@ -1060,14 +1060,16 @@ EOF;
$options = $curl->get_options();
$this->assertNotEmpty($options);
$moodlebot = \core_useragent::get_moodlebot_useragent();
$curl->call_apply_opt($options);
$this->assertTrue(in_array('User-Agent: MoodleBot/1.0', $curl->header));
$this->assertTrue(in_array("User-Agent: $moodlebot", $curl->header));
$this->assertFalse(in_array('User-Agent: Test/1.0', $curl->header));
$options['CURLOPT_USERAGENT'] = 'Test/1.0';
$curl->call_apply_opt($options);
$this->assertTrue(in_array('User-Agent: Test/1.0', $curl->header));
$this->assertFalse(in_array('User-Agent: MoodleBot/1.0', $curl->header));
$this->assertFalse(in_array("User-Agent: $moodlebot", $curl->header));
$curl->set_option('CURLOPT_USERAGENT', 'AnotherUserAgent/1.0');
$curl->call_apply_opt();
@@ -1082,7 +1084,7 @@ EOF;
$curl->unset_option('CURLOPT_USERAGENT');
$curl->call_apply_opt();
$this->assertTrue(in_array('User-Agent: MoodleBot/1.0', $curl->header));
$this->assertTrue(in_array("User-Agent: $moodlebot", $curl->header));
// Finally, test it via exttests, to ensure the agent is sent properly.
// Matching.