Code Duplication    Length = 27-31 lines in 2 locations

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

@@ 441-467 (lines=27) @@
438
		$this->assertSame('10.0.0.2', $request->getRemoteAddress());
439
	}
440
441
	public function testGetRemoteAddressWithSingleTrustedRemote() {
442
		$this->config
443
			->expects($this->at(0))
444
			->method('getSystemValue')
445
			->with('trusted_proxies')
446
			->will($this->returnValue(['10.0.0.2']));
447
		$this->config
448
			->expects($this->at(1))
449
			->method('getSystemValue')
450
			->with('forwarded_for_headers')
451
			->will($this->returnValue(['HTTP_X_FORWARDED']));
452
453
		$request = new Request(
454
			[
455
				'server' => [
456
					'REMOTE_ADDR' => '10.0.0.2',
457
					'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
458
					'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
459
				],
460
			],
461
			$this->secureRandom,
462
			$this->config,
463
			$this->stream
464
		);
465
466
		$this->assertSame('10.4.0.5', $request->getRemoteAddress());
467
	}
468
469
	public function testGetRemoteAddressVerifyPriorityHeader() {
470
		$this->config
@@ 469-499 (lines=31) @@
466
		$this->assertSame('10.4.0.5', $request->getRemoteAddress());
467
	}
468
469
	public function testGetRemoteAddressVerifyPriorityHeader() {
470
		$this->config
471
			->expects($this->at(0))
472
			->method('getSystemValue')
473
			->with('trusted_proxies')
474
			->will($this->returnValue(['10.0.0.2']));
475
		$this->config
476
			->expects($this->at(1))
477
			->method('getSystemValue')
478
			->with('forwarded_for_headers')
479
			->will($this->returnValue([
480
				'HTTP_CLIENT_IP',
481
				'HTTP_X_FORWARDED_FOR',
482
				'HTTP_X_FORWARDED'
483
			]));
484
485
		$request = new Request(
486
			[
487
				'server' => [
488
					'REMOTE_ADDR' => '10.0.0.2',
489
					'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
490
					'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
491
				],
492
			],
493
			$this->secureRandom,
494
			$this->config,
495
			$this->stream
496
		);
497
498
		$this->assertSame('192.168.0.233', $request->getRemoteAddress());
499
	}
500
501
	/**
502
	 * @return array