I'm working on a module that has some business logic around the user agent, but I cannot write functional tests for this because changing the user agent breaks the drupal_valid_test_ua
function which validates if a Drupal request originates from a test.
BrowserTestBase has this code that is called before each request:
protected function prepareRequest() {
$session = $this->getSession();
$session->setCookie('SIMPLETEST_USER_AGENT', drupal_generate_test_ua($this->databasePrefix));
}
Sprinkled throughout core are calls to drupal_valid_test_ua
which has a regex for checking the user agent is valid for a test:
preg_match("/^simple(\w+\d+):(.+):(.+):(.+)$/", $user_agent, $matches)
I propose that the regex be changed to something like this, so other user agent text can be added to the end, separated by a space:
preg_match("/^simple(\w+\d+):(.+):(.+):([^ ]+)/", $user_agent, $matches)
Needs work
9.5
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.