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
Don't rely on netloc for determining hostname and port, just use hostname and port #56270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and this change is good. Hooray for deleting code.
Please add unit tests to test/units/module_utils/urls/test_urls.py:78
url = 'https://[2a00:16d8:0:7::205]:4443/'
handler = urls.maybe_add_ssl_handler(url, True)
assert handler.hostname == '2a00:16d8:0:7::205'
assert handler.port == 4443
url = 'https://[2a00:16d8:0:7::205]/'
handler = urls.maybe_add_ssl_handler(url, True)
assert handler.hostname == '2a00:16d8:0:7::205'
assert handler.port == 443
Maybe add integration tests as well.
I've added unit tests, and resolved some Python2.6 issues that were causing tracebacks. Integration tests aren't possible at this time, since the httptester container and intra-contatiner communications isn't IPv6 enabled. |
…just use hostname and port (ansible#56270) * Add changelog fragment * Fix IPv6 address parsing for py2.6, and add tests * make sure hostname isn't None (cherry picked from commit 493cf81) Co-authored-by: Matt Martz <matt@sivel.net>
SUMMARY
Don't rely on netloc for determining hostname and port, just use hostname and port. Fixes #56258
This resolves a bug when handling redirects with IPv6 addresses in the URL.
ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/urls.py
ADDITIONAL INFORMATION