Behat / WebApiExtension

Behat extension to test web APIs
http://extensions.behat.org
MIT License
111 stars 114 forks source link

disable ssl check #32

Closed greg0ire closed 8 years ago

greg0ire commented 9 years ago

We are testing, which means we are probably using a self-signed certificate.

greg0ire commented 9 years ago

@stof I believe the build should pass if you restart it…

forceedge01 commented 6 years ago

Until that PR is merged (has been open since 2016, you can do this - hack but works). Put in a method to retrieve the api and then work with it.

public function getWebApiContext() {
       $api = $this->getExternalContext(WebApiContext::class);

        $reflection = new ReflectionObject($api);
        $reflectionMethod = $reflection->getMethod('getClient');
        $reflectionMethod->setAccessible(true);
        $client = $reflectionMethod->invoke($api);

        $reflection = new ReflectionObject($client);
        $reflectionProperty = $reflection->getProperty('config');
        $reflectionProperty->setAccessible(true);
        $config = $reflectionProperty->getValue($client);
        $config['verify'] = false;

        $reflectionProperty->setValue($client, $config);

        return $api;
}