diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-12-14 04:30:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-14 04:30:23 +0300 |
commit | 67f4ec5704efb3242218527b906b1082e3e1f5e8 (patch) | |
tree | 38f8610fbac5c7863be9af661fd0f2411ebddba5 /tests/PHPUnit/Unit | |
parent | ef323275e351ab26370ba67aa5ca62b85035cb45 (diff) |
Revert "Always fail during tracking when authentication is required b… (#13858)
* Revert "Always fail during tracking when authentication is required but invalid token is used (#13675)"
This reverts commit 2862316a05301755681305fbe060591c08d8c265.
* remove tests moved to integration test
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r-- | tests/PHPUnit/Unit/Tracker/RequestTest.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php index 5b125559f1..0620fea492 100644 --- a/tests/PHPUnit/Unit/Tracker/RequestTest.php +++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php @@ -9,7 +9,6 @@ namespace Piwik\Tests\Unit\Tracker; use Piwik\Cookie; -use Piwik\Exception\InvalidRequestParameterException; use Piwik\Network\IPUtils; use Piwik\Piwik; use Piwik\Plugins\CustomVariables\CustomVariables; @@ -494,6 +493,30 @@ class RequestTest extends UnitTestCase $this->assertSame('00:00:00', $request->getLocalTime()); } + public function test_getIpString_ShouldDefaultToServerAddress() + { + $this->assertEquals($_SERVER['REMOTE_ADDR'], $this->request->getIpString()); + } + + public function test_getIpString_ShouldDefaultToServerAddress_IfCustomIpIsSetButNotAuthenticated() + { + $request = $this->buildRequest(array('cip' => '192.192.192.192')); + $this->assertEquals($_SERVER['REMOTE_ADDR'], $request->getIpString()); + } + + public function test_getIpString_ShouldReturnCustomIp_IfAuthenticated() + { + $request = $this->buildRequest(array('cip' => '192.192.192.192')); + $request->setIsAuthenticated(); + $this->assertEquals('192.192.192.192', $request->getIpString()); + } + + public function test_getIp() + { + $ip = $_SERVER['REMOTE_ADDR']; + $this->assertEquals(IPUtils::stringToBinaryIP($ip), $this->request->getIp()); + } + public function test_getCookieName_ShouldReturnConfigValue() { $this->assertEquals('_pk_uid', $this->request->getCookieName()); |