class ProxyConfigTest in Raven: Sentry Integration 8.2
Same name and namespace in other branches
- 3.x tests/src/Unit/ProxyConfigTest.php \Drupal\Tests\raven\Unit\ProxyConfigTest
Test proxy configuration.
@group raven
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\raven\Unit\ProxyConfigTest
Expanded class hierarchy of ProxyConfigTest
File
- tests/
src/ Unit/ ProxyConfigTest.php, line 16
Namespace
Drupal\Tests\raven\UnitView source
class ProxyConfigTest extends UnitTestCase {
/**
* Config factory.
*
* @var \PHPUnit\Framework\MockObject\MockBuilder
*/
protected $configFactory;
/**
* Environment.
*
* @var string
*/
protected $environment;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The message's placeholders parser.
*
* @var \Drupal\Core\Logger\LogMessageParserInterface
*/
protected $parser;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->parser = $this
->createMock(LogMessageParserInterface::class);
$this->moduleHandler = $this
->createMock(ModuleHandlerInterface::class);
$this->environment = 'testing';
}
/**
* Data provider for testProxyConfiguration().
*/
public function proxyConfigurationData() {
return [
// HTTP DSN, Empty proxy white-list.
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [],
],
'http',
],
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [],
],
'http',
],
// HTTP DSN, Not empty proxy white-list.
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [
'some.server.test',
],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [
'some.server.test',
],
],
'http',
],
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
],
],
'http',
],
// HTTP DSN, Not empty proxy white-list, Sentry white-listed.
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'http://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
// HTTPS DSN, Empty proxy white-list.
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [],
],
'https',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [],
],
'https',
],
// HTTPS DSN, Not empty proxy white-list.
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [
'some.server.test',
],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [
'some.server.test',
],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
],
],
'https',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
],
],
'https',
],
// HTTPS DSN, Not empty proxy white-list, Sentry white-listed.
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => NULL,
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => NULL,
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => NULL,
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
[
'https://user:password@sentry.test/123456',
[
'http' => 'http-proxy.server.test:3129',
'https' => 'https-proxy.server.test:3129',
'no' => [
'some.server.test',
'sentry.test',
],
],
'no',
],
];
}
/**
* Test proxy configuration.
*
* @dataProvider proxyConfigurationData
*/
public function testProxyConfiguration($dsn, $config, $proxy) {
$this->configFactory = $this
->getConfigFactoryStub([
'raven.settings' => [
'client_key' => $dsn,
// We need this to avoid registering error handlers in
// \Drupal\raven\Logger\Raven constructor.
'fatal_error_handler' => FALSE,
],
]);
new Settings([
'http_client_config' => [
'proxy' => $config,
],
]);
$raven = new Raven($this->configFactory, $this->parser, $this->moduleHandler, $this->environment);
if ($proxy === 'no') {
self::assertEmpty($raven->client->http_proxy, 'No proxy configured for Raven_Client');
}
else {
self::assertSame($config[$proxy], $raven->client->http_proxy, strtoupper($proxy) . ' proxy configured for Raven_Client');
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
ProxyConfigTest:: |
protected | property | Config factory. | |
ProxyConfigTest:: |
protected | property | Environment. | |
ProxyConfigTest:: |
protected | property | The module handler. | |
ProxyConfigTest:: |
protected | property | The message's placeholders parser. | |
ProxyConfigTest:: |
public | function | Data provider for testProxyConfiguration(). | |
ProxyConfigTest:: |
protected | function |
Overrides UnitTestCase:: |
|
ProxyConfigTest:: |
public | function | Test proxy configuration. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |