From ff0cec8cd866a409c974ffe390c205e39d55ffa8 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Wed, 6 Dec 2023 18:32:47 +0000 Subject: [PATCH] Allow configuration of insecure https --- docker-compose.testing.yml | 1 + tests/smoke/src/Drivers/ChromeDriver.php | 6 +++++- tests/smoke/src/SmokeExtension.php | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docker-compose.testing.yml b/docker-compose.testing.yml index df205ee966..de18050dca 100644 --- a/docker-compose.testing.yml +++ b/docker-compose.testing.yml @@ -25,6 +25,7 @@ services: BEHAT_ACTOR_URL: http://proxy:9002 BEHAT_OLD_VIEWER_URL: http://proxy:9001 BEHAT_OLD_ACTOR_URL: http://proxy:9002 + BEHAT_PARAMS: '{"extensions":{"Smoke\\SmokeExtension":{"allow_insecure_https":true}}}' XDEBUG_CONFIG: client_host=host.docker.internal client_port=9000 XDEBUG_MODE: develop,debug,coverage diff --git a/tests/smoke/src/Drivers/ChromeDriver.php b/tests/smoke/src/Drivers/ChromeDriver.php index 7a1a84d3bc..59fac8d1a6 100644 --- a/tests/smoke/src/Drivers/ChromeDriver.php +++ b/tests/smoke/src/Drivers/ChromeDriver.php @@ -11,6 +11,7 @@ class ChromeDriver implements Driver private ?Process $process; public function __construct( + bool $allowInsecureHttps = false, private string $binPath = '/usr/bin/google-chrome-stable', private array $binArguments = [ '--disable-gpu', @@ -25,10 +26,13 @@ public function __construct( '--no-startup-window', '--no-first-run', '--no-pings', - '--ignore-certificate-errors', ], ) { $this->process = null; + + if ($allowInsecureHttps) { + $this->binArguments[] = '--ignore-certificate-errors'; + } } public function start(): void diff --git a/tests/smoke/src/SmokeExtension.php b/tests/smoke/src/SmokeExtension.php index 6340478fd6..8c9355d1bb 100644 --- a/tests/smoke/src/SmokeExtension.php +++ b/tests/smoke/src/SmokeExtension.php @@ -8,12 +8,11 @@ use Behat\Testwork\ServiceContainer\Extension; use Behat\Testwork\ServiceContainer\ExtensionManager; use Behat\Testwork\ServiceContainer\ServiceProcessor; +use Smoke\Drivers\ChromeDriver; use Smoke\Drivers\Driver; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Smoke\Drivers\ChromeDriver; -use Smoke\DriverSubscriber; class SmokeExtension implements Extension { @@ -60,6 +59,12 @@ public function initialize(ExtensionManager $extensionManager): void */ public function configure(ArrayNodeDefinition $builder): void { + $builder + ->children() + ->scalarNode('allow_insecure_https') + ->defaultFalse() + ->end() + ->end(); } /** @@ -84,6 +89,7 @@ public function process(ContainerBuilder $container): void public function load(ContainerBuilder $container, array $config): void { $definition = new Definition(ChromeDriver::class); + $definition->addArgument($config['allow_insecure_https']); $definition->addTag(Driver::DRIVER_TAG); $container->setDefinition('smokedriver.driver.chrome', $definition);