Commit graph

32 commits

Author SHA1 Message Date
Pedro Algarvio
c920ba443d
Remove all kitchen and jenkins related resources
The salt-project hasn't been using them for a very long time.
2024-02-29 10:27:02 +00:00
Gareth J. Greenaway
eece6b8c03
Mock salt.utils.platform.is_windows as False for those tests that should simulate running on a system that is not Windows. 2023-01-31 15:09:52 -08:00
Gareth J. Greenaway
48344faaa5
Running pre-commit manually 2023-01-30 18:12:35 -08:00
Gareth J. Greenaway
380c9035ec
When the shell is passed as powershell or pwsh, only wrapper the shell in quotes if cmd.run is running on Windows. When quoted on Linux hosts, this results in an error when the keyword arguments are appended. 2023-01-30 18:02:28 -08:00
Pedro Algarvio
1b18b4e5ab Use the minion_opts and master_opts fixtures instead.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-11-18 12:36:51 -07:00
Megan Wilhite
114bbdb361 Parameterize the bundled test for cmdmod runas tests 2022-09-14 14:07:05 -06:00
Megan Wilhite
f89c866162 fix pre-commit 2022-09-14 14:07:05 -06:00
Megan Wilhite
8f4471b2f4 fix failing test 2022-09-14 14:07:05 -06:00
Megan Wilhite
46ac0767fb Fix runas when using the onedir bundled packages 2022-09-14 14:07:05 -06:00
jeanluc
14a932aca4 Fix tests for real this time 2022-09-07 14:08:18 -06:00
jeanluc
25b6c1d32c Fix test on everything but MacOS (where it passed already) 2022-09-07 14:08:18 -06:00
jeanluc
d53cbac432 Fix cmdmod availability during minion startup on MacOS 2022-09-07 14:08:18 -06:00
Pedro Algarvio
4d49013247 Update to isort 5.10.1
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-08-01 12:49:16 -06:00
Pedro Algarvio
8ea83784ac Move deferred handler tests to pytest
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-04-12 09:46:02 -04:00
Victor Zhestkov
f5af594a44 Add test for NOTIFY_SOCKET env variable wiping 2022-03-01 19:38:25 -08:00
Thomas Phipps
0472b0c709 forgot to remove the windows false 2022-02-08 10:32:25 -08:00
Thomas Phipps
de9efde465 attempt to fix broken tests 2022-02-08 10:32:25 -08:00
Thomas Phipps
a094b35a2a fix missing __opts__ if we do not have __opts__ we should use base 2022-02-08 10:32:25 -08:00
Thomas Phipps
21d3f4bc9e fixes salt bug 61507 2022-02-08 10:32:25 -08:00
Benjamin Drung
cc0abfe717 tests: Replace os.getlogin by getpass.getuser
The test `test_run_cwd_in_combination_with_runas` fails in some test
environments (like Debian autopkgtest):

```
======================================================================
ERROR: test_run_cwd_in_combination_with_runas (unit.modules.test_cmdmod.CMDMODTestCase)
[CPU:0.0%|MEM:6.5%] cmd.run executes command in the cwd directory
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/modules/test_cmdmod.py", line 449, in test_run_cwd_in_combination_with_runas
    runas = os.getlogin()
OSError: [Errno 6] No such device or address

----------------------------------------------------------------------
```

Therefore replace `os.getlogin` by `getpass.getuser` as recommended by
upstream: "For most purposes, it is more useful to use
`getpass.getuser()` since the latter checks the environment variables
`LOGNAME` or `USERNAME` to find out who the user is, and falls back to
`pwd.getpwuid(os.getuid())[0]` to get the login name of the current real
user id."

Bug-Debian: https://bugs.debian.org/964270
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2021-10-13 14:54:07 -04:00
Gareth J. Greenaway
ba66308561 reverting https://github.com/saltstack/salt/pull/60890 and taking a different approach to fixing the Mac brew failures. 2021-09-22 18:50:10 -07:00
Gareth J. Greenaway
c1e38f4a8a Fixing failling tests. Needt to patch cmd.shells so it returns the expected paths. 2021-09-20 15:28:12 -07:00
Daniel A. Wozniak
e6dd6a482a Make sure cmdmod._log_cmd handles tuples properly 2021-08-06 21:57:06 -07:00
Pedro Algarvio
76e50885b0 Fix strings 2021-08-06 13:09:47 -07:00
Pedro Algarvio
6abb43d2df Upgrade to black 21.7b0 2021-08-06 13:09:47 -07:00
Benjamin Drung
d22ec839fd Fix test_run_with_tuple if home directory does not exist
When the home directory points to a directory that does not exist (e.g.
when building salt with sbuild), some test cases will fail:

```
_____________________________ test_run_with_tuple ______________________________
    def test_run_with_tuple():
        """
        Tests return when cmd is a tuple
        """
        mock_true = MagicMock(return_value=True)
        with patch("salt.modules.cmdmod._is_valid_shell", mock_true):
            with patch("salt.utils.platform.is_windows", MagicMock(return_value=False)):
                with patch("os.path.isfile", mock_true):
                    with patch("os.access", mock_true):
>                       cmdmod._run(("echo", "foo"), python_shell=True)

tests/pytests/unit/modules/test_cmdmod.py:159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
        if not os.path.isabs(cwd) or not os.path.isdir(cwd):
>           raise CommandExecutionError(
                "Specified cwd '{}' either not absolute or does not exist".format(cwd)
            )
E           salt.exceptions.CommandExecutionError: Specified cwd '/sbuild-nonexistent' either not absolute or does not exist

salt/modules/cmdmod.py:665: CommandExecutionError
```

So change to `/`, because this directory exists on every system.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2021-05-04 14:03:59 -04:00
Loren Gordon
3ab29ad148 Lints backport with new rules 2021-04-05 14:45:12 -04:00
Pablo Suárez Hernández
2944e2d14b Fix test to work on Windows 2021-03-05 10:00:47 -05:00
Pablo Suárez Hernández
44332ebfe8 Skip failing test on windows 2021-03-05 10:00:47 -05:00
Pablo Suárez Hernández
de51cb306c Fix unit test to avoid failing on Windows 2021-03-05 10:00:47 -05:00
Pablo Suárez Hernández
302965c99a Add unit tests to ensure cmd.run accepts tuples 2021-03-05 10:00:47 -05:00
Pedro Algarvio
85e6f04555
Migrate tests/unit/modules/test_cmdmod.py to pytest 2021-02-26 10:38:52 +00:00