Code Duplication    Length = 14-16 lines in 7 locations

tests/lib/appframework/http/RequestTest.php 7 locations

@@ 799-812 (lines=14) @@
796
		];
797
	}
798
799
	public function testInsecureServerHostServerNameHeader() {
800
		$request = new Request(
801
			[
802
				'server' => [
803
					'SERVER_NAME' => 'from.server.name:8080',
804
				]
805
			],
806
			$this->secureRandom,
807
			$this->config,
808
			$this->stream
809
		);
810
811
		$this->assertSame('from.server.name:8080',  $request->getInsecureServerHost());
812
	}
813
814
	public function testInsecureServerHostHttpHostHeader() {
815
		$request = new Request(
@@ 814-828 (lines=15) @@
811
		$this->assertSame('from.server.name:8080',  $request->getInsecureServerHost());
812
	}
813
814
	public function testInsecureServerHostHttpHostHeader() {
815
		$request = new Request(
816
			[
817
				'server' => [
818
					'SERVER_NAME' => 'from.server.name:8080',
819
					'HTTP_HOST' => 'from.host.header:8080',
820
				]
821
			],
822
			$this->secureRandom,
823
			$this->config,
824
			$this->stream
825
		);
826
827
		$this->assertSame('from.host.header:8080',  $request->getInsecureServerHost());
828
	}
829
830
	public function testInsecureServerHostHttpFromForwardedHeaderSingle() {
831
		$request = new Request(
@@ 830-845 (lines=16) @@
827
		$this->assertSame('from.host.header:8080',  $request->getInsecureServerHost());
828
	}
829
830
	public function testInsecureServerHostHttpFromForwardedHeaderSingle() {
831
		$request = new Request(
832
			[
833
				'server' => [
834
					'SERVER_NAME' => 'from.server.name:8080',
835
					'HTTP_HOST' => 'from.host.header:8080',
836
					'HTTP_X_FORWARDED_HOST' => 'from.forwarded.host:8080',
837
				]
838
			],
839
			$this->secureRandom,
840
			$this->config,
841
			$this->stream
842
		);
843
844
		$this->assertSame('from.forwarded.host:8080',  $request->getInsecureServerHost());
845
	}
846
847
	public function testInsecureServerHostHttpFromForwardedHeaderStacked() {
848
		$request = new Request(
@@ 847-862 (lines=16) @@
844
		$this->assertSame('from.forwarded.host:8080',  $request->getInsecureServerHost());
845
	}
846
847
	public function testInsecureServerHostHttpFromForwardedHeaderStacked() {
848
		$request = new Request(
849
			[
850
				'server' => [
851
					'SERVER_NAME' => 'from.server.name:8080',
852
					'HTTP_HOST' => 'from.host.header:8080',
853
					'HTTP_X_FORWARDED_HOST' => 'from.forwarded.host2:8080,another.one:9000',
854
				]
855
			],
856
			$this->secureRandom,
857
			$this->config,
858
			$this->stream
859
		);
860
861
		$this->assertSame('from.forwarded.host2:8080',  $request->getInsecureServerHost());
862
	}
863
864
	public function testGetServerHostWithOverwriteHost() {
865
		$this->config
@@ 1007-1020 (lines=14) @@
1004
		$this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost'));
1005
	}
1006
1007
	public function testGetPathInfoWithSetEnv() {
1008
		$request = new Request(
1009
			[
1010
				'server' => [
1011
					'PATH_INFO' => 'apps/files/',
1012
				]
1013
			],
1014
			$this->secureRandom,
1015
			$this->config,
1016
			$this->stream
1017
		);
1018
1019
		$this->assertSame('apps/files/',  $request->getPathInfo());
1020
	}
1021
1022
	/**
1023
	 * @expectedException \Exception
@@ 1026-1040 (lines=15) @@
1023
	 * @expectedException \Exception
1024
	 * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php')
1025
	 */
1026
	public function testGetPathInfoNotProcessible() {
1027
		$request = new Request(
1028
			[
1029
				'server' => [
1030
					'REQUEST_URI' => '/foo.php',
1031
					'SCRIPT_NAME' => '/var/www/index.php',
1032
				]
1033
			],
1034
			$this->secureRandom,
1035
			$this->config,
1036
			$this->stream
1037
		);
1038
1039
		$request->getPathInfo();
1040
	}
1041
1042
	/**
1043
	 * @expectedException \Exception
@@ 1046-1060 (lines=15) @@
1043
	 * @expectedException \Exception
1044
	 * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php')
1045
	 */
1046
	public function testGetRawPathInfoNotProcessible() {
1047
		$request = new Request(
1048
			[
1049
				'server' => [
1050
					'REQUEST_URI' => '/foo.php',
1051
					'SCRIPT_NAME' => '/var/www/index.php',
1052
				]
1053
			],
1054
			$this->secureRandom,
1055
			$this->config,
1056
			$this->stream
1057
		);
1058
1059
		$request->getRawPathInfo();
1060
	}
1061
1062
	/**
1063
	 * @dataProvider genericPathInfoProvider