You are here

public function RequestTest::testGetClientIpsProvider in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testGetClientIpsProvider()

File

vendor/symfony/http-foundation/Tests/RequestTest.php, line 905

Class

RequestTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testGetClientIpsProvider() {

  //        $expected                   $remoteAddr                $httpForwardedFor            $trustedProxies
  return array(
    // simple IPv4
    array(
      array(
        '88.88.88.88',
      ),
      '88.88.88.88',
      null,
      null,
    ),
    // trust the IPv4 remote addr
    array(
      array(
        '88.88.88.88',
      ),
      '88.88.88.88',
      null,
      array(
        '88.88.88.88',
      ),
    ),
    // simple IPv6
    array(
      array(
        '::1',
      ),
      '::1',
      null,
      null,
    ),
    // trust the IPv6 remote addr
    array(
      array(
        '::1',
      ),
      '::1',
      null,
      array(
        '::1',
      ),
    ),
    // forwarded for with remote IPv4 addr not trusted
    array(
      array(
        '127.0.0.1',
      ),
      '127.0.0.1',
      '88.88.88.88',
      null,
    ),
    // forwarded for with remote IPv4 addr trusted
    array(
      array(
        '88.88.88.88',
      ),
      '127.0.0.1',
      '88.88.88.88',
      array(
        '127.0.0.1',
      ),
    ),
    // forwarded for with remote IPv4 and all FF addrs trusted
    array(
      array(
        '88.88.88.88',
      ),
      '127.0.0.1',
      '88.88.88.88',
      array(
        '127.0.0.1',
        '88.88.88.88',
      ),
    ),
    // forwarded for with remote IPv4 range trusted
    array(
      array(
        '88.88.88.88',
      ),
      '123.45.67.89',
      '88.88.88.88',
      array(
        '123.45.67.0/24',
      ),
    ),
    // forwarded for with remote IPv6 addr not trusted
    array(
      array(
        '1620:0:1cfe:face:b00c::3',
      ),
      '1620:0:1cfe:face:b00c::3',
      '2620:0:1cfe:face:b00c::3',
      null,
    ),
    // forwarded for with remote IPv6 addr trusted
    array(
      array(
        '2620:0:1cfe:face:b00c::3',
      ),
      '1620:0:1cfe:face:b00c::3',
      '2620:0:1cfe:face:b00c::3',
      array(
        '1620:0:1cfe:face:b00c::3',
      ),
    ),
    // forwarded for with remote IPv6 range trusted
    array(
      array(
        '88.88.88.88',
      ),
      '2a01:198:603:0:396e:4789:8e99:890f',
      '88.88.88.88',
      array(
        '2a01:198:603:0::/65',
      ),
    ),
    // multiple forwarded for with remote IPv4 addr trusted
    array(
      array(
        '88.88.88.88',
        '87.65.43.21',
        '127.0.0.1',
      ),
      '123.45.67.89',
      '127.0.0.1, 87.65.43.21, 88.88.88.88',
      array(
        '123.45.67.89',
      ),
    ),
    // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted
    array(
      array(
        '87.65.43.21',
        '127.0.0.1',
      ),
      '123.45.67.89',
      '127.0.0.1, 87.65.43.21, 88.88.88.88',
      array(
        '123.45.67.89',
        '88.88.88.88',
      ),
    ),
    // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle
    array(
      array(
        '88.88.88.88',
        '127.0.0.1',
      ),
      '123.45.67.89',
      '127.0.0.1, 87.65.43.21, 88.88.88.88',
      array(
        '123.45.67.89',
        '87.65.43.21',
      ),
    ),
    // multiple forwarded for with remote IPv4 addr and all reverse proxies trusted
    array(
      array(
        '127.0.0.1',
      ),
      '123.45.67.89',
      '127.0.0.1, 87.65.43.21, 88.88.88.88',
      array(
        '123.45.67.89',
        '87.65.43.21',
        '88.88.88.88',
        '127.0.0.1',
      ),
    ),
    // multiple forwarded for with remote IPv6 addr trusted
    array(
      array(
        '2620:0:1cfe:face:b00c::3',
        '3620:0:1cfe:face:b00c::3',
      ),
      '1620:0:1cfe:face:b00c::3',
      '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3',
      array(
        '1620:0:1cfe:face:b00c::3',
      ),
    ),
    // multiple forwarded for with remote IPv6 addr and some reverse proxies trusted
    array(
      array(
        '3620:0:1cfe:face:b00c::3',
      ),
      '1620:0:1cfe:face:b00c::3',
      '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3',
      array(
        '1620:0:1cfe:face:b00c::3',
        '2620:0:1cfe:face:b00c::3',
      ),
    ),
    // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle
    array(
      array(
        '2620:0:1cfe:face:b00c::3',
        '4620:0:1cfe:face:b00c::3',
      ),
      '1620:0:1cfe:face:b00c::3',
      '4620:0:1cfe:face:b00c::3,3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3',
      array(
        '1620:0:1cfe:face:b00c::3',
        '3620:0:1cfe:face:b00c::3',
      ),
    ),
    // client IP with port
    array(
      array(
        '88.88.88.88',
      ),
      '127.0.0.1',
      '88.88.88.88:12345, 127.0.0.1',
      array(
        '127.0.0.1',
      ),
    ),
  );
}