diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-03-22 14:26:54 +0300 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-03-22 14:26:54 +0300 |
commit | ff01ac4df1e88950bcdec82c75c90fa084044ac5 (patch) | |
tree | 361fcb6d0eb1a6b81af455f2028a1f2b7c75de95 /plugins/SitesManager/tests | |
parent | 103c1f33a13babcbce01b51f2e9e93e3568209ea (diff) |
Fixes #43
- modify websites admin UI, API to add a column Exclude IPs
- IPs contain wildcards, unlimited IPs per website
- below the website table, added a "Global IP exclude" list. Ips there are excluded from all websites automatically.
- IPs are stored in the tracker cache file for fast access at Tracking time.
- added new field in website table "excluded_ips"
- refactored the ajax loading/error display to allow multiple loading/error div per page
Diffstat (limited to 'plugins/SitesManager/tests')
-rw-r--r-- | plugins/SitesManager/tests/SitesManager.test.php | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/plugins/SitesManager/tests/SitesManager.test.php b/plugins/SitesManager/tests/SitesManager.test.php index 67eecdec5e..eb090a5c0c 100644 --- a/plugins/SitesManager/tests/SitesManager.test.php +++ b/plugins/SitesManager/tests/SitesManager.test.php @@ -105,6 +105,48 @@ class Test_Piwik_SitesManager extends Test_Database } /** + * Test with valid IPs + */ + public function test_addSite_excludedIps_valid() + { + $ips = '1.2.3.4,1.1.1.*,1.2.*.*,1.*.*.*'; + $idsite = Piwik_SitesManager_API::getInstance()->addSite("name","http://piwik.net/", $ips); + $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite); + $this->assertEqual($siteInfo['excluded_ips'], $ips); + } + + /** + * Test with invalid IPs + */ + public function test_addSite_excludedIps_notValid() + { + $invalidIps = array( + '35817587341', + 'ieagieha', + '1.2.3', + '*.1.1.1', + '*.*.1.1', + '*.*.*.1', + '*.*.*.*', + '1.1.1.1.1', + ); + foreach($invalidIps as $ip) + { + $raised = false; + try { + $idsite = Piwik_SitesManager_API::getInstance()->addSite("name","http://piwik.net/", $ip); + } catch(Exception $e) { + $raised = true; + } + if(!$raised) + { + $this->fail('was expecting invalid IP exception to raise'); + } + } + $this->pass(); + } + + /** * one url -> one main_url and nothing inserted as alias urls */ public function test_addSite_oneUrl() @@ -440,8 +482,8 @@ class Test_Piwik_SitesManager extends Test_Database $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org")); $resultWanted = array( - 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net"), - 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org"), + 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "excluded_ips" => ""), + 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "excluded_ips" => ""), ); FakeAccess::setIdSitesAdmin (array(1,3)); @@ -476,8 +518,8 @@ class Test_Piwik_SitesManager extends Test_Database $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org")); $resultWanted = array( - 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net"), - 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org"), + 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "excluded_ips" => ""), + 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "excluded_ips" => ""), ); FakeAccess::setIdSitesView (array(1,3)); @@ -512,8 +554,8 @@ class Test_Piwik_SitesManager extends Test_Database $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3",array("http://piwik.org")); $resultWanted = array( - 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net"), - 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org"), + 0 => array("idsite" => 1, "name" => "site1", "main_url" =>"http://piwik.net", "excluded_ips" => ""), + 1 => array("idsite" => 3, "name" => "site3", "main_url" =>"http://piwik.org", "excluded_ips" => ""), ); FakeAccess::setIdSitesView (array(1,3)); |