Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxyError: Cannot connect to proxy #31

Open
terezachudobova opened this issue Aug 12, 2022 · 3 comments
Open

ProxyError: Cannot connect to proxy #31

terezachudobova opened this issue Aug 12, 2022 · 3 comments

Comments

@terezachudobova
Copy link

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
Copy link
Member

bhirsz commented Aug 12, 2022

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:

  • allow user to configure proxies before generating the classess
  • add option for autodetecting proxy settings (I recall it's possible to use system default proxies)

@terezachudobova
Copy link
Author

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
Copy link
Member

bhirsz commented Aug 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants