Index: standard/trunk/tests/Zend/Controller/Request/HttpTest.php =================================================================== --- standard/trunk/tests/Zend/Controller/Request/HttpTest.php (revision 14636) +++ standard/trunk/tests/Zend/Controller/Request/HttpTest.php (working copy) @@ -617,27 +617,69 @@ /** * @group ZF-3161 + * @group ZFI-233 + * @group ZF-5818 */ - public function testRetrievingRequestUriShouldStripProtocolHostAndPortWhenPresent() + public function testStrippingHttpProtocolAndHostFromRequestUriOnlyWhenPresentAtBeginningOfUri() { - $_SERVER['REQUEST_URI'] = 'http://foo.example.com/foo/bar'; + $_SERVER['REQUEST_URI'] = 'http://foo.example.com/foo/bar?r=http://foo.example.com/bar/baz'; $_SERVER['HTTP_HOST'] = 'foo.example.com'; $request = new Zend_Controller_Request_Http(); $test = $request->getRequestUri(); - $this->assertEquals('/foo/bar', $test); + $this->assertEquals('/foo/bar?r=http://foo.example.com/bar/baz', $test); + + $_SERVER['REQUEST_URI'] = '/foo/bar?r=http://foo.example.com/bar/baz'; + $_SERVER['HTTP_HOST'] = 'foo.example.com'; + $request = new Zend_Controller_Request_Http(); + $test = $request->getRequestUri(); + $this->assertEquals('/foo/bar?r=http://foo.example.com/bar/baz', $test); } /** + * @group ZF-3161 * @group ZFI-233 + * @group ZF-5818 */ - public function testStrippingProtocolHostAndPortShouldStripFromBeginningOfUri() + public function testStrippingHttpsProtocolAndHostFromRequestUriOnlyWhenPresentAtBeginningOfUri() { - $_SERVER['REQUEST_URI'] = 'http://foo.example.com/foo/bar?r=http://foo.example.com/bar/baz'; + $_SERVER['REQUEST_URI'] = 'https://foo.example.com/foo/bar?r=https://foo.example.com/bar/baz'; $_SERVER['HTTP_HOST'] = 'foo.example.com'; + $_SERVER['HTTPS'] = 'on'; $request = new Zend_Controller_Request_Http(); $test = $request->getRequestUri(); - $this->assertEquals('/foo/bar?r=http://foo.example.com/bar/baz', $test); + $this->assertEquals('/foo/bar?r=https://foo.example.com/bar/baz', $test); + + $_SERVER['REQUEST_URI'] = '/foo/bar?r=https://foo.example.com/bar/baz'; + $_SERVER['HTTP_HOST'] = 'foo.example.com'; + $_SERVER['HTTPS'] = 'on'; + $request = new Zend_Controller_Request_Http(); + $test = $request->getRequestUri(); + $this->assertEquals('/foo/bar?r=https://foo.example.com/bar/baz', $test); } + + /** + * @group ZF-3161 + * @group ZFI-233 + * @group ZF-5818 + */ + public function testStrippingHttpProtocolHostAndNonStandardPortFromRequestUriOnlyWhenPresentAtBeginningOfUri() + { + $_SERVER['REQUEST_URI'] = 'http://foo.example.com:8888/foo/bar?r=http://foo.example.com:8888/bar/baz'; + $_SERVER['HTTP_HOST'] = ''; + $_SERVER['SERVER_NAME'] = 'foo.example.com'; + $_SERVER['SERVER_PORT'] = '8888'; + $request = new Zend_Controller_Request_Http(); + $test = $request->getRequestUri(); + $this->assertEquals('/foo/bar?r=http://foo.example.com:8888/bar/baz', $test); + + $_SERVER['REQUEST_URI'] = '/foo/bar?r=https://foo.example.com:8888/bar/baz'; + $_SERVER['HTTP_HOST'] = ''; + $_SERVER['SERVER_NAME'] = 'foo.example.com'; + $_SERVER['SERVER_PORT'] = '8888'; + $request = new Zend_Controller_Request_Http(); + $test = $request->getRequestUri(); + $this->assertEquals('/foo/bar?r=https://foo.example.com:8888/bar/baz', $test); + } } // Call Zend_Controller_Request_HttpTest::main() if this source file is executed directly.