Skip to content
Snippets Groups Projects
Commit a47bf769 authored by catch's avatar catch
Browse files

Issue #2503063 by alexpott, Lendude: Removing XssTest causes test failures due...

Issue #2503063 by alexpott, Lendude: Removing XssTest causes test failures due to UrlHelper's static $allowedProtocols
parent b5208e28
Branches
Tags
Loading
......@@ -18,8 +18,13 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
/**
* @covers ::validate
* @dataProvider providerValidate
* @runInSeparateProcess
*/
public function testValidate($value, $valid) {
public function testValidate($url, $valid) {
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn(Url::fromUri($url));
$context = $this->createMock(ExecutionContextInterface::class);
if ($valid) {
......@@ -38,7 +43,7 @@ public function testValidate($value, $valid) {
$validator = new LinkExternalProtocolsConstraintValidator();
$validator->initialize($context);
$validator->validate($value, $constraint);
$validator->validate($link, $constraint);
}
/**
......@@ -56,15 +61,6 @@ public function providerValidate() {
// Invalid protocols.
$data[] = ['ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt', FALSE];
foreach ($data as &$single_data) {
$url = Url::fromUri($single_data[0]);
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn($url);
$single_data[0] = $link;
}
return $data;
}
......
......@@ -449,6 +449,8 @@ public static function providerTestIsExternal() {
* Expected escaped value.
* @param array $protocols
* Protocols to allow.
*
* @runInSeparateProcess
*/
public function testFilterBadProtocol($uri, $expected, $protocols) {
UrlHelper::setAllowedProtocols($protocols);
......@@ -488,6 +490,8 @@ public static function providerTestFilterBadProtocol() {
* Expected escaped value.
* @param array $protocols
* Protocols to allow.
*
* @runInSeparateProcess
*/
public function testStripDangerousProtocols($uri, $expected, $protocols) {
UrlHelper::setAllowedProtocols($protocols);
......
......@@ -23,6 +23,8 @@
* Relevant CVEs:
* - CVE-2002-1806, ~CVE-2005-0682, ~CVE-2005-2106, CVE-2005-3973,
* CVE-2006-1226 (= rev. 1.112?), CVE-2008-0273, CVE-2008-3740.
*
* @runTestsInSeparateProcesses
*/
class XssTest extends TestCase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment