Commit Graph

3289 Commits (devel)

Author SHA1 Message Date
Abhijeet Kasurde 78c16d983e Remove type_regex testcase
This is leftover testcase for type checker regex removed in
https://github.com/ansible/ansible/pull/82153

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 months ago
Matt Clay 916a20fccd Ignore coverage of test code that does not run 7 months ago
JustinWayland dec9eeb2e5
Remove create_new_password parameter in CLI.build_vault_ids (#82066)
* Remove unused argument in call to build_vault_ids

* Remove obsolete build_vault_ids tests

* Change tests to account for argument removal

* Remove redundant test
7 months ago
Matt Clay ac3ae94ae1
Ignore coverage on code intended never to execute (#82128)
* Ignore coverage on code intended never to execute

* Fail collection loader test if wrong code runs

* Update boilerplate test to accommodate nocover
7 months ago
Matt Clay 1df791cd90
Ignore code which coverage can't analyze (#82125)
* Ignore code which coverage can't analyze

Our own tracing function can't be traced.

* Use `nocover` instead of `no cover` for consistency
7 months ago
Jordan Borean f8a9fd4758
Remove duplicate winrm test (#82124) 7 months ago
Matt Clay 5b1b0ce762 Remove Python 2 compat (via six) from unit tests 7 months ago
Matt Clay 18e8401edd
Remove Python 2.x compat from unit tests (#82109) 7 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.
8 months ago
Matt Clay 9295bb5b5d
Unit test cleanup (#81958)
Remove obsolete Python 2.7 and 3.6 support code and fix up existing tests.
8 months ago
Sviatoslav Sydorenko d2ba76c117
Remove Python `< 3.5` `selectors` fallbacks (#81872) 8 months ago
Sviatoslav Sydorenko 350a394185
Remove Python 2 importlib.import_module compat (#81879) 8 months ago
Matt Martz 92d2c66db2
Remove py2 support from urls.py (#81880) 8 months ago
Jordan Borean 8a5ccc9d63
ansible-galaxy - fix traceback error for invalid req file (#81917)
Provide a better error message when encountering a YAML requirements file that is not a dictionary or list.

Fixes: #81901
8 months ago
Jordan Borean 976067c15f
Add more winrm coverage (#81923) 8 months ago
Jordan Borean 282908c57e
Add test coverage for winrm (#81910) 8 months ago
Matt Clay 9f899f9492
Require `from __future__ import annotations` (#81902) 8 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
8 months ago
Martin Krizek 9b3ed5ec68
Properly template tags in parent blocks (#81624)
When templating tags (which happens outside of standard `post_validate`) we
need to template each object in the inheritance chain and set the templated
values on those objects individually. That way when `task.tags` is called the
`extend` functionality properly picks up the templated values of all
parents into one flatten list.

Fixes #81053
8 months ago
Hungtsetse 51f2ddd445
Extend mount info (#81768) 8 months ago
Abhijeet Kasurde 86fd7026a8
Handle exceptions in interpreter discovery (#81745)
* Handle exceptions like AnsibleError, AnsibleConnectionFailure
  raise while interpreter discovery.

Fixes: #78264

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
9 months ago
Carlos Camacho 9244b2bff8
Make sure paths are treated correctly when building collection files manifest (#81619)
* Make sure paths are correct when building collection files manifest

This commit makes sure the path of the files part of
the collection build manifest are correct.

This commit uses os.path.commonprefix instead of
dealing with strings.

Signed-off-by: Carlos Camacho <ccamacho@redhat.com>

Bugfix Pull Request
Fixes: #81618

* Revert the change note type to `minor_changes`

* Clarify the change note with user-oriented details

---------

Signed-off-by: Carlos Camacho <ccamacho@redhat.com>
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
9 months ago
Abhijeet Kasurde 0ea40e09d1
vars: handle exception in combine_vars (#81700)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
9 months ago
Matt Clay 7d3d4572ed
Fix set filters to use set operations (#81639)
* Fix set filters to use set operations

* Fix integration tests

* Update filter documentation
9 months ago
Abhijeet Kasurde cd0aa35c19
encrypt: deprecate passlib_or_crypt (#81571)
* deprecate passlib_or_crypt in favor of do_encrypt

Fixes: #55839
9 months ago
Matt Clay 6627ba9ace
Unit test cleanup (#81556)
* Fix cleanup_tmp_file unit tests

* Simplify the problematic wcwidth chars unit test
10 months ago
Matt Clay d0699cb44a
Add unit tests for module_utils.compat.datetime (#81483) 10 months ago
Matt Clay 580b87252c
Remove unreachable code in password lookup test (#81482) 10 months ago
Matt Clay 726d9a5fcc
Fix constructed inventory plugin unit test (#81481) 10 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>
10 months ago
Kristopher Newsome a1569ea4ca
iptables chain creation does not populate with a rule (#80257)
* iptables chain creation does not populate with a rule

fixes #80256

* Add changelog fragment

* Add rules and flush chain during integration tests

* Check chain rule on comment

* Update test/integration/targets/iptables/tasks/chain_management.yml
10 months ago
Abhijeet Kasurde 95fdd555b3
galaxy: Cross check the collection type (#81423)
* User-provided collection type might differ from collection
  source. Cross-check the type before proceeding

Fixes: #79463

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
10 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>
10 months ago
Abhijeet Kasurde 923ede4f72
pep8: fix sanity for 3.12 (#81348)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
10 months ago
ERIK a5ccc0124f
Fix ansible_pkg_mgr is unknown in Kylin Linux (#81314)
Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
10 months ago
freddiewanah 2a19c80b89
Refactor test cases to improve unit test quality (#81334) 10 months ago
Sloane Hertel 48dfe8e215
add Python 3.12 support to ansible-test (#80834)
* update docker containers versions to use newer ansible-test ref in the pre-built venvs

* Allow invoking ansible-test with Python 3.12

* Add python3.12 to the INTERPRETER_PYTHON_FALLBACK

* changelog

* add Python 3.12 as a non-default Python version for the test containers

* Update mypy ignores for Python 3.12

* Add Python 3.12 to CI matrix for unit tests, generic tests, and galaxy

* Update unit test for using the Python 2 collection loader path with Python 3.

Skip the existing test on Python 3.12, since find_module is removed.

Suppress the pre-existing deprecation warnings using the Python 2
codepath with Python 3.

Add a test for Python >= 3.12, which doesn't call find_module.

* Ignore sanity test errors on systems without libselinux present.
11 months ago
Sloane Hertel efbc00b6e4
Consider all configured collection paths when installing collections (#81243)
* Only install collections which can't be satisfied by a collection in any of the configured paths.

* Improve warning for unexpected collection install path

Fix warning when path is configured, but is a pip-managed path

Normalize the path before validating to fix warning consistency
11 months ago
Sloane Hertel d20a0c02cc
ansible-test - update module_utils/urls.py unit test to support cryptography >= 41.0.0 (#81296) 11 months ago
Yuri Khan 371b62eab1
Add test for 256-color configuration values (#78613)
* Add test for 256-color configuration values

See #78607.

* color is not restricted to 16 choices

 currently supports up to 256, not listing them all
 TOOD: create examples and point to/list the basic 16

---------

Co-authored-by: Brian Coca <brian.coca+git@gmail.com>
Co-authored-by: Matt Clay <matt@mystile.com>
11 months ago
Sviatoslav Sydorenko b6ebb9d41a
Replace `reboot_command` integration test with unit tests (#78956)
Co-authored-by: Matt Clay <matt@mystile.com>
11 months ago
Matt Clay 876be11f8c
Add pymarkdown sanity test for core (#81220)
* Clean up markdown

* Add pymarkdown sanity test for core

* Update unit test SHA
11 months ago
Sloane Hertel 67b78a17c4
Remove Python 3.9 support for the controller (#80973)
* Remove obsolete Python <=3.9 controller code
* Remove Python 3.9 test controller bootstrapping
* Update test requirements

Co-authored-by: Matt Clay <matt@mystile.com>
11 months ago
Matt Clay 8c9f5c9106
Remove unused unit test code (#81150) 11 months ago
Matt Clay b06f7de24a
Remove unused strategy plugin unit tests (#81146) 11 months ago
Matt Clay 63946eaed6
Remove unreachable code in curses unit test (#81138) 11 months ago
Matt Clay 5f58775a1f
More unit test code coverage improvements (#81136) 11 months ago
Everson Leal 2f820381ea
Inventory Script Plugin: raise execution error (#81104)
It adds exception treatment when execute a inventory based on script with the --host argument

---------

Co-authored-by: Everson Leal <everson.leal@sonda.com>
11 months ago
Sloane Hertel e780b5e56d
ansible-galaxy - add config option for the default ansible-galaxy timeout (#81108)
allow configuring the default server timeout via env/ini
11 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
11 months ago
Matt Clay da2cd157f1
Fix arg splitting and key/value parsing (#80030)
* Improve readability of unit test output

This drops the trailing `-expectedXXX` suffixes from test names generated by parametrize.

* Add more splitter unit tests

This fills in code coverage gaps in the exising unit tests.

* Bug fixes and code cleanup

- Fix IndexError exceptions caused by parsing a leading newline, space or escaped space.
- Fix an AttributeError exception in `parse_args` when parsing `None`.
- Fix incorrect parsing of multi-line Jinja2 blocks, which resulted in doubling newlines.
- Remove unreachable exception handlers in the `parse_kv` function.
  The unreachable code was verified through analysis of the code as well as use of the `atheris` fuzzer.
- Remove unnecessary code in the `split_args` function.
- Add an optimization to `split_args` for the empty args case.

* Add unit tests for bug fixes

The splitter code is now fully covered by unit tests.

* Add another issue ref in changelog
12 months ago
Brian Coca a7d2a4e032
display, also proxy warnings and deprecations (#81060)
Use generic proxy for display  methods with decorator
12 months ago
Matt Martz 56b67cccc5
Resolve issues on python pre-3.10.6 with collection dirs longer than 100 characters (#81061) 12 months ago
Sloane Hertel ecbbd7e5d1
Remove Python 3.5 support (#80972)
* Remove Python 3.5 support

* changelog

* add requested changes

* Update changelogs/fragments/remove-python3.5.yml

Co-authored-by: Matt Clay <matt@mystile.com>

* remove Python3 < 3.5 error handling

* remove Python3 < 3.5 error handling in TE too

---------

Co-authored-by: Matt Clay <matt@mystile.com>
12 months ago
Matt Martz 92d5ffda82
Update galaxy_ng container for tests (#80721) 1 year ago
Matt Clay 43c31c5dc2
Use isinstance in unit tests for type checks (#80906) 1 year ago
Matt Clay 585b82838b
Improve code coverage of unit tests (#80904)
* Improve coverage of validate-modules unit tests

* Remove unused galaxy unit test code

* Fix galaxy unit test teardown logic

* Improve coverage of galaxy unit test code

* Improve coverage of galaxy unit tests

* Remove unused code in galaxy API tests

* Remove unused galaxy collection unit test code

* Improve coverage of galaxy collection unit tests

* Remove unused galaxy unit test code
1 year ago
Abhijeet Kasurde 652ddc4078
Fix pylint disallowed-name errors (#80854)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
1 year ago
Brian Coca 4899d4a4d6
simple skip of connection (#80638)
Avoid 'persistent' connection handling if not needed
removed useless connection passing
added property to action classes as indicator/selector
1 year ago
Jordan Borean 8db9bd7574
Remove deprecated include (#80752)
* Remove deprecated include

* Add tombstone entry for include

* Use string for date

* Use todays date

* Remove uneeded if statement
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 2fd64161c1
Fix hard-coded interpreter in test_async_wrapper (#80816) 1 year ago
Matt Clay 2ba24957dd
Use subset checks for some collection loader tests (#80812) 1 year ago
Abhijeet Kasurde 7ef8e0e102
Remove unnecessary test case in vault editor (#80741)
* Remove test_real_path_symlink test case
* Check if we do not get `-` return when some value other `-` is passed

Fixes: #80444

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
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
Matt Clay 23e2ca91c2
Improve coverage of role unit tests (#80695) 1 year ago
Matt Clay 884215bd1c
Improve unit test code coverage (#80683) 1 year ago
Matt Clay 71f6e10dae
Use assertRaisesRegex in unit test (#80663) 1 year ago
Sloane Hertel d18d4f84ec
_symbolic_mode_to_octal- fix raising ValueError for invalid symbolic modes (#80449)
validate the full user and perm strings instead of just first character

fixes unhelpful unarchive error for some invalid modes
1 year ago
Landson Guo ece8da71ea
Add TTY check and argument to disable it (#50603) (#68260)
* Add TTY check and argument to disable it (#50603)

* Fix formatting

* add changelog

* rename flag and updated help description

* add tests for tty check

* replace deprecated uses of assertRaisesRegexp to assertRaisesRegex

* fix yaml syntax

* shorten line 79

* Revert "replace deprecated uses of assertRaisesRegexp to assertRaisesRegex"

This reverts commit cea5fe1655.

* change back to assertRaisesRegexp
1 year ago
Maxwell G f4615d69ad
tests: replace a mock import with unittest.mock (#80589) 1 year ago
Martin Krizek 748f534312
Use target of /usr/bin/dnf for dnf version detection (#80550)
Fixes #80376
1 year ago
Matt Clay 43c5cbcaef
Fix galaxy CLI unit test assertions (#80504) 1 year ago
Matt Clay 3ec828703f
Fix unit test asserts (#80500) 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
Sean Reifschneider 243aea45ce
Symbolic modes with X or =[ugo] always use original mode (#80132)
* Symbolic modes with X or =[ugo] always use original mode (Fixes #80128)

Here's what's happening, by way of this mode example: u=,u=rX

At the first step in the loop, the "u" bits of are set to 0. On the next
step in the loop, the current stat of the filesystem object is used to
determine X, not the "new_mode" in the previous iteration of the loop. So
while most operations kind of operate left to right, "X" is always going
back to the original file to determine whether to set x bit.

The Linux "chmod" (the only one I've tested) doesn't operate this way. In
it, "X" operates on the current state the loop understands it is in,
based on previous operations (and starting with the file permissions).

This is an issue with "X" and any of the "=[ugo]" settings, because
they are lookups. For example, if a file is 755 and you do "ug=rx,o=u",
file module produces 0557 and chmod produces 0555.

This really becomes a problem when you want to recursively change a
directory of files, and the files are currently 755, but you want to
change the directory to 750 and the files to 640. In chmod you can do
"a=,ug=rX,u+w" (or "a=,u=rwX,g=rX"), and have it apply equally to the
directory and the files. I can't come up with a single way in the ansible
file module to deterministically, recursively, set a directory to 750
and the contents to 640 no matter what the current permissions are,
as the code currently is.

The fix is to pass in "new_mode" to _get_octal_mode_from_symbolic_perms
in lib/ansible/module_utils/basic.py inside _symbolic_mode_to_octal. And
then take "new_mode" as an argument and use it instead of the filesystem
object stat.st_mode value.

* Fixing my new unit test, fixing bug in test comments
1 year ago
Felix Fontein 92c694372b
Replace validate-modules's semantic markup parser with antsibull-docs-parser (#80406) 1 year ago
Matt Martz 6d1e355639
Only use the selectors code path when we are prompt matching (#79931) 1 year ago
Brian Coca 0fd88717c9
password lookup, handle ident properly when saved (#80251)
* password lookup, handle ident properly when saved

  Currently we format and save ident when present but we didn't account for this when reading the saved file
  Also added some more robust error handling.
1 year ago
Matt Martz 42355d181a
Do not double calculate loops and `delegate_to` (#80171) 1 year ago
Martin Krizek cfa7acbc19
Raise an error on invalid FA.isa value (#80040)
Avoids bad definitions of playbook classes
1 year ago
Sloane Hertel 46c08c4467
move test so it runs when the plugin is modified (#80158) 1 year ago
Sloane Hertel 9a03c8f5b3
update paramiko_ssh unit tests load the connection with plugin loader (#80157)
* Load the paramiko_ssh connection plugin properly using plugin loader so it can use config manager when _connect() is called
1 year ago
Sloane Hertel b981a9dfcd
add a worker queue to get updates from the main results thread (#79886)
* Create a queue per WorkerProcess to receive intra-task updates
* Update `pause` action to use the worker queue
* Deprecate ConnectionBase()._new_stdin
* Add new `Display`  convenience method `prompt_until` to manage both controller- and worker-sourced prompting without cross-fork stdin sharing, in-worker mechanism to handle request-response over new worker queue.
1 year ago
Matt Clay c2ea56e12e
Relocate and refactor ansible-test diff unit tests (#80113)
This provides the same test coverage as the previous tests, without the dependency on git.
It also includes many more specific test cases with assertions, instead of simply relying on the code to not raise an exception.
1 year ago
Matt Clay a895cae5a1
Relocate validate-modules unit tests (#80087)
This allows the validate-modules unit tests to run as part of the regular unit test suite.
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
Miklos Sagi b7ef2c1589
ansible-playbook -K breaks when passwords have quotes (#79837)
Now only 'unquote' when ini config file is the source
1 year ago
Matt Clay 72c59cfd98
Avoid trailing spaces in unit test (#80033) 1 year ago
Jordan Borean 1e6b8249e7
Add condition that causes a when to skip a task to output msg (#78918)
* Add condition that causes a when to skip a task

* Fix up tests

* Use false_condition instead of failed_condition

* Remove formatting accidentially added

* Fix sanity
1 year ago
Martin Krizek bd329dc543
Make using blocks as handlers a parser error (#79993)
Fixes #79968
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
Matt Clay 91807695c3
Remove unused unit test code (#79879)
* Remove unused test fixtures

* Removed unused _old_dump_load_cycle method

* Remove Python 2.x compat

* Remove unused code

* Remove unused context manager

* Fix cowsay test

- The test no longer depends on another test to initialize config.
- Also remove unreachable code.

* Remove Python 2.x compat
1 year ago
Matt Clay c33c8cf086
Remove unused and unreachable unit test code (#79854) 1 year ago