Skip to content
Extraits de code Groupes Projets
Valider 1ab1ca62 rédigé par mattab's avatar mattab
Parcourir les fichiers

getSitesIdFromSiteUrl should match when website url has unusual scheme eg. fb://example-host

parent ce353896
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -418,6 +418,7 @@ class API extends \Piwik\Plugin\API ...@@ -418,6 +418,7 @@ class API extends \Piwik\Plugin\API
// return all variations of the URL // return all variations of the URL
return array( return array(
$url,
"http://" . $hostname, "http://" . $hostname,
"http://www." . $hostname, "http://www." . $hostname,
"https://" . $hostname, "https://" . $hostname,
......
...@@ -1004,22 +1004,21 @@ class ApiTest extends IntegrationTestCase ...@@ -1004,22 +1004,21 @@ class ApiTest extends IntegrationTestCase
public function test_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls_asSuperUser() public function test_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls_asSuperUser()
{ {
API::getInstance()->addSite("site1", array("https://piwik.org", "http://example.com")); API::getInstance()->addSite("site1", array("https://piwik.org", "http://example.com", "fb://special-url"));
$this->assert_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls(); $this->assert_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls();
} }
public function test_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls_asUserWithViewPermission() public function test_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls_asUserWithViewPermission()
{ {
API::getInstance()->addSite("site1", array("https://piwik.org", "http://example.com")); API::getInstance()->addSite("site1", array("https://piwik.org", "http://example.com", "fb://special-url"));
APIUsersManager::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias"); APIUsersManager::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
APIUsersManager::getInstance()->setUserAccess("user1", "view", array(1)); APIUsersManager::getInstance()->setUserAccess("user1", "view", array(1));
// Make sure we're not Super user
FakeAccess::setSuperUserAccess(false); FakeAccess::setSuperUserAccess(false);
FakeAccess::$identity = 'user1'; FakeAccess::$identity = 'user1';
// Make sure we're not Super user
$this->assertFalse(Piwik::hasUserSuperUserAccess()); $this->assertFalse(Piwik::hasUserSuperUserAccess());
$this->assert_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls(); $this->assert_getSitesIdFromSiteUrl_matchesBothHttpAndHttpsUrls();
...@@ -1039,6 +1038,9 @@ class ApiTest extends IntegrationTestCase ...@@ -1039,6 +1038,9 @@ class ApiTest extends IntegrationTestCase
$idsites = API::getInstance()->getSitesIdFromSiteUrl('https://example.com'); $idsites = API::getInstance()->getSitesIdFromSiteUrl('https://example.com');
$this->assertTrue(count($idsites) == 1); $this->assertTrue(count($idsites) == 1);
$idsites = API::getInstance()->getSitesIdFromSiteUrl("fb://special-url");
$this->assertTrue(count($idsites) == 1);
$idsites = API::getInstance()->getSitesIdFromSiteUrl('https://random-example.com'); $idsites = API::getInstance()->getSitesIdFromSiteUrl('https://random-example.com');
$this->assertTrue(count($idsites) == 0); $this->assertTrue(count($idsites) == 0);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter