mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 23:44:11 +01:00
URL containing ":" in their path were rejected. This caused problems with some URL from Alfresco or Sharepoint... The default regexp used by AttributeURL was updated to avoid this. Warning, check your config to see if you have any custom regexp configured (`url_validation_pattern` config parameter) ! Also a test was added to document the default regexp.
44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Combodo\iTop\Test\UnitTest\Core;
|
|
|
|
use AttributeURLDefaultPattern;
|
|
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
|
|
|
/**
|
|
* @runTestsInSeparateProcesses
|
|
* @preserveGlobalState disabled
|
|
* @backupGlobals disabled
|
|
*/
|
|
class AttributeURLTest extends ItopTestCase {
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
require_once APPROOT.'core/attributedef.class.inc.php';
|
|
require_once APPROOT.'test/core/AttributeURLDefaultPattern.php';
|
|
}
|
|
|
|
/**
|
|
* @throws \Exception
|
|
* @dataProvider CheckFormatProvider
|
|
*/
|
|
public function testCheckFormat(string $sUrlValue, int $iExpectedResult): void
|
|
{
|
|
$oAttDefUrl = new AttributeURLDefaultPattern('myCode', ["target"=>'_blank', "allowed_values"=>null, "sql"=>'url', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false]);
|
|
$bResult = $oAttDefUrl->CheckFormat($sUrlValue);
|
|
|
|
$this->assertSame($iExpectedResult, $bResult);
|
|
}
|
|
|
|
public function CheckFormatProvider(): array
|
|
{
|
|
return [
|
|
'Simple https URL' => ['https://www.combodo.com/itop', 1],
|
|
'Simple FTP URL' => ['ftp://user:password@myftp.mydomain.com', 1],
|
|
'Sharepoint URL 1' => ['https://mydomain1.sharepoint.com/:i:/r/sites/DSIMyDept/Shared%20Documents/Architecture%20Technique/02%20-%20R%C3%A9seau/Baie%2025C/Baie%201er/Baie-25C-1er.jpg?csf=1&web=1&e=Il3txR', 1],
|
|
'Sharepoint URL 2' => ['https://mydomain2.sharepoint.com/:u:/r/sites/DIS/ITSM/00_Admin_iTOP/iTop%20-%20Upgrade%20manuel/Procedure%20upgrade%20Combodo.url?csf=1&web=1&e=DAF0i3', 1],
|
|
'Alfresco URL 2' => ['http://alfresco.mydomain3.org/share/page/site/books/document-details?nodeRef=workspace://SpacesStore/6274f55f-a25b-4762-a863-77f7066f2034', 1],
|
|
];
|
|
}
|
|
}
|