Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed Jan 6, 2023
1 parent fd046d2 commit cc4e537
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/lib/test-vip-request-block.php
Expand Up @@ -11,7 +11,8 @@ class VIP_Request_Block_Test extends WP_UnitTestCase {
*/

public function tearDown(): void {
unset( $_SERVER['HTTP_TRUE_CLIENT_IP'], $_SERVER['HTTP_X_FORWARDED_FOR'], $_SERVER['HTTP_USER_AGENT'] );
// phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
unset( $_SERVER['HTTP_TRUE_CLIENT_IP'], $_SERVER['HTTP_X_FORWARDED_FOR'], $_SERVER['HTTP_USER_AGENT'] );
parent::tearDown();
}

Expand Down Expand Up @@ -81,13 +82,13 @@ public function data_ipv6_corner_cases(): iterable {

public function test_ua_partial_match() {
// Test that a partial match of the user agent string blocks bad site.
$_SERVER['HTTP_USER_AGENT'] = 'WordPress/6.1.1; https://www.BadSite.com';
$actual = VIP_Request_Block::ua_partial_match( 'https://www.BadSite.com' );
$_SERVER['HTTP_USER_AGENT'] = 'WordPress/6.1.1; https://www.BadSite.com'; // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
$actual = VIP_Request_Block::ua_partial_match( 'https://www.BadSite.com' );
self::assertTrue( $actual, 'Expected request to be blocked based on partial User Agent string match.' );

// Test that allowed user agent string is not blocked.
$_SERVER['HTTP_USER_AGENT'] = 'WordPress/6.1.1; https://www.example.com';
$actual = VIP_Request_Block::ua_partial_match( 'https://www.BadSite.com' );
$_SERVER['HTTP_USER_AGENT'] = 'WordPress/6.1.1; https://www.example.com'; // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
$actual = VIP_Request_Block::ua_partial_match( 'https://www.BadSite.com' );
self::assertFalse( $actual, 'Expected request to be allowed.' );
}
}

0 comments on commit cc4e537

Please sign in to comment.