Merge branch 'master' into docs/fix-alphabetic-ordering

This commit is contained in:
Imran Iqbal 2020-03-17 14:56:13 +00:00 committed by GitHub
commit 12e9c5dfb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 2223 additions and 626 deletions

View file

@ -6,7 +6,7 @@ This changelog follows [keepachangelog](https://keepachangelog.com/en/1.0.0/) fo
This project versioning is _similar_ to [Semantic Versioning](https://semver.org), and is documented in [SEP 14](https://github.com/saltstack/salt-enhancement-proposals/pull/20/files).
Versions are `MAJOR.PATCH`.
### Unreleased (3000.1)
### 3000.1
### Removed
@ -16,6 +16,31 @@ Versions are `MAJOR.PATCH`.
### Fixed
- [#56237](https://github.com/saltstack/salt/pull/56237) - Fix alphabetical ordering and remove duplicates across all documentation indexes - [@myii](https://github.com/myii)
- [#56082](https://github.com/saltstack/salt/pull/56082) - Fix saltversioninfo grain for new version
- [#56143](https://github.com/saltstack/salt/pull/56143) - Use encoding when caching pillar data
- [#56172](https://github.com/saltstack/salt/pull/56172) - Only change mine data if using new allow_tgt feature
- [#56094](https://github.com/saltstack/salt/pull/56094) - Fix type error in TornadoImporter
- [#56174](https://github.com/saltstack/salt/pull/56174) - MySQL module fixes
- [#56149](https://github.com/saltstack/salt/pull/56149) - Fix to scheduler for use of when and splay
- [#56197](https://github.com/saltstack/salt/pull/56197) - Allows use of inline powershell for cmd.script args
- [#55894](https://github.com/saltstack/salt/pull/55894) - pdbedit module should check for version 4.8.x or newer
- [#55906](https://github.com/saltstack/salt/pull/55906) - smartos.vm_present could not handle nics with vrrp_vrid property
- [#56218](https://github.com/saltstack/salt/pull/56218) - Changed StrictVersion checking of setuptools to LooseVersion
- [#56099](https://github.com/saltstack/salt/pull/56099) - Fix Windows and macOS requirements handling in setup.py
- [#56068](https://github.com/saltstack/salt/pull/56068) - Update the bootstrap script to latest version, v2020.02.24
- [#56185](https://github.com/saltstack/salt/pull/56185) - Fix regression in service states with reload argument
- [#56341](https://github.com/saltstack/salt/pull/56341) - Revert "Don't remove one directory level from slspath"
- [#56290](https://github.com/saltstack/salt/pull/56290) - Ensures popping lgpo.secedit_data does not throw KeyError
- [#56339](https://github.com/saltstack/salt/pull/56339) - Fix win_dns_client when used with scheduler
- [#56215](https://github.com/saltstack/salt/pull/56215) - Fix for unless requisite when pip is not installed
- [#56060](https://github.com/saltstack/salt/pull/56060) - Fix regex string for Del and DelVals
- [#56337](https://github.com/saltstack/salt/pull/56337) - Handle Adapter Type 53 and Undefined Types
- [#56160](https://github.com/saltstack/salt/pull/56160) - Fix issue with existing reg_dword entries
- [#56358](https://github.com/saltstack/salt/pull/56358) - Fix version instantiation when minor is an empty string
- [#56272](https://github.com/saltstack/salt/pull/56272) - Properly resolve the policy name
- [#56310](https://github.com/saltstack/salt/pull/56310) - Only process ADMX files when loading policies
- [#56327](https://github.com/saltstack/salt/pull/56327) - keep cache_copied_files variable a list
- [#56360](https://github.com/saltstack/salt/pull/56360) - dont require virtualenv.virtualenv_version call, removed in 20.0.10
### Added

View file

@ -96,10 +96,11 @@ include option.
slspath
=======
The `slspath` variable contains the path to the current sls file. The value
of `slspath` in files referenced in the current sls depends on the reference
method. For jinja includes `slspath` is the path to the current file. For
salt includes `slspath` is the path to the included file.
The `slspath` variable contains the path to the directory of the current sls
file. The value of `slspath` in files referenced in the current sls depends on
the reference method. For jinja includes `slspath` is the path to the current
directory of the file. For salt includes `slspath` is the path to the directory
of the included file.
.. code-block:: jinja

View file

@ -0,0 +1,555 @@
.. _release-3000-1:
=========================
Salt 3000.1 Release Notes
=========================
Version 3000.1 is a bugfix release for :ref:`3000 <release-3000>`.
Statistics
==========
- Total Merges: **39**
- Total Issue References: **14**
- Total PR References: **40**
- Contributors: **15** (`Ch3LL`_, `UtahDave`_, `cmcmarrow`_, `dwoz`_, `frogunder`_, `garethgreenaway`_, `lorengordon`_, `mchugh19`_, `oeuftete`_, `raddessi`_, `s0undt3ch`_, `sjorge`_, `terminalmage`_, `twangboy`_, `waynew`_)
Changelog for v3000..v3000.1
============================
*Generated at: 2020-03-13 17:24:15 UTC*
* **PR** `#56365`_: (`Ch3LL`_) Update 3000.1 changelog
@ *2020-03-13 17:21:02 UTC*
* 62857a9f0e Merge pull request `#56365`_ from Ch3LL/changelog_3000.1
* 851d7d8fc7 Update 3000.1 changelog
* **PR** `#56360`_: (`Ch3LL`_) Use virtualenv 20.0.10 for macosx tests
@ *2020-03-13 16:39:57 UTC*
* a660e96fb2 Merge pull request `#56360`_ from Ch3LL/mac_virtual
* abda125086 Update static requirements files
* dca3390c0c skip zcbuildout state test when virtualenv 20.0.0
* fdeae1f0e1 Use virtualenv 20.0.10 for macosx tests
* **ISSUE** `#56324`_: (`kiemlicz`_) Cannot use Saltcheck module (refs: `#56327`_)
* **PR** `#56327`_: (`mchugh19`_) keep cache_copied_files variable a list
@ *2020-03-13 16:39:32 UTC*
* d8fc07274c Merge pull request `#56327`_ from mchugh19/56324
* e1e2df2b1d Merge branch 'master' into 56324
* 6d7572706d use includes for saltcheck integration test
* 5b7073b01d keep cache_copied_files variable a list
* **PR** `#56023`_: (`cmcmarrow`_) add fix for bin_env
@ *2020-03-13 16:39:09 UTC*
* 2d31d61ab9 Merge pull request `#56023`_ from cmcmarrow/binary_fix_pip_bin_env
* f780fd013e Merge branch 'master' into binary_fix_pip_bin_env
* d642c7c270 Merge branch 'master' into binary_fix_pip_bin_env
* 82b39d26f8 Merge branch 'binary_fix_pip_bin_env' of https://github.com/cmcmarrow/salt into binary_fix_pip_bin_env
* a5fa22528a Merge branch 'master' into binary_fix_pip_bin_env
* 10ca0fa5d6 fix space
* 22fff6c180 fix _pip_bin_env
* d5425e6630 Merge branch 'master' into binary_fix_pip_bin_env
* ceda3fde00 add full support for when missing kwargs or args
* cf4ab215b5 add fix for bin_env
* **PR** `#56310`_: (`twangboy`_) Only process ADMX files when loading policies
@ *2020-03-11 23:47:50 UTC*
* 19bb6aae0c Merge pull request `#56310`_ from twangboy/fix_lgpo_admx
* 4bc5b05586 Fix some lint
* ce282f9754 Mark destructive test
* 8af09c31ca Add test case
* 547d35cf4c Only process ADMX files when loading policies
* **PR** `#56272`_: (`twangboy`_) Properly resolve the policy name
@ *2020-03-11 22:11:02 UTC*
* 2d78931eaf Merge pull request `#56272`_ from twangboy/fix_lgpo_names
* 233ed12472 Add comments to helper function
* a7369e41d7 Remove redundent code... some more
* 1db3052b94 Consolidate duplicate code
* b25b56299d Fix failing PY2 tests
* 36a24ac28f Only load adml data once
* bc13be6850 Add some tests
* 2e9be6e461 Properly resolve the policy name
* **PR** `#56358`_: (`s0undt3ch`_) Fix version instantiation when minor is an empty string
@ *2020-03-11 22:10:04 UTC*
* c6c6e2e3d9 Merge pull request `#56358`_ from s0undt3ch/hotfix/version-parsing
* cb22e78502 Fix version instantiation when minor is an empty string
* **PR** `#56160`_: (`twangboy`_) Fix issue with existing reg_dword entries
@ *2020-03-11 22:09:21 UTC*
* b33047c574 Merge pull request `#56160`_ from twangboy/fix_reg_dword
* 80650c2a8c Make test more explicit
* 67dd1c18c7 Fix issue with existing reg_dword entries
* **PR** `#56337`_: (`twangboy`_) Handle Adapter Type 53 and Undefined Types
@ *2020-03-11 22:08:19 UTC*
* 8f23706871 Merge pull request `#56337`_ from twangboy/fix_win_network_type
* 18a31a0b22 Merge branch 'master' into fix_win_network_type
* d92914ad91 Merge branch 'master' into fix_win_network_type
* 224629bdeb Handle Adapter Type 53 and Undefined Types
* **PR** `#56060`_: (`twangboy`_) Fix regex string for \*\*Del and \*\*DelVals
@ *2020-03-11 22:05:43 UTC*
* e551ff6a31 Merge pull request `#56060`_ from twangboy/fix_lgpo_regex
* ca260ef582 Use byte-strings in the test
* 7c81874a5b Add some tests
* 944b022f33 Fix regex string for \*\*Del and \*\*DelVals
* **ISSUE** `#56131`_: (`thusoy`_) Salt v3000 crashes with unless clause if pip is missing (refs: `#56215`_)
* **PR** `#56215`_: (`dwoz`_) Fix for unless requisite when pip is not installed
@ *2020-03-11 22:04:30 UTC*
* c9bc9431c1 Merge pull request `#56215`_ from dwoz/issue-56131
* 5dd8f8eabe Fix linter
* 7492c2f7c7 Remove crufty prints from test
* 8ceaa6e6f3 Only remove pip relasted modules
* 69b21e5e68 Add regression test for issue 56131
* 9d23f55adc Fix for unless requisite when pip is not installed
* **PR** `#56339`_: (`twangboy`_) Fix win_dns_client when used with scheduler
@ *2020-03-11 22:01:32 UTC*
* 74b67ea741 Merge pull request `#56339`_ from twangboy/fix_win_dns_client
* d6a4fbe85d Fix bad test (lint)
* 47bd67373f Add some tests
* 995975649a Add missing import, improve docs
* **ISSUE** `#56288`_: (`lorengordon`_) win_lgpo: `lgpo.set` with secedit policy always generates `KeyError: u'lgpo.secedit_data'` (refs: `#56290`_)
* **PR** `#56290`_: (`lorengordon`_) Ensures popping lgpo.secedit_data does not throw KeyError
@ *2020-03-11 17:27:04 UTC*
* 7701e8762d Merge pull request `#56290`_ from lorengordon/pop-secdata
* 62453bb6ce Merge branch 'master' into pop-secdata
* 95d5cea9ff Merge branch 'master' into pop-secdata
* 2979158a8b Tests the `if _secedits:` logic path in `lgpo.set_`
* d1f776178c Ensures popping lgpo.secedit_data does not throw KeyError
* **ISSUE** `#56119`_: (`finalduty`_) Release notes for v3000 do not mention changes to `slspath` variable (refs: `#56341`_)
* **PR** `#56341`_: (`dwoz`_) Revert "Don't remove one directory level from slspath"
@ *2020-03-11 17:03:33 UTC*
* 84c60708cd Merge pull request `#56341`_ from dwoz/issue-56119
* afe6e84c36 Clarify slspath documentation
* 6dfc098fd1 Add debug for test asserts
* 9fa9dab8b2 Fix linter warts
* fd702bdd44 Add regression test for `#56119`_
* 3d3b673cec Revert "Don't remove one directory level from slspath"
* **PR** `#56185`_: (`terminalmage`_) Fix regression in service states with reload argument
@ *2020-03-11 16:45:58 UTC*
* 4f9813a49c Merge pull request `#56185`_ from terminalmage/issue56167
* 65b3f4c9a0 Merge branch 'master' into issue56167
* 7b41a00b4f Merge branch 'master' into issue56167
* 8f7034d946 Merge branch 'master' into issue56167
* e9fbb634e1 Skip on OSX for now
* 5996280241 Add __opts__ and __grains__ just in case
* af3e841d08 Fix failing test
* 586f21aedc Add functional test
* 1afb9c10f0 Fix regression in service states with reload argument
* **PR** `#56068`_: (`s0undt3ch`_) Update the bootstrap script to latest version, v2020.02.24
@ *2020-03-11 16:44:23 UTC*
* 74f8b2a926 Merge pull request `#56068`_ from s0undt3ch/hotfix/update-bootstrap
* ce83b190ed Merge branch 'master' into hotfix/update-bootstrap
* ccd231d82d Merge branch 'master' into hotfix/update-bootstrap
* 88a52f88ff Update the bootstrap script to latest version, v2020.02.24
* 012fb5bc4b Update the bootstrap script to latest version, v2020.02.04
* **PR** `#56321`_: (`oeuftete`_) Tidy up formatting in boto_secgroup docs
@ *2020-03-11 08:14:48 UTC*
* 154257e2e9 Merge pull request `#56321`_ from oeuftete/tidy-boto-secgroup-docs
* 616f11b33e Merge branch 'master' into tidy-boto-secgroup-docs
* 412bb4d62d Tidy up formatting in boto_secgroup docs
* **PR** `#56336`_: (`Ch3LL`_) Fix test_issue_2594_non_invalidated_cache test (update zope.interface)
@ *2020-03-11 00:08:43 UTC*
* 11d33e3d90 Merge pull request `#56336`_ from Ch3LL/fix_56330
* bbf37e090b Fix test_issue_2594_non_invalidated_cache test (update zope.interface)
* **PR** `#56346`_: (`frogunder`_) Update man pages to 3000.1
@ *2020-03-11 00:07:31 UTC*
* a640bd30fc Merge pull request `#56346`_ from frogunder/man_pages_3000_1
* 6d7c1b6482 Update man pages to 3000.1
* **PR** `#56099`_: (`s0undt3ch`_) Fix Windows and macOS requirements handling in setup.py
@ *2020-03-11 00:04:37 UTC*
* 2f783d247e Merge pull request `#56099`_ from s0undt3ch/hotfix/requirements
* c19f4a3fae Merge branch 'master' into hotfix/requirements
* 1e7bc8fc8f Also take into account macOS requirements
* 7eef14952c Also include req_win.txt
* **PR** `#56218`_: (`raddessi`_) Changed StrictVersion checking of setuptools to LooseVersion
@ *2020-03-10 23:59:54 UTC*
* 7c4d879073 Merge pull request `#56218`_ from raddessi/master.v3000-conda
* 44556f6d57 Merge branch 'master' into master.v3000-conda
* 566c03b786 Merge branch 'master' into master.v3000-conda
* 82773a9799 Removed now-unused StrictVersion import from setup.py
* 31bb0f7cd1 Changed StrictVersion checking of setuptools to LooseVersion
* **PR** `#56128`_: (`waynew`_) Update CHANGELOG with release date and unreleased.
@ *2020-03-10 23:58:15 UTC*
* acbd3556e5 Merge pull request `#56128`_ from waynew/master
* e3216db3e5 Update CHANGELOG with release date and unreleased.
* **PR** `#55937`_: (`twangboy`_) Update windows build scripts
@ *2020-03-10 23:55:55 UTC*
* 12140545ab Merge pull request `#55937`_ from twangboy/update_deps
* f00a504a48 Add back the pylauncher
* 30b9c32356 Revert changes to req and req_win
* 98dc0e970c Fix some warts in the build_env scripts
* 8404141f65 Update dependencies
* **PR** `#55906`_: (`sjorge`_) smartos.vm_present could not handle nics with vrrp_vrid property
@ *2020-03-10 23:54:44 UTC*
* 485a47cdf1 Merge pull request `#55906`_ from sjorge/smartos_vrrp
* 5bd7dd009a Merge branch 'master' into smartos_vrrp
* f77719c179 smartos state should handle vrrp config
* **ISSUE** `#55185`_: (`sjorge`_) salt.modules.pdbedit doesn't work on samba older than 4.8 (refs: `#55894`_)
* **PR** `#55894`_: (`sjorge`_) `#55185`_ pdbedit module should check for version 4.8.x or newer
@ *2020-03-10 23:54:21 UTC*
* 1fa8555360 Merge pull request `#55894`_ from sjorge/pdbedit_55185
* 9dc7b71122 Merge branch 'master' into pdbedit_55185
* **ISSUE** `#56195`_: (`lorengordon`_) Windows: Using inline powershell in args with `cmd.script` and `shell: powershell` (refs: `#56197`_)
* **PR** `#56197`_: (`lorengordon`_) Allows use of inline powershell for cmd.script args
@ *2020-03-10 23:52:47 UTC*
* 3e57d58db2 Merge pull request `#56197`_ from lorengordon/file-or-no-file
* fcd1699f5e Allows use of inline powershell for cmd.script args
* be2e67c0a0 Tests that powershell processes inline powershell in args
* **ISSUE** `#53152`_: (`jbeaird`_) daily highstate fails after 2019.2 upgrade (refs: `#56149`_)
* **PR** `#56149`_: (`garethgreenaway`_) [master] Fix to scheduler for use of when and splay
@ *2020-03-10 23:52:16 UTC*
* 547c73e4cc Merge pull request `#56149`_ from garethgreenaway/53152_fix_schedule_when_splay
* 8f068f6f9b Fix for when using a combination of when and splay. Previously comparing the wrong value when determining if the job should be run and next_fire_time updated. This resulted in multiple job runs when `when` and `splay` were used together. Code updated and test updated to ensure only one run at the specific time. Skip eval tests is dateutil.parser is unavailable.
* **PR** `#56345`_: (`s0undt3ch`_) Bump Windows Py3 builds timeout to 10 hours
@ *2020-03-10 20:43:41 UTC*
* 192ce76a95 Merge pull request `#56345`_ from s0undt3ch/hotfix/win-py3-timeouts
* 11bdc38ae3 Bump Windows 2019 Py3 builds timeout to 10 hours
* **PR** `#55888`_: (`s0undt3ch`_) Disable codecov PR comments and status checks
@ *2020-03-10 15:45:52 UTC*
* a204906c80 Merge pull request `#55888`_ from s0undt3ch/hotfix/coverage-reporting
* 4b8dc8a586 Disable codecov PR comments and status checks
* cb0f4dff87 Apply the suggestion given by the codecov team
* **ISSUE** `#56177`_: (`jodok`_) mysql states fail because conv is `` instead of None (refs: `#56174`_)
* **ISSUE** `#56170`_: (`jeffdyke`_) mariadb socket access must be enabled before highstate - salt 3K still tries empty password (refs: `#56174`_)
* **ISSUE** `#56124`_: (`ymasson`_) MySQL state and module broken after upgrade to 3000 (refs: `#56174`_)
* **PR** `#56174`_: (`garethgreenaway`_) [master] MySQL module fixes
@ *2020-03-10 04:03:23 UTC*
* 3e913631bb Merge pull request `#56174`_ from garethgreenaway/56124_mysql_module_state_fixes
* fcc061368b Removing quotes from the plugin_status query. Updating tests to reflect changes.
* 3dc66393b2 Adding better error reporting around plugins. Updating tests. Only attempt to delete a user if they exist.
* 1337da1e4e Ensure _mysql_user_exists is using auth_socket. Updating mysql and mariadb chpass functions to ensure that the respective plugins are enabled before attempting to use them.
* 34995ba4e8 Reworking the unix_socket code to support the differences between MySQL and MariaDB. Adding some functions to install, remove, and check the status of plugins which we can then use when adding users which will use the unix_socket & auth_socket plugins. Adding additional tests for these new functions as well as test to ensure the correct SQL is being generated when using passwordless and unix_socket options.
* 5bfd67c13e Minor tweak to mysql module. Fixing failing tests.
* e871a3ffd1 Various fixes to the mysql module to break out the handling of user management into different functions based on MySQL variant.
* **ISSUE** `#56063`_: (`terminalmage`_) [master] Traceback in esxi grain module on import (refs: `#56094`_)
* **PR** `#56094`_: (`dwoz`_) Fix type error in TornadoImporter
@ *2020-03-10 01:39:08 UTC*
* 211c88bfbc Merge pull request `#56094`_ from dwoz/fix_56063
* 7b1632e8e3 Fix type error in TornadoImporter
* **PR** `#56172`_: (`Ch3LL`_) Only change mine data if using new allow_tgt feature
@ *2020-03-10 01:34:27 UTC*
* fb5252fc53 Merge pull request `#56172`_ from Ch3LL/mine_g
* f4c9c2a5cf Fix docs
* 6c914caec8 Use different targeting for windows/linux
* f6348127dc Only change mine data if using new allow_tgt feature
* **ISSUE** `#56121`_: (`githubcdr`_) salt-minion broken after upgrade to 3000 (refs: `#56143`_)
* **ISSUE** `#51854`_: (`Oloremo`_) Fluorine: minion_pillar_cache: True leads to exception (refs: `#52195`_, `#56143`_)
* **PR** `#56143`_: (`waynew`_) Use encoding when caching pillar data
@ *2020-03-10 01:33:37 UTC*
* **PR** `#52195`_: (`waynew`_) Use encoding when caching pillar data (refs: `#56143`_)
* 8a8e9c9c5f Merge pull request `#56143`_ from waynew/51854-minion-pillar-cache-exception
* 58cc9488aa Merge branch 'master' into 51854-minion-pillar-cache-exception
* **PR** `#56082`_: (`Ch3LL`_) Fix saltversioninfo grain for new version
@ *2020-03-10 01:32:11 UTC*
* 9f27caa7d0 Merge pull request `#56082`_ from Ch3LL/ver_grains
* e6abd6d31b ensure full_info/noc_info work with new versioning
* bcc520ccc4 Add saltversioninfo grains test
* 510e149b87 Fix saltversioninfo grain for new version
* **PR** `#56285`_: (`UtahDave`_) Add missing colon.
@ *2020-03-09 22:22:17 UTC*
* 602ff3b9f1 Merge pull request `#56285`_ from UtahDave/fix_f5_doc
* 1034013831 Add missing colon.
* **PR** `#56333`_: (`Ch3LL`_) add pylint ignore in django returner
@ *2020-03-09 20:42:42 UTC*
* de5184a206 Merge pull request `#56333`_ from Ch3LL/lint_fix
* 6a213a429a add pylint ignore in django returner
* 759290a055 Use encoding when caching pillar data
* **ISSUE** `#56080`_: (`sagetherage`_) Update release notes, pip download page and install docs on pycrpto (refs: `#56095`_)
* **PR** `#56095`_: (`waynew`_) Provide security advisory for PyCrypto
@ *2020-02-10 18:42:00 UTC*
* 9adc2214c3 Merge pull request `#56095`_ from waynew/crypto-warning
* 484bc51f4b Add warnings to a couple of other places
* 2711c04ca9 Provide security advisory for PyCrypto
* **PR** `#56092`_: (`twangboy`_) Add LGPO and Network PRs to changelogs
@ *2020-02-10 18:17:28 UTC*
* 1acd492bb9 Merge pull request `#56092`_ from twangboy/waynew-update-changelog
* 4e03620d4e Fix a docs issue
* e7b64277e1 Add LGPO and Network PRs to changelogs
* **PR** `#56115`_: (`s0undt3ch`_) Add information about the pip install salt on windows issue.
@ *2020-02-10 17:33:44 UTC*
* 65d59b0ee9 Merge pull request `#56115`_ from s0undt3ch/hotfix/release-notes
* aeac9f36cd Add information about the pip install salt on windows issue.
* a5179434e7 Merge branch 'master' into pdbedit_55185
* 95d46d6cc8 `#55185`_ pdbedit module should check for version 4.8.x or newer
.. _`#51854`: https://github.com/saltstack/salt/issues/51854
.. _`#52195`: https://github.com/saltstack/salt/pull/52195
.. _`#53152`: https://github.com/saltstack/salt/issues/53152
.. _`#55185`: https://github.com/saltstack/salt/issues/55185
.. _`#55888`: https://github.com/saltstack/salt/pull/55888
.. _`#55894`: https://github.com/saltstack/salt/pull/55894
.. _`#55906`: https://github.com/saltstack/salt/pull/55906
.. _`#55937`: https://github.com/saltstack/salt/pull/55937
.. _`#56023`: https://github.com/saltstack/salt/pull/56023
.. _`#56060`: https://github.com/saltstack/salt/pull/56060
.. _`#56063`: https://github.com/saltstack/salt/issues/56063
.. _`#56068`: https://github.com/saltstack/salt/pull/56068
.. _`#56080`: https://github.com/saltstack/salt/issues/56080
.. _`#56082`: https://github.com/saltstack/salt/pull/56082
.. _`#56092`: https://github.com/saltstack/salt/pull/56092
.. _`#56094`: https://github.com/saltstack/salt/pull/56094
.. _`#56095`: https://github.com/saltstack/salt/pull/56095
.. _`#56099`: https://github.com/saltstack/salt/pull/56099
.. _`#56115`: https://github.com/saltstack/salt/pull/56115
.. _`#56119`: https://github.com/saltstack/salt/issues/56119
.. _`#56121`: https://github.com/saltstack/salt/issues/56121
.. _`#56124`: https://github.com/saltstack/salt/issues/56124
.. _`#56128`: https://github.com/saltstack/salt/pull/56128
.. _`#56131`: https://github.com/saltstack/salt/issues/56131
.. _`#56143`: https://github.com/saltstack/salt/pull/56143
.. _`#56149`: https://github.com/saltstack/salt/pull/56149
.. _`#56160`: https://github.com/saltstack/salt/pull/56160
.. _`#56170`: https://github.com/saltstack/salt/issues/56170
.. _`#56172`: https://github.com/saltstack/salt/pull/56172
.. _`#56174`: https://github.com/saltstack/salt/pull/56174
.. _`#56177`: https://github.com/saltstack/salt/issues/56177
.. _`#56185`: https://github.com/saltstack/salt/pull/56185
.. _`#56195`: https://github.com/saltstack/salt/issues/56195
.. _`#56197`: https://github.com/saltstack/salt/pull/56197
.. _`#56215`: https://github.com/saltstack/salt/pull/56215
.. _`#56218`: https://github.com/saltstack/salt/pull/56218
.. _`#56272`: https://github.com/saltstack/salt/pull/56272
.. _`#56285`: https://github.com/saltstack/salt/pull/56285
.. _`#56288`: https://github.com/saltstack/salt/issues/56288
.. _`#56290`: https://github.com/saltstack/salt/pull/56290
.. _`#56310`: https://github.com/saltstack/salt/pull/56310
.. _`#56321`: https://github.com/saltstack/salt/pull/56321
.. _`#56324`: https://github.com/saltstack/salt/issues/56324
.. _`#56327`: https://github.com/saltstack/salt/pull/56327
.. _`#56333`: https://github.com/saltstack/salt/pull/56333
.. _`#56336`: https://github.com/saltstack/salt/pull/56336
.. _`#56337`: https://github.com/saltstack/salt/pull/56337
.. _`#56339`: https://github.com/saltstack/salt/pull/56339
.. _`#56341`: https://github.com/saltstack/salt/pull/56341
.. _`#56345`: https://github.com/saltstack/salt/pull/56345
.. _`#56346`: https://github.com/saltstack/salt/pull/56346
.. _`#56358`: https://github.com/saltstack/salt/pull/56358
.. _`#56360`: https://github.com/saltstack/salt/pull/56360
.. _`#56365`: https://github.com/saltstack/salt/pull/56365
.. _`Ch3LL`: https://github.com/Ch3LL
.. _`Oloremo`: https://github.com/Oloremo
.. _`UtahDave`: https://github.com/UtahDave
.. _`cmcmarrow`: https://github.com/cmcmarrow
.. _`dwoz`: https://github.com/dwoz
.. _`finalduty`: https://github.com/finalduty
.. _`frogunder`: https://github.com/frogunder
.. _`garethgreenaway`: https://github.com/garethgreenaway
.. _`githubcdr`: https://github.com/githubcdr
.. _`jbeaird`: https://github.com/jbeaird
.. _`jeffdyke`: https://github.com/jeffdyke
.. _`jodok`: https://github.com/jodok
.. _`kiemlicz`: https://github.com/kiemlicz
.. _`lorengordon`: https://github.com/lorengordon
.. _`mchugh19`: https://github.com/mchugh19
.. _`oeuftete`: https://github.com/oeuftete
.. _`raddessi`: https://github.com/raddessi
.. _`s0undt3ch`: https://github.com/s0undt3ch
.. _`sagetherage`: https://github.com/sagetherage
.. _`sjorge`: https://github.com/sjorge
.. _`terminalmage`: https://github.com/terminalmage
.. _`thusoy`: https://github.com/thusoy
.. _`twangboy`: https://github.com/twangboy
.. _`waynew`: https://github.com/waynew
.. _`ymasson`: https://github.com/ymasson

View file

@ -25,7 +25,7 @@ rfc3987
salttesting==2017.6.1
strict_rfc3339
supervisor==3.3.5; python_version < '3'
virtualenv
virtualenv==20.0.10
watchdog
yamlordereddictloader
vcert~=0.7.0

View file

@ -5,6 +5,7 @@
# pip-compile -o requirements/static/py2.7/darwin.txt -v pkg/osx/req.txt pkg/osx/req_ext.txt requirements/base.txt requirements/zeromq.txt requirements/pytest.txt requirements/static/darwin.in
#
apache-libcloud==2.4.0
appdirs==1.4.3 # via virtualenv
argh==0.26.2 # via watchdog
asn1crypto==1.3.0 # via certvalidator, cryptography, oscrypto
atomicwrites==1.3.0 # via pytest
@ -30,16 +31,18 @@ cherrypy==17.4.1
click==7.0
clustershell==1.8.1
configparser==4.0.2 # via importlib-metadata
contextlib2==0.5.5 # via cherrypy, importlib-metadata
contextlib2==0.6.0.post1 # via cherrypy, importlib-metadata, importlib-resources, virtualenv
cookies==2.2.1 # via responses
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
docutils==0.14 # via botocore
ecdsa==0.13.3 # via python-jose
enum34==1.1.6
filelock==3.0.12 # via virtualenv
funcsigs==1.0.2 # via mock, pytest
functools32==3.2.3.post2 # via jsonschema
future==0.17.1 # via python-jose
@ -50,7 +53,8 @@ gitdb==0.6.4
gitpython==2.1.11
google-auth==1.6.3 # via kubernetes
idna==2.8
importlib-metadata==0.23 # via pluggy, pytest
importlib-metadata==0.23 # via importlib-resources, pluggy, pytest, virtualenv
importlib-resources==1.3.1 # via virtualenv
ipaddress==1.0.22
jaraco.functools==2.0 # via tempora
jinja2==2.10.1
@ -77,7 +81,7 @@ netaddr==0.7.19 # via junos-eznc
oscrypto==1.2.0 # via certvalidator
packaging==19.2 # via pytest
paramiko==2.4.2 # via junos-eznc, ncclient, scp
pathlib2==2.3.3 # via importlib-metadata, pytest
pathlib2==2.3.3 # via importlib-metadata, importlib-resources, pytest, virtualenv
pathtools==0.1.2 # via watchdog
pluggy==0.13.1 # via pytest
portend==2.4 # via cherrypy
@ -116,16 +120,17 @@ scp==0.13.2 # via junos-eznc
selectors2==2.0.1 # via ncclient
setproctitle==1.1.10
singledispatch==3.4.0.3 ; python_version < "3.4"
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, vcert, websocket-client
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, vcert, virtualenv, websocket-client
smmap2==2.0.5 # via gitdb2
smmap==0.9.0
strict-rfc3339==0.7
supervisor==3.3.5 ; python_version < "3"
tempora==1.14.1 # via portend
timelib==0.2.4
typing==3.7.4.1 # via importlib-resources
urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests
vcert==0.7.3
virtualenv==16.4.3
virtualenv==20.0.10
vultr==1.0.1
watchdog==0.9.0
wcwidth==0.1.7 # via pytest
@ -136,6 +141,6 @@ wrapt==1.11.1 # via aws-xray-sdk
xmltodict==0.12.0 # via moto
yamlordereddictloader==0.4.0
zc.lockfile==1.4 # via cherrypy
zipp==0.6.0 # via importlib-metadata
zipp==0.6.0 # via importlib-metadata, importlib-resources
# Passthrough dependencies from pkg/osx/req.txt
pyobjc==5.1.2

View file

@ -5,6 +5,7 @@
# pip-compile -o requirements/static/py3.5/darwin.txt -v pkg/osx/req.txt pkg/osx/req_ext.txt requirements/base.txt requirements/zeromq.txt requirements/pytest.txt requirements/static/darwin.in
#
apache-libcloud==2.4.0
appdirs==1.4.3 # via virtualenv
argh==0.26.2 # via watchdog
asn1crypto==1.3.0 # via certvalidator, cryptography, oscrypto
atomicwrites==1.3.0 # via pytest
@ -29,12 +30,14 @@ clustershell==1.8.1
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
docutils==0.14 # via botocore
ecdsa==0.13.3 # via python-jose
enum34==1.1.6
filelock==3.0.12 # via virtualenv
future==0.17.1 # via python-jose
genshi==0.7.3
gitdb2==2.0.5 # via gitpython
@ -42,7 +45,8 @@ gitdb==0.6.4
gitpython==2.1.11
google-auth==1.6.3 # via kubernetes
idna==2.8
importlib-metadata==0.23 # via pluggy, pytest
importlib-metadata==0.23 # via importlib-resources, pluggy, pytest, virtualenv
importlib-resources==1.3.1 # via virtualenv
ipaddress==1.0.22
jaraco.functools==2.0 # via tempora
jinja2==2.10.1
@ -104,7 +108,7 @@ s3transfer==0.2.0 # via boto3
salttesting==2017.6.1
scp==0.13.2 # via junos-eznc
setproctitle==1.1.10
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, websocket-client
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, virtualenv, websocket-client
smmap2==2.0.5 # via gitdb2
smmap==0.9.0
strict-rfc3339==0.7
@ -112,7 +116,7 @@ tempora==1.14.1 # via portend
timelib==0.2.4
urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests
vcert==0.7.3
virtualenv==16.4.3
virtualenv==20.0.10
vultr==1.0.1
watchdog==0.9.0
wcwidth==0.1.7 # via pytest
@ -122,6 +126,6 @@ wrapt==1.11.1 # via aws-xray-sdk
xmltodict==0.12.0 # via moto
yamlordereddictloader==0.4.0
zc.lockfile==1.4 # via cherrypy
zipp==0.6.0 # via importlib-metadata
zipp==0.6.0 # via importlib-metadata, importlib-resources
# Passthrough dependencies from pkg/osx/req.txt
pyobjc==5.1.2

View file

@ -5,6 +5,7 @@
# pip-compile -o requirements/static/py3.6/darwin.txt -v pkg/osx/req.txt pkg/osx/req_ext.txt requirements/base.txt requirements/zeromq.txt requirements/pytest.txt requirements/static/darwin.in
#
apache-libcloud==2.4.0
appdirs==1.4.3 # via virtualenv
argh==0.26.2 # via watchdog
asn1crypto==1.3.0 # via certvalidator, cryptography, oscrypto
atomicwrites==1.3.0 # via pytest
@ -29,12 +30,14 @@ clustershell==1.8.1
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
docutils==0.14 # via botocore
ecdsa==0.13.3 # via python-jose
enum34==1.1.6
filelock==3.0.12 # via virtualenv
future==0.17.1 # via python-jose
genshi==0.7.3
gitdb2==2.0.5 # via gitpython
@ -42,7 +45,8 @@ gitdb==0.6.4
gitpython==2.1.11
google-auth==1.6.3 # via kubernetes
idna==2.8
importlib-metadata==0.23 # via pluggy, pytest
importlib-metadata==0.23 # via importlib-resources, pluggy, pytest, virtualenv
importlib-resources==1.3.1 # via virtualenv
ipaddress==1.0.22
jaraco.functools==2.0 # via tempora
jinja2==2.10.1
@ -103,7 +107,7 @@ s3transfer==0.2.0 # via boto3
salttesting==2017.6.1
scp==0.13.2 # via junos-eznc
setproctitle==1.1.10
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, websocket-client
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, virtualenv, websocket-client
smmap2==2.0.5 # via gitdb2
smmap==0.9.0
strict-rfc3339==0.7
@ -111,7 +115,7 @@ tempora==1.14.1 # via portend
timelib==0.2.4
urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests
vcert==0.7.3
virtualenv==16.4.3
virtualenv==20.0.10
vultr==1.0.1
watchdog==0.9.0
wcwidth==0.1.7 # via pytest
@ -121,6 +125,6 @@ wrapt==1.11.1 # via aws-xray-sdk
xmltodict==0.12.0 # via moto
yamlordereddictloader==0.4.0
zc.lockfile==1.4 # via cherrypy
zipp==0.6.0 # via importlib-metadata
zipp==0.6.0 # via importlib-metadata, importlib-resources
# Passthrough dependencies from pkg/osx/req.txt
pyobjc==5.1.2

View file

@ -5,6 +5,7 @@
# pip-compile -o requirements/static/py3.7/darwin.txt -v pkg/osx/req.txt pkg/osx/req_ext.txt requirements/base.txt requirements/zeromq.txt requirements/pytest.txt requirements/static/darwin.in
#
apache-libcloud==2.4.0
appdirs==1.4.3 # via virtualenv
argh==0.26.2 # via watchdog
asn1crypto==1.3.0 # via certvalidator, cryptography, oscrypto
atomicwrites==1.3.0 # via pytest
@ -29,12 +30,14 @@ clustershell==1.8.1
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
docutils==0.14 # via botocore
ecdsa==0.13.3 # via python-jose
enum34==1.1.6
filelock==3.0.12 # via virtualenv
future==0.17.1 # via python-jose
genshi==0.7.3
gitdb2==2.0.5 # via gitpython
@ -42,7 +45,7 @@ gitdb==0.6.4
gitpython==2.1.11
google-auth==1.6.3 # via kubernetes
idna==2.8
importlib-metadata==0.23 # via pluggy, pytest
importlib-metadata==0.23 # via pluggy, pytest, virtualenv
ipaddress==1.0.22
jaraco.functools==2.0 # via tempora
jinja2==2.10.1
@ -103,7 +106,7 @@ s3transfer==0.2.0 # via boto3
salttesting==2017.6.1
scp==0.13.2 # via junos-eznc
setproctitle==1.1.10
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, websocket-client
six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, tempora, vcert, virtualenv, websocket-client
smmap2==2.0.5 # via gitdb2
smmap==0.9.0
strict-rfc3339==0.7
@ -111,7 +114,7 @@ tempora==1.14.1 # via portend
timelib==0.2.4
urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests
vcert==0.7.3
virtualenv==16.4.3
virtualenv==20.0.10
vultr==1.0.1
watchdog==0.9.0
wcwidth==0.1.7 # via pytest

File diff suppressed because it is too large Load diff

View file

@ -88,6 +88,7 @@ import shutil
import sys
import tempfile
# Import Salt libs
import salt.utils.data
import salt.utils.files
@ -99,6 +100,7 @@ import salt.utils.url
import salt.utils.versions
from salt.ext import six
from salt.exceptions import CommandExecutionError, CommandNotFoundError
import salt.utils.platform
# This needs to be named logger so we don't shadow it in pip.install
logger = logging.getLogger(__name__) # pylint: disable=C0103
@ -122,6 +124,19 @@ def __virtual__():
return 'pip'
def _pip_bin_env(cwd, bin_env):
"""
Binary builds need to have the 'cwd' set when using pip on Windows. This will
set cwd if pip is being used in 'bin_env', 'cwd' is None and salt is on windows.
"""
if salt.utils.platform.is_windows():
if bin_env is not None and cwd is None and 'pip' in os.path.basename(bin_env):
cwd = os.path.dirname(bin_env)
return cwd
def _clear_context(bin_env=None):
'''
Remove the cached pip version
@ -652,6 +667,8 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
editable=git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed upgrade=True no_deps=True
'''
cwd = _pip_bin_env(cwd, bin_env)
cmd = _get_pip_bin(bin_env)
cmd.append('install')
@ -666,7 +683,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
if error:
return error
cur_version = version(bin_env)
cur_version = version(bin_env, cwd)
if use_wheel:
min_version = '1.4'
@ -1037,6 +1054,8 @@ def uninstall(pkgs=None,
salt '*' pip.uninstall <package name> bin_env=/path/to/virtualenv
salt '*' pip.uninstall <package name> bin_env=/path/to/pip_bin
'''
cwd = _pip_bin_env(cwd, bin_env)
cmd = _get_pip_bin(bin_env)
cmd.extend(['uninstall', '-y'])
@ -1148,12 +1167,14 @@ def freeze(bin_env=None,
salt '*' pip.freeze bin_env=/home/code/path/to/virtualenv
'''
cwd = _pip_bin_env(cwd, bin_env)
cmd = _get_pip_bin(bin_env)
cmd.append('freeze')
# Include pip, setuptools, distribute, wheel
min_version = '8.0.3'
cur_version = version(bin_env)
cur_version = version(bin_env, cwd)
if salt.utils.versions.compare(ver1=cur_version, oper='<', ver2=min_version):
logger.warning(
'The version of pip installed is %s, which is older than %s. '
@ -1202,10 +1223,12 @@ def list_(prefix=None,
salt '*' pip.list salt
'''
cwd = _pip_bin_env(cwd, bin_env)
packages = {}
if prefix is None or 'pip'.startswith(prefix):
packages['pip'] = version(bin_env)
packages['pip'] = version(bin_env, cwd)
for line in freeze(bin_env=bin_env,
user=user,
@ -1249,7 +1272,7 @@ def list_(prefix=None,
return packages
def version(bin_env=None):
def version(bin_env=None, cwd=None):
'''
.. versionadded:: 0.17.0
@ -1264,6 +1287,8 @@ def version(bin_env=None):
salt '*' pip.version
'''
cwd = _pip_bin_env(cwd, bin_env)
contextkey = 'pip.version'
if bin_env is not None:
contextkey = '{0}.{1}'.format(contextkey, bin_env)
@ -1274,7 +1299,7 @@ def version(bin_env=None):
cmd = _get_pip_bin(bin_env)[:]
cmd.append('--version')
ret = __salt__['cmd.run_all'](cmd, python_shell=False)
ret = __salt__['cmd.run_all'](cmd, cwd=cwd, python_shell=False)
if ret['retcode']:
raise CommandNotFoundError('Could not find a `pip` binary')
@ -1299,10 +1324,12 @@ def list_upgrades(bin_env=None,
salt '*' pip.list_upgrades
'''
cwd = _pip_bin_env(cwd, bin_env)
cmd = _get_pip_bin(bin_env)
cmd.extend(['list', '--outdated'])
pip_version = version(bin_env)
pip_version = version(bin_env, cwd)
# Pip started supporting the ability to output json starting with 9.0.0
min_version = '9.0'
if salt.utils.versions.compare(ver1=pip_version,
@ -1388,6 +1415,8 @@ def is_installed(pkgname=None,
salt '*' pip.is_installed salt
'''
cwd = _pip_bin_env(cwd, bin_env)
for line in freeze(bin_env=bin_env, user=user, cwd=cwd):
if line.startswith('-f') or line.startswith('#'):
# ignore -f line as it contains --find-links directory
@ -1431,6 +1460,8 @@ def upgrade_available(pkg,
salt '*' pip.upgrade_available <package name>
'''
cwd = _pip_bin_env(cwd, bin_env)
return pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd)
@ -1459,6 +1490,8 @@ def upgrade(bin_env=None,
salt '*' pip.upgrade
'''
cwd = _pip_bin_env(cwd, bin_env)
ret = {'changes': {},
'result': True,
'comment': '',
@ -1544,6 +1577,7 @@ def list_all_versions(pkg,
salt '*' pip.list_all_versions <package name>
'''
cwd = _pip_bin_env(cwd, bin_env)
cmd = _get_pip_bin(bin_env)
cmd.extend(['install', '{0}==versions'.format(pkg)])

View file

@ -1133,8 +1133,8 @@ class StateTestLoader(object):
'{0}.tst'.format(split_sls[-1]))
])
# for this state, find matching test files and load them
cached_copied_files = set(cached_copied_files)
for this_cached_test_file in list(cached_copied_files):
cached_copied_files = list(set(cached_copied_files))
for this_cached_test_file in cached_copied_files:
if this_cached_test_file.endswith(tuple(sls_path_names)):
self.test_files.add(this_cached_test_file)
cached_copied_files.remove(this_cached_test_file)

View file

@ -43,6 +43,37 @@ def __virtual__():
return __virtualname__
def virtualenv_ver(venv_bin, user=None, **kwargs):
'''
return virtualenv version if exists
'''
# Virtualenv package
try:
import virtualenv
version = getattr(virtualenv, '__version__', None)
if not version:
version = virtualenv.virtualenv_version
virtualenv_version_info = tuple(
[int(i) for i in version.split('rc')[0].split('.')]
)
except ImportError:
# Unable to import?? Let's parse the version from the console
version_cmd = [venv_bin, '--version']
ret = __salt__['cmd.run_all'](
version_cmd, runas=user, python_shell=False, **kwargs
)
if ret['retcode'] > 0 or not ret['stdout'].strip():
raise CommandExecutionError(
'Unable to get the virtualenv version output using \'{0}\'. '
'Returned data: {1}'.format(version_cmd, ret)
)
virtualenv_version_info = tuple(
[int(i) for i in
ret['stdout'].strip().split('rc')[0].split('.')]
)
return virtualenv_version_info
def create(path,
venv_bin=None,
system_site_packages=False,
@ -164,29 +195,7 @@ def create(path,
)
# <---- Stop the user if pyvenv only options are used ----------------
# Virtualenv package
try:
import virtualenv
version = getattr(virtualenv, '__version__',
virtualenv.virtualenv_version)
virtualenv_version_info = tuple(
[int(i) for i in version.split('rc')[0].split('.')]
)
except ImportError:
# Unable to import?? Let's parse the version from the console
version_cmd = [venv_bin, '--version']
ret = __salt__['cmd.run_all'](
version_cmd, runas=user, python_shell=False, **kwargs
)
if ret['retcode'] > 0 or not ret['stdout'].strip():
raise CommandExecutionError(
'Unable to get the virtualenv version output using \'{0}\'. '
'Returned data: {1}'.format(version_cmd, ret)
)
virtualenv_version_info = tuple(
[int(i) for i in
ret['stdout'].strip().split('rc')[0].split('.')]
)
virtualenv_version_info = virtualenv_ver(venv_bin, user=user, **kwargs)
if distribute:
if virtualenv_version_info >= (1, 10):

View file

@ -12,8 +12,10 @@ import salt.utils.platform
try:
import wmi
import salt.utils.winapi
HAS_LIBS = True
except ImportError:
pass
HAS_LIBS = False
log = logging.getLogger(__name__)
@ -22,15 +24,25 @@ def __virtual__():
'''
Only works on Windows systems
'''
if salt.utils.platform.is_windows():
return 'win_dns_client'
return (False, "Module win_dns_client: module only works on Windows systems")
if not salt.utils.platform.is_windows():
return False, 'Module win_dns_client: module only works on Windows ' \
'systems'
if not HAS_LIBS:
return False, 'Module win_dns_client: missing required libraries'
return 'win_dns_client'
def get_dns_servers(interface='Local Area Connection'):
'''
Return a list of the configured DNS servers of the specified interface
Args:
interface (str): The name of the network interface. This is the name as
it appears in the Control Panel under Network Connections
Returns:
list: A list of dns servers
CLI Example:
.. code-block:: bash
@ -121,7 +133,14 @@ def dns_dhcp(interface='Local Area Connection'):
def get_dns_config(interface='Local Area Connection'):
'''
Get the type of DNS configuration (dhcp / static)
Get the type of DNS configuration (dhcp / static).
Args:
interface (str): The name of the network interface. This is the
Description in the Network Connection Details for the device
Returns:
bool: ``True`` if DNS is configured, otherwise ``False``
CLI Example:

View file

@ -4986,6 +4986,12 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
for root, dirs, files in salt.utils.path.os_walk(path):
if root == path:
for t_admx_file in files:
admx_file_name, admx_file_ext = os.path.splitext(t_admx_file)
# Only process ADMX files, any other file will cause a
# stacktrace later on
if not admx_file_ext == '.admx':
log.debug('{0} is not an ADMX file'.format(t_admx_file))
continue
admx_file = os.path.join(root, t_admx_file)
# Parse xml for the ADMX file
try:
@ -5001,9 +5007,6 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
namespaces['None'] = namespaces[None]
namespaces.pop(None)
namespace_string = 'None:'
this_prefix = xml_tree.xpath(
'/{0}policyDefinitions/{0}policyNamespaces/{0}target/@prefix'.format(namespace_string),
namespaces=namespaces)[0]
this_namespace = xml_tree.xpath(
'/{0}policyDefinitions/{0}policyNamespaces/{0}target/@namespace'.format(namespace_string),
namespaces=namespaces)[0]
@ -5038,7 +5041,7 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
adml_file = os.path.join(
root,
language,
os.path.splitext(t_admx_file)[0] + '.adml')
admx_file_name + '.adml')
if not __salt__['file.file_exists'](adml_file):
log.info('An ADML file in the specified ADML language '
'"%s" does not exist for the ADMX "%s", the '
@ -5048,7 +5051,7 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
adml_file = os.path.join(
root,
language.split('-')[0],
os.path.splitext(t_admx_file)[0] + '.adml')
admx_file_name + '.adml')
if not __salt__['file.file_exists'](adml_file):
log.info('An ADML file in the specified ADML language '
'code %s does not exist for the ADMX "%s", '
@ -5058,7 +5061,7 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
adml_file = os.path.join(
root,
display_language_fallback,
os.path.splitext(t_admx_file)[0] + '.adml')
admx_file_name + '.adml')
if not __salt__['file.file_exists'](adml_file):
log.info('An ADML file in the specified ADML '
'fallback language "%s" '
@ -5070,7 +5073,7 @@ def _load_policy_definitions(path='c:\\Windows\\PolicyDefinitions',
adml_file = os.path.join(
root,
display_language_fallback.split('-')[0],
os.path.splitext(t_admx_file)[0] + '.adml')
admx_file_name + '.adml')
if not __salt__['file.file_exists'](adml_file):
msg = ('An ADML file in the specified ADML language '
'"{0}" and the fallback language "{1}" do not '
@ -5526,7 +5529,7 @@ def _write_secedit_data(inf_data):
# Success
if retcode == 0:
# Pop secedit data so it will always be current
__context__.pop('lgpo.secedit_data')
__context__.pop('lgpo.secedit_data', None)
return True
# Failure
return False
@ -5658,25 +5661,48 @@ def _getAdmlPresentationRefId(adml_data, ref_id):
helper function to check for a presentation label for a policy element
'''
search_results = adml_data.xpath('//*[@*[local-name() = "refId"] = "{0}"]'.format(ref_id))
prepended_text = ''
alternate_label = ''
if search_results:
for result in search_results:
the_localname = etree.QName(result.tag).localname
if the_localname == 'textBox' \
or the_localname == 'comboBox':
# We want to prefer result.text as the label, however, if it is none
# we will fall back to this method for getting the label
# Brings some code back from:
# https://github.com/saltstack/salt/pull/55823/files#diff-b2e4dac5ccc17ab548f245371ec5d6faL5658
if result.text is None:
# Get the label from the text element above the referenced
# element. For example:
# --- taken from AppPrivacy.adml ---
# <text>Force allow these specific apps (use Package Family Names):</text>
# <multiTextBox refId="LetAppsSyncWithDevices_ForceAllowTheseApps_List"/>
# In this case, the label for the refId is the text element
# above it.
presentation_element = PRESENTATION_ANCESTOR_XPATH(result)
if presentation_element:
presentation_element = presentation_element[0]
if TEXT_ELEMENT_XPATH(presentation_element):
for p_item in presentation_element.getchildren():
if p_item == result:
break
if etree.QName(p_item.tag).localname == 'text':
if getattr(p_item, 'text'):
alternate_label = getattr(p_item, 'text').rstrip()
if alternate_label.endswith('.'):
alternate_label = ''
if the_localname in ['textBox', 'comboBox']:
label_items = result.xpath('.//*[local-name() = "label"]')
for label_item in label_items:
if label_item.text:
return (prepended_text + ' ' + label_item.text.rstrip().rstrip(':')).lstrip()
elif the_localname == 'decimalTextBox' \
or the_localname == 'longDecimalTextBox' \
or the_localname == 'dropdownList' \
or the_localname == 'listBox' \
or the_localname == 'checkBox' \
or the_localname == 'text' \
or the_localname == 'multiTextBox':
return label_item.text.rstrip().rstrip(':')
elif the_localname in ['decimalTextBox', 'longDecimalTextBox',
'dropdownList', 'listBox', 'checkBox',
'text', 'multiTextBox']:
if result.text:
return (prepended_text + ' ' + result.text.rstrip().rstrip(':')).lstrip()
return result.text.rstrip().rstrip(':')
else:
return alternate_label.rstrip(':')
return None
@ -6139,6 +6165,10 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
if standard_element_expected_string and not check_deleted:
if this_element_value is not None:
# Sometimes values come in as strings
if isinstance(this_element_value, str):
log.debug('Converting {0} to bytes'.format(this_element_value))
this_element_value = this_element_value.encode('utf-32-le')
expected_string = b''.join(['['.encode('utf-16-le'),
reg_key,
encoded_null,
@ -6777,13 +6807,16 @@ def _regexSearchKeyValueCombo(policy_data, policy_regpath, policy_regkey):
for a policy_regpath and policy_regkey combo
'''
if policy_data:
specialValueRegex = salt.utils.stringutils.to_bytes(r'(\*\*Del\.|\*\*DelVals\.){0,1}')
regex_str = [r'(\*', r'\*', 'D', 'e', 'l', r'\.', r'|\*', r'\*', 'D',
'e', 'l', 'V', 'a', 'l', 's', r'\.', '){0,1}']
specialValueRegex = '\x00'.join(regex_str)
specialValueRegex = salt.utils.stringutils.to_bytes(specialValueRegex)
_thisSearch = b''.join([salt.utils.stringutils.to_bytes(r'\['),
re.escape(policy_regpath),
b'\00;',
specialValueRegex,
re.escape(policy_regkey),
b'\00;'])
re.escape(policy_regpath),
b'\x00;\x00',
specialValueRegex,
re.escape(policy_regkey.lstrip(b'\x00')),
b'\x00;'])
match = re.search(_thisSearch, policy_data, re.IGNORECASE)
if match:
# add 2 so we get the ']' and the \00

View file

@ -95,7 +95,7 @@ TASK_TRIGGER_LOGON = 9
TASK_TRIGGER_SESSION_STATE_CHANGE = 11
duration = {'Immediately': 'PT0M',
'Indefinitely': 'PT0M',
'Indefinitely': '',
'Do not wait': 'PT0M',
'15 seconds': 'PT15S',
'30 seconds': 'PT30S',
@ -571,10 +571,7 @@ def create_task(name,
logon_type=task_definition.Principal.LogonType)
# Verify task was created
if name in list_tasks(location):
return True
else:
return False
return name in list_tasks(location)
def create_task_from_xml(name,
@ -679,10 +676,7 @@ def create_task_from_xml(name,
log.debug('Failed to create task: %s', failure_code)
# Verify creation
if name in list_tasks(location):
return True
else:
return False
return name in list_tasks(location)
def create_folder(name, location='\\'):
@ -724,10 +718,7 @@ def create_folder(name, location='\\'):
task_folder.CreateFolder(name)
# Verify creation
if name in list_folders(location):
return True
else:
return False
return name in list_folders(location)
def edit_task(name=None,
@ -1132,10 +1123,7 @@ def delete_task(name, location='\\'):
task_folder.DeleteTask(name, 0)
# Verify deletion
if name not in list_tasks(location):
return True
else:
return False
return name not in list_tasks(location)
def delete_folder(name, location='\\'):

View file

@ -51,7 +51,7 @@ def purge_pip():
return
pip_related_entries = [
(k, v) for (k, v) in sys.modules.items()
or getattr(v, '__module__', '').startswith('pip.')
if getattr(v, '__module__', '').startswith('pip.')
or (isinstance(v, types.ModuleType) and v.__name__.startswith('pip.'))
]
for name, entry in pip_related_entries:
@ -96,21 +96,8 @@ try:
HAS_PIP = True
except ImportError:
HAS_PIP = False
# Remove references to the loaded pip module above so reloading works
import sys
pip_related_entries = [
(k, v) for (k, v) in sys.modules.items()
or getattr(v, '__module__', '').startswith('pip.')
or (isinstance(v, types.ModuleType) and v.__name__.startswith('pip.'))
]
for name, entry in pip_related_entries:
sys.modules.pop(name)
del entry
purge_pip()
del pip
sys_modules_pip = sys.modules.pop('pip', None)
if sys_modules_pip is not None:
del sys_modules_pip
if HAS_PIP is True:
if not hasattr(purge_pip, '__pip_ver__'):

View file

@ -396,10 +396,13 @@ def present(name,
vname=vname,
use_32bit_registry=use_32bit_registry)
# Cast the vdata according to the vtype
vdata_decoded = __utils__['reg.cast_vdata'](vdata=vdata, vtype=vtype)
# Check if the key already exists
# If so, check perms
# We check `vdata` and `success` because `vdata` can be None
if vdata == reg_current['vdata'] and reg_current['success']:
if vdata_decoded == reg_current['vdata'] and reg_current['success']:
ret['comment'] = '{0} in {1} is already present' \
''.format(salt.utils.stringutils.to_unicode(vname, 'utf-8') if vname else '(Default)',
salt.utils.stringutils.to_unicode(name, 'utf-8'))
@ -413,9 +416,6 @@ def present(name,
inheritance=win_inheritance,
reset=win_perms_reset)
# Cast the vdata according to the vtype
vdata_decoded = __utils__['reg.cast_vdata'](vdata=vdata, vtype=vtype)
add_change = {'Key': r'{0}\{1}'.format(hive, key),
'Entry': '{0}'.format(salt.utils.stringutils.to_unicode(vname, 'utf-8') if vname else '(Default)'),
'Value': vdata_decoded,
@ -440,10 +440,10 @@ def present(name,
if not ret['result']:
ret['changes'] = {}
ret['comment'] = r'Failed to add {0} to {1}\{2}'.format(name, hive, key)
ret['comment'] = r'Failed to add {0} to {1}\{2}'.format(vname, hive, key)
else:
ret['changes'] = {'reg': {'Added': add_change}}
ret['comment'] = r'Added {0} to {1}\{2}'.format(name, hive, key)
ret['comment'] = r'Added {0} to {1}\{2}'.format(vname, hive, key)
if ret['result']:
ret = __utils__['dacl.check_perms'](

View file

@ -487,7 +487,7 @@ def running(name,
time.sleep(init_delay)
# only force a change state if we have explicitly detected them
after_toggle_status = __salt__['service.status'](name, sig, **kwargs)
after_toggle_status = __salt__['service.status'](name, sig, **status_kwargs)
if 'service.enabled' in __salt__:
after_toggle_enable_status = __salt__['service.enabled'](name)
else:

View file

@ -112,6 +112,7 @@ import logging
import salt.utils.data
import salt.utils.dictdiffer
import salt.utils.json
import salt.utils.stringutils
import salt.utils.versions
import salt.utils.win_functions
@ -152,6 +153,35 @@ def _compare_policies(new_policy, current_policy):
return False
def _convert_to_unicode(data):
'''
Helper function that makes sure all items in the dictionary are unicode for
comparing the existing state with the desired state. This function is only
needed for Python 2 and can be removed once we've migrated to Python 3.
The data returned by the current settings sometimes has a mix of unicode and
string values (these don't matter in Py3). This causes the comparison to
say it's not in the correct state even though it is. They basically compares
apples to apples, etc.
Also, in Python 2, the utf-16 encoded strings remain utf-16 encoded (each
character separated by `/x00`) In Python 3 it returns a utf-8 string. This
will just remove all the null bytes (`/x00`), again comparing apples to
apples.
'''
if isinstance(data, six.string_types):
data = data.replace('\x00', '')
return salt.utils.stringutils.to_unicode(data)
elif isinstance(data, dict):
return dict((_convert_to_unicode(k),
_convert_to_unicode(v))
for k, v in data.items())
elif isinstance(data, list):
return list(_convert_to_unicode(v) for v in data)
else:
return data
def set_(name,
setting=None,
policy_class=None,
@ -342,6 +372,9 @@ def set_(name,
requested_policy_check = salt.utils.json.loads(requested_policy_json)
current_policy_check = salt.utils.json.loads(current_policy_json)
if six.PY2:
current_policy_check = _convert_to_unicode(current_policy_check)
# Are the requested and current policies identical
policies_are_equal = _compare_policies(
requested_policy_check, current_policy_check)

View file

@ -122,6 +122,8 @@ def wrap_tmpl_func(render_str):
slspath = context['sls'].replace('.', '/')
if tmplpath is not None:
context['tplpath'] = tmplpath
if not tmplpath.lower().replace('\\', '/').endswith('/init.sls'):
slspath = os.path.dirname(slspath)
template = tmplpath.replace('\\', '/')
i = template.rfind(slspath.replace('.', '/'))
if i != -1:

View file

@ -58,6 +58,7 @@ enum_adapter_types = {
28: 'Slip',
37: 'ATM',
48: 'GenericModem',
53: 'TAPAdapter', # Not in MSDN Defined enumeration
62: 'FastEthernetT',
63: 'ISDN',
69: 'FastEthernetFx',
@ -108,12 +109,16 @@ def __virtual__():
def _get_base_properties(i_face):
raw_mac = i_face.GetPhysicalAddress().ToString()
try:
i_face_type = enum_adapter_types[i_face.NetworkInterfaceType]
except KeyError:
i_face_type = i_face.Description
return {
'alias': i_face.Name,
'description': i_face.Description,
'id': i_face.Id,
'receive_only': i_face.IsReceiveOnly,
'type': enum_adapter_types[i_face.NetworkInterfaceType],
'type': i_face_type,
'status': enum_operational_status[i_face.OperationalStatus],
'physical_address': ':'.join(raw_mac[i:i+2] for i in range(0, 12, 2))}

View file

@ -113,8 +113,8 @@ class SaltStackVersion(object):
'Sodium' : (MAX_SIZE - 98, 0),
'Magnesium' : (MAX_SIZE - 97, 0),
'Aluminium' : (MAX_SIZE - 96, 0),
'Silicon' : (MAX_SIZE - 95, 0),
'Phosphorus' : (MAX_SIZE - 94, 0),
'Silicon' : (MAX_SIZE - 95, 0),
'Phosphorus' : (MAX_SIZE - 94, 0),
# pylint: disable=E8265
#'Sulfur' : (MAX_SIZE - 93, 0),
#'Chlorine' : (MAX_SIZE - 92, 0),
@ -232,7 +232,11 @@ class SaltStackVersion(object):
major = int(major)
if isinstance(minor, string_types):
minor = int(minor)
if not minor:
# Empty string
minor = None
else:
minor = int(minor)
if bugfix is None and not self.new_version(major=major):
bugfix = 0

View file

@ -0,0 +1,10 @@
# archive-test
vault:
archive.extracted:
- name: {{ pillar['unzip_to'] }}
- source: salt://issue-56131.zip
- source_hash: sha256=4fc6f049d658a414aca066fb11c2109d05b59f082d707d5d6355b6c574d25720
- archive_format: zip
- enforce_toplevel: False
- unless:
- echo hello && 1

Binary file not shown.

View file

@ -0,0 +1,3 @@
directory-level1-init-test-pass:
test.succeed_without_changes:
- name: testing-saltcheck

View file

@ -0,0 +1,3 @@
directory-level1-test-pass:
test.succeed_without_changes:
- name: testing-saltcheck

View file

@ -1,3 +1,7 @@
include:
- validate-saltcheck.directory
- validate-saltcheck.directory.level1
saltcheck-test-pass:
test.succeed_without_changes:
- name: testing-saltcheck

View file

@ -2268,3 +2268,26 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
self.assertEqual(state_run[state_id]['comment'],
'Success!')
self.assertTrue(state_run[state_id]['result'])
def test_issue_56131(self):
module_path = os.path.join(RUNTIME_VARS.CODE_DIR, 'pip.py')
if six.PY3:
modulec_path = os.path.join(RUNTIME_VARS.CODE_DIR, '__pycache__', 'pip.pyc')
else:
modulec_path = os.path.join(RUNTIME_VARS.CODE_DIR, 'pip.pyc')
unzip_path = os.path.join(RUNTIME_VARS.TMP, 'issue-56131.txt')
def clean_paths(paths):
for path in paths:
try:
os.remove(path)
except OSError:
log.warn("Path not found: %s", path)
with salt.utils.files.fopen(module_path, 'w') as fp:
fp.write('raise ImportError("No module named pip")')
self.addCleanup(clean_paths, [unzip_path, module_path, modulec_path])
assert not os.path.exists(unzip_path)
state_run = self.run_function('state.sls', mods='issue-56131', pillar={'unzip_to': RUNTIME_VARS.TMP}, timeout=30)
assert state_run is not False
assert os.path.exists(unzip_path)

View file

@ -506,6 +506,22 @@ class WinLgpoTest(ModuleCase):
'Not Configured',
[r'; Source file: c:\\windows\\system32\\grouppolicy\\machine\\registry.pol[\s]*; PARSING COMPLETED.'])
@destructiveTest
def test_set_computer_policy_GuestAccountStatus(self):
'''
Test setting/unsetting/changing GuestAccountStatus
'''
# disable GuestAccountStatus
self._testSeceditPolicy(
'GuestAccountStatus',
'Disabled',
[r'^EnableGuestAccount = 0'])
# enable GuestAccountStatus
self._testSeceditPolicy(
'GuestAccountStatus',
'Enabled',
[r'^EnableGuestAccount = 1'])
@destructiveTest
def test_set_computer_policy_PasswordComplexity(self):
'''

View file

@ -405,8 +405,12 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
pprint.pformat(ret)
)
)
import salt.modules.virtualenv_mod
msg = 'New python executable'
if salt.modules.virtualenv_mod.virtualenv_ver(venv_dir) >= (20, 0, 2):
msg = 'created virtual environment'
self.assertIn(
'New python executable',
msg,
ret['stdout'],
msg='Expected STDOUT did not match. Full return dictionary:\n{}'.format(
pprint.pformat(ret)

View file

@ -14,12 +14,29 @@ from tests.support.mock import MagicMock, patch
import salt.utils.platform
import salt.modules.pip as pip
from salt.exceptions import CommandExecutionError
import salt.utils.platform
class PipTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
return {pip: {'__salt__': {'cmd.which_bin': lambda _: 'pip'}}}
def test__pip_bin_env(self):
ret = pip._pip_bin_env(None, 'C:/Users/ch44d/Documents/salt/tests/pip.exe')
if salt.utils.platform.is_windows():
self.assertEqual(ret, 'C:/Users/ch44d/Documents/salt/tests')
else:
self.assertEqual(ret, None)
def test__pip_bin_env_no_change(self):
cwd = 'C:/Users/ch44d/Desktop'
ret = pip._pip_bin_env(cwd, 'C:/Users/ch44d/Documents/salt/tests/pip.exe')
self.assertEqual(ret, cwd)
def test__pip_bin_env_no_bin_env(self):
ret = pip._pip_bin_env(None, None)
self.assertEqual(None, None)
def test_fix4361(self):
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):

View file

@ -350,3 +350,31 @@ class VirtualenvTestCase(TestCase, LoaderModuleMockMixin):
runas=None,
python_shell=False
)
def test_virtualenv_ver(self):
'''
test virtualenv_ver when there is no ImportError
'''
ret = virtualenv_mod.virtualenv_ver(venv_bin='pyvenv')
assert ret == (1, 9, 1)
def test_virtualenv_ver_importerror(self):
'''
test virtualenv_ver when there is an ImportError
'''
with ForceImportErrorOn('virtualenv'):
mock_ver = MagicMock(return_value={'retcode': 0, 'stdout': '1.9.1'})
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock_ver}):
ret = virtualenv_mod.virtualenv_ver(venv_bin='pyenv')
assert ret == (1, 9, 1)
def test_virtualenv_ver_importerror_cmd_error(self):
'''
test virtualenv_ver when there is an ImportError
and virtualenv --version does not return anything
'''
with ForceImportErrorOn('virtualenv'):
mock_ver = MagicMock(return_value={'retcode': 0, 'stdout': ''})
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock_ver}):
with self.assertRaises(CommandExecutionError):
virtualenv_mod.virtualenv_ver(venv_bin='pyenv')

View file

@ -10,11 +10,7 @@ import types
# Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.mock import (
MagicMock,
patch,
Mock,
)
from tests.support.mock import MagicMock, patch, Mock
# Import Salt Libs
import salt.modules.win_dns_client as win_dns_client
@ -68,7 +64,6 @@ class WinDnsClientTestCase(TestCase, LoaderModuleMockMixin):
'''
Test cases for salt.modules.win_dns_client
'''
def setup_loader_modules(self):
# wmi and pythoncom modules are platform specific...
mock_pythoncom = types.ModuleType(
@ -89,8 +84,7 @@ class WinDnsClientTestCase(TestCase, LoaderModuleMockMixin):
Test if it return a list of the configured DNS servers
of the specified interface.
'''
with patch('salt.utils', Mockwinapi), \
patch('salt.utils.winapi.Com', MagicMock()), \
with patch('salt.utils.winapi.Com', MagicMock()), \
patch.object(self.WMI, 'Win32_NetworkAdapter',
return_value=[Mockwmi()]), \
patch.object(self.WMI, 'Win32_NetworkAdapterConfiguration',
@ -159,3 +153,22 @@ class WinDnsClientTestCase(TestCase, LoaderModuleMockMixin):
return_value=[Mockwmi()]), \
patch.object(wmi, 'WMI', Mock(return_value=self.WMI)):
self.assertTrue(win_dns_client.get_dns_config())
@patch('salt.utils.platform.is_windows')
def test___virtual__non_windows(self, mock):
mock.return_value = False
result = win_dns_client.__virtual__()
expected = (False, 'Module win_dns_client: module only works on '
'Windows systems')
self.assertEqual(result, expected)
@patch.object(win_dns_client, 'HAS_LIBS', False)
def test___virtual__missing_libs(self):
result = win_dns_client.__virtual__()
expected = (False, 'Module win_dns_client: missing required libraries')
self.assertEqual(result, expected)
def test___virtual__(self):
result = win_dns_client.__virtual__()
expected = 'win_dns_client'
self.assertEqual(result, expected)

View file

@ -5,6 +5,7 @@
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import glob
import os
# Import Salt Testing Libs
@ -15,31 +16,28 @@ from tests.support.unit import TestCase, skipIf
# Import Salt Libs
import salt.config
import salt.modules.cmdmod
import salt.modules.file
import salt.modules.win_file as win_file
import salt.loader
import salt.modules.win_lgpo as win_lgpo
import salt.states.win_lgpo
import salt.utils.files
import salt.utils.platform
import salt.utils.win_dacl
import salt.utils.win_lgpo_auditpol
import salt.utils.win_reg
import salt.utils.stringutils
# Import 3rd Party Libs
import salt.ext.six as six
# We're going to actually use the loader, without grains (slow)
opts = salt.config.DEFAULT_MINION_OPTS.copy()
utils = salt.loader.utils(opts)
modules = salt.loader.minion_mods(opts, utils=utils)
LOADER_DICTS = {
win_lgpo: {
'__salt__': {
'file.file_exists': salt.modules.file.file_exists,
'file.makedirs': win_file.makedirs_,
'file.write': salt.modules.file.write,
'file.remove': win_file.remove,
'cmd.run': salt.modules.cmdmod.run},
'__opts__': salt.config.DEFAULT_MINION_OPTS.copy(),
'__utils__': {
'reg.read_value': salt.utils.win_reg.read_value,
'auditpol.get_auditpol_dump':
salt.utils.win_lgpo_auditpol.get_auditpol_dump}},
win_file: {
'__utils__': {
'dacl.set_perms': salt.utils.win_dacl.set_perms}}}
'__opts__': opts,
'__salt__': modules,
'__utils__': utils,
}
}
class WinLGPOTestCase(TestCase):
@ -60,6 +58,88 @@ class WinLGPOTestCase(TestCase):
expected = '300000 or 5 minutes (recommended)'
self.assertEqual(result, expected)
def test__regexSearchKeyValueCombo_enabled(self):
'''
Make sure
'''
policy_data = b'[\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
b'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
b'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
b'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
b'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
b'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
b'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00\x00;\x00D' \
b'\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n\x00s' \
b'\x00e\x00n\x00t\x00\x00\x00;\x00\x01\x00\x00\x00;\x00' \
b'\x04\x00\x00\x00;\x00\x02\x00\x00\x00]\x00'
policy_regpath = b'\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
b'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
b'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
b'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
b'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
b'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
b'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = b'\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
b'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertEqual(test, policy_data)
def test__regexSearchKeyValueCombo_not_configured(self):
'''
Make sure
'''
policy_data = b''
policy_regpath = b'\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
b'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
b'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
b'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
b'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
b'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
b'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = b'\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
b'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertIsNone(test)
def test__regexSearchKeyValueCombo_disabled(self):
'''
Make sure
'''
policy_data = b'[\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
b'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
b'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
b'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
b'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
b'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
b'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00\x00;\x00*' \
b'\x00*\x00d\x00e\x00l\x00.\x00D\x00e\x00f\x00a\x00u' \
b'\x00l\x00t\x00C\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00' \
b'\x00;\x00\x01\x00\x00\x00;\x00\x04\x00\x00\x00;\x00 ' \
b'\x00\x00\x00]\x00'
policy_regpath = b'\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
b'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
b'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
b'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
b'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
b'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
b'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = b'\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
b'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertEqual(test, policy_data)
def test__encode_string(self):
'''
``_encode_string`` should return a null terminated ``utf-16-le`` encoded
@ -254,6 +334,39 @@ class WinLGPOGetPolicyADMXTestCase(TestCase, LoaderModuleMockMixin):
'Allow Telemetry': 'Not Configured'}}}}}
self.assertDictEqual(result, expected)
@destructiveTest
def test__load_policy_definitions(self):
'''
Test that unexpected files in the PolicyDefinitions directory won't
cause the _load_policy_definitions function to explode
https://gitlab.com/saltstack/enterprise/lock/issues/3826
'''
# The PolicyDefinitions directory should only contain ADMX files. We
# want to make sure the `_load_policy_definitions` function skips non
# ADMX files in this directory.
# Create a bogus ADML file in PolicyDefinitions directory
bogus_fle = os.path.join(
'c:\\Windows\\PolicyDefinitions',
'_bogus.adml')
cache_dir = os.path.join(
win_lgpo.__opts__['cachedir'],
'lgpo',
'policy_defs')
try:
with salt.utils.files.fopen(bogus_fle, 'w+') as fh:
fh.write('<junk></junk>')
# This function doesn't return anything (None), it just loads
# the XPath structures into __context__. We're just making sure it
# doesn't stack trace here
self.assertIsNone(win_lgpo._load_policy_definitions())
finally:
# Remove source file
os.remove(bogus_fle)
# Remove cached file
search_string = '{0}\\_bogus*.adml'.format(cache_dir)
for file_name in glob.glob(search_string):
os.remove(file_name)
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
class WinLGPOGetPolicyFromPolicyInfoTestCase(TestCase, LoaderModuleMockMixin):
@ -605,13 +718,16 @@ class WinLGPOGetPointAndPrintENTestCase(TestCase, LoaderModuleMockMixin):
policy_class=policy_class,
adml_language='en-US')
if success:
return salt.modules.win_lgpo._get_policy_adm_setting(
results = salt.modules.win_lgpo._get_policy_adm_setting(
admx_policy=policy_obj,
policy_class=policy_class,
adml_language='en-US',
return_full_policy_names=return_full_policy_names,
hierarchical_return=hierarchical_return
)
if six.PY2:
results = salt.states.win_lgpo._convert_to_unicode(results)
return results
return 'Policy Not Found'
def test_point_and_print_enabled(self):
@ -631,7 +747,7 @@ class WinLGPOGetPointAndPrintENTestCase(TestCase, LoaderModuleMockMixin):
True,
'PointAndPrint_TrustedServers_Chk':
True,
u'PointAndPrint_TrustedServers_Edit':
'PointAndPrint_TrustedServers_Edit':
'fakeserver1;fakeserver2'}}
self.assertDictEqual(result, expected)
@ -655,7 +771,7 @@ class WinLGPOGetPointAndPrintENTestCase(TestCase, LoaderModuleMockMixin):
True,
'PointAndPrint_TrustedServers_Chk':
True,
u'PointAndPrint_TrustedServers_Edit':
'PointAndPrint_TrustedServers_Edit':
'fakeserver1;fakeserver2'}}}}}
self.assertDictEqual(result, expected)
@ -674,8 +790,8 @@ class WinLGPOGetPointAndPrintENTestCase(TestCase, LoaderModuleMockMixin):
'Show warning and elevation prompt',
'Users can only point and print to machines in their forest':
True,
u'Users can only point and print to these servers': True,
u'When updating drivers for an existing connection':
'Users can only point and print to these servers': True,
'When updating drivers for an existing connection':
'Show warning only'}}
self.assertDictEqual(result, expected)
@ -699,8 +815,36 @@ class WinLGPOGetPointAndPrintENTestCase(TestCase, LoaderModuleMockMixin):
'Users can only point and print to machines in '
'their forest':
True,
u'Users can only point and print to these servers':
'Users can only point and print to these servers':
True,
u'When updating drivers for an existing connection':
'When updating drivers for an existing connection':
'Show warning only'}}}}}
self.assertDictEqual(result, expected)
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
class WinLGPOGetPolicyFromPolicyResources(TestCase, LoaderModuleMockMixin):
'''
Test functions related to policy info gathered from ADMX/ADML files
'''
adml_data = None
def setup_loader_modules(self):
return LOADER_DICTS
def setUp(self):
if self.adml_data is None:
self.adml_data = win_lgpo._get_policy_resources('en-US')
def test__getAdmlPresentationRefId(self):
ref_id = 'LetAppsAccessAccountInfo_Enum'
expected = 'Default for all apps'
result = win_lgpo._getAdmlPresentationRefId(self.adml_data, ref_id)
self.assertEqual(result, expected)
def test__getAdmlPresentationRefId_result_text_is_none(self):
ref_id = 'LetAppsAccessAccountInfo_UserInControlOfTheseApps_List'
expected = 'Put user in control of these specific apps (use Package ' \
'Family Names)'
result = win_lgpo._getAdmlPresentationRefId(self.adml_data, ref_id)
self.assertEqual(result, expected)

View file

@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
# Import Salt Testing Libs
from tests.support.unit import TestCase, skipIf
from tests.support.helpers import destructiveTest
# Import Salt Libs
import salt.modules.win_task as win_task
import salt.utils.platform
@destructiveTest
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
class WinTaskTestCase(TestCase):
'''
Test cases for salt.modules.win_task
'''
def test_repeat_interval(self):
task_name = 'SaltTest1'
try:
ret = win_task.create_task(task_name,
user_name='System',
force=True,
action_type='Execute',
cmd='c:\\salt\\salt-call.bat',
trigger_type='Daily',
trigger_enabled=True,
repeat_duration='30 minutes',
repeat_interval='30 minutes')
self.assertTrue(ret)
ret = win_task.info(task_name)
self.assertEqual(ret['triggers'][0]['trigger_type'], 'Daily')
finally:
ret = win_task.delete_task(task_name)
self.assertTrue(ret)
def test_repeat_interval_and_indefinitely(self):
task_name = 'SaltTest2'
try:
ret = win_task.create_task(task_name,
user_name='System',
force=True,
action_type='Execute',
cmd='c:\\salt\\salt-call.bat',
trigger_type='Daily',
trigger_enabled=True,
repeat_duration='Indefinitely',
repeat_interval='30 minutes')
self.assertTrue(ret)
ret = win_task.info(task_name)
self.assertEqual(ret['triggers'][0]['trigger_type'], 'Daily')
finally:
ret = win_task.delete_task(task_name)
self.assertTrue(ret)

View file

@ -27,6 +27,7 @@ import salt.utils.files
import salt.utils.path
import salt.utils.platform
import salt.modules.zcbuildout as buildout
import salt.modules.virtualenv_mod
import salt.modules.cmdmod as cmd
from salt.ext import six
@ -466,6 +467,9 @@ class BuildoutOnlineTestCase(Base):
@requires_network()
def test_run_buildout(self):
if salt.modules.virtualenv_mod.virtualenv_ver(self.ppy_st) >= (20, 0, 0):
self.skipTest("Skiping until upstream resolved https://github.com/pypa/virtualenv/issues/1715")
b_dir = os.path.join(self.tdir, 'b')
ret = buildout.bootstrap(b_dir, buildout_ver=2, python=self.py_st)
self.assertTrue(ret['status'])
@ -477,6 +481,9 @@ class BuildoutOnlineTestCase(Base):
@requires_network()
def test_buildout(self):
if salt.modules.virtualenv_mod.virtualenv_ver(self.ppy_st) >= (20, 0, 0):
self.skipTest("Skiping until upstream resolved https://github.com/pypa/virtualenv/issues/1715")
b_dir = os.path.join(self.tdir, 'b')
ret = buildout.buildout(b_dir, buildout_ver=2, python=self.py_st)
self.assertTrue(ret['status'])

View file

@ -49,7 +49,7 @@ class RegTestCase(TestCase, LoaderModuleMockMixin):
Test to set a registry entry.
'''
expected = {
'comment': 'Added {0} to {0}'.format(self.name),
'comment': 'Added {0} to {1}'.format(self.vname, self.name),
'pchanges': {},
'changes': {
'reg': {
@ -58,15 +58,65 @@ class RegTestCase(TestCase, LoaderModuleMockMixin):
'Perms': {
'Deny': None,
'Grant': None},
'Value': '0.15.3',
'Value': self.vdata,
'Key': self.name,
'Owner': None,
'Entry': 'version'}}},
'Entry': self.vname}}},
'name': self.name,
'result': True}
ret = reg.present(self.name, vname=self.vname, vdata=self.vdata)
self.assertDictEqual(ret, expected)
@destructiveTest
def test_present_string_dword(self):
'''
Test to set a registry entry.
'''
vname = 'dword_data'
vdata = '00000001'
vtype = 'REG_DWORD'
expected_vdata = 1
expected = {
'comment': 'Added {0} to {1}'.format(vname, self.name),
'pchanges': {},
'changes': {
'reg': {
'Added': {
'Inheritance': True,
'Perms': {
'Deny': None,
'Grant': None},
'Value': expected_vdata,
'Key': self.name,
'Owner': None,
'Entry': vname}}},
'name': self.name,
'result': True}
ret = reg.present(
self.name, vname=vname, vdata=vdata, vtype=vtype)
self.assertDictEqual(ret, expected)
@destructiveTest
def test_present_string_dword_existing(self):
'''
Test to set a registry entry.
'''
vname = 'dword_data'
vdata = '0000001'
vtype = 'REG_DWORD'
# Set it first
reg.present(
self.name, vname=vname, vdata=vdata, vtype=vtype)
expected = {
'comment': '{0} in {1} is already present'.format(vname, self.name),
'pchanges': {},
'changes': {},
'name': self.name,
'result': True}
ret = reg.present(
self.name, vname=vname, vdata=vdata, vtype=vtype)
self.assertDictEqual(ret, expected)
def test_present_test_true(self):
expected = {
'comment': '',

View file

@ -7,14 +7,15 @@
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing Libs
from tests.support.helpers import destructiveTest
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase
from tests.support.mock import (
MagicMock,
patch,
)
from tests.support.unit import TestCase, skipIf
from tests.support.mock import MagicMock, patch
# Import Salt Libs
import salt.utils.platform
import salt.config
import salt.loader
import salt.states.service as service
@ -251,3 +252,71 @@ class ServiceTestCase(TestCase, LoaderModuleMockMixin):
ret[3])
self.assertDictEqual(service.mod_watch("salt", "stack"), ret[1])
@destructiveTest
@skipIf(salt.utils.platform.is_darwin(), "service.running is currently failing on OSX")
class ServiceTestCaseFunctional(TestCase, LoaderModuleMockMixin):
'''
Validate the service state
'''
def setup_loader_modules(self):
self.opts = salt.config.DEFAULT_MINION_OPTS.copy()
self.opts['grains'] = salt.loader.grains(self.opts)
self.utils = salt.loader.utils(self.opts)
self.modules = salt.loader.minion_mods(self.opts, utils=self.utils)
self.service_name = 'cron'
cmd_name = 'crontab'
os_family = self.opts['grains']['os_family']
os_release = self.opts['grains']['osrelease']
if os_family == 'RedHat':
self.service_name = 'crond'
elif os_family == 'Arch':
self.service_name = 'sshd'
cmd_name = 'systemctl'
elif os_family == 'MacOS':
self.service_name = 'org.ntp.ntpd'
if int(os_release.split('.')[1]) >= 13:
self.service_name = 'com.openssh.sshd'
elif os_family == 'Windows':
self.service_name = 'Spooler'
if os_family != 'Windows' and salt.utils.path.which(cmd_name) is None:
self.skipTest('{0} is not installed'.format(cmd_name))
return {
service: {
'__grains__': self.opts['grains'],
'__opts__': self.opts,
'__salt__': self.modules,
'__utils__': self.utils,
},
}
def setUp(self):
self.pre_srv_enabled = True if self.service_name in self.modules['service.get_enabled']() else False
self.post_srv_disable = False
if not self.pre_srv_enabled:
self.modules['service.enable'](self.service_name)
self.post_srv_disable = True
def tearDown(self):
if self.post_srv_disable:
self.modules['service.disable'](self.service_name)
def test_running_with_reload(self):
with patch.dict(service.__opts__, {'test': False}):
service.dead(self.service_name, enable=False)
result = service.running(name=self.service_name, enable=True, reload=False)
expected = {
'changes': {
self.service_name: True
},
'comment': 'Service {0} has been enabled, and is '
'running'.format(self.service_name),
'name': self.service_name,
'result': True
}
self.assertDictEqual(result, expected)

View file

@ -13,37 +13,26 @@ from tests.support.unit import TestCase, skipIf
# Import Salt Libs
import salt.config
import salt.modules.cmdmod
import salt.modules.file
import salt.modules.win_file as win_file
import salt.modules.win_lgpo as win_lgpo_mod
import salt.loader
import salt.states.win_lgpo as win_lgpo
import salt.utils.platform
import salt.utils.win_dacl
import salt.utils.win_lgpo_auditpol
import salt.utils.win_reg
import salt.utils.stringutils
# Import 3rd Party Libs
import salt.ext.six as six
# We're going to actually use the loader, without grains (slow)
opts = salt.config.DEFAULT_MINION_OPTS.copy()
utils = salt.loader.utils(opts)
modules = salt.loader.minion_mods(opts, utils=utils)
LOADER_DICTS = {
win_lgpo: {
'__salt__': {
'lgpo.get_policy': win_lgpo_mod.get_policy,
'lgpo.get_policy_info': win_lgpo_mod.get_policy_info,
'lgpo.set': win_lgpo_mod.set_}},
win_lgpo_mod: {
'__salt__': {
'cmd.run': salt.modules.cmdmod.run,
'file.file_exists': salt.modules.file.file_exists,
'file.makedirs': win_file.makedirs_,
'file.remove': win_file.remove,
'file.write': salt.modules.file.write},
'__opts__': salt.config.DEFAULT_MINION_OPTS.copy(),
'__utils__': {
'reg.read_value': salt.utils.win_reg.read_value,
'auditpol.get_auditpol_dump':
salt.utils.win_lgpo_auditpol.get_auditpol_dump}},
win_file: {
'__utils__': {
'dacl.set_perms': salt.utils.win_dacl.set_perms}}}
'__opts__': opts,
'__salt__': modules,
'__utils__': utils,
}
}
class WinLGPOComparePoliciesTestCase(TestCase):
@ -193,6 +182,7 @@ class WinLGPOPolicyElementNames(TestCase, LoaderModuleMockMixin):
with patch.dict(win_lgpo.__opts__, {'test': False}):
result = win_lgpo.set_(name='test_state',
computer_policy=computer_policy)
result = win_lgpo._convert_to_unicode(result)
expected = {
'Point and Print Restrictions': {
'Enter fully qualified server names separated by '
@ -203,9 +193,9 @@ class WinLGPOPolicyElementNames(TestCase, LoaderModuleMockMixin):
'Users can only point and print to machines in '
'their forest':
True,
u'Users can only point and print to these servers':
'Users can only point and print to these servers':
True,
u'When updating drivers for an existing connection':
'When updating drivers for an existing connection':
'Show warning only'}}
self.assertDictEqual(
result['changes']['new']['Computer Configuration'], expected)
@ -231,6 +221,8 @@ class WinLGPOPolicyElementNames(TestCase, LoaderModuleMockMixin):
with patch.dict(win_lgpo.__opts__, {'test': False}):
result = win_lgpo.set_(name='test_state',
computer_policy=computer_policy)
if six.PY2:
result = win_lgpo._convert_to_unicode(result)
expected = {
'Point and Print Restrictions': {
'Enter fully qualified server names separated by '
@ -241,9 +233,9 @@ class WinLGPOPolicyElementNames(TestCase, LoaderModuleMockMixin):
'Users can only point and print to machines in '
'their forest':
True,
u'Users can only point and print to these servers':
'Users can only point and print to these servers':
True,
u'When updating drivers for an existing connection':
'When updating drivers for an existing connection':
'Show warning only'}}
self.assertDictEqual(
result['changes']['new']['Computer Configuration'], expected)
@ -332,7 +324,7 @@ class WinLGPOPolicyElementNamesTestTrue(TestCase, LoaderModuleMockMixin):
'comment': 'All specified policies are properly configured'}
self.assertDictEqual(result['changes'], expected['changes'])
self.assertTrue(result['result'])
self.assertEqual(result['comment'], result['comment'])
self.assertEqual(result['comment'], expected['comment'])
def test_old_element_naming_style(self):
computer_policy = {
@ -362,7 +354,7 @@ class WinLGPOPolicyElementNamesTestTrue(TestCase, LoaderModuleMockMixin):
'All specified policies are properly configured'}
self.assertDictEqual(result['changes'], expected['changes'])
self.assertTrue(result['result'])
self.assertEqual(result['comment'], result['comment'])
self.assertEqual(result['comment'], expected['comment'])
def test_invalid_elements(self):
computer_policy = {

View file

@ -8,11 +8,12 @@ import os
from tests.support.helpers import requires_network
from tests.support.runtests import RUNTIME_VARS
from tests.support.unit import skipIf
from tests.unit.modules.test_zcbuildout import Base, KNOWN_VIRTUALENV_BINARY_NAMES
# Import Salt libs
import salt.utils.path
from tests.unit.modules.test_zcbuildout import Base, KNOWN_VIRTUALENV_BINARY_NAMES
import salt.modules.zcbuildout as modbuildout
import salt.modules.virtualenv_mod
import salt.states.zcbuildout as buildout
import salt.modules.cmdmod as cmd
@ -60,6 +61,8 @@ class BuildoutTestCase(Base):
@requires_network()
def test_installed(self):
if salt.modules.virtualenv_mod.virtualenv_ver(self.ppy_st) >= (20, 0, 0):
self.skipTest("Skiping until upstream resolved https://github.com/pypa/virtualenv/issues/1715")
b_dir = os.path.join(self.tdir, 'b')
ret = buildout.installed(b_dir,
python=self.py_st,

View file

@ -42,6 +42,7 @@ class VersionTestCase(TestCase):
('v4518.1', (4518, 1, '', 0, 0, None), '4518.1'),
('v3000rc1', (3000, 'rc', 1, 0, None), '3000rc1'),
('v3000rc1-n/a-abcdefff', (3000, 'rc', 1, -1, 'abcdefff'), None),
('3000-n/a-1e7bc8f', (3000, '', 0, -1, '1e7bc8f'), None)
)
@ -148,6 +149,27 @@ class VersionTestCase(TestCase):
assert not ver.bugfix
assert ver.string == '{0}.{1}'.format(maj_ver, min_ver)
def test_string_new_version_minor_as_string(self):
'''
Validate string property method
using new versioning scheme alongside
minor version
'''
maj_ver = '3000'
min_ver = '1'
ver = SaltStackVersion(major=maj_ver, minor=min_ver)
assert ver.minor == int(min_ver)
assert not ver.bugfix
assert ver.string == '{0}.{1}'.format(maj_ver, min_ver)
# This only seems to happen on a cloned repo without its tags
maj_ver = '3000'
min_ver = ''
ver = SaltStackVersion(major=maj_ver, minor=min_ver)
assert ver.minor is None, '{!r} is not {!r}'.format(ver.minor, min_ver) # pylint: disable=repr-flag-used-in-string
assert not ver.bugfix
assert ver.string == maj_ver
def test_string_old_version(self):
'''
Validate string property method

View file

@ -5,13 +5,16 @@ Unit tests for salt.utils.templates.py
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
import logging
# Import Salt libs
import salt.utils.templates
import salt.utils.files
# Import Salt Testing Libs
from tests.support.helpers import with_tempdir
from tests.support.unit import TestCase, skipIf
log = logging.getLogger(__name__)
@ -181,3 +184,46 @@ class RenderTestCase(TestCase):
ctx['var'] = 'OK'
res = salt.utils.templates.render_cheetah_tmpl(tmpl, ctx)
self.assertEqual(res.strip(), 'OK')
class MockRender(object):
def __call__(self, tplstr, context, tmplpath=None):
self.tplstr = tplstr
self.context = context
self.tmplpath = tmplpath
return tplstr
class WrapRenderTestCase(TestCase):
@with_tempdir()
def test_wrap_issue_56119_a(self, tempdir):
slsfile = os.path.join(tempdir, 'foo')
with salt.utils.files.fopen(slsfile, 'w') as fp:
fp.write('{{ slspath }}')
context = {'opts': {}, 'saltenv': 'base', 'sls': 'foo.bar'}
render = MockRender()
wrapped = salt.utils.templates.wrap_tmpl_func(render)
res = wrapped(
slsfile,
context=context,
tmplpath='/tmp/foo/bar/init.sls'
)
assert render.context['slspath'] == 'foo/bar', render.context['slspath']
assert render.context['tpldir'] == 'foo/bar', render.context['tpldir']
@with_tempdir()
def test_wrap_issue_56119_b(self, tempdir):
slsfile = os.path.join(tempdir, 'foo')
with salt.utils.files.fopen(slsfile, 'w') as fp:
fp.write('{{ slspath }}')
context = {'opts': {}, 'saltenv': 'base', 'sls': 'foo.bar.bang'}
render = MockRender()
wrapped = salt.utils.templates.wrap_tmpl_func(render)
res = wrapped(
slsfile,
context=context,
tmplpath='/tmp/foo/bar/bang.sls'
)
assert render.context['slspath'] == 'foo/bar', render.context['slspath']
assert render.context['tpldir'] == 'foo/bar', render.context['tpldir']

View file

@ -10,16 +10,6 @@ from tests.support.unit import TestCase, skipIf
import salt.utils.platform
import salt.utils.win_network as win_network
mock_base = MagicMock(return_value={
'alias': 'Ethernet',
'description': 'Dell GigabitEthernet',
'id': '{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
'receive_only': False,
'status': 'Up',
'type': 'Ethernet',
'physical_address': '02:D5:F1:DD:31:E0'
})
mock_ip_base = MagicMock(return_value={
'dns_enabled': False,
'dns_suffix': '',
@ -75,11 +65,36 @@ mock_anycast = MagicMock(return_value={'ip_anycast': [],
mock_wins = MagicMock(return_value={'ip_wins': []})
class PhysicalAddress(object):
def __init__(self, address):
self.address = address
def ToString(self):
return str(self.address)
class Interface(object):
Name = 'Ethernet'
'''
Mocked interface object
'''
def __init__(self,
i_address='02D5F1DD31E0',
i_description='Dell GigabitEthernet',
i_id='{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
i_name='Ethernet',
i_receive_only=False,
i_status=1,
i_type=6):
self.PhysicalAddress = PhysicalAddress(i_address)
self.Description = i_description
self.Id = i_id
self.Name = i_name
self.NetworkInterfaceType = i_type
self.IsReceiveOnly = i_receive_only
self.OperationalStatus = i_status
mock_int = MagicMock(return_value=[Interface()])
def GetPhysicalAddress(self):
return self.PhysicalAddress
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
@ -130,8 +145,8 @@ class WinNetworkTestCase(TestCase):
'status': 'Up',
'type': 'Ethernet'}}
mock_int = MagicMock(return_value=[Interface()])
with patch.object(win_network, '_get_network_interfaces', mock_int), \
patch.object(win_network, '_get_base_properties', mock_base), \
patch.object(win_network, '_get_ip_base_properties', mock_ip_base), \
patch.object(win_network, '_get_ip_unicast_info', mock_unicast), \
patch.object(win_network, '_get_ip_gateway_info', mock_gateway), \
@ -157,8 +172,8 @@ class WinNetworkTestCase(TestCase):
'inet6': [{'address': 'fe80::e8a4:1224:5548:2b81',
'gateway': 'fe80::208:a2ff:fe0b:de70'}],
'up': True}}
mock_int = MagicMock(return_value=[Interface()])
with patch.object(win_network, '_get_network_interfaces', mock_int), \
patch.object(win_network, '_get_base_properties', mock_base), \
patch.object(win_network, '_get_ip_base_properties', mock_ip_base), \
patch.object(win_network, '_get_ip_unicast_info', mock_unicast), \
patch.object(win_network, '_get_ip_gateway_info', mock_gateway), \
@ -171,3 +186,55 @@ class WinNetworkTestCase(TestCase):
results = win_network.get_interface_info()
self.assertDictEqual(expected, results)
def test__get_base_properties_tap_adapter(self):
'''
Adapter Type 53 is apparently an undocumented type corresponding to
OpenVPN TAP Adapters and possibly other TAP Adapters. This test makes
sure the win_network util will catch that.
https://github.com/saltstack/salt/issues/56196
https://github.com/saltstack/salt/issues/56275
'''
i_face = Interface(
i_address='03DE4D0713FA',
i_description='Windows TAP Adapter',
i_id='{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
i_name='Windows TAP Adapter',
i_receive_only=False,
i_status=1,
i_type=53)
expected = {
'alias': 'Windows TAP Adapter',
'description': 'Windows TAP Adapter',
'id': '{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
'receive_only': False,
'physical_address': '03:DE:4D:07:13:FA',
'status': 'Up',
'type': 'TAPAdapter'}
results = win_network._get_base_properties(i_face=i_face)
self.assertDictEqual(expected, results)
def test__get_base_properties_undefined_adapter(self):
'''
The Adapter Type 53 may be an arbitrary number assigned by OpenVPN.
This will test the ability to avoid stack tracing on an undefined
adapter type. If one is encountered, just use the description.
'''
i_face = Interface(
i_address='03DE4D0713FA',
i_description='Undefined Adapter',
i_id='{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
i_name='Undefined',
i_receive_only=False,
i_status=1,
i_type=50)
expected = {
'alias': 'Undefined',
'description': 'Undefined Adapter',
'id': '{C5F468C0-DD5F-4C2B-939F-A411DCB5DE16}',
'receive_only': False,
'physical_address': '03:DE:4D:07:13:FA',
'status': 'Up',
'type': 'Undefined Adapter'}
results = win_network._get_base_properties(i_face=i_face)
self.assertDictEqual(expected, results)

View file

@ -630,12 +630,17 @@ class WinFunctionsTestCase(TestCase):
Should always return integer
'''
vdata = 1
expected = 1
result = win_reg.cast_vdata(vdata=vdata, vtype='REG_DWORD')
self.assertTrue(isinstance(result, six.integer_types))
self.assertEqual(result, expected)
vdata = '1'
result = win_reg.cast_vdata(vdata=vdata, vtype='REG_DWORD')
self.assertTrue(isinstance(result, six.integer_types))
self.assertEqual(result, expected)
vdata = '0000001'
result = win_reg.cast_vdata(vdata=vdata, vtype='REG_DWORD')
self.assertEqual(result, expected)
def test_cast_vdata_reg_expand_sz(self):
'''