public function testCheckURLAllowedWithRegex()
{
$original = $_SERVER;
\SimpleSAML_Configuration::loadFromArray(array('trusted.url.domains' => array('.*\\.example\\.com'), 'trusted.url.regex' => true), '[ARRAY]', 'simplesaml');
$_SERVER['REQUEST_URI'] = '/module.php';
$allowed = array('https://sp.example.com/', 'http://sp.example.com/', 'https://app1.example.com/', 'http://app1.example.com/', 'https://app2.example.com/', 'http://app2.example.com/');
foreach ($allowed as $url) {
$this->assertEquals(HTTP::checkURLAllowed($url), $url);
}
$this->setExpectedException('SimpleSAML_Error_Exception');
HTTP::checkURLAllowed('https://evil.com');
$_SERVER = $original;
}