Commit Graph

3798 Commits

Author SHA1 Message Date
Erik Johnson
f9f187e915
Improve reliability/idempotence of file.blockreplace state
This makes the following changes:

- The `append_newline` argument to the `file.blockreplace`
  remote-execution function has been modified so that if its value is
  `None`, it only appends a newline when the content block does not end
  in one.
- A couple of fixes were made to newline handling. The existing code
  normalized the newlines in the content block, replacing them with
  os.linesep. However, when the file contains newlines that don't match
  the OS (i.e. POSIX newlines in a file on a Windows box, or Windows
  newlines on a Linux/Mac/BSD/etc. box), then we would still end up with
  mixed newlines. The line separator is now detected when we read in the
  original file, and the detected line separator is used when writing
  the content block. Additionally, the same newline mismatch was
  possible when appending/prepending the content block. This has been
  fixed by using a common function for appending, prepending, and
  replacing the content block.
- Support for the `append_newline` argument has been added to the
  `file.blockreplace` state. The default value for the state is `None`.
  A `versionchanged` has been added to the remote execution function to
  let users know that the Fluorine release will change the default value
  of that variable.
- 20 new integration tests have been written to test the
  `file.blockreplace` state.
2018-03-07 22:29:39 -06:00
Erik Johnson
4798187035
Improve reliability/idempotence of file.blockreplace state (2018.3 branch)
This makes the following changes:

- The `append_newline` argument to the `file.blockreplace`
  remote-execution function has been modified so that if its value is
  `None`, it only appends a newline when the content block does not end
  in one.
- A couple of fixes were made to newline handling. The existing code
  normalized the newlines in the content block, replacing them with
  os.linesep. However, when the file contains newlines that don't match
  the OS (i.e. POSIX newlines in a file on a Windows box, or Windows
  newlines on a Linux/Mac/BSD/etc. box), then we would still end up with
  mixed newlines. The line separator is now detected when we read in the
  original file, and the detected line separator is used when writing
  the content block. Additionally, the same newline mismatch was
  possible when appending/prepending the content block. This has been
  fixed by using a common function for appending, prepending, and
  replacing the content block.
- Support for the `append_newline` argument has been added to the
  `file.blockreplace` state. The default value for the state is `None`.
  A `versionchanged` has been added to the remote execution function to
  let users know that the Fluorine release will change the default value
  of that variable.
- 20 new integration tests have been written to test the
  `file.blockreplace` state.
2018-03-07 22:29:09 -06:00
Mihai Dinca
b5e508f339 Fix openscap push 2018-03-07 14:55:50 +01:00
rallytime
d83727fdf9
Merge branch '2017.7' into '2018.3'
Conflicts:
  - salt/cli/api.py
  - salt/client/ssh/wrapper/state.py
  - salt/config/__init__.py
  - salt/crypt.py
  - salt/daemons/masterapi.py
  - salt/key.py
  - salt/loader.py
  - salt/master.py
  - salt/modules/archive.py
  - salt/modules/hipchat.py
  - salt/modules/pip.py
  - salt/modules/state.py
  - salt/modules/virt.py
  - salt/modules/x509.py
  - salt/state.py
  - salt/transport/tcp.py
  - salt/transport/zeromq.py
  - salt/utils/__init__.py
  - salt/utils/event.py
  - salt/utils/extmods.py
  - salt/utils/files.py
  - salt/utils/parsers.py
  - salt/utils/verify.py
  - tests/integration/shell/test_call.py
  - tests/unit/utils/test_args.py
2018-03-06 13:45:59 -05:00
Erik Johnson
61ab47ee70
Merge branch '2017.7' into merge-2017.7-2018.3
Conflicts:
- salt/cloud/clouds/openstack.py
- salt/daemons/masterapi.py
- salt/master.py
- salt/modules/gentoo_service.py
- salt/pillar/__init__.py
- salt/pillar/git_pillar.py
- salt/runners/cache.py
- salt/runners/git_pillar.py
- salt/runners/winrepo.py
- salt/utils/docker/__init__.py
- salt/utils/gitfs.py
2018-03-02 16:20:20 -06:00
Dheeraj
727ebe1056
Merge branch '2017.7' into fix-46127 2018-03-01 10:19:38 +05:30
Nicole Thomas
da60399b8f
Merge pull request #46183 from oeuftete/fix-docker-container-running-host-config-ulimits
Fix docker_container.running HostConfig Ulimits comparison
2018-02-28 17:22:11 -05:00
Nicole Thomas
a97a3e6fb0
Merge pull request #46101 from jfindlay/openrc_ret
In OpenRC exec module, make sure to ignore retcode on status
2018-02-28 15:01:36 -05:00
Dheeraj Gupta
aa9d709015 Pass env_vars to pip.freeze
pip.installed state calls pip.freeze to check for existing installation
and to verify installation post-install. This patch propagates the
env_vars passed to pip.installed to the pip.freeze function. It also modifies
existing pip unit tests to test new functionality and adds an integration test
that verifies the expected correct behavior

Fixes #46127
2018-02-28 16:44:20 +05:30
Ken Crowell
5b09644429
Sort lists from Ulimits before comparing 2018-02-27 23:49:05 -04:00
twangboy
415821eee9
Fix encoding issue 2018-02-27 14:38:07 -07:00
rallytime
776f2ea5d7
Merge branch '2018.3.0rc1' into '2018.3'
Conflicts:
  - salt/pillar/file_tree.py
  - tests/unit/modules/test_yumpkg.py
2018-02-26 11:01:42 -05:00
rallytime
cffbf52c10
Lint fix: remove extra line 2018-02-24 06:51:25 -05:00
Nicole Thomas
705caa8cca
Merge pull request #46148 from rallytime/merge-2017.7
[2017.7] Merge forward from 2017.7.3 to 2017.7
2018-02-23 14:21:38 -05:00
rallytime
79bed6cff1
Merge branch '2017.7' into '2018.3'
Conflicts:
  - salt/modules/cmdmod.py
  - salt/modules/reg.py
  - salt/modules/win_lgpo.py
  - salt/modules/win_path.py
  - salt/modules/win_pkg.py
  - salt/pillar/file_tree.py
  - salt/states/boto3_route53.py
  - salt/states/reg.py
  - salt/utils/win_functions.py
  - tests/unit/modules/test_kubernetes.py
  - tests/unit/modules/test_win_path.py
2018-02-23 09:50:19 -05:00
Nicole Thomas
e6374bf68d
Merge pull request #46149 from rallytime/bp-46145
Back-port #46145 to oxygen.rc1
2018-02-22 16:57:51 -05:00
rallytime
29468f3dce
Lint fixes 2018-02-22 14:18:28 -05:00
Erik Johnson
2b887dd77d
Update tests to reflect changes to the SaltCacheLoader 2018-02-22 10:51:36 -05:00
rallytime
25deebf7a6
Merge branch '2017.7.3' into '2017.7'
Conflicts:
  - salt/modules/git.py
2018-02-22 10:22:22 -05:00
Erik Johnson
e2c4702e0c
Update tests to reflect changes to the SaltCacheLoader 2018-02-21 23:20:02 -06:00
Erik Johnson
1668a489c4
Update refrences to Oxygen codename to 2018.3.0 2018-02-21 21:47:41 -06:00
Nicole Thomas
b92346645b
Merge pull request #46107 from amendlik/yumpkg-assumeyes
Add --assumeyes on YUM/DNF commands
2018-02-20 17:52:05 -05:00
Nicole Thomas
8f245ea62e
Merge pull request #46069 from rallytime/bp-46036
Back-port #46036 to oxygen.rc1
2018-02-20 17:50:17 -05:00
Nicole Thomas
0dc8d17540
Merge pull request #46104 from isbm/isbm-x509fixonfix
x509 fix update
2018-02-20 16:08:23 -05:00
Bo Maryniuk
201ce62c45 Fix unit test on Python3 2018-02-20 18:50:10 +01:00
Bo Maryniuk
62d2472c01 Lintfix: unused import 2018-02-20 18:49:58 +01:00
Adam Mendlik
8d9a432fb2
Add --assumeyes to yum/dnf commands in yumpkg.refresh_db
Without --assumeyes, these commands can hang waiting for
user confirmation if there is an unaccepted repository key.
2018-02-19 17:51:11 -07:00
Justin Findlay
2eef3c65a6
tests.unit.modules.gentoo_service add retcode arg 2018-02-19 11:27:11 -08:00
Bo Maryniuk
43026b67da Add unit test for x509 module on function _parse_subject 2018-02-19 15:53:42 +01:00
Benjamin Drung
dd3f936557 Fix skipping Kubernetes tests if client is not installed
When the Kubernetes client is not installed, the import of
salt.modules.kubernetes will still succeed, but HAS_LIBS will be set to
False (since the library import will be covered by a try-except clause).

Therefore expect the salt.modules.kubernetes to always succeed and check
kubernetes.HAS_LIBS instead for the presence of the kubernetes library.

Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
2018-02-19 12:32:14 +01:00
Ch3LL
edc6243d1c
Patch salt.utils call for test_parse_localectl test 2018-02-16 15:26:06 -05:00
rallytime
144b29f68b
Update old utils paths to new paths for oxygen 2018-02-16 10:35:22 -05:00
Erik Johnson
149e9edf8c
Mock the ssh.key_is_encrypted utils func 2018-02-16 10:29:30 -05:00
Erik Johnson
3fac72431f
git.latest: Fix regression with identity file usage
Unit test included
2018-02-16 10:25:25 -05:00
Erik Johnson
e2140d9a84
Mock the ssh.key_is_encrypted utils func 2018-02-15 14:37:50 -06:00
Nicole Thomas
edcb64de76
Merge pull request #45763 from twangboy/win_fix_path_rehash
Fix rehash function in win_path.py
2018-02-15 15:05:15 -05:00
Erik Johnson
f2b69f703d
git.latest: Fix regression with identity file usage
Unit test included
2018-02-15 09:35:10 -06:00
rallytime
e060a74fd8
Merge branch '2017.7' into 'oxygen'
Conflicts:
  - salt/cloud/clouds/dimensiondata.py
  - salt/config/__init__.py
  - salt/modules/yumpkg.py
  - salt/pillar/ec2_pillar.py
  - salt/utils/docker/__init__.py
  - salt/utils/vault.py
  - tests/integration/states/test_docker_container.py
  - tests/unit/modules/test_yumpkg.py
  - tests/unit/templates/test_jinja.py
  - tests/unit/utils/test_docker.py
2018-02-14 16:31:31 -05:00
Erik Johnson
ee6bf2e634
yumpkg: Fix a couple issues with _get_extra_opts
`_get_extra_opts()` and `_get_branch_option()` were unnecessarily
quoting the value, causing it to be interpreted as a literal quote by
`subprocess.Popen()`.

Also, because there were separate helpers for repo options,
disableexcludes, branch options, and extra options, and specifically
because `_get_extra_opts()` parses *all* kwargs, any of the options from
the other helper funcs would end up being added to the command line
twice if `_get_extra_opts()` was used.

This commit consolidates all of the kwarg inspection and CLI opts
construction to a single helper function. It also adds unit tests to
make sure that we are formatting our commands properly.

Additionally, it makes a minor fix in `refresh_db()` which was not
accounted for when we changed the osmajorrelease grain to an integer in
2017.7.0.
2018-02-14 13:36:57 -06:00
Nicole Thomas
a1f4092811
Merge pull request #46015 from rallytime/bp-45785
Back-port #45785 to 2017.7
2018-02-14 13:16:08 -05:00
Nicole Thomas
1279924f5f
Merge pull request #45991 from terminalmage/fix-duplicate-extra-opts
yumpkg: Fix a couple issues with _get_extra_opts
2018-02-14 11:48:28 -05:00
Erik Johnson
916766f651
yumpkg: Fix a couple issues with _get_extra_opts
`_get_extra_opts()` and `_get_branch_option()` were unnecessarily
quoting the value, causing it to be interpreted as a literal quote by
`subprocess.Popen()`.

Also, because there were separate helpers for repo options,
disableexcludes, branch options, and extra options, and specifically
because `_get_extra_opts()` parses *all* kwargs, any of the options from
the other helper funcs would end up being added to the command line
twice if `_get_extra_opts()` was used.

This commit consolidates all of the kwarg inspection and CLI opts
construction to a single helper function. It also adds unit tests to
make sure that we are formatting our commands properly.

Additionally, it makes a minor fix in `refresh_db()` which was not
accounted for when we changed the osmajorrelease grain to an integer in
2017.7.0.
2018-02-13 22:46:27 -06:00
Ollie Armstrong
ef6ffb1492
Resolve linting errors 2018-02-13 13:27:38 -05:00
Ollie Armstrong
8047066c46
Remove unused import 2018-02-13 13:27:38 -05:00
Ollie Armstrong
8f7c45935a
Add tests for salt.modules.selinux.fcontext_get_policy 2018-02-13 13:27:38 -05:00
rallytime
e04e7bdfc9
Remove extra patch 2018-02-09 09:40:22 -05:00
twangboy
29912adc15
Move the test_rehash test to test_win_functions 2018-02-08 17:44:30 -07:00
rallytime
a16ea53430
Update old utils path to new path for which() function 2018-02-08 14:38:25 -05:00
Erik Johnson
22c676ce57
Add option to cmdmod funcs to specify the output encoding 2018-02-07 02:01:55 -06:00
Erik Johnson
6cef37f310
2 unicode-compatibility fixes for cmdmod.py
First, `shlex.split()` will raise an exception when passed a unicode
type with unicode characters in the string. This modifies our
`shlex.split()` helper to first convert the passed string to a `str`
type, and then return a decoded copy of the result of the split.

Second, this uses our `to_unicode` helper to more gracefully decode the
stdout and stderr from the command. Unit tests have been added to
confirm that the output is properly decoded, including instances where
decoding fails because the return from the command contains binary data.
2018-02-07 02:01:55 -06:00
Nicole Thomas
becfb56ed0
Merge pull request #45786 from isbm/isbm-localectl-use
Multiple bugfixes for localemod
2018-02-02 09:09:22 -05:00
Benjamin Drung
b6181b5ed6 Fix Unicode tests when run with LC_ALL=POSIX
When running the unit tests with the locale set to POSIX, some Unicode
tests fail:

$ LC_ALL=POSIX python3 ./tests/runtests.py --unit
[...]
======================================================================
ERROR: test_list_products (unit.modules.test_zypper.ZypperTestCase)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/modules/test_zypper.py", line 236, in
test_list_products
    'stdout': get_test_data(filename)
  File "tests/unit/modules/test_zypper.py", line 53, in get_test_data
    return rfh.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
828: ordinal not in range(128)

======================================================================
ERROR: test_non_ascii (unit.templates.test_jinja.TestGetTemplate)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/templates/test_jinja.py", line 341, in test_non_ascii
    result = fp.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5:
ordinal not in range(128)

======================================================================
ERROR: test_non_ascii_encoding
(unit.templates.test_jinja.TestGetTemplate)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/templates/test_jinja.py", line 303, in
test_non_ascii_encoding
    fp_.read(),
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5:
ordinal not in range(128)
----------------------------------------------------------------------

Therefore open files in binary mode and explicitly decode them with
utf-8 instead of their default locale.
2018-02-01 19:24:23 +01:00
Erik Johnson
01194d6cdd
Update syslog_ng tests to reflect change in PATH behavior 2018-02-01 10:54:09 -06:00
Erik Johnson
1b78e49e1c
win_path: Do not normalize path to lowercase
This removes the lowercase normalization and handles case-insensitive
path matches. It also combines local path and system path inspection
into a single helper function in both add() and remove(), for simplicity.

Additionally, the add/remove unit tests have been rewritten to test
a wider array of use cases.
2018-02-01 10:54:09 -06:00
Bo Maryniuk
9e86a7d5f6 Lintfix: E8303 -- too many empty lines 2018-02-01 12:58:15 +01:00
Bo Maryniuk
5af6f147e6 Add unit test on set_locale for error handling when update-locale is not installed 2018-01-31 15:55:34 +01:00
Bo Maryniuk
4131f2e964 Fix unit test (mock everything!) 2018-01-31 15:52:36 +01:00
Bo Maryniuk
222b929d92 Add unit test for dbus locale parser which does not matching the results. 2018-01-31 15:42:32 +01:00
Bo Maryniuk
d2dcf9986e Add unit test for dbus locale parser matching the results. 2018-01-31 15:36:51 +01:00
Bo Maryniuk
9468f7d91e Flatten the code 2018-01-31 13:28:07 +01:00
Bo Maryniuk
eeb08405f4 Remove old-style camel assertion in favour of PyTest built-in assertions 2018-01-31 13:24:47 +01:00
Bo Maryniuk
ec77e92dcf Move unit test test_avail to py.test 2018-01-31 13:20:46 +01:00
Bo Maryniuk
a4e44c40f9 Add unit test for gen_locale is handling error while calling not installed localedef on Suse os-family. 2018-01-31 13:17:53 +01:00
Bo Maryniuk
3d4e44e18c Add unit test gen_locale is calling localedef on Suse os-family. 2018-01-31 13:14:35 +01:00
Bo Maryniuk
16419ec6d3 Add check on gen_locale for Suse-specific path 2018-01-31 13:00:12 +01:00
Bo Maryniuk
58dde2ccbc Add unit test for gen_locale on Suse os_family with invalid locale 2018-01-31 12:54:42 +01:00
Bo Maryniuk
00f2695c79 Lintfix W1699: Python3 incompat 2018-01-31 10:19:04 +01:00
Bo Maryniuk
d423df4ded Lintfix E8301: expected 1 blank line 2018-01-31 10:17:44 +01:00
Bo Maryniuk
ea0b2e171f Lintfix: E8302, PEP8 expected two blank lines 2018-01-31 10:17:04 +01:00
Bo Maryniuk
13087b2062 Fix unit test: capture log message and redirect it to the test assertion 2018-01-30 21:14:04 +01:00
Bo Maryniuk
8a9dacc30b Fix unit tests for HAS_DBUS removal 2018-01-30 21:05:00 +01:00
Bo Maryniuk
56f5645a09 Add unit test for localectl on arbitrary structure parser 2018-01-30 20:59:23 +01:00
Bo Maryniuk
5af33fbb0d Add unit test for localectl output parse on broken content 2018-01-30 20:51:23 +01:00
Bo Maryniuk
bcd04fa0ab Add log call verification 2018-01-30 20:47:26 +01:00
Bo Maryniuk
4f39075883 Add unit test for calling localectl parser on an empty output 2018-01-30 20:47:04 +01:00
Bo Maryniuk
a5d3098e9e Add unit test for localectl output status parser when no systemd installed 2018-01-30 20:38:33 +01:00
Bo Maryniuk
b4b0ea7d58 Add unit test for localectl output status parser 2018-01-30 20:36:17 +01:00
Bo Maryniuk
ec4ef24cd3 Add unit test for set_locale on unknown system 2018-01-30 19:16:15 +01:00
Bo Maryniuk
98c5ed8ef6 Remove an old unit test for set_locale 2018-01-30 19:15:54 +01:00
Bo Maryniuk
bdff4dc74c Fix system tuning conditions 2018-01-30 19:15:26 +01:00
Bo Maryniuk
e78dd78247 Add unit test for solaris when list_avail does not return proper locale 2018-01-30 19:07:40 +01:00
Bo Maryniuk
67d287316c Add unit test on solaris with list_avail returning proper locale 2018-01-30 18:58:44 +01:00
Bo Maryniuk
2e07701a0a Add unit test for set_locale on Gentoo system without systemd 2018-01-30 18:52:37 +01:00
Bo Maryniuk
a5acac5fc7 Add unit test for set_locale on Debian without systemd 2018-01-30 18:48:14 +01:00
Bo Maryniuk
cfb25f0e90 Add unit test for set_locale on RedHat systems without systemd 2018-01-30 18:45:55 +01:00
Bo Maryniuk
b1e8606d02 Add unit test with systemd and dbus enabled on SLE12 2018-01-30 18:43:01 +01:00
Bo Maryniuk
ceda257846 Add unit test for set_locale with dbus and systemd on any platform 2018-01-30 18:34:06 +01:00
Bo Maryniuk
b91ee79ef6 Add unit test for set_locale on any system with systemd and no dbus available 2018-01-30 18:32:34 +01:00
Bo Maryniuk
5bb80575d1 Fix unit test for calling a proper function while parsing localectl 2018-01-30 17:32:37 +01:00
Bo Maryniuk
b73c1d7308 Add unit test for calling unknown platform 2018-01-30 17:32:14 +01:00
Bo Maryniuk
d82b60a807 Add unit test for get_locale on Solaris 2018-01-30 17:28:28 +01:00
Bo Maryniuk
11805e47af Add unit test for get_locale on gentoo 2018-01-30 17:27:26 +01:00
Bo Maryniuk
933b365010 Add unit test for get_locale on Debian without systemd/dbus 2018-01-30 17:26:26 +01:00
Bo Maryniuk
409de1e5f6 Fix docstring on RedHat unit test for get_locale 2018-01-30 17:26:05 +01:00
Bo Maryniuk
7c19e235b1 Add unit test for get_locale on redhat systems with no systemd 2018-01-30 17:24:04 +01:00
Bo Maryniuk
df16df3abf Disable salt.utils.systemd.booted to be actually called 2018-01-30 17:23:40 +01:00
Bo Maryniuk
b3fff6744c Add unit test for getting locale on SLE12 with systemd and dbus available 2018-01-30 17:18:13 +01:00
Bo Maryniuk
22630b7a32 Fix doc for unit test 2018-01-30 17:17:46 +01:00
Bo Maryniuk
0ef739b8a7 Add unit test calling get_locale with systemd and dbus available 2018-01-30 17:06:10 +01:00
Bo Maryniuk
3c37cfd76a Add unit test calling get_locale with systemd but no dbus available 2018-01-30 17:04:37 +01:00