summaryrefslogtreecommitdiffstats
path: root/test/units/modules (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Cover unit tests with mypy (#84084)Matt Clay2024-10-081-81/+89
| | | | | | | | | * Added support for testing unit tests with mypy. * Added support for ignoring individual mypy error codes. * Added missing assert on unit tests and marked xfail. * Added type hints for some unit tests. * Added ignores for unit tests not passing mypy. * Fixed incorrect autouse argument in unit test fixtures. * Fixed minor issues causing problems with mypy in unit tests.
* Fix error message given by ansible.module_utils.facts.timeout.timeout (#83945)Sloane Hertel2024-10-031-3/+1
| | | | | * Update unit test Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
* debconf: set empty password value (#83217)Abhijeet Kasurde2024-10-011-0/+63
| | | | | | Fixes: #83214 --------- Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Add mount_facts module (#83508)Sloane Hertel2024-09-192-0/+994
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a mount_facts module capable of gathering mounts skipped by default fact gathering * By default, collect mount facts from standard locations including /etc/mtab, /proc/mounts, /etc/fstab, /etc/mnttab, /etc/vfstab, and on AIX, /etc/filesystems. When no file-based source for the current mounts can be found (like /proc/mounts), the module falls back to using mount as a source. This allows BSD and AIX to collect the existing mounts by default, without causing Linux hosts to use both /proc/mounts and mount output. * Non-standard locations and "mount" can be configured as a sources. * Support returning an aggregate list of mount points in addition to first found. When there are multiple mounts for the same mount point in an individual source, a warning is given if the include_aggregate_mounts option is not configured. * Add options to filter on fstypes and devices (supporting UNIX shell wildcards). * Support configuring a timeout and timeout behavior to make it easier to use the module as a default facts module without risking a hang. * Include the source and line(s) corresponding to a mount for easier debugging. Co-authored-by: Brian Coca <bcoca@users.noreply.github.com> Co-authored-by: Matt Clay <matt@mystile.com> Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>
* iptables, use existing validation (#83907)Brian Coca2024-09-061-14/+0
| | | also remove redundant and wrong test
* unarchive: Better handling of files with an invalid timestamp in zip file ↵Gilson Guimarães2024-06-131-0/+53
| | | | | | | | (#81520) Fixes: #81092 Signed-off-by: gilsongpfe <gilson.gpf@gmail.com> Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* test_apt: migrate from unittest to pytest (#82666)Abhijeet Kasurde2024-03-151-40/+40
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Follow fix for test_iptables (#82768)Abhijeet Kasurde2024-03-051-1/+1
| | | | | | * rename 'test_policy_table' to 'test_policy_table_flush' to remove duplicate test case name. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* test: migrate iptables tests from unittests to pytest (#82647)Abhijeet Kasurde2024-03-011-1154/+1410
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* iptables: added choices in match_set_flags option (#82641)Abhijeet Kasurde2024-02-061-56/+61
| | | | | | | | * 'src,src', 'dst,dst' added as new option choices in match_set_flags option Fixes: #81281 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Remove the yum module, redirect it to dnf (#81895)Martin Krizek2024-01-231-221/+0
| | | Fixes #81728
* uri: Handle the "force" parameter properly (#82187)Mike Bonnet2024-01-231-0/+43
| | | | | | | | | | | | | | | | | | | | | * uri: Two tests that demonstrate missing handling of the "force" parameter Add unit and integration tests that demonstrate that the uri module is not handling the "force" parameter. The unit test demonstrates that when "force" is present in the module parameters, it is not being passed through to fetch_url(). The integration test demonstrates that "force" does not disable caching as documented, and calls with a "dest" parameter that points to an existing file can result in a "304 Not Modified" response. * uri: Handle the "force" parameter properly The uri module documents a "force" parameter that can be used to disable caching. The module accepted the parameter but didn't pass it through to the fetch_url() method which implements the logic to handle setting the appropriate headers for disabling caching. This change passes the "force" parameter through as expected, allowing caching to be disabled when requested by the module caller.
* Remove Python 2 compat (via six) from unit testsMatt Clay2023-11-022-5/+1
|
* Remove Python 2.x compat from unit tests (#82109)Matt Clay2023-11-029-13/+13
|
* Require `from __future__ import annotations` (#81902)Matt Clay2023-10-0515-32/+15
|
* iptables chain creation does not populate with a rule (#80257)Kristopher Newsome2023-08-041-31/+9
| | | | | | | | | | | | | * 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
* Improve code coverage of unit tests (#81119)Matt Clay2023-06-245-56/+13
| | | | | | - Remove unused code - Remove unnecessary code - Ignore coverage for unreachable code - Use previously unused code to increase coverage
* Fix pylint disallowed-name errors (#80854)Abhijeet Kasurde2023-05-221-8/+8
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Fix hard-coded interpreter in test_async_wrapper (#80816)Matt Clay2023-05-171-2/+2
|
* Use ansible.module_utils.common.text.converters (#80704)Matt Clay2023-05-033-3/+3
| | | Replace use of old `ansible.module_utils._text` and add a unit test to maintain backwards compatibility.
* _symbolic_mode_to_octal- fix raising ValueError for invalid symbolic modes ↵Sloane Hertel2023-04-271-0/+4
| | | | | | | (#80449) validate the full user and perm strings instead of just first character fixes unhelpful unarchive error for some invalid modes
* Symbolic modes with X or =[ugo] always use original mode (#80132)Sean Reifschneider2023-04-111-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Update collections.abc imports (#79911)Matt Clay2023-02-041-1/+1
| | | | | | | | | | | | | | * 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.
* Clean up unused imports in unit tests (#79893)Matt Clay2023-02-032-6/+0
|
* Prefer unittest.mock over mock. (#77886)Matt Clay2022-05-237-15/+13
|
* unarchive: fix io_buffer_size option, remove ignore.txt entry (#77271)Felix Fontein2022-03-171-0/+2
| | | | | | | | | * Fix io_buffer_size option. * Remove ignore.txt entry by adding action plugin only options to module's argument spec. * Add changelog fragment. * Adjust unit tests.
* Remove obsolete units.compat.mock compat layer. (#77118)Matt Clay2022-02-237-7/+9
| | | | * Remove obsolete units.compat.mock compat layer. * Update remaining units.compat.mock references.
* Resubmit: Use SystemdStrategy for Debian in the hostname module (#76929)Thomas Sjögren2022-02-091-0/+13
| | | | | | | | * add DebianStrategy tests * ensure hostname can be changed by using become * use Systemd strat for debian and Base for generic. * add test to ensure all strategies are available Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
* iptables - added a ``chain_management`` parameter to control chain (#76378)Éloi Rivard2022-01-241-13/+197
| | | | | | creation and deletion fixes #25099 closes #32158
* Unbreak hostname.RedHatStrategy (#76032)Martijn Pieters2021-11-151-0/+99
| | | | | | | - On Python 3, decode bytes to str - Tolerate whitespace around the line. - Report a missing HOSTNAME line as an error. - Don't clobber line separators when setting a new hostname. - Add some tests for this strategy to verify correct operation.
* pip - Use pip from the current Python interpreter. (#75634)Matt Clay2021-09-041-0/+2
| | | | | | | | | | | | | | | | | * pip - Use pip from the current Python interpreter. If `executable` and `virtualenv` were not specified, and the `pip` Python module is available for the current interpreter, use that `pip` module instead of searching for a `pip` command. * Add comment about needing `__main__` to run `pip`. * Fix unit test. * Add porting guide entry. * Update changelog to match porting guide description. ci_complete
* yum: fix parsing of check-update with subsequent empty lines (#75452)Martin Krizek2021-08-201-0/+15
| | | | | | | Rather than adding further complexity to the regex, preprocess the output to remove any empty lines. Now the only purpose of the regex is to fix wrapped lines. Fixes #70949
* modules moved to use best_parsable_locale (#75250)Brian Coca2021-07-151-0/+5
| | | | | | | | | | | | | | | * modules moved to use best_parsable_locale * fixed invocations * better better * also module_utils * converted to function as per fb * patch testt * whitespace
* get_distribution - Return distribution for all platforms (#71641)Sam Doran2021-06-111-0/+2
| | | | | | | | | | | | | | Since moving to distro, it is possible to return this information for all platforms, not just Linux. Also return version information for all platfrom not just Linux. Update unit tests. Remove some duplicate unit tests though I think there are more to remove. * Fix docstring formatting * Minor docstring changes * Mock distro.id for Solaris service test * Update comment
* apt_key: add --recv argument as last one (#74949)Jonathan Kirszling2021-06-101-0/+27
| | | | | | | | | * apt_key: add --recv argument as last one * Add unit test * Add the required boilerplate Co-authored-by: Marius Gedminas <marius@gedmin.as>
* unarchive - do not fail in init when trying to find required binary (#74892)Sam Doran2021-06-071-18/+33
| | | | | | | | | Test for the required binaries in the can_handle_archive() method and fail there. This prevents failures for missing binaries unrelated to the archive type. * Update missing zip binary message to match tar message * Update unit tests * Add integration tests * Define packages based on the system rather than ignoring failures
* unarchive: Fail when zipinfo is not available (#74632)Abhijeet Kasurde2021-06-021-0/+76
| | | | | Fixes: #39029 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Remove commented code (#74860)Abhijeet Kasurde2021-06-011-10/+0
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* hostname: clean up strategiesAlexander Sowitzki2021-05-271-1/+1
| | | | Apply #74744 and #69929 to #70828
* [hostname] don't write in get_*() methodsRick Elrod2021-05-271-0/+35
| | | | | | | | | | | | | | | | Change: - Hostname strategies' get_*() methods should never write to the filesystem. They are used in check_mode by default to determine if there is any work to be done. Test Plan: - New unit tests to ensure that (at least when in check_mode) the get methods don't ever call write. Tickets: - Fixes #66432 Signed-off-by: Rick Elrod <rick@elrod.me>
* async_wrapper more info on end (#74199)Brian Coca2021-04-131-2/+3
| | | | | | be consistent on information returned normalize 'return functions' fix unit test add a bit more context on some failures
* Solaris: Correct version check in svcadm_supports_sync API (#73860)Guillermo Adrián Molina2021-04-101-0/+68
| | | Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Fix comment in iptables unit test (#74061)Amin Vakil2021-03-301-1/+1
|
* iptables: Added set module/match_set support (#72984)Martin Zimmermann2021-01-111-0/+63
|
* iptables: Adding multiport module support (#72928)Martin Zimmermann2020-12-141-0/+36
|
* iptables: Reorder comment postition (#71496)Amin Vakil2020-11-091-0/+41
| | | | | | | | | | | | | | | | | | | * Reorder comment postition * Add comment unit test * Fix unit test * Fix unit test * Add changelog * Add paramaters which would be problematic without this fix * Fix typo * Fix unit test * Fix unit test
* service_facts: return service state information on AIX (#72073)dberg12020-10-131-0/+126
| | | | | | | | | | * service_facts: return service state information on AIX AIX uses the System Resource Controller (SRC) to manage services. See https://www.ibm.com/support/knowledgecenter/ssw_aix_72/osmanagement/sysrescon.htm Use lssrc command on AIX to return service state information. Co-authored-by: dberg1 <dberg1@github.com>
* sanity: remove ansible-bad-function (#70431)Abhijeet Kasurde2020-07-071-1/+1
| | | | | | * Updated docs and ignore.txt * Replaced with correct function calls Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Add intentional unit tests for basic._set_cwd and common.dict_merge (#70283)jctanner2020-06-251-0/+57
| | | | | | | * Add unit tests for basic._set_cwd * incidental coverage for dict_merge * add test for async stderr inclusion
* Clean up unit test boilerplate.Matt Clay2020-06-229-2/+24
|