diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-07-06 10:22:00 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2015-07-12 17:43:13 +0200 |
commit | 775803a05cdba9d7fc1b37af4b15ecd80a8cbcc2 (patch) | |
tree | 9a161fb97e69880f3ac8a034714418428937db6b /tests | |
parent | 7f1dfd1c12a143b324fbe68213a49de0586febfa (diff) | |
download | Shaarli-775803a05cdba9d7fc1b37af4b15ecd80a8cbcc2.tar.gz Shaarli-775803a05cdba9d7fc1b37af4b15ecd80a8cbcc2.tar.zst Shaarli-775803a05cdba9d7fc1b37af4b15ecd80a8cbcc2.zip |
Prevent redirection loop everytime we rely on HTTP_REFERER:
* search tag
* delete tag
* pagination
* display privates only
* delete link
* new/edit/cancel link return page
Move location generation to Utils.php + unit tests.
Fixes #256
ninja
Diffstat (limited to 'tests')
-rw-r--r-- | tests/UtilsTest.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 90392dfb..8355c7f8 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php | |||
@@ -93,5 +93,30 @@ class UtilsTest extends PHPUnit_Framework_TestCase | |||
93 | $this->assertFalse(checkDateFormat('Y-m-d', '2015-06')); | 93 | $this->assertFalse(checkDateFormat('Y-m-d', '2015-06')); |
94 | $this->assertFalse(checkDateFormat('Ymd', 'DeLorean')); | 94 | $this->assertFalse(checkDateFormat('Ymd', 'DeLorean')); |
95 | } | 95 | } |
96 | |||
97 | /** | ||
98 | * Test generate location with valid data. | ||
99 | */ | ||
100 | public function testGenerateLocation() { | ||
101 | $ref = 'http://localhost/?test'; | ||
102 | $this->assertEquals($ref, generateLocation($ref, 'localhost')); | ||
103 | $ref = 'http://localhost:8080/?test'; | ||
104 | $this->assertEquals($ref, generateLocation($ref, 'localhost:8080')); | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * Test generate location - anti loop. | ||
109 | */ | ||
110 | public function testGenerateLocationLoop() { | ||
111 | $ref = 'http://localhost/?test'; | ||
112 | $this->assertEquals('?', generateLocation($ref, 'localhost', ['test'])); | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * Test generate location - from other domain. | ||
117 | */ | ||
118 | public function testGenerateLocationOut() { | ||
119 | $ref = 'http://somewebsite.com/?test'; | ||
120 | $this->assertEquals('?', generateLocation($ref, 'localhost')); | ||
121 | } | ||
96 | } | 122 | } |
97 | ?> | ||