PHP Class VectorFace\WhipTests\WhipTest

Author: Daniel Bruce ([email protected])
Inheritance: extends PHPUnit_Framework_TestCas\PHPUnit_Framework_TestCase
Show file Open project: vectorface/whip

Public Methods

Method Description
proxyMethodWhitelistProvider ( ) Repeats the above test twice for ipv4 and ipv6
testCustomHeader ( ) Test a custom header with a whitelisted IP.
testEmptySuperglobal ( ) Tests that we get back 127.0.0.1 when there is no superglobal information at all.
testHttpXRealIpHeader ( ) Test HTTP_X_REAL_IP header.
testIPv4AddressRejectedDueToEmptyWhitelist ( ) Test that an IPv4 address is rejected because the whitelist is empty for IPv4.
testIPv6AddressFoundInWhitelist ( ) Tests that we reject a proxy listed IPv6 address that does not fall within the allowed subnet.
testIPv6AddressRejectedDueToEmptyWhitelist ( ) Test that an IPv6 address is rejected because the whitelist is empty for IPv6.
testIPv6AddressRejectedDueToWhitelist ( ) Tests that we reject a proxy listed IPv6 address that does not fall within the allowed subnet.
testInvalidIPv4Address ( ) Tests that an invalid IPv4 address returns false.
testInvalidSource ( ) Tests that an invalid source format is rejected.
testNoAddresFoundDueToBitmask ( ) Tests that we get false when no valid IP address could be found.
testPsr7Request ( ) Tests that we can use a PSR-7 ServerRequestInterface compatible class.
testRemoteAddrMethod ( ) Tests the standard REMOTE_ADDR method.
testSetSourceArrayOverridesServerSuperglobal ( ) Tests that if we specify the source array through Whip::setSource, the class will override any values found in $_SERVER.
testSourceArrayOverridesServerSuperglobal ( ) Tests that if we specify the source array, it overrides any values found in the $_SERVER array.
testSuperglobal ( ) Tests that we get back the right IP when there using superglobals.
testValidIPv6Address ( ) Tests a valid IPv6 address.
testValidIpRejectedDueToWhitelist ( ) Tests that we get false if there is a valid IP in a proxy header but we reject it due to REMOTE_ADDR not being in the whitelist.
testValidWhitelistedProxyMethod ( $remoteAddr ) Tests that we accept whitelisted proxy methods when the IP matches, even if the IP listed is a comma separated list.
testValidWhitelistedProxyMethodWithCIDRdNotation ( ) Tests that we accept proxy method based on a whitelisted IP using the CIDR address notation.
testValidWhitelistedProxyMethodWithDashNotation ( ) Tests that we accept proxy method based on a whitelisted IP using the dashed range notation.
testValidWhitelistedProxyMethodWithWildcardNotation ( ) Tests that we accept proxy method based on a whitelisted IP using the wildcard asterix notation.

Private Methods

Method Description
getHttpMessageMock ( string $remoteAddr, array $headers = [] ) Helper to get a mocked PSR-7 instance.

Method Details

proxyMethodWhitelistProvider() public method

Repeats the above test twice for ipv4 and ipv6

testCustomHeader() public method

Test a custom header with a whitelisted IP.
public testCustomHeader ( )

testEmptySuperglobal() public method

Tests that we get back 127.0.0.1 when there is no superglobal information at all.

testHttpXRealIpHeader() public method

Test HTTP_X_REAL_IP header.

testIPv4AddressRejectedDueToEmptyWhitelist() public method

Test that an IPv4 address is rejected because the whitelist is empty for IPv4.

testIPv6AddressFoundInWhitelist() public method

Tests that we reject a proxy listed IPv6 address that does not fall within the allowed subnet.

testIPv6AddressRejectedDueToEmptyWhitelist() public method

Test that an IPv6 address is rejected because the whitelist is empty for IPv6.

testIPv6AddressRejectedDueToWhitelist() public method

Tests that we reject a proxy listed IPv6 address that does not fall within the allowed subnet.

testInvalidIPv4Address() public method

Tests that an invalid IPv4 address returns false.

testInvalidSource() public method

Tests that an invalid source format is rejected.
public testInvalidSource ( )

testNoAddresFoundDueToBitmask() public method

Tests that we get false when no valid IP address could be found.

testPsr7Request() public method

Tests that we can use a PSR-7 ServerRequestInterface compatible class.
public testPsr7Request ( )

testRemoteAddrMethod() public method

Tests the standard REMOTE_ADDR method.

testSetSourceArrayOverridesServerSuperglobal() public method

Tests that if we specify the source array through Whip::setSource, the class will override any values found in $_SERVER.

testSourceArrayOverridesServerSuperglobal() public method

Tests that if we specify the source array, it overrides any values found in the $_SERVER array.

testSuperglobal() public method

Tests that we get back the right IP when there using superglobals.
public testSuperglobal ( )

testValidIPv6Address() public method

Tests a valid IPv6 address.

testValidIpRejectedDueToWhitelist() public method

Tests that we get false if there is a valid IP in a proxy header but we reject it due to REMOTE_ADDR not being in the whitelist.

testValidWhitelistedProxyMethod() public method

Tests that we accept whitelisted proxy methods when the IP matches, even if the IP listed is a comma separated list.
public testValidWhitelistedProxyMethod ( $remoteAddr )

testValidWhitelistedProxyMethodWithCIDRdNotation() public method

Tests that we accept proxy method based on a whitelisted IP using the CIDR address notation.

testValidWhitelistedProxyMethodWithDashNotation() public method

Tests that we accept proxy method based on a whitelisted IP using the dashed range notation.

testValidWhitelistedProxyMethodWithWildcardNotation() public method

Tests that we accept proxy method based on a whitelisted IP using the wildcard asterix notation.