imbo / behat-api-extension

API extension for Behat, used to ease testing of JSON-based APIs
MIT License
109 stars 42 forks source link

Disable Guzzle client proxy #50

Closed hiromik closed 7 years ago

hiromik commented 7 years ago

Hi @christeredvartsen,

I was using the context https://github.com/knpuniversity/rest/blob/master/features/api/ApiFeatureContext.php but decided to use this behat-api-extension, my only issue is that I need to disable the proxy which I used to do in the constructor of the class.

I've read the part about extending the extension, could anyone show me how to disable proxy using the middleware ? Thanks

christeredvartsen commented 7 years ago

Not entirely sure what you want to achieve.

Are you using the proxy request option, but can't figure out a way to use this in the Behat API extension?

hiromik commented 7 years ago

I want to know how you pass the option ['proxy' => ''] to the Guzzle client that's being used by the extension, workplace has a proxy that breaks my scenarios by returning a 503 error that I can fix by disabling the proxy.

christeredvartsen commented 7 years ago

Do you have a class that extends the context class from the extension? If so you can try to add a proxy element to the request options property:

<?php
class MyContext extends ApiContext {
    public function __construct() {
        $this->requestOptions['proxy'] = '';
    }
}

Is your code publicly available?

hiromik commented 7 years ago

I have exactly a class extending that ApiContext, I was following the guide here : https://behat-api-extension.readthedocs.io/en/latest/guide/extending-the-extension.html#manipulate-the-api-client and wanted to know how you'd disable the proxy using setClient() I will try your method though.

christeredvartsen commented 7 years ago

@hiromik Closing this issue for now. If the above method did not work for you, feel free to reopen.