You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units/module_utils/urls
Yacht Shaver c7334ea92c
Fix url encoded credentials in netloc (#82552)
Prior to this commit, it was impossible to use a module like dnf with a
URL that contains a username with an @ such as an email address
username, because:

  dnf:
    name: https://foo@example.com:bar@example.com/some.rpm

Would cause netloc parsing to fail. However, the following:

  dnf:
    name: https://foo%40example.com:bar@example.com/some.rpm

Would also fail because ansible would *not* URL-decode the credentials,
causing the following to be base64 encoded in the Authorization header:

  Zm9vJTQwZXhhbXBsZS5jb206YmFyCg==

Which decodes to:

  foo%40example.com:foo

Which is *not* the authorized username, and as such, *won't* pass basic
auth.

With this commit, Ansible's url lib behaves like curl, chromium, wget,
etc, and encodes the above to:

  Zm9vQGV4YW1wbGUuY29tOmJhcgo=

Which decodes to:

  foo@example.com:bar

Which will actually pass the HTTP Basic Auth, and is the same behaviour
that you will find ie. with:

  curl -vvI https://foo%40bar:test@example.com 2>&1 |grep Auth | awk '{ print $4 }'
4 months ago
..
fixtures Make `test_prepare_multipart` succeed on non Debian distros 3 years ago
__init__.py Add unit tests for ansible.module_utils.urls (#38059) 6 years ago
test_RedirectHandlerFactory.py Remove py2 support from urls.py (#81880) 8 months ago
test_Request.py Fix url encoded credentials in netloc (#82552) 4 months ago
test_channel_binding.py Require `from __future__ import annotations` (#81902) 8 months ago
test_fetch_file.py Require `from __future__ import annotations` (#81902) 8 months ago
test_fetch_url.py Remove Python 2.x compat from unit tests (#82109) 7 months ago
test_generic_urlparse.py Remove Python 2 compat (via six) from unit tests 7 months ago
test_gzip.py Remove py2 support from urls.py (#81880) 8 months ago
test_prepare_multipart.py Require `from __future__ import annotations` (#81902) 8 months ago
test_split.py Require `from __future__ import annotations` (#81902) 8 months ago
test_urls.py Remove py2 support from urls.py (#81880) 8 months ago