MarketSquare / roboswag

Apache License 2.0
26 stars 2 forks source link

ProxyError: Cannot connect to proxy #31

Open terezachudobova opened 2 years ago

terezachudobova commented 2 years ago

Dear Mateusz,

thank you for your hard work and contributions to the RF community!

we were beyond excited to try the tool at work, however I am having issues to make the SwaggerPetshop example to work. I am not able to connect to proxy from the company's laptop (while having heavy security measurements in place).

Using OperatingSystem's Set Environment Variable to set both HTTP_PROXY and HTTPS_PROXY within the test case does not seem to work either.

The error: ProxyError: HTTPSConnectionPool(host='petstore3.swagger.io', port=443): Max retries exceeded with url: /api/v3/pet/findByStatus?status=available (Caused by ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory')))

Thank you for looking into this, Tereza

bhirsz commented 2 years ago

I'm not Mateusz but I'm also author :) I once had to deal with heavily protected workstation when I worked for the bank and I also had to deal with proxy in API tests so it's familiar.. . I'm just returning to supporting roboswag (had quite longer break due to robotidy & robocop updates) but if I recall correctly you can use proxies kwarg in APIModel. Add proxies to autogenerated classess:

class Pet(APIModel):
    def __init__(self, url):
        proxies = # set it like in this SO answer https://stackoverflow.com/questions/8287628/proxies-with-python-requests-module
        super().__init__(base_url=url, proxies=proxies)

It's bit of the workaround for now (if it works at all, please let me know). The plan for the future would be:

terezachudobova commented 2 years ago

Dear Bartłomiej, thank you for the immediate reply. Unfortunately I was not able to make your suggestion work.

class Pet(APIModel):
    def __init__(self, url):
        proxies = {
            'http': 'http://ip:port',   # while "ip" and "port" being filled
            'https': 'http://ip:port'
        }
        super().__init__(base_url=url, proxies=proxies)

I've tried both "scheme://ip:port" and "scheme://user:pass@ip:port" formats. Would you, please, have any idea how to deal with authentization in this case? Thank you kindly, Tereza

bhirsz commented 2 years ago

Thanks for the update, I will try to setup some environment with proxy enabled and see if I can reproduce the issue