diff options
-rw-r--r-- | .travis.yml | 55 | ||||
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | Gemfile.lock | 32 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/group/dscl.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/windows_task.rb | 34 | ||||
-rw-r--r-- | lib/chef/resource/execute.rb | 3 | ||||
-rw-r--r-- | lib/chef/resource/windows_task.rb | 37 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 | ||||
-rw-r--r-- | omnibus/Gemfile.lock | 28 | ||||
-rw-r--r-- | omnibus_overrides.rb | 2 | ||||
-rw-r--r-- | spec/support/shared/unit/execute_resource.rb | 9 | ||||
-rw-r--r-- | spec/unit/provider/group/dscl_spec.rb | 19 | ||||
-rw-r--r-- | spec/unit/provider/user/dscl_spec.rb | 26 | ||||
-rw-r--r-- | spec/unit/provider/windows_task_spec.rb | 94 | ||||
-rw-r--r-- | spec/unit/resource/windows_task_spec.rb | 18 |
18 files changed, 265 insertions, 118 deletions
diff --git a/.travis.yml b/.travis.yml index ab0411e4b3..b68193644c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: ruby -sudo: required cache: bundler dist: trusty @@ -39,7 +38,7 @@ matrix: bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - env: INTEGRATION_SPECS_24: 1 - rvm: 2.4.2 + rvm: 2.4.3 sudo: true script: sudo -E $(which bundle) exec rake spec:integration; bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen @@ -51,7 +50,7 @@ matrix: bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - env: FUNCTIONAL_SPECS_24: 1 - rvm: 2.4.2 + rvm: 2.4.3 sudo: true script: sudo -E $(which bundle) exec rake spec:functional; bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen @@ -65,7 +64,7 @@ matrix: bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - env: UNIT_SPECS_24: 1 - rvm: 2.4.2 + rvm: 2.4.3 sudo: true script: - sudo -E $(which bundle) exec rake spec:unit; @@ -73,13 +72,13 @@ matrix: bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - env: CHEFSTYLE: 1 - rvm: 2.4.2 + rvm: 2.4.3 script: bundle exec rake style # also remove integration / external tests bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen - env: AUDIT_CHECK: 1 - rvm: 2.4.2 + rvm: 2.4.3 script: bundle exec bundle-audit check --update # also remove integration / external tests bundler_args: --without ci docgen guard integration maintenance omnibus_package --frozen @@ -89,43 +88,43 @@ matrix: - env: TEST_GEM: sethvargo/chef-sugar script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake - rvm: 2.4.2 + rvm: 2.4.3 - env: PEDANT_OPTS: --skip-oc_id TEST_GEM: chef/chef-zero script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec cheffs - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: chef/cheffish script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: chefspec/chefspec script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: foodcritic/foodcritic script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake test - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: poise/halite script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: chef/knife-windows script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake unit_spec - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: poise/poise script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec - rvm: 2.4.2 + rvm: 2.4.3 - env: TEST_GEM: chef/knife-windows script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake unit_spec - rvm: 2.4.2 + rvm: 2.4.3 ### START TEST KITCHEN ONLY ### # - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -142,7 +141,7 @@ matrix: env: - AMAZON=LATEST - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -159,7 +158,7 @@ matrix: env: - UBUNTU=14.04 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -176,7 +175,7 @@ matrix: env: - UBUNTU=16.04 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -193,7 +192,7 @@ matrix: env: - DEBIAN=7 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -210,7 +209,7 @@ matrix: env: - DEBIAN=8 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -227,7 +226,7 @@ matrix: env: - DEBIAN=9 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -244,7 +243,7 @@ matrix: env: - CENTOS=6 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -261,7 +260,7 @@ matrix: env: - CENTOS=7 - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -278,7 +277,7 @@ matrix: env: - FEDORA=latest - KITCHEN_YAML=.kitchen.travis.yml - - rvm: 2.4.2 + - rvm: 2.4.3 services: docker sudo: required gemfile: kitchen-tests/Gemfile @@ -295,7 +294,7 @@ matrix: env: - OPENSUSELEAP=42 - KITCHEN_YAML=.kitchen.travis.yml -# - rvm: 2.4.2 +# - rvm: 2.4.3 # services: docker # sudo: required # gemfile: kitchen-tests/Gemfile @@ -312,7 +311,7 @@ matrix: # env: # - AWESOME_CUSTOMERS_UBUNTU=1 # - KITCHEN_YAML=.kitchen.travis.yml -# - rvm: 2.4.2 +# - rvm: 2.4.3 # services: docker # sudo: required # gemfile: kitchen-tests/Gemfile @@ -330,7 +329,7 @@ matrix: # - AWESOME_CUSTOMERS_RHEL=1 # - KITCHEN_YAML=.kitchen.travis.yml # ### END TEST KITCHEN ONLY ### - - rvm: 2.4.2 + - rvm: 2.4.3 sudo: required before_install: - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d94f502b0..ae39c0604b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,19 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> -<!-- latest_release 13.7.4 --> -## [v13.7.4](https://github.com/chef/chef/tree/v13.7.4) (2018-01-03) +<!-- latest_release 13.7.8 --> +## [v13.7.8](https://github.com/chef/chef/tree/v13.7.8) (2018-01-08) #### Merged Pull Requests -- Modernize windows_path resource [#6699](https://github.com/chef/chef/pull/6699) ([tas50](https://github.com/tas50)) +- Fix dscl group provider gid_used? [#6703](https://github.com/chef/chef/pull/6703) ([get9](https://github.com/get9)) <!-- latest_release --> <!-- release_rollup since=13.6.4 --> ### Changes since 13.6.4 release #### Merged Pull Requests +- Fix dscl group provider gid_used? [#6703](https://github.com/chef/chef/pull/6703) ([get9](https://github.com/get9)) <!-- 13.7.8 --> +- Fix windows_task resource not being idempotent for random_delay and execution_time_limit [#6688](https://github.com/chef/chef/pull/6688) ([Vasu1105](https://github.com/Vasu1105)) <!-- 13.7.7 --> +- Update to Ruby 2.4.3 [#6737](https://github.com/chef/chef/pull/6737) ([tas50](https://github.com/tas50)) <!-- 13.7.6 --> +- DSCL: Check for set home property before file existence (fixes #5777) [#6735](https://github.com/chef/chef/pull/6735) ([get9](https://github.com/get9)) <!-- 13.7.5 --> - Modernize windows_path resource [#6699](https://github.com/chef/chef/pull/6699) ([tas50](https://github.com/tas50)) <!-- 13.7.4 --> - Don't check both platform_family / os in provides when platform_family will do [#6711](https://github.com/chef/chef/pull/6711) ([tas50](https://github.com/tas50)) <!-- 13.7.3 --> - Update the knife editor error message to point to the correct document [#6726](https://github.com/chef/chef/pull/6726) ([tas50](https://github.com/tas50)) <!-- 13.7.2 --> diff --git a/Gemfile.lock b/Gemfile.lock index 4211fd0eda..023b5e4de6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GIT GIT remote: https://github.com/rubysec/bundler-audit.git - revision: 06e6077aaaed3744915b1dda71effeea2ea41751 + revision: b84d88f76c4d656421c1d810c9760b0fdea5d13a specs: bundler-audit (0.6.0) bundler (~> 1.2) @@ -17,10 +17,10 @@ GIT PATH remote: . specs: - chef (13.7.4) + chef (13.7.8) addressable bundler (>= 1.10) - chef-config (= 13.7.4) + chef-config (= 13.7.8) chef-zero (>= 13.0) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -47,10 +47,10 @@ PATH specinfra (~> 2.10) syslog-logger (~> 1.6) uuidtools (~> 2.1.5) - chef (13.7.4-universal-mingw32) + chef (13.7.8-universal-mingw32) addressable bundler (>= 1.10) - chef-config (= 13.7.4) + chef-config (= 13.7.8) chef-zero (>= 13.0) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -92,7 +92,7 @@ PATH PATH remote: chef-config specs: - chef-config (13.7.4) + chef-config (13.7.8) addressable fuzzyurl mixlib-config (~> 2.0) @@ -106,7 +106,7 @@ GEM appbundler (0.10.0) mixlib-cli (~> 1.4) ast (2.3.0) - backports (3.10.3) + backports (3.11.0) binding_of_caller (0.7.3) debug_inspector (>= 0.0.1) builder (3.2.3) @@ -133,7 +133,7 @@ GEM erubis (2.7.0) ethon (0.11.0) ffi (>= 1.3.0) - excon (0.59.0) + excon (0.60.0) faraday (0.13.1) multipart-post (>= 1.2, < 3) faraday_middleware (0.12.2) @@ -163,7 +163,7 @@ GEM htmlentities (4.3.4) httpclient (2.8.3) iniparse (1.4.4) - inspec (1.48.0) + inspec (1.49.2) addressable (~> 2.4) faraday (>= 0.9.0) hashie (~> 3.4) @@ -181,7 +181,7 @@ GEM sslshake (~> 1.2) thor (~> 0.19) tomlrb (~> 1.2) - train (~> 0.31, >= 0.31.1) + train (~> 0.32) ipaddress (0.8.3) iso8601 (0.9.1) json (2.1.0) @@ -220,7 +220,7 @@ GEM net-telnet (0.1.1) netrc (0.11.0) nori (2.6.0) - octokit (4.7.0) + octokit (4.8.0) sawyer (~> 0.8.0, >= 0.5.3) ohai (13.7.0) chef-config (>= 12.5.0.alpha.1, < 14) @@ -234,7 +234,7 @@ GEM plist (~> 3.1) systemu (~> 2.6.4) wmi-lite (~> 1.0) - parallel (1.12.0) + parallel (1.12.1) parser (2.4.0.2) ast (~> 2.3) parslet (1.8.1) @@ -287,7 +287,7 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-prof (0.16.2) + ruby-prof (0.17.0) ruby-progressbar (1.9.0) ruby-shadow (2.5.0) rubyntlm (0.6.2) @@ -319,7 +319,7 @@ GEM systemu (2.6.5) thor (0.20.0) tomlrb (1.2.6) - train (0.31.1) + train (0.32.0) docker-api (~> 1.26) json (>= 1.8, < 3.0) mixlib-shellout (~> 2.0) @@ -340,7 +340,7 @@ GEM ethon (>= 0.8.0) unicode-display_width (1.3.0) uuidtools (2.1.5) - webmock (3.1.1) + webmock (3.2.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -414,4 +414,4 @@ DEPENDENCIES yard BUNDLED WITH - 1.16.0 + 1.16.1 @@ -1 +1 @@ -13.7.4
\ No newline at end of file +13.7.8
\ No newline at end of file diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 28dbcb34f2..faec04337f 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "13.7.4" + VERSION = "13.7.8" end # diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb index 71e42b36ba..fe152eda33 100644 --- a/lib/chef/provider/group/dscl.rb +++ b/lib/chef/provider/group/dscl.rb @@ -88,8 +88,12 @@ class Chef def gid_used?(gid) return false unless gid - groups_gids = safe_dscl("list", "/Groups", "gid") - !!( groups_gids =~ Regexp.new("#{Regexp.escape(gid.to_s)}\n") ) + search_gids = safe_dscl("search", "/Groups", "PrimaryGroupID", gid.to_s) + + # dscl -search should not return anything if the gid doesn't exist, + # but on the off-chance that it does, check whether the given gid is + # in the output. + !!(search_gids =~ /\b#{gid}\b/) end def set_gid diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 60167856d1..bc865b17c5 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -318,7 +318,7 @@ user password using shadow hash.") end def current_home_exists? - ::File.exist?(current_resource.home) + !!current_resource.home && ::File.exist?(current_resource.home) end def new_home_exists? diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb index 02e45cb9e0..d8f9094fd1 100644 --- a/lib/chef/provider/windows_task.rb +++ b/lib/chef/provider/windows_task.rb @@ -229,8 +229,7 @@ class Chef current_resource.frequency_modifier != new_resource.frequency_modifier || current_resource.frequency != new_resource.frequency || current_resource.idle_time != new_resource.idle_time || - current_resource.random_delay != new_resource.random_delay || - !new_resource.execution_time_limit.include?(current_resource.execution_time_limit) || + random_delay_updated? || execution_time_limit_updated? || (new_resource.start_day && new_resource.start_day != "N/A" && start_day_updated?) || (new_resource.start_time && new_resource.start_time != "N/A" && start_time_updated?) begin @@ -243,6 +242,37 @@ class Chef false end + # Comparing random_delay values using ISO8601::Duration object Ref: https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23 + # di = ISO8601::Duration.new(65707200) + # ds = ISO8601::Duration.new('P65707200S') + # dp = ISO8601::Duration.new('P2Y1MT2H') + # di == dp # => true + # di == ds # => true + def random_delay_updated? + if new_resource.random_delay.nil? + false + elsif current_resource.random_delay.nil? && new_resource.random_delay == "PT0S" # when user sets random_dealy to 0 sec + false + elsif current_resource.random_delay.nil? + true + else + ISO8601::Duration.new(current_resource.random_delay) != ISO8601::Duration.new(new_resource.random_delay) + end + end + + # Comparing execution_time_limit values using Ref: https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23 + def execution_time_limit_updated? + if new_resource.execution_time_limit.nil? + false + elsif current_resource.execution_time_limit.nil? && new_resource.execution_time_limit == "PT0S" # when user sets random_dealy to 0 sec + false + elsif current_resource.execution_time_limit.nil? + true + else + ISO8601::Duration.new(current_resource.execution_time_limit) != ISO8601::Duration.new(new_resource.execution_time_limit) + end + end + def start_day_updated? current_day = DateTime.strptime(current_resource.start_day, convert_system_date_format_to_ruby_date_format) new_day = parse_day(new_resource.start_day) diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index de927ec06e..616195deee 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -133,7 +133,8 @@ class Chef property :password, String, sensitive: true - property :sensitive, [ TrueClass, FalseClass ], default: false, coerce: proc { |x| password ? true : x } + # lazy used to set default value of sensitive to true if password is set + property :sensitive, [ TrueClass, FalseClass ], default: lazy { |r| r.password ? true : false } property :elevated, [ TrueClass, FalseClass ], default: false diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index f61a119b5a..14f5da46fa 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -205,38 +205,13 @@ class Chef end end - # Convert the number of seconds to an ISO8601 duration format - # @see http://tools.ietf.org/html/rfc2445#section-4.3.6 - # @param [Integer] seconds The amount of seconds for this duration + # Converts the number of seconds to an ISO8601 duration format and returns it. + # Ref : https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23 + # e.g. + # ISO8601::Duration.new(65707200) + # returns 'P65707200S' def sec_to_dur(seconds) - seconds = seconds.to_i - iso_str = "P" - if seconds > 604_800 # more than a week - weeks = seconds / 604_800 - seconds -= (604_800 * weeks) - iso_str << "#{weeks}W" - end - if seconds > 86_400 # more than a day - days = seconds / 86_400 - seconds -= (86_400 * days) - iso_str << "#{days}D" - end - if seconds >= 0 - iso_str << "T" - if seconds > 3600 # more than an hour - hours = seconds / 3600 - seconds -= (3600 * hours) - iso_str << "#{hours}H" - end - if seconds > 60 # more than a minute - minutes = seconds / 60 - seconds -= (60 * minutes) - iso_str << "#{minutes}M" - end - iso_str << "#{seconds}S" - end - - iso_str + ISO8601::Duration.new(seconds.to_i).to_s end end diff --git a/lib/chef/version.rb b/lib/chef/version.rb index b2781c7367..98e79848c6 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require "chef/version_string" class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = Chef::VersionString.new("13.7.4") + VERSION = Chef::VersionString.new("13.7.8") end # diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index 06ef842859..928cc8eeaf 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/chef/license_scout - revision: d736df0d72f84ed3f0c8e3eb66b12562a3dccbda + revision: d044136f0b464ed3894a172f06a50167106ec5d1 specs: license_scout (0.1.3) ffi-yajl (~> 2.2) @@ -26,7 +26,7 @@ GIT GIT remote: https://github.com/chef/omnibus-software - revision: d6accc79f166cc6fc552e07088951bf467c30989 + revision: 918dcb6b883ce2edb1528040875257b8e9b1c79f specs: omnibus-software (4.0.0) chef-sugar (>= 3.4.0) @@ -38,13 +38,13 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) awesome_print (1.8.0) - aws-sdk (2.10.99) - aws-sdk-resources (= 2.10.99) - aws-sdk-core (2.10.99) + aws-sdk (2.10.112) + aws-sdk-resources (= 2.10.112) + aws-sdk-core (2.10.112) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.10.99) - aws-sdk-core (= 2.10.99) + aws-sdk-resources (2.10.112) + aws-sdk-core (= 2.10.112) aws-sigv4 (1.0.2) berkshelf (4.3.5) addressable (~> 2.3, >= 2.3.4) @@ -108,7 +108,7 @@ GEM ffi (>= 1.0.1) gyoku (1.3.1) builder (>= 2.1.2) - hashie (3.5.6) + hashie (3.5.7) hitimes (1.2.6) hitimes (1.2.6-x86-mingw32) httpclient (2.7.2) @@ -130,7 +130,7 @@ GEM mixlib-authentication (1.4.2) mixlib-cli (1.7.0) mixlib-config (2.2.4) - mixlib-install (3.8.0) + mixlib-install (3.9.0) mixlib-shellout mixlib-versioning thor @@ -148,9 +148,9 @@ GEM net-ssh (4.2.0) net-ssh-gateway (1.3.0) net-ssh (>= 2.6.5) - nio4r (2.1.0) + nio4r (2.2.0) nori (2.6.0) - octokit (4.7.0) + octokit (4.8.0) sawyer (~> 0.8.0, >= 0.5.3) ohai (8.25.1) chef-config (>= 12.5.0.alpha.1, < 14) @@ -170,7 +170,7 @@ GEM multipart-post (~> 2.0.0) progressbar zhexdump (>= 0.0.2) - plist (3.3.0) + plist (3.4.0) progressbar (1.9.0) pry (0.11.3) coderay (~> 1.1.0) @@ -204,7 +204,6 @@ GEM ruby-progressbar (1.9.0) rubyntlm (0.6.2) rubyzip (1.2.1) - safe_yaml (1.0.4) sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) @@ -219,7 +218,6 @@ GEM net-scp (~> 1.1) net-ssh (>= 2.9, < 5.0) net-ssh-gateway (~> 1.2) - safe_yaml (~> 1.0) thor (~> 0.19, < 0.19.2) winrm (~> 2.0) winrm-elevated (~> 1.0) @@ -273,4 +271,4 @@ DEPENDENCIES winrm-fs (~> 1.0) BUNDLED WITH - 1.16.0 + 1.16.1 diff --git a/omnibus_overrides.rb b/omnibus_overrides.rb index c88ebfdcc1..8da7dc9940 100644 --- a/omnibus_overrides.rb +++ b/omnibus_overrides.rb @@ -14,7 +14,7 @@ override "libyaml", version: "0.1.7" override "makedepend", version: "1.0.5" override "ncurses", version: "5.9" override "pkg-config-lite", version: "0.28-1" -override "ruby", version: "2.4.2" +override "ruby", version: "2.4.3" override "ruby-windows-devkit-bash", version: "3.1.23-4-msys-1.0.18" override "util-macros", version: "1.19.0" override "xproto", version: "7.0.28" diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb index ae56a9697d..c15b02612e 100644 --- a/spec/support/shared/unit/execute_resource.rb +++ b/spec/support/shared/unit/execute_resource.rb @@ -139,7 +139,14 @@ shared_examples_for "an execute resource" do it "should be true if the password is non-nil but the value is explicitly set to false" do @resource.password("we.funk!") @resource.sensitive false - expect(@resource.sensitive).to eq(true) + expect(@resource.sensitive).to eq(false) + end + + # added this test to ensure setting of password property after or before sensitive does not matter + it "should be false if the sensitive is set before password property" do + @resource.sensitive false + @resource.password("we.funk!") + expect(@resource.sensitive).to eq(false) end end diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index e25b77c051..cf3f0237f5 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -117,11 +117,16 @@ describe Chef::Provider::Group::Dscl do before do @node = Chef::Node.new @provider = Chef::Provider::Group::Dscl.new(@node, @new_resource) - allow(@provider).to receive(:safe_dscl).and_return("\naj 500\n") + allow(@provider).to receive(:safe_dscl).and_return(<<-eos + someprogram somethingElse:gid = ( + 500 + ) + eos + ) end - it "should run safe_dscl with list /Groups gid" do - expect(@provider).to receive(:safe_dscl).with(*"list /Groups gid".split(" ")) + it "should run safe_dscl with search /Groups gid" do + expect(@provider).to receive(:safe_dscl).with(*"search /Groups PrimaryGroupID 500".split(" ")) @provider.gid_used?(500) end @@ -130,7 +135,11 @@ describe Chef::Provider::Group::Dscl do end it "should return false for an unused gid number" do - expect(@provider.gid_used?(501)).to be_falsey + expect(@provider.gid_used?(0)).to be_falsey + expect(@provider.gid_used?(50)).to be_falsey + expect(@provider.gid_used?(5000)).to be_falsey + expect(@provider.gid_used?(1500)).to be_falsey + expect(@provider.gid_used?(18)).to be_falsey end it "should return false if not given any valid gid number" do @@ -171,7 +180,7 @@ describe Chef::Provider::Group::Dscl do describe "with a valid gid number which is not already in use" do it "should run safe_dscl with create /Groups/group PrimaryGroupID gid" do allow(@provider).to receive(:get_free_gid).and_return(50) - expect(@provider).to receive(:safe_dscl).with(*"list /Groups gid".split(" ")) + expect(@provider).to receive(:safe_dscl).with(*"search /Groups PrimaryGroupID 50".split(" ")).and_return("") expect(@provider).to receive(:safe_dscl).with("create", "/Groups/aj", "PrimaryGroupID", 50).and_return(true) @provider.set_gid end diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb index f59709e717..956c32664d 100644 --- a/spec/unit/provider/user/dscl_spec.rb +++ b/spec/unit/provider/user/dscl_spec.rb @@ -213,6 +213,32 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" end end + describe "current_home_exists?" do + let(:current_resource) do + new_resource.dup + end + + before do + provider.current_resource = current_resource + end + + it "returns false for nil home dir" do + current_resource.home nil + expect(provider.current_home_exists?).to be_falsey + end + + it "is false for empty string" do + current_resource.home "" + expect(provider.current_home_exists?).to be_falsey + end + + it "is true for existing directory" do + current_resource.home "/Users/blah" + allow(::File).to receive(:exist?).with("/Users/blah").and_return(true) + expect(provider.current_home_exists?).to be_truthy + end + end + describe "when modifying the home directory" do let(:current_resource) do new_resource.dup diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb index ce0fe9e50e..a71ce92f56 100644 --- a/spec/unit/provider/windows_task_spec.rb +++ b/spec/unit/provider/windows_task_spec.rb @@ -620,4 +620,98 @@ describe Chef::Provider::WindowsTask do expect(provider.send(:frequency_modifier_allowed)).to be(false) end end + + # In windows_task resource sec_to_dur method converts seconds to duration in format 60 == 'PT60S' + # random_delay_updated? method use the value return by sec_to_dur as input for comparison for new_resource.random_delay mocking the same here + describe "#random_delay_updated?" do + before do + new_resource.command "chef-client" + new_resource.run_level :highest + new_resource.frequency :minute + new_resource.frequency_modifier 15 + new_resource.user "SYSTEM" + end + + it "returns false if current_resource.random_delay = nil & random_delay is set to '0' seconds" do + task_hash[:random_delay] = nil + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.random_delay = "PT0S" + expect(provider.send(:random_delay_updated?)).to be(false) + end + + it "returns false if current_resource.random_delay = 'P7D' & random_delay is set to '604800' seconds " do + task_hash[:random_delay] = "P7D" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.random_delay = "PT604800S" + expect(provider.send(:random_delay_updated?)).to be(false) + end + + it "returns false if current_resource.random_delay = 'P7DT1S' & random_delay is set to '604801' seconds" do + task_hash[:random_delay] = "P7DT1S" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.random_delay = "PT604801S" + expect(provider.send(:random_delay_updated?)).to be(false) + end + + it "returns true if current_resource.random_delay = 'PT1S' & random_delay is set to '3600' seconds" do + task_hash[:random_delay] = "PT1S" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.random_delay = "PT3600S" + expect(provider.send(:random_delay_updated?)).to be(true) + end + + it "returns false if current_resource.random_delay = 'P2Y1MT2H' & random_delay is set to '65707200' seconds" do + task_hash[:random_delay] = "P2Y1MT2H" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.random_delay = "PT65707200S" + expect(provider.send(:random_delay_updated?)).to be(false) + end + end + + describe "#execution_time_limit_updated?" do + before do + new_resource.command "chef-client" + new_resource.run_level :highest + new_resource.frequency :minute + new_resource.frequency_modifier 15 + new_resource.user "SYSTEM" + end + + it "returns false if current_resource.execution_time_limit = 'P7D' & execution_time_limit is set to 604800 seconds " do + task_hash[:execution_time_limit] = "P7D" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.execution_time_limit = "PT604800S" + expect(provider.send(:execution_time_limit_updated?)).to be(false) + end + + it "returns false if current_resource.execution_time_limit = 'P7DT1S' & execution_time_limit is set to 604801 seconds" do + task_hash[:execution_time_limit] = "P7DT1S" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.execution_time_limit = "PT604801S" + expect(provider.send(:execution_time_limit_updated?)).to be(false) + end + + it "returns true if current_resource.execution_time_limit = 'PT1S' & execution_time_limit is set to '3600' seconds" do + task_hash[:execution_time_limit] = "PT1S" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.execution_time_limit = "PT3600S" + expect(provider.send(:execution_time_limit_updated?)).to be(true) + end + + it "returns false if current_resource.execution_time_limit = 'P2Y1MT2H' & execution_time_limit is set to '65707200' seconds" do + task_hash[:execution_time_limit] = "P2Y1MT2H" + allow(provider).to receive(:load_task_hash).and_return(task_hash) + provider.load_current_resource + new_resource.execution_time_limit = "PT65707200S" + expect(provider.send(:execution_time_limit_updated?)).to be(false) + end + end end diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb index fe0c55ecaf..145063b53e 100644 --- a/spec/unit/resource/windows_task_spec.rb +++ b/spec/unit/resource/windows_task_spec.rb @@ -281,23 +281,23 @@ describe Chef::Resource::WindowsTask do end context "#sec_to_dur" do - it "return PT0S when passed 0" do + it "return nil when passed 0" do expect(resource.send(:sec_to_dur, 0)).to eql("PT0S") end it "return PT1S when passed 1" do expect(resource.send(:sec_to_dur, 1)).to eql("PT1S") end - it "return PT24H0S when passed 86400" do - expect(resource.send(:sec_to_dur, 86400)).to eql("PT24H0S") + it "return PT86400S when passed 86400" do + expect(resource.send(:sec_to_dur, 86400)).to eql("PT86400S") end - it "return P1DT1S when passed 86401" do - expect(resource.send(:sec_to_dur, 86401)).to eql("P1DT1S") + it "return PT86401S when passed 86401" do + expect(resource.send(:sec_to_dur, 86401)).to eql("PT86401S") end - it "return P1DT1M40S when passed 86500" do - expect(resource.send(:sec_to_dur, 86500)).to eql("P1DT1M40S") + it "return PT86500S when passed 86500" do + expect(resource.send(:sec_to_dur, 86500)).to eql("PT86500S") end - it "return P1WT1S when passed 604801" do - expect(resource.send(:sec_to_dur, 604801)).to eql("P1WT1S") + it "return PT604801S when passed 604801" do + expect(resource.send(:sec_to_dur, 604801)).to eql("PT604801S") end end end |