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

Don't rely on netloc for determining hostname and port, just use hostname and port #56270

Merged
merged 5 commits into from May 20, 2019

Conversation

sivel
Copy link
Member

@sivel sivel commented May 9, 2019

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
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/module_utils/urls.py

ADDITIONAL INFORMATION

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 9, 2019
@sivel sivel requested a review from samdoran May 16, 2019 16:32
@jillr jillr removed the needs_triage Needs a first human triage before being processed. label May 16, 2019
Copy link
Contributor

@samdoran samdoran left a 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.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed core_review In order to be merged, this PR must follow the core review workflow. labels May 20, 2019
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 20, 2019
@sivel
Copy link
Member Author

sivel commented May 20, 2019

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.

@sivel sivel requested a review from samdoran May 20, 2019 20:21
@samdoran samdoran merged commit 493cf81 into ansible:devel May 20, 2019
sivel added a commit to sivel/ansible that referenced this pull request May 21, 2019
…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>
abadger pushed a commit that referenced this pull request May 22, 2019
…just use hostname and port (#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>
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uri module fails when url contains some IPv6 addresses
4 participants