You are here

public function ClientIpRestoreTest::requestProvider in CloudFlare 8

Provider for testing ClientIpRestoreProvider.

Return value

array Test Data to simulate incoming request and the expected results..

File

tests/src/Unit/ClientIpRestoreTest.php, line 154

Class

ClientIpRestoreTest
Tests functionality of CloudFlareState object.

Namespace

Drupal\Tests\cloudflare\Unit

Code

public function requestProvider() {

  // The setup container is not yet available.
  $this->container = new ContainerBuilder();
  $this->container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($this->container);
  $message0 = $this
    ->t('Request came through without being routed through CloudFlare.');
  $message1 = $this
    ->t("Client IP of 192.168.2.203 does not match a known CloudFlare IP but there is HTTP_CF_CONNECTING_IP of 103.21.244.0.");
  $message2 = $this
    ->t('Request has already been updated.  This functionality should be deactivated. Please go <a href="@link_to_settings">here</a> to disable "Restore Client Ip Address".', [
    '@link_to_settings' => "/admin/config/services/cloudflare",
  ]);
  $test0 = [
    FALSE,
    'cftest.dev',
    '192.168.2.201',
    NULL,
    'edit.cftest.dev',
    '',
    '192.168.2.201',
  ];
  $test1 = [
    TRUE,
    'cftest.dev',
    '192.168.2.202',
    '',
    'edit.cftest.dev',
    $message0,
    '192.168.2.202',
  ];
  $test2 = [
    TRUE,
    'cftest.dev',
    '192.168.2.203',
    '103.21.244.0',
    'edit.cftest.dev',
    $message1,
    '192.168.2.203',
  ];
  $test3 = [
    TRUE,
    'cftest.dev',
    '103.21.244.0',
    '103.21.244.0',
    'edit.cftest.dev',
    $message2,
    '103.21.244.0',
  ];
  $test4 = [
    TRUE,
    'cftest.dev',
    '103.21.244.0',
    '5.5.5.5',
    'edit.cftest.dev',
    '',
    '5.5.5.5',
  ];
  $test5 = [
    FALSE,
    'edit.cftest.dev',
    '192.168.2.201',
    NULL,
    'edit.cftest.dev',
    '',
    '192.168.2.201',
  ];
  $test6 = [
    TRUE,
    'edit.cftest.dev',
    '192.168.2.202',
    '',
    'edit.cftest.dev',
    '',
    '192.168.2.202',
  ];
  $test7 = [
    TRUE,
    'edit.cftest.dev',
    '192.168.2.203',
    '103.21.244.0',
    'edit.cftest.dev',
    '',
    '192.168.2.203',
  ];
  $test8 = [
    TRUE,
    'edit.cftest.dev',
    '103.21.244.0',
    '103.21.244.0',
    'edit.cftest.dev',
    '',
    '103.21.244.0',
  ];
  $test9 = [
    TRUE,
    'edit.cftest.dev',
    '103.21.244.0',
    '5.5.5.5',
    'edit.cftest.dev',
    '',
    '103.21.244.0',
  ];
  $test10 = [
    FALSE,
    '',
    '192.168.2.201',
    NULL,
    '',
    '',
    '192.168.2.201',
  ];
  $test11 = [
    TRUE,
    '',
    '192.168.2.202',
    '',
    '',
    $message0,
    '192.168.2.202',
  ];
  $test12 = [
    TRUE,
    '',
    '192.168.2.203',
    '103.21.244.0',
    '',
    $message1,
    '192.168.2.203',
  ];
  $test13 = [
    TRUE,
    '',
    '103.21.244.0',
    '103.21.244.0',
    '',
    $message2,
    '103.21.244.0',
  ];
  $test14 = [
    TRUE,
    '',
    '103.21.244.0',
    '5.5.5.5',
    '',
    '',
    '5.5.5.5',
  ];
  return [
    $test0,
    $test1,
    $test2,
    $test3,
    $test4,
    $test5,
    $test6,
    $test7,
    $test8,
    $test9,
    $test10,
    $test11,
    $test12,
    $test13,
    $test14,
  ];
}