/**
* Tests validation of the User-Agent header we use to perform test requests.
*/
public function testUserAgentValidation() { $assert_session =
$this->
assertSession();
$system_path =
$this->
buildUrl(\Drupal::
service('extension.list.module'
)->
getPath('system'
));
$http_path =
$system_path . '/tests/http.php/user/login';
$https_path =
$system_path . '/tests/https.php/user/login';
// Generate a valid test User-Agent to pass validation.
$this->
assertNotFalse(preg_match('/test\d+/',
$this->databasePrefix,
$matches), 'Database prefix contains test prefix.'
);
$this->agent =
drupal_generate_test_ua($matches[0
]);
// Test pages only available for testing.
$this->
drupalGet($http_path);
$assert_session->
statusCodeEquals(200
);
$this->
drupalGet($https_path);
$assert_session->
statusCodeEquals(200
);
// Now slightly modify the HMAC on the header, which should not validate.
$this->agent = 'X';
$this->
drupalGet($http_path);
$assert_session->
statusCodeEquals(403
);