MinkExtension icon indicating copy to clipboard operation
MinkExtension copied to clipboard

added: support to configure symfony http client parameters

Open coderste opened this issue 2 years ago • 3 comments

Had an issue with SSL certificate problems when trying to run my tests locally using BrowserKitFactory.php. We have a self-signed certificate locally and unless it's added to the system store the Symfony HttpClient will say there's a certificate problem.

Symfony offers us config options with http_client to disable verify_host and verify_peer.

This PR adds the ability to configure these http_client options inside the browserkit_http driver.

These changes were done by @acsauk over in his own fork here: https://github.com/FriendsOfBehat/MinkExtension/compare/master...acsauk:MinkExtension:master#diff-f973be034feb9afd968a2139eb090d22a81cdd3cfa572dac6d93836a5785b4c9R40-R51

I feel like it would be beneficial for the changes to be over in this forked repo as others might need the ability to disable the verify options on the HttpClient and then there is one less place to maintain the repo also

coderste avatar Dec 08 '22 13:12 coderste

I know little about the Symfony HttpClient, but it seems this change forces the usage of NativeHttpClient where previously HttpClient was used. According to the docblock, HttpClient is used ...

to instantiate the best possible HTTP client for the runtime.

mpdude avatar Dec 09 '22 10:12 mpdude

Q: Should this be considered closed by #22 ? (disclaimer, I've not looked to the changes at all, just sounded like an alternative approach has been followed there, and accepted)

Ciao :-)

stronk7 avatar Sep 15 '23 07:09 stronk7

Q: Should this be considered closed by #22 ? (disclaimer, I've not looked to the changes at all, just sounded like an alternative approach has been followed there, and accepted)

Ciao :-)

Looking at #22 compared to this diff, I've forgotten an important part which makes my version not usable:

    public function configure(ArrayNodeDefinition $builder)
    {
+        $builder
+            ->children()
+                ->arrayNode('http_client_parameters')
+                    ->useAttributeAsKey('key')
+                    ->prototype('variable')->end()
+                ->info('Set parameters on HttpClient (see https://symfony.com/doc/current/reference/configuration/framework.html#http-client)')
+                ->end()
+            ->end();
    }

The configure method has not been updated, so users cannot define the parameters in the configuration file without getting an error (Unrecognized option "http_client_parameters"). I must have gotten mixed up while testing and thought this wasn't needed. I will create a new PR to fix this in the next hour, thank you for making me check twice! (even though I should have done so myself)

BastienGarcia avatar Sep 15 '23 09:09 BastienGarcia