Skip to content

Commit

Permalink
add test case for trusted proxy with REMOTE_ADDR
Browse files Browse the repository at this point in the history
  • Loading branch information
chuoke committed Sep 26, 2024
1 parent db51764 commit 50cee4f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Http/Middleware/TrustProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ public function test_trusted_proxy_sets_trusted_proxies_with_double_wildcard_for
});
}

/**
* Test the next most typical usage of TrustedProxies:
* Trusted X-Forwarded-For header, REMOTE_ADDR for TrustedProxies.
*/
public function test_trusted_proxy_sets_trusted_proxies_with_REMOTE_ADDR()
{
$trustedProxy = $this->createTrustedProxy($this->headerAll, 'REMOTE_ADDR');
$request = $this->createProxiedRequest();

$trustedProxy->handle($request, function ($request) {
$this->assertSame('173.174.200.38', $request->getClientIp(), 'Assert trusted proxy x-forwarded-for header used with REMOTE_ADDR proxy setting');
});
}

/**
* Test the most typical usage of TrustProxies:
* Trusted X-Forwarded-For header.
Expand Down

0 comments on commit 50cee4f

Please sign in to comment.