Skip to content

Commit

Permalink
Allow configuration of insecure https
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperaj committed Dec 6, 2023
1 parent defbe76 commit ff0cec8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker-compose.testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion tests/smoke/src/Drivers/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions tests/smoke/src/SmokeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}

/**
Expand All @@ -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);

Expand Down

0 comments on commit ff0cec8

Please sign in to comment.