Commit Graph

519 Commits (c7334ea92cb061fc9dd8cc7ed41d0c7e15440eb9)

Author SHA1 Message Date
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 }'
5 months ago
Sviatoslav Sydorenko (Святослав Сидоренко) a3e5546e43
🔥 Exterminate `__builtin__` import from tests (#82569)
This patch removes an import fallback that was only executed under
Python 2. Now that we don't run tests against that runtime, it
generates an uncovered line. Dropping it will slightly increase the
coverage metric as a side effect.
5 months ago
Harshvardhan Sharma 623e0eee42
Add Alp-Dolomite to Suse family list (#82496) 6 months ago
Matt Clay 0e6942a4d7
Remove unused unit test code (#82168) 8 months ago
Matt Clay dae4e2f07f
Remove unused/unreachable unit test code (#82160) 8 months ago
Matt Clay 0be33551d7
Remove unit tests dependent on systemd bindings (#82161)
These do no not run as part of our test suite.
8 months ago
Matt Clay 5b1b0ce762 Remove Python 2 compat (via six) from unit tests 8 months ago
Matt Clay 18e8401edd
Remove Python 2.x compat from unit tests (#82109) 8 months ago
Jordan Borean 22568305d6
Add ignore invalid options override for mod wrapper (#81899)
Adds an option that can have an action plugin tell the module to ignore
options that do not fit its arg spec. This is to enable support for core
running modules that exist outside of the collection that may not be new
enough to support some of the options supplied to it.
9 months ago
Matt Clay 9295bb5b5d
Unit test cleanup (#81958)
Remove obsolete Python 2.7 and 3.6 support code and fix up existing tests.
9 months ago
Sviatoslav Sydorenko d2ba76c117
Remove Python `< 3.5` `selectors` fallbacks (#81872) 9 months ago
Matt Martz 92d2c66db2
Remove py2 support from urls.py (#81880) 9 months ago
Matt Clay 9f899f9492
Require `from __future__ import annotations` (#81902) 9 months ago
Matt Clay b94ee1cefd
Drop Python 2.7 and Python 3.6 support (#81866)
* Drop Python 2.7 and Python 3.6 support

* Remove obsolete _json_compat
9 months ago
Hungtsetse 51f2ddd445
Extend mount info (#81768) 9 months ago
Matt Clay d0699cb44a
Add unit tests for module_utils.compat.datetime (#81483) 11 months ago
Matt Martz 553f51e728
Revert logic to use Popen.communicate (#80874)
* Back out use of communicate, add better comments, add bufsize, and align with subprocess._communicate

* tests

* re-order logic slightly

* more comments

* loopty loop

* yet another comment

* Revert "yet another comment"

This reverts commit 96cd8ada5fa0441b92f2298bdaa6cb40594847d2.

* Revert "loopty loop"

This reverts commit 96ea066f6a7d18902c04a14f18dd79b38e56f5e7.

* ci_complete

* Copy in comment too

* Wording updates

Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>

* Back out bufsize

---------

Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>
11 months ago
Sloane Hertel 4c41562270
remove deprecated datetime.datetime methods (#81323)
* Remove datetime.datetime.utcfromtimestamp and datetime.datetime.uctnow
  from controller code since they are deprecated in Python 3.12.

* Update target side code to use new utcfromtimestamp and utcnow utils in ansible.module_utils.compat.datetime that return aware datetime objects on Python 2.7 and 3.

Co-authored-by: Matt Clay <matt@mystile.com>
11 months ago
Abhijeet Kasurde 923ede4f72
pep8: fix sanity for 3.12 (#81348)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
11 months ago
ERIK a5ccc0124f
Fix ansible_pkg_mgr is unknown in Kylin Linux (#81314)
Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
11 months ago
Sloane Hertel d20a0c02cc
ansible-test - update module_utils/urls.py unit test to support cryptography >= 41.0.0 (#81296) 12 months ago
Matt Clay 82b5544b09
Improve code coverage of unit tests (#81119)
- Remove unused code
- Remove unnecessary code
- Ignore coverage for unreachable code
- Use previously unused code to increase coverage
1 year ago
Matt Clay 43c31c5dc2
Use isinstance in unit tests for type checks (#80906) 1 year ago
Abhijeet Kasurde 652ddc4078
Fix pylint disallowed-name errors (#80854)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
1 year ago
Arne de Laat 070ce87440
Add test for symbolic to octal when others is omitted (#80822)
* Add test for symbolic to octal when others is omitted

Add case when there should be no permissions for other.
And specific permissions for owner and group.

* Fix permissions test by explicitly setting no permissions for others

* Add additional cases where multiple permissions are specified
1 year ago
Jordan Borean 0df794e5a4
urls - remove deprecated client key calls (#80751) 1 year ago
Matt Clay 2cd1744be3
Use ansible.module_utils.common.text.converters (#80704)
Replace use of old `ansible.module_utils._text` and add a unit test to maintain backwards compatibility.
1 year ago
Martin Krizek 748f534312
Use target of /usr/bin/dnf for dnf version detection (#80550)
Fixes #80376
1 year ago
Matt Clay 74b102b33c
Fix unit tests returning values (#80499) 1 year ago
Matt Clay bd22b849c6
Fix unclosed files in unit tests (#80497) 1 year ago
Matt Martz 2a795e5747
Manage basic.selinux completely, instead of mocking potentially missing module (#80448)
* Manage basic.selinux completely, instead of mocking potentially missing module. Fixes #80436

* pep8
1 year ago
Matt Martz 6d1e355639
Only use the selectors code path when we are prompt matching (#79931) 1 year ago
Yaakov Selkowitz c028006aaf
Define all processor facts on s390x (#19755) (#79806)
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
1 year ago
Matt Clay 9d65e122ff
Fix detection of available hashlib algorithms (#79946)
* Fix detection of available hashlib algorithms

Detection of hashlib algorithms now works on Python 3.x.
The new implementation works on Python 2.7 and later.

Test coverage is provided by both integration and unit tests.

* Add additional details about hashlib in docs
1 year ago
Matt Clay 1ba100a3b4
Fix pointless statements in unit tests (#79940) 1 year ago
Matt Clay 379058e10f
Update collections.abc imports (#79911)
* Update `collections.abc` imports

- Use `six.moves` for modules and module_utils
- Use `collections.abc` for controller code

This avoids using `ansible.module_utils.common._collections_compat`,
which was added before the vendored `six` was updated to provide these
imports.

* Update _collections_compat to use six.moves

Also update the custom pylint rule to reflect this change.
1 year ago
Matt Clay 25d859f8fb
Clean up unused imports in unit tests (#79893) 1 year ago
Felix Fontein 8a7185c224
Argument spec alias handling: actually report deprecated aliases in suboptions, and fix warning message in suboptions when two aliases of the same option are used (#79740)
* Normalize deprecation records.

* Fix alias deprecations in suboptions.

* Report in which option an alias warning happened for suboptions.

* Add deprecation tests for suboptions.

* Also test deprecation in list of dicts.

* Adjust unit tests for toplevel alias deprecation field name change.
1 year ago
Matt Martz 9acca5b3b9
Allow test to run on system with selinux enabled. Fixes #77564 (#79510) 2 years ago
Matt Martz f53dbf90ea
Don't assume column index for netmask and broadcast (#79121)
* Don't assume column index for netmask and broadcast. Fixes #79117

* fix typo
2 years ago
Donatas Abraitis 11c1777d56
facts: List all local (scope host) IP address ranges (#79018)
After changes:
```
        "ansible_locally_reachable_ips": {
            "ipv4": [
                "127.0.0.0/8",
                "127.0.0.1",
                "192.168.0.1",
                "192.168.1.0/24"
            ],
            "ipv6": [
                "::1",
                "fe80::2eea:7fff:feca:fe68",
                ...
            ]
        },
```

192.168.1.0/24 is a local prefix, where any IP address inside this range
is reachable locally (or outside this host if this prefix is announced via
EGP/IGP).

Signed-off-by: Donatas Abraitis <donatas.abraitis@hostinger.com>
2 years ago
Markus Opolka 616ad883ad
Add OSMC to Debian OS_FAMILY_MAP (#78778)
* Add OSMC to Debian OS_FAMILY_MAP

 - os_family fact of the Debian-based OSMC distribution was not detected correctly

* tweak changelog

Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>
2 years ago
Artur a26c325bd8
uri: added use_netrc argument to allow ignoring netrc (#74397) (#78569) 2 years ago
Matt Martz b8025ac160
Allow selection of TLS/SSL ciphers (#78650)
* Allow selection of TLS/SSL ciphers. Fixes #78633
* Never pass None as the password. Fixes #53373
2 years ago
Johanan Liebermann fbd828673d
Fix distro fact handling for Flatcar (#77635)
* Fix distro fact handling for Flatcar

The existence of the file /etc/flatcar/update.conf depends on
bootstrap configuration typically provided by the user. For that
reason this file is unsuitable for determining distro facts for
Flatcar Container Linux.

The distribution_release fact is meaningless in the case of Flatcar
since Flatcar doesn't have named releases. The distribution_version
fact, however, IS meaningful and should contain a number such as
"3139.2.0".

- Use /etc/os-release instead of /etc/flatcar/update.conf.
- Drop the distribution_release fact.
- Set the distribution_version fact.
- Update distro test fixture for Flatcar
- Generate the fixture using gen_distribution_version_testcase.py.
- Override result.distribution and result.os_family manually as the
  generator script gives wrong values.
- Use a recent Flatcar version.

Signed-off-by: Johanan Liebermann <jliebermann@microsoft.com>
2 years ago
Sam Doran 8ebca4a6a3
fetch_file - properly split files with multi-part file extensions (#75257) 2 years ago
Matt Martz f6d2b18322
Correctly get the filename from a url in fetch_file. Fixes #29680 (#78383) 2 years ago
Matt Clay b86a18bd27
Remove unit test pytz requirement. (#78368) 2 years ago
Ruediger Pluem 0ef1376966
Make distro.id() report newer versions of OpenSuSE (at least >=15) also report as opensuse (#76121)
* Report OpenSuSE >= 15 as opensuse

Make distro.id() report newer versions of OpenSuSE (at least >=15) also report
as opensuse. They report themselves as opensuse-leap.

* Add a test
2 years ago
Matt Martz d58e69c82d
Add support for gzip decoding responses (#41925) 2 years ago