summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavin Taddeo <davin@chef.io>2020-07-02 10:58:35 -0400
committerDavin Taddeo <davin@chef.io>2020-07-02 10:58:35 -0400
commit51938cc45ae88d2fc921a9b711bdddda6e30925d (patch)
treea1abf0a29e9dd2b9468d8403950b20ec0e77e050
parentd6ba0c5c97895c569bc7dad67c4e569aa8dce5b6 (diff)
parent09db58acb1df121c5661a8dd672219d8f0ddbd03 (diff)
downloadchef-51938cc45ae88d2fc921a9b711bdddda6e30925d.tar.gz
Merge branch 'master' of github.com:chef/chef into windows_firewall_profile
-rwxr-xr-x.expeditor/cleanup_orphaned_test_resources.sh15
-rw-r--r--.expeditor/config.yml12
-rw-r--r--.expeditor/verify.pipeline.yml (renamed from .expeditor/verify_public.pipeline.yml)23
-rw-r--r--.expeditor/verify_private.pipeline.yml41
-rw-r--r--CHANGELOG.md45
-rw-r--r--Dockerfile2
-rw-r--r--Gemfile.lock60
-rw-r--r--RELEASE_NOTES.md12
-rw-r--r--VERSION2
-rw-r--r--chef-bin/lib/chef-bin/version.rb2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef-utils/lib/chef-utils/version.rb2
-rw-r--r--chef.gemspec4
-rw-r--r--habitat/tests/spec.ps17
-rw-r--r--lib/chef/application.rb12
-rw-r--r--lib/chef/application/apply.rb1
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb4
-rw-r--r--lib/chef/client.rb2
-rw-r--r--lib/chef/deprecated.rb4
-rw-r--r--lib/chef/digester.rb5
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/windows_user_privilege.rb27
-rw-r--r--lib/chef/version.rb2
-rw-r--r--omnibus/Gemfile.lock72
-rw-r--r--omnibus/README.md7
-rw-r--r--omnibus/config/software/more-ruby-cleanup.rb11
-rw-r--r--omnibus/files/openssl-customization/windows/ssl_env_hack.rb4
-rw-r--r--omnibus/omnibus.rb2
-rw-r--r--spec/functional/knife/configure_spec.rb2
-rwxr-xr-xspec/functional/resource/aix_service_spec.rb10
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb2
-rw-r--r--spec/functional/resource/base.rb28
-rw-r--r--spec/functional/resource/bash_spec.rb5
-rw-r--r--spec/functional/resource/bff_spec.rb2
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb4
-rw-r--r--spec/functional/resource/cron_spec.rb11
-rw-r--r--spec/functional/resource/dnf_package_spec.rb5
-rw-r--r--spec/functional/resource/execute_spec.rb2
-rw-r--r--spec/functional/resource/group_spec.rb10
-rw-r--r--spec/functional/resource/ifconfig_spec.rb10
-rw-r--r--spec/functional/resource/insserv_spec.rb5
-rw-r--r--spec/functional/resource/link_spec.rb7
-rw-r--r--spec/functional/resource/mount_spec.rb10
-rw-r--r--spec/functional/resource/msu_package_spec.rb12
-rw-r--r--spec/functional/resource/powershell_script_spec.rb8
-rw-r--r--spec/functional/resource/remote_file_spec.rb12
-rw-r--r--spec/functional/resource/rpm_spec.rb2
-rw-r--r--spec/functional/resource/timezone_spec.rb2
-rw-r--r--spec/functional/resource/windows_package_spec.rb1
-rw-r--r--spec/functional/resource/windows_path_spec.rb4
-rw-r--r--spec/functional/resource/windows_security_policy_spec.rb1
-rw-r--r--spec/functional/resource/windows_service_spec.rb4
-rw-r--r--spec/functional/resource/windows_task_spec.rb7
-rw-r--r--spec/functional/resource/windows_user_privilege_spec.rb1
-rw-r--r--spec/functional/resource/yum_package_spec.rb5
-rw-r--r--spec/functional/resource/zypper_package_spec.rb5
-rw-r--r--spec/functional/shell_spec.rb1
-rw-r--r--spec/functional/win32/crypto_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_upload_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_from_file_spec.rb2
-rw-r--r--spec/integration/knife/environment_from_file_spec.rb2
-rw-r--r--spec/integration/knife/node_from_file_spec.rb2
-rw-r--r--spec/integration/knife/role_from_file_spec.rb2
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb4
-rw-r--r--spec/integration/recipes/resource_load_spec.rb4
-rw-r--r--spec/support/shared/functional/securable_resource.rb3
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb1
-rw-r--r--spec/support/shared/functional/windows_script.rb4
-rw-r--r--spec/support/shared/unit/provider/file.rb20
-rw-r--r--spec/unit/application/solo_spec.rb6
-rw-r--r--spec/unit/chef_fs/config_spec.rb4
-rw-r--r--spec/unit/chef_fs/diff_spec.rb17
-rw-r--r--spec/unit/client_spec.rb5
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb50
-rw-r--r--spec/unit/data_bag_spec.rb9
-rw-r--r--spec/unit/decorator_spec.rb46
-rw-r--r--spec/unit/environment_spec.rb6
-rw-r--r--spec/unit/guard_interpreter_spec.rb2
-rw-r--r--spec/unit/http/api_versions_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb4
-rw-r--r--spec/unit/knife/cookbook_show_spec.rb12
-rw-r--r--spec/unit/knife/data_bag_edit_spec.rb2
-rw-r--r--spec/unit/lwrp_spec.rb7
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb6
-rw-r--r--spec/unit/mixin/powershell_type_coercions_spec.rb2
-rw-r--r--spec/unit/mixin/subclass_directive_spec.rb4
-rw-r--r--spec/unit/mixin/unformatter_spec.rb4
-rw-r--r--spec/unit/mixin/uris_spec.rb2
-rw-r--r--spec/unit/provider/batch_spec.rb2
-rw-r--r--spec/unit/provider/cron/unix_spec.rb2
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb60
-rw-r--r--spec/unit/provider/dsc_script_spec.rb20
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/git_spec.rb6
-rw-r--r--spec/unit/provider/mdadm_spec.rb4
-rw-r--r--spec/unit/provider/package/openbsd_spec.rb2
-rw-r--r--spec/unit/provider/package/pacman_spec.rb37
-rw-r--r--spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb6
-rw-r--r--spec/unit/provider/user/dscl_spec.rb4
-rw-r--r--spec/unit/provider/windows_env_spec.rb9
-rw-r--r--spec/unit/resource/chef_client_cron_spec.rb30
-rw-r--r--spec/unit/resource/chef_client_systemd_timer_spec.rb11
-rw-r--r--spec/unit/resource/file/verification_spec.rb3
-rw-r--r--spec/unit/resource_spec.rb33
-rw-r--r--spec/unit/util/backup_spec.rb2
-rw-r--r--spec/unit/util/powershell/ps_credential_spec.rb4
-rw-r--r--spec/unit/util/selinux_spec.rb2
107 files changed, 567 insertions, 472 deletions
diff --git a/.expeditor/cleanup_orphaned_test_resources.sh b/.expeditor/cleanup_orphaned_test_resources.sh
deleted file mode 100755
index ccf1c7473a..0000000000
--- a/.expeditor/cleanup_orphaned_test_resources.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-echo "--- Setting up Azure credentials"
-export VAULT_UTIL_SECRETS="{\"ARM_TENANT_ID\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"tenant_id\"},\"ARM_CLIENT_ID\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"client_id\"},\"ARM_CLIENT_SECRET\":{\"account\":\"azure/engineering-dev-test\",\"field\":\"client_secret\"}}"
-. <(vault-util fetch-secret-env)
-
-# this allows time for the new service-principal to become available
-sleep 10
-
-az login --service-principal --tenant "$ARM_TENANT_ID" --username "$ARM_CLIENT_ID" --password "$ARM_CLIENT_SECRET"
-
-echo "--- Deleting Azure kitchen-end-to-end-windows-10 resource groups"
-az group list --query "[?starts_with(name, 'kitchen-end-to-end-windows-10-')].name" --output tsv | xargs -n1 -t -I% az group delete -y --no-wait --name "%"
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index 3323d1f470..090a31808a 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -25,10 +25,7 @@ docker_images:
pipelines:
- verify:
- definition: .expeditor/verify_public.pipeline.yml
public: true
- - verify/private:
- definition: .expeditor/verify_private.pipeline.yml
- verify/habitat:
description: >
A temporary pipeline to verify the habitat plans. Performs a local build,
@@ -69,11 +66,6 @@ github:
- chef-14:
version_constraint: 14*
-schedules:
- - name: cleanup_orphaned_test_resources
- description: Cleanup orphaned test resources
- cronline: "0 1 * * *" # every day at 1am
-
changelog:
rollup_header: Changes not yet released to stable
@@ -101,10 +93,6 @@ merge_actions:
only_if: built_in:bump_version
subscriptions:
- - workload: schedule_triggered:{{agent_id}}:cleanup_orphaned_test_resources:*
- actions:
- - bash:.expeditor/cleanup_orphaned_test_resources.sh
-
# the omnibus/docker/gem chain
- workload: artifact_published:unstable:chef:{{version_constraint}}
actions:
diff --git a/.expeditor/verify_public.pipeline.yml b/.expeditor/verify.pipeline.yml
index 7d016140cd..60142e9928 100644
--- a/.expeditor/verify_public.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -291,7 +291,7 @@ steps:
# EXTERNAL GEM TESTING
#########################################################################
-- label: "chef-sugar gem :ruby: 2.6"
+- label: "chef-sugar gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
@@ -299,9 +299,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.6
+ image: rubydistros/ubuntu-18.04:2.7
-- label: "chef-zero gem :ruby: 2.6"
+- label: "chef-zero gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
@@ -309,12 +309,12 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.6
+ image: rubydistros/ubuntu-18.04:2.7
environment:
- PEDANT_OPTS=--skip-oc_id
- CHEF_FS=true
-- label: "cheffish gem :ruby: 2.6"
+- label: "cheffish gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
@@ -324,7 +324,7 @@ steps:
docker:
image: rubydistros/ubuntu-18.04:2.6
-- label: "chefspec gem :ruby: 2.6"
+- label: "chefspec gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
@@ -332,9 +332,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.6
+ image: rubydistros/ubuntu-18.04:2.7
-- label: "knife-windows gem :ruby: 2.6"
+- label: "knife-windows gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
@@ -342,20 +342,19 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.6
+ image: rubydistros/ubuntu-18.04:2.7
-- label: "berkshelf gem :ruby: 2.6"
+- label: "berkshelf gem :ruby: 2.7"
commands:
- /workdir/scripts/bk_tests/bk_container_prep.sh
- apt-get update -y
- apt-get install -y graphviz
- - gem install bundler -v 1.17.3 # necessary for berks Gemfile.lock for now
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
- bundle exec tasks/bin/run_external_test berkshelf/berkshelf master rake
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.6
+ image: rubydistros/ubuntu-18.04:2.7
#########################################################################
# START TEST KITCHEN ONLY
diff --git a/.expeditor/verify_private.pipeline.yml b/.expeditor/verify_private.pipeline.yml
deleted file mode 100644
index 5d62c77ae3..0000000000
--- a/.expeditor/verify_private.pipeline.yml
+++ /dev/null
@@ -1,41 +0,0 @@
----
-expeditor:
- cached_folders:
- - vendor
- defaults:
- buildkite:
- retry:
- automatic:
- limit: 1
- timeout_in_minutes: 30
-
-steps:
-
-#########################################################################
- # START TEST KITCHEN ONLY
-#########################################################################
-
-- label: "Kitchen Tests Windows 10"
- commands:
- - scripts/bk_tests/bk_linux_exec.sh
- - cd kitchen-tests
- - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-windows-10
- artifact_paths:
- - $PWD/.kitchen/logs/kitchen.log
- env:
- KITCHEN_YAML: kitchen.azure.yml
- expeditor:
- executor:
- linux:
- privileged: true
- single-use: true
- secrets:
- AZURE_TENANT_ID:
- account: azure/engineering-dev-test
- field: tenant_id
- AZURE_CLIENT_ID:
- account: azure/engineering-dev-test
- field: client_id
- AZURE_CLIENT_SECRET:
- account: azure/engineering-dev-test
- field: client_secret
diff --git a/CHANGELOG.md b/CHANGELOG.md
index daa5baa233..b9cfb0d692 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,24 +1,48 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
-<!-- latest_release 16.2.56 -->
-## [v16.2.56](https://github.com/chef/chef/tree/v16.2.56) (2020-06-24)
+<!-- latest_release 16.2.74 -->
+## [v16.2.74](https://github.com/chef/chef/tree/v16.2.74) (2020-07-01)
#### Merged Pull Requests
-- consume powershell shim DLLs from hab package [#10022](https://github.com/chef/chef/pull/10022) ([mwrock](https://github.com/mwrock))
+- Reserve deprecation ID that was used in Chef-15 [#10091](https://github.com/chef/chef/pull/10091) ([lamont-granquist](https://github.com/lamont-granquist))
<!-- latest_release -->
-<!-- release_rollup since=16.2.50 -->
+<!-- release_rollup since=16.2.73 -->
### Changes not yet released to stable
#### Merged Pull Requests
-- consume powershell shim DLLs from hab package [#10022](https://github.com/chef/chef/pull/10022) ([mwrock](https://github.com/mwrock)) <!-- 16.2.56 -->
-- Inline some constants to prevent redefenition warnings in tests. [#10047](https://github.com/chef/chef/pull/10047) ([phiggins](https://github.com/phiggins)) <!-- 16.2.55 -->
-- Bump diff-lcs to get bugfix. [#10057](https://github.com/chef/chef/pull/10057) ([phiggins](https://github.com/phiggins)) <!-- 16.2.54 -->
-- Setup cspell to pull from our common dictionary [#10021](https://github.com/chef/chef/pull/10021) ([tas50](https://github.com/tas50)) <!-- 16.2.53 -->
-- Fix broken tests after updating diff-lcs dep [#10052](https://github.com/chef/chef/pull/10052) ([phiggins](https://github.com/phiggins)) <!-- 16.2.52 -->
-- More aggressively deprecate config_value [#10025](https://github.com/chef/chef/pull/10025) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.51 -->
+- Reserve deprecation ID that was used in Chef-15 [#10091](https://github.com/chef/chef/pull/10091) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 16.2.74 -->
<!-- release_rollup -->
<!-- latest_stable_release -->
+## [v16.2.73](https://github.com/chef/chef/tree/v16.2.73) (2020-07-01)
+
+#### Merged Pull Requests
+- More aggressively deprecate config_value [#10025](https://github.com/chef/chef/pull/10025) ([lamont-granquist](https://github.com/lamont-granquist))
+- Fix broken tests after updating diff-lcs dep [#10052](https://github.com/chef/chef/pull/10052) ([phiggins](https://github.com/phiggins))
+- Setup cspell to pull from our common dictionary [#10021](https://github.com/chef/chef/pull/10021) ([tas50](https://github.com/tas50))
+- Bump diff-lcs to get bugfix. [#10057](https://github.com/chef/chef/pull/10057) ([phiggins](https://github.com/phiggins))
+- Inline some constants to prevent redefenition warnings in tests. [#10047](https://github.com/chef/chef/pull/10047) ([phiggins](https://github.com/phiggins))
+- consume powershell shim DLLs from hab package [#10022](https://github.com/chef/chef/pull/10022) ([mwrock](https://github.com/mwrock))
+- Fixed broken chef-apply with -j [#10066](https://github.com/chef/chef/pull/10066) ([komazarari](https://github.com/komazarari))
+- Bump train-core to 3.3.4 [#10067](https://github.com/chef/chef/pull/10067) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot]))
+- Bump the external tests to 2.7 [#10062](https://github.com/chef/chef/pull/10062) ([lamont-granquist](https://github.com/lamont-granquist))
+- specs: Remove more methods defined on the top-level scope [#10060](https://github.com/chef/chef/pull/10060) ([phiggins](https://github.com/phiggins))
+- Update the windows_user_privilege resource to have a `:clear` action [#10063](https://github.com/chef/chef/pull/10063) ([chef-davin](https://github.com/chef-davin))
+- fix habitat based windows service tests [#10070](https://github.com/chef/chef/pull/10070) ([mwrock](https://github.com/mwrock))
+- Update ffi-libarchive for windows fixes / pin the dep [#10072](https://github.com/chef/chef/pull/10072) ([tas50](https://github.com/tas50))
+- Remove Azure private verify pipeline [#10019](https://github.com/chef/chef/pull/10019) ([christopher-snapp](https://github.com/christopher-snapp))
+- Pick some of the unit test fixes from #10068 [#10074](https://github.com/chef/chef/pull/10074) ([lamont-granquist](https://github.com/lamont-granquist))
+- Revert openssl digest update that broke FIPS [#10058](https://github.com/chef/chef/pull/10058) ([tas50](https://github.com/tas50))
+- Update tests and docs for umask on Windows. [#10077](https://github.com/chef/chef/pull/10077) ([phiggins](https://github.com/phiggins))
+- Revert &quot;Merge pull request #10052 from chef/fix-diff-tests&quot; [#10078](https://github.com/chef/chef/pull/10078) ([phiggins](https://github.com/phiggins))
+- specs: Remove test file that added a method to top-level scope. [#10027](https://github.com/chef/chef/pull/10027) ([phiggins](https://github.com/phiggins))
+- Bump inspec-core-bin to 4.21.1 [#10081](https://github.com/chef/chef/pull/10081) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot]))
+- Pin dff-lcs, bump ohai, &amp; misc omnibus updates [#10085](https://github.com/chef/chef/pull/10085) ([tas50](https://github.com/tas50))
+- Fix release build tests [#10088](https://github.com/chef/chef/pull/10088) ([phiggins](https://github.com/phiggins))
+- Fix release build tests, part 2 [#10089](https://github.com/chef/chef/pull/10089) ([phiggins](https://github.com/phiggins))
+- Fix release build tests, part 3 [#10093](https://github.com/chef/chef/pull/10093) ([phiggins](https://github.com/phiggins))
+<!-- latest_stable_release -->
+
## [v16.2.50](https://github.com/chef/chef/tree/v16.2.50) (2020-06-23)
#### Merged Pull Requests
@@ -28,7 +52,6 @@
- Add more examples to the resource code [#10020](https://github.com/chef/chef/pull/10020) ([tas50](https://github.com/tas50))
- Resource doc updates [#10024](https://github.com/chef/chef/pull/10024) ([phiggins](https://github.com/phiggins))
- Bump ohai to 16.2.1 [#10035](https://github.com/chef/chef/pull/10035) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot]))
-<!-- latest_stable_release -->
## [v16.2.44](https://github.com/chef/chef/tree/v16.2.44) (2020-06-17)
diff --git a/Dockerfile b/Dockerfile
index 46ea6a4f14..fb92e9f904 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,7 @@ LABEL maintainer="Chef Software, Inc. <docker@chef.io>"
ARG EXPEDITOR_CHANNEL
ARG CHANNEL=stable
ARG EXPEDITOR_VERSION
-ARG VERSION=16.2.50
+ARG VERSION=16.2.73
# Allow the build arg below to be controlled by either build arguments
ENV VERSION ${EXPEDITOR_VERSION:-${VERSION}}
diff --git a/Gemfile.lock b/Gemfile.lock
index 9d1ce3cf1c..bbd4aa854a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,17 +1,17 @@
GIT
remote: https://github.com/chef/chefstyle.git
- revision: 309b638d8434b8a98f7c54329947ea11c8373ef4
+ revision: d8d6cc3aa61b8ba9611be452f43618f5a6138ade
branch: master
specs:
- chefstyle (1.1.1)
- rubocop (= 0.85.1)
+ chefstyle (1.1.2)
+ rubocop (= 0.86.0)
GIT
remote: https://github.com/chef/ohai.git
- revision: 7bd12469af0ba7227d77124dce4cdf7b9051e331
+ revision: 6a5391298d6fa2f2c2e8fa9a09c31f33a1497ae0
branch: master
specs:
- ohai (16.2.1)
+ ohai (16.2.3)
chef-config (>= 12.8, < 17)
chef-utils (>= 16.0, < 17)
ffi (~> 1.9)
@@ -28,19 +28,19 @@ GIT
PATH
remote: .
specs:
- chef (16.2.56)
+ chef (16.2.74)
addressable
bcrypt_pbkdf (= 1.1.0.rc1)
bundler (>= 1.10)
- chef-config (= 16.2.56)
- chef-utils (= 16.2.56)
+ chef-config (= 16.2.74)
+ chef-utils (= 16.2.74)
chef-vault
chef-zero (>= 14.0.11)
- diff-lcs (~> 1.2, >= 1.2.4)
+ diff-lcs (>= 1.2.4, < 1.4.0)
ed25519 (~> 1.2)
erubis (~> 2.7)
ffi (>= 1.9.25)
- ffi-libarchive
+ ffi-libarchive (~> 1.0, >= 1.0.3)
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
iniparse (~> 1.4)
@@ -62,19 +62,19 @@ PATH
train-winrm (>= 0.2.5)
tty-screen (~> 0.6)
uuidtools (~> 2.1.5)
- chef (16.2.56-universal-mingw32)
+ chef (16.2.74-universal-mingw32)
addressable
bcrypt_pbkdf (= 1.1.0.rc1)
bundler (>= 1.10)
- chef-config (= 16.2.56)
- chef-utils (= 16.2.56)
+ chef-config (= 16.2.74)
+ chef-utils (= 16.2.74)
chef-vault
chef-zero (>= 14.0.11)
- diff-lcs (~> 1.2, >= 1.2.4)
+ diff-lcs (>= 1.2.4, < 1.4.0)
ed25519 (~> 1.2)
erubis (~> 2.7)
ffi (>= 1.9.25)
- ffi-libarchive
+ ffi-libarchive (~> 1.0, >= 1.0.3)
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
iniparse (~> 1.4)
@@ -112,15 +112,15 @@ PATH
PATH
remote: chef-bin
specs:
- chef-bin (16.2.56)
- chef (= 16.2.56)
+ chef-bin (16.2.74)
+ chef (= 16.2.74)
PATH
remote: chef-config
specs:
- chef-config (16.2.56)
+ chef-config (16.2.74)
addressable
- chef-utils (= 16.2.56)
+ chef-utils (= 16.2.74)
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
@@ -129,7 +129,7 @@ PATH
PATH
remote: chef-utils
specs:
- chef-utils (16.2.56)
+ chef-utils (16.2.74)
GEM
remote: https://rubygems.org/
@@ -166,7 +166,7 @@ GEM
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.3)
- diff-lcs (1.4.2)
+ diff-lcs (1.3)
ecma-re-validator (0.2.1)
regexp_parser (~> 1.2)
ed25519 (1.2.4)
@@ -180,7 +180,7 @@ GEM
ffi (1.13.1)
ffi (1.13.1-x64-mingw32)
ffi (1.13.1-x86-mingw32)
- ffi-libarchive (1.0.0)
+ ffi-libarchive (1.0.3)
ffi (~> 1.0)
ffi-win32-extensions (1.0.3)
ffi
@@ -198,7 +198,7 @@ GEM
htmlentities (4.3.4)
httpclient (2.8.3)
iniparse (1.5.0)
- inspec-core (4.20.10)
+ inspec-core (4.21.1)
addressable (~> 2.4)
chef-telemetry (~> 1.0)
faraday (>= 0.9.0)
@@ -223,11 +223,11 @@ GEM
train-core (~> 3.0)
tty-prompt (~> 0.17)
tty-table (~> 0.10)
- inspec-core-bin (4.20.10)
- inspec-core (= 4.20.10)
+ inspec-core-bin (4.21.1)
+ inspec-core (= 4.21.1)
ipaddress (0.8.3)
iso8601 (0.12.2)
- json (2.3.0)
+ json (2.3.1)
json_schemer (0.2.11)
ecma-re-validator (~> 0.2)
hana (~> 1.3)
@@ -318,16 +318,16 @@ GEM
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
- rubocop (0.85.1)
+ rubocop (0.86.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
- rubocop-ast (>= 0.0.3)
+ rubocop-ast (>= 0.0.3, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
- rubocop-ast (0.0.3)
+ rubocop-ast (0.1.0)
parser (>= 2.7.0.1)
ruby-prof (1.2.0)
ruby-progressbar (1.10.1)
@@ -353,7 +353,7 @@ GEM
tins (1.25.0)
sync
tomlrb (1.2.9)
- train-core (3.3.1)
+ train-core (3.3.4)
addressable (~> 2.5)
ffi (!= 1.13.0)
json (>= 1.8, < 3.0)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 5ca8fda4bf..8744bb4dd4 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,5 +1,17 @@
This file holds "in progress" release notes for the current release under development and is intended for consumption by the Chef Documentation team. Please see <https://docs.chef.io/release_notes/> for the official Chef release notes.
+# What's New in 16.2.72
+
+- Habitat packages for Chef Infra Client 16 are now published with full support for the `powershell_exec` helper now added.
+- Added a new `clear` action to the `windows_user_privilege` resource.
+- Resolved a regression in Chef Infra Client 16.1 and later that caused failures running on FIPS enabled systems.
+- Resolved failures in the `archive_file` resource when running on Windows hosts.
+- Resolved a failure when running `chef-apply` with the `-j` option. Thanks [@komazarari](https://github.com/komazarari).
+- Chef Infra Client running within GitHub Actions is now properly identified as running in a Docker container. Thanks [@jaymzh](http://github.com/jaymzh).
+- SSH connections are now reused, improving the speed of knife bootstrap and remote resources on slow network links. Thanks [@tecracer-theinen](https://github.com/tecracer-theinen).
+- `node['network']['interfaces']` data now correctly identifies IPv6 next hops for IPv4 routes. Thanks [@cooperlees](https://github.com/cooperlees).
+- Updated InSpec from 4.20.10 to 4.21.1.
+
# What's New in 16.2.50
- Correctly identify the new macOS Big Sur (11.0) beta as platform "mac_os_x".
diff --git a/VERSION b/VERSION
index fd167d1e60..627b27b1e1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-16.2.56 \ No newline at end of file
+16.2.74 \ No newline at end of file
diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb
index 1085441bf4..ace030ab66 100644
--- a/chef-bin/lib/chef-bin/version.rb
+++ b/chef-bin/lib/chef-bin/version.rb
@@ -21,7 +21,7 @@
module ChefBin
CHEFBIN_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "16.2.56".freeze
+ VERSION = "16.2.74".freeze
end
#
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index eafe665a32..b374ddf94e 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -15,5 +15,5 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "16.2.56".freeze
+ VERSION = "16.2.74".freeze
end
diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb
index ac03c19eae..8f18a2a8dd 100644
--- a/chef-utils/lib/chef-utils/version.rb
+++ b/chef-utils/lib/chef-utils/version.rb
@@ -15,5 +15,5 @@
module ChefUtils
CHEFUTILS_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "16.2.56".freeze
+ VERSION = "16.2.74".freeze
end
diff --git a/chef.gemspec b/chef.gemspec
index 69644f0fb5..42b7e16522 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -39,8 +39,8 @@ Gem::Specification.new do |s|
s.add_dependency "tty-screen", "~> 0.6" # knife list
s.add_dependency "pastel" # knife ui.color
s.add_dependency "erubis", "~> 2.7"
- s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4"
- s.add_dependency "ffi-libarchive"
+ s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output
+ s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3"
s.add_dependency "chef-zero", ">= 14.0.11"
s.add_dependency "chef-vault"
diff --git a/habitat/tests/spec.ps1 b/habitat/tests/spec.ps1
index ab1656b221..0229ac487f 100644
--- a/habitat/tests/spec.ps1
+++ b/habitat/tests/spec.ps1
@@ -10,6 +10,13 @@ $chef_gem_root = (hab pkg exec $PackageIdentifier gem.cmd which chef | Split-Pat
try {
Push-Location $chef_gem_root
$env:PATH = "C:\hab\bin;$env:PATH"
+
+ # Put chef's GEM_PATH in the machine environment so that the windows service
+ # tests will be able to consume the win32-service gem
+ $pkgEnv = hab pkg env $PackageIdentifier
+ $gemPath = $pkgEnv | Where-Object { $_.StartsWith("`$env:GEM_PATH=") }
+ SETX GEM_PATH $($gemPath.Split("=")[1]) /m
+
hab pkg binlink --force $PackageIdentifier
/hab/bin/rspec --format progress --tag ~executables --tag ~choco_installed spec/functional
if (-not $?) { throw "functional testing failed"}
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 0d80123bda..1e3b72e1ad 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -194,8 +194,10 @@ class Chef
chef_config[:log_location].map! do |log_location|
case log_location
when :syslog, "syslog"
+ force_force_logger
logger::Syslog.new
when :win_evt, "win_evt"
+ force_force_logger
logger::WinEvt.new
else
# should be a path or STDOUT
@@ -204,6 +206,16 @@ class Chef
end
end
+ # Force the logger by default for the :winevt and :syslog loggers. Since we do not and cannot
+ # support multiple log levels in a mix-and-match situation with formatters and loggers, and the
+ # formatters do not support syslog, we force the formatter off by default and the log level is
+ # thus info by default. Users can add `--force-formatter -l info` to get back formatter output
+ # on STDOUT along with syslog logging.
+ #
+ def force_force_logger
+ chef_config[:force_logger] = true unless chef_config[:force_formatter]
+ end
+
# Use of output formatters is assumed if `force_formatter` is set or if `force_logger` is not set
def using_output_formatter?
chef_config[:force_formatter] || !chef_config[:force_logger]
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 4ed2d2a1f2..c8c0c0eaf6 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -21,6 +21,7 @@ require_relative "../../chef"
require_relative "../application"
require_relative "../client"
require_relative "../config"
+require_relative "../config_fetcher"
require_relative "../log"
require "fileutils" unless defined?(FileUtils)
require "tempfile" unless defined?(Tempfile)
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
index 1a81676c26..c49ed51d81 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
@@ -18,7 +18,7 @@
require_relative "../base_fs_object"
require_relative "../../../http/simple"
-require "openssl" unless defined?(OpenSSL)
+require "digest" unless defined?(Digest)
class Chef
module ChefFS
@@ -69,7 +69,7 @@ class Chef
private
def calc_checksum(value)
- OpenSSL::Digest.hexdigest("MD5", value)
+ ::Digest::MD5.hexdigest(value)
end
end
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index a43740258d..b6f9958d64 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -343,7 +343,7 @@ class Chef
formatters_for_run.map do |formatter_name, output_path|
if output_path.nil?
Chef::Formatters.new(formatter_name, STDOUT_FD, STDERR_FD)
- else
+ elsif output_path.is_a?(String)
io = File.open(output_path, "a+")
io.sync = true
Chef::Formatters.new(formatter_name, io, io)
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index d67cee8153..4a2ac69b04 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -241,6 +241,10 @@ class Chef
target 30
end
+ class ResourceNameWithoutProvides < Base
+ target 31
+ end
+
class Generic < Base
def url
"https://docs.chef.io/chef_deprecations_client/"
diff --git a/lib/chef/digester.rb b/lib/chef/digester.rb
index 2f6869728c..b9180ddd24 100644
--- a/lib/chef/digester.rb
+++ b/lib/chef/digester.rb
@@ -19,6 +19,7 @@
#
require "openssl" unless defined?(OpenSSL)
+require "digest" unless defined?(Digest)
require "singleton" unless defined?(Singleton)
class Chef
@@ -50,11 +51,11 @@ class Chef
end
def generate_md5_checksum_for_file(file)
- checksum_file(file, OpenSSL::Digest.new("MD5"))
+ checksum_file(file, ::Digest::MD5.new)
end
def generate_md5_checksum(io)
- checksum_io(io, OpenSSL::Digest.new("MD5"))
+ checksum_io(io, ::Digest::MD5.new)
end
private
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 37e964a243..bd6757c6f7 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -460,7 +460,7 @@ class Chef
property :umask, String,
desired_state: false,
introduced: "16.2",
- description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask."
+ description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask. Unsupported on Windows because Windows lacks a direct equivalent to UNIX's umask."
# The time it took (in seconds) to run the most recently-run action. Not
# cumulative across actions. This is set to 0 as soon as a new action starts
diff --git a/lib/chef/resource/windows_user_privilege.rb b/lib/chef/resource/windows_user_privilege.rb
index aeff7ad468..c6d7a16346 100644
--- a/lib/chef/resource/windows_user_privilege.rb
+++ b/lib/chef/resource/windows_user_privilege.rb
@@ -112,6 +112,15 @@ class Chef
action :remove
end
```
+
+ **Clear all users from the SeDenyNetworkLogonRight Privilege**:
+
+ ```ruby
+ windows_user_privilege 'Allow any user the Network Logon right' do
+ privilege 'SeDenyNetworkLogonRight'
+ action :clear
+ end
+ ```
DOC
property :principal, String,
@@ -132,8 +141,8 @@ class Chef
}
load_current_value do |new_resource|
- unless new_resource.principal.nil?
- privilege Chef::ReservedNames::Win32::Security.get_account_right(new_resource.principal) unless new_resource.action.include?(:set)
+ if new_resource.principal && (new_resource.action.include?(:add) || new_resource.action.include?(:remove))
+ privilege Chef::ReservedNames::Win32::Security.get_account_right(new_resource.principal)
end
end
@@ -180,6 +189,20 @@ class Chef
end
end
+ action :clear do
+ new_resource.privilege.each do |privilege|
+ accounts = Chef::ReservedNames::Win32::Security.get_account_with_user_rights(privilege)
+
+ # comparing the existing accounts for privilege with users
+ # Removing only accounts which is not matching with users in new_resource
+ accounts.each do |account|
+ converge_by("removing user '#{account}' from privilege #{privilege}") do
+ Chef::ReservedNames::Win32::Security.remove_account_right(account, privilege)
+ end
+ end
+ end
+ end
+
action :remove do
curr_res_privilege = current_resource.privilege
missing_res_privileges = (new_resource.privilege - curr_res_privilege)
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 42ef2513bd..f98f3d2bfc 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require_relative "version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("16.2.56")
+ VERSION = Chef::VersionString.new("16.2.74")
end
#
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index 87bf6688c3..696331c372 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/chef/omnibus
- revision: d75718522deb9faeb3c21b50c60e94daf70ce9b6
+ revision: 320d9350cdf39abdcc4c37d5bc2971b3c222a0a0
branch: master
specs:
- omnibus (7.0.13)
+ omnibus (7.0.14)
aws-sdk-s3 (~> 1)
chef-cleanroom (~> 1.0)
chef-sugar (>= 3.3)
@@ -18,7 +18,7 @@ GIT
GIT
remote: https://github.com/chef/omnibus-software
- revision: 86a1c7ebb859161385676e3bfe537e13ba680f59
+ revision: 2cf96c6c07de7d05ded6b45a0531feb10ae7cd9e
branch: master
specs:
omnibus-software (4.0.0)
@@ -32,26 +32,26 @@ GEM
artifactory (3.0.15)
awesome_print (1.8.0)
aws-eventstream (1.1.0)
- aws-partitions (1.329.0)
- aws-sdk-core (3.100.0)
+ aws-partitions (1.337.0)
+ aws-sdk-core (3.102.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
- aws-sdk-kms (1.34.1)
+ aws-sdk-kms (1.35.0)
aws-sdk-core (~> 3, >= 3.99.0)
aws-sigv4 (~> 1.1)
- aws-sdk-s3 (1.68.1)
- aws-sdk-core (~> 3, >= 3.99.0)
+ aws-sdk-s3 (1.72.0)
+ aws-sdk-core (~> 3, >= 3.102.1)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
- aws-sigv4 (1.1.4)
- aws-eventstream (~> 1.0, >= 1.0.2)
+ aws-sigv4 (1.2.1)
+ aws-eventstream (~> 1, >= 1.0.2)
bcrypt_pbkdf (1.1.0.rc1)
bcrypt_pbkdf (1.1.0.rc1-x64-mingw32)
bcrypt_pbkdf (1.1.0.rc1-x86-mingw32)
- berkshelf (7.0.10)
- chef (>= 13.6.52)
+ berkshelf (7.1.0)
+ chef (>= 15.7.32)
chef-config
cleanroom (~> 1.0)
concurrent-ruby (~> 1.0)
@@ -64,18 +64,18 @@ GEM
solve (~> 4.0)
thor (>= 0.20)
builder (3.2.4)
- chef (16.1.16)
+ chef (16.2.50)
addressable
bcrypt_pbkdf (= 1.1.0.rc1)
bundler (>= 1.10)
- chef-config (= 16.1.16)
- chef-utils (= 16.1.16)
+ chef-config (= 16.2.50)
+ chef-utils (= 16.2.50)
chef-vault
chef-zero (>= 14.0.11)
diff-lcs (~> 1.2, >= 1.2.4)
ed25519 (~> 1.2)
erubis (~> 2.7)
- ffi (~> 1.9, >= 1.9.25)
+ ffi (>= 1.9.25)
ffi-libarchive
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
@@ -86,8 +86,8 @@ GEM
mixlib-cli (>= 2.1.1, < 3.0)
mixlib-log (>= 2.0.3, < 4.0)
mixlib-shellout (>= 3.0.3, < 4.0)
- net-sftp (~> 2.1, >= 2.1.2)
- net-ssh (>= 4.2, < 6)
+ net-sftp (>= 2.1.2, < 4.0)
+ net-ssh (>= 4.2, < 7)
net-ssh-multi (~> 1.2, >= 1.2.1)
ohai (~> 16.0)
pastel
@@ -98,18 +98,18 @@ GEM
train-winrm (>= 0.2.5)
tty-screen (~> 0.6)
uuidtools (~> 2.1.5)
- chef (16.1.16-universal-mingw32)
+ chef (16.2.50-universal-mingw32)
addressable
bcrypt_pbkdf (= 1.1.0.rc1)
bundler (>= 1.10)
- chef-config (= 16.1.16)
- chef-utils (= 16.1.16)
+ chef-config (= 16.2.50)
+ chef-utils (= 16.2.50)
chef-vault
chef-zero (>= 14.0.11)
diff-lcs (~> 1.2, >= 1.2.4)
ed25519 (~> 1.2)
erubis (~> 2.7)
- ffi (~> 1.9, >= 1.9.25)
+ ffi (>= 1.9.25)
ffi-libarchive
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
@@ -121,8 +121,8 @@ GEM
mixlib-cli (>= 2.1.1, < 3.0)
mixlib-log (>= 2.0.3, < 4.0)
mixlib-shellout (>= 3.0.3, < 4.0)
- net-sftp (~> 2.1, >= 2.1.2)
- net-ssh (>= 4.2, < 6)
+ net-sftp (>= 2.1.2, < 4.0)
+ net-ssh (>= 4.2, < 7)
net-ssh-multi (~> 1.2, >= 1.2.1)
ohai (~> 16.0)
pastel
@@ -145,15 +145,15 @@ GEM
win32-taskscheduler (~> 2.0)
wmi-lite (~> 1.0)
chef-cleanroom (1.0.2)
- chef-config (16.1.16)
+ chef-config (16.2.50)
addressable
- chef-utils (= 16.1.16)
+ chef-utils (= 16.2.50)
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-sugar (5.1.9)
- chef-utils (16.1.16)
+ chef-utils (16.2.50)
chef-vault (4.0.1)
chef-zero (15.0.0)
ffi-yajl (~> 2.2)
@@ -164,7 +164,7 @@ GEM
citrus (3.0.2)
cleanroom (1.0.0)
concurrent-ruby (1.1.6)
- diff-lcs (1.3)
+ diff-lcs (1.4.3)
ed25519 (1.2.4)
equatable (0.6.1)
erubi (1.9.0)
@@ -174,7 +174,7 @@ GEM
ffi (1.13.1)
ffi (1.13.1-x64-mingw32)
ffi (1.13.1-x86-mingw32)
- ffi-libarchive (1.0.0)
+ ffi-libarchive (1.0.3)
ffi (~> 1.0)
ffi-win32-extensions (1.0.3)
ffi
@@ -191,9 +191,9 @@ GEM
iniparse (1.5.0)
iostruct (0.0.4)
ipaddress (0.8.3)
- iso8601 (0.12.1)
+ iso8601 (0.12.2)
jmespath (1.4.0)
- json (2.3.0)
+ json (2.3.1)
kitchen-vagrant (1.6.1)
test-kitchen (>= 1.4, < 3)
libyajl2 (1.2.0)
@@ -235,9 +235,9 @@ GEM
necromancer (0.5.1)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
- net-sftp (2.1.2)
- net-ssh (>= 2.6.5)
- net-ssh (5.2.0)
+ net-sftp (3.0.0)
+ net-ssh (>= 5.0.0, < 7.0.0)
+ net-ssh (6.1.0)
net-ssh-gateway (2.0.0)
net-ssh (>= 4.0.0)
net-ssh-multi (1.2.1)
@@ -247,7 +247,7 @@ GEM
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
- ohai (16.1.1)
+ ohai (16.2.1)
chef-config (>= 12.8, < 17)
chef-utils (>= 16.0, < 17)
ffi (~> 1.9)
@@ -312,7 +312,7 @@ GEM
toml-rb (2.0.1)
citrus (~> 3.0, > 3.0)
tomlrb (1.3.0)
- train-core (3.3.1)
+ train-core (3.3.4)
addressable (~> 2.5)
ffi (!= 1.13.0)
json (>= 1.8, < 3.0)
diff --git a/omnibus/README.md b/omnibus/README.md
index 6e49f091a5..a10190c136 100644
--- a/omnibus/README.md
+++ b/omnibus/README.md
@@ -1,17 +1,16 @@
-# Client Tools Omnibus project
+# Chef Infra Client Omnibus project
This project creates full-stack platform-specific packages for the following projects:
- AngryChef
- Chef
-- Chef with FIPS enabled
## Installation
You must have a sane Ruby environment with Bundler installed. Ensure all the required gems are installed:
```shell
-$ bundle install --without development
+bundle install --without development
```
## Usage
@@ -117,7 +116,7 @@ For a complete list of all commands and platforms, run `kitchen list` or `kitche
## License
```text
-Copyright 2012-2018, Chef Software, Inc.
+Copyright:: Chef Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/omnibus/config/software/more-ruby-cleanup.rb b/omnibus/config/software/more-ruby-cleanup.rb
index f5af0501cd..f83e210512 100644
--- a/omnibus/config/software/more-ruby-cleanup.rb
+++ b/omnibus/config/software/more-ruby-cleanup.rb
@@ -24,6 +24,8 @@ license :project_license
source path: "#{project.files_path}/#{name}"
+dependency "ruby"
+
build do
block "Removing console and setup binaries" do
Dir.glob("#{install_dir}/embedded/lib/ruby/gems/*/gems/*/bin/{console,setup}").each do |f|
@@ -31,9 +33,14 @@ build do
FileUtils.rm_rf(f)
end
end
-end
-build do
+ block "remove any .gitkeep files" do
+ Dir.glob("#{install_dir}/**/{.gitkeep,.keep}").each do |f|
+ puts "Deleting #{f}"
+ File.delete(f)
+ end
+ end
+
block "Removing additional non-code files from installed gems" do
# find the embedded ruby gems dir and clean it up for globbing
target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/")
diff --git a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
index eaa5949f2d..b86c17db82 100644
--- a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
+++ b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb
@@ -16,8 +16,8 @@
#
# This script sets the SSL_CERT_FILE environment variable to the CA cert bundle
-# that ships with omnibus packages of Chef and Chef DK. If this environment
-# variable is already configured, this script is a no-op.
+# that ships with omnibus packages of Chef Infra Client and Chef Workstation. If
+# this environment variable is already configured, this script is a no-op.
#
# This is required to make Chef tools use https URLs out of the box.
diff --git a/omnibus/omnibus.rb b/omnibus/omnibus.rb
index e839174138..c04c3a87a0 100644
--- a/omnibus/omnibus.rb
+++ b/omnibus/omnibus.rb
@@ -1,5 +1,5 @@
#
-# This file is used to configure the Omnibus projects in this repo. It contains
+# This file is used to configure the Chef Infra Client project. It contains
# some minimal configuration examples for working with Omnibus. For a full list
# of configurable options, please see the documentation for +omnibus/config.rb+.
#
diff --git a/spec/functional/knife/configure_spec.rb b/spec/functional/knife/configure_spec.rb
index 78e2e801bc..8f2a5b4d6e 100644
--- a/spec/functional/knife/configure_spec.rb
+++ b/spec/functional/knife/configure_spec.rb
@@ -21,7 +21,7 @@ require "spec_helper"
require "chef/knife/configure"
describe "knife configure" do
- let (:ohai) do
+ let(:ohai) do
OHAI_SYSTEM
end
diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb
index 0bc3dd2aad..e7e6d0e822 100755
--- a/spec/functional/resource/aix_service_spec.rb
+++ b/spec/functional/resource/aix_service_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
shared_examples "src service" do
@@ -80,6 +79,15 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
shell_out("id -u #{ENV["USER"]}").stdout.chomp
end
+ let(:run_context) do
+ node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ end
+
describe "When service is a subsystem" do
before(:all) do
script_dir = File.join(File.dirname(__FILE__), "/../assets/")
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index ed99472df3..bb89277e40 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
require "fileutils"
@@ -57,6 +56,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
# Actual tests
let(:new_resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
new_resource = Chef::Resource::Service.new("chefinittest", run_context)
new_resource.provider Chef::Provider::Service::AixInit
new_resource.supports({ status: true, restart: true, reload: true })
diff --git a/spec/functional/resource/base.rb b/spec/functional/resource/base.rb
deleted file mode 100644
index df7eb3ed5d..0000000000
--- a/spec/functional/resource/base.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
-# Copyright:: Copyright (c) Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-def run_context
- @run_context ||= begin
- node = Chef::Node.new
- node.default[:platform] = ohai[:platform]
- node.default[:platform_version] = ohai[:platform_version]
- node.default[:os] = ohai[:os]
- events = Chef::EventDispatch::Dispatcher.new
- Chef::RunContext.new(node, {}, events)
- end
-end
diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb
index acebc312ee..abb88f499f 100644
--- a/spec/functional/resource/bash_spec.rb
+++ b/spec/functional/resource/bash_spec.rb
@@ -17,18 +17,19 @@
#
require "spec_helper"
-require "functional/resource/base"
describe Chef::Resource::Bash, :unix_only do
let(:code) { "echo hello" }
let(:resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+
resource = Chef::Resource::Bash.new("foo_resource", run_context)
resource.code(code) unless code.nil?
resource
end
describe "when setting the command property" do
- let (:command) { "wizard racket" }
+ let(:command) { "wizard racket" }
it "should raise an exception when trying to set the command" do
expect { resource.command command }.to raise_error(Chef::Exceptions::Script)
diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb
index 4368824067..ad45552c16 100644
--- a/spec/functional/resource/bff_spec.rb
+++ b/spec/functional/resource/bff_spec.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-require "functional/resource/base"
require "chef/mixin/shell_out"
# Run the test only for AIX platform.
@@ -24,6 +23,7 @@ describe Chef::Resource::BffPackage, :requires_root, external: ohai[:platform] !
include Chef::Mixin::ShellOut
let(:new_resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
new_resource = Chef::Resource::BffPackage.new(@pkg_name, run_context)
new_resource.source @pkg_path
new_resource
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index e8b175f487..24975d2e01 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -25,6 +25,10 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
subject do
new_resource = Chef::Resource::ChocolateyPackage.new("test choco package", run_context)
new_resource.package_name package_name
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb
index ed4905b980..bd75a86558 100644
--- a/spec/functional/resource/cron_spec.rb
+++ b/spec/functional/resource/cron_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
describe Chef::Resource::Cron, :requires_root, :unix_only do
@@ -53,6 +52,16 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
end
# Actual tests
+
+ let(:run_context) do
+ node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ end
+
let(:new_resource) do
new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context)
new_resource.user "root"
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index d8618a5dee..eef0d6296b 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -16,7 +16,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
# run this test only for following platforms.
@@ -66,6 +65,10 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
end
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
let(:package_name) { "chef_rpm" }
let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) }
diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb
index 874e2e5a41..3d7e185e17 100644
--- a/spec/functional/resource/execute_spec.rb
+++ b/spec/functional/resource/execute_spec.rb
@@ -17,11 +17,11 @@
#
require "spec_helper"
-require "functional/resource/base"
require "timeout"
describe Chef::Resource::Execute do
let(:resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
resource = Chef::Resource::Execute.new("foo_resource", run_context)
resource.command("echo hello")
resource
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 540e51f1e4..8fca689e68 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
describe Chef::Resource::Group, :requires_root_or_running_windows do
@@ -113,6 +112,15 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
# TODO: User shouldn't exist
end
+ let(:run_context) do
+ node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ end
+
shared_examples_for "correct group management" do
def add_members_to_group(members)
temp_resource = group_resource.dup
diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb
index a37dfac668..127e4e6331 100644
--- a/spec/functional/resource/ifconfig_spec.rb
+++ b/spec/functional/resource/ifconfig_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
# run this test only for following platforms.
@@ -26,6 +25,15 @@ include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai
describe Chef::Resource::Ifconfig, :requires_root, :requires_ifconfig, external: include_flag do
include Chef::Mixin::ShellOut
+ let(:run_context) do
+ node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ end
+
let(:new_resource) do
new_resource = Chef::Resource::Ifconfig.new("10.10.0.1", run_context)
new_resource
diff --git a/spec/functional/resource/insserv_spec.rb b/spec/functional/resource/insserv_spec.rb
index 6d66516bab..788a46469b 100644
--- a/spec/functional/resource/insserv_spec.rb
+++ b/spec/functional/resource/insserv_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
require "fileutils"
@@ -54,6 +53,8 @@ describe Chef::Resource::Service, :requires_root, :opensuse do
# Actual tests
let(:new_resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+
new_resource = Chef::Resource::Service.new("inittest", run_context)
new_resource.provider Chef::Provider::Service::Insserv
new_resource.supports({ status: true, restart: true, reload: true })
@@ -65,7 +66,7 @@ describe Chef::Resource::Service, :requires_root, :opensuse do
provider
end
- let (:service_name) { "Chef::Util::PathHelper.escape_glob_dir(current_resource.service_name)" }
+ let(:service_name) { "Chef::Util::PathHelper.escape_glob_dir(current_resource.service_name)" }
let(:current_resource) do
provider.load_current_resource
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index 24a1f5cd7b..c9177ebc77 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -64,13 +64,10 @@ describe Chef::Resource::Link do
end
end
- def node
+ def user(user)
node = Chef::Node.new
node.consume_external_attrs(ohai.data, {})
- node
- end
-
- def user(user)
+ run_context = Chef::RunContext.new(node, {}, Chef::EventDispatch::Dispatcher.new)
usr = Chef::Resource.resource_for_node(:user, node).new(user, run_context)
usr.password("ComplexPass11!") if windows?
usr
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index abaf74a506..55738a4326 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
require "tmpdir"
@@ -101,6 +100,15 @@ describe Chef::Resource::Mount, :requires_root, external: include_flag do
expect(shell_out("cat #{unix_mount_config_file}").stdout).not_to include("#{mount_point}:")
end
+ let(:run_context) do
+ node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ end
+
let(:new_resource) do
new_resource = Chef::Resource::Mount.new(@mount_point, run_context)
new_resource.device @device
diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb
index 1161049571..2e6fcdcbca 100644
--- a/spec/functional/resource/msu_package_spec.rb
+++ b/spec/functional/resource/msu_package_spec.rb
@@ -26,11 +26,17 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" }
let(:timeout) { 3600 }
- let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") }
- let(:cab_provider) do
+ let(:run_context) do
node = Chef::Node.new
+ node.default[:platform] = ohai[:platform]
+ node.default[:platform_version] = ohai[:platform_version]
+ node.default[:os] = ohai[:os]
events = Chef::EventDispatch::Dispatcher.new
- run_context = Chef::RunContext.new(node, {}, events)
+ Chef::RunContext.new(node, {}, events)
+ end
+
+ let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") }
+ let(:cab_provider) do
Chef::Provider::Package::Cab.new(new_resource, run_context)
end
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index b74cfc6116..5e8a00fd4d 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -23,8 +23,8 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
include_context Chef::Resource::WindowsScript
- let (:architecture_command) { "echo $env:PROCESSOR_ARCHITECTURE" }
- let (:output_command) { " | out-file -encoding ASCII " }
+ let(:architecture_command) { "echo $env:PROCESSOR_ARCHITECTURE" }
+ let(:output_command) { " | out-file -encoding ASCII " }
it_behaves_like "a Windows script running on Windows"
@@ -68,8 +68,8 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
end
end
- let (:negative_exit_status) { -27 }
- let (:unsigned_exit_status) { (-negative_exit_status ^ 65535) + 1 }
+ let(:negative_exit_status) { -27 }
+ let(:unsigned_exit_status) { (-negative_exit_status ^ 65535) + 1 }
it "returns the exit status -27 as a signed integer or an unsigned 16-bit 2's complement value of 65509 for a powershell script that exits with -27" do
# Versions of PowerShell prior to 4.0 return a 16-bit unsigned value --
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index a5ae59d876..f4a3d5346d 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -229,8 +229,8 @@ describe Chef::Resource::RemoteFile do
end
context "when the resource is accessed using an alternate user's identity with no access to the file" do
- let (:windows_nonadmin_user) { "chefremfile1" }
- let (:windows_nonadmin_user_password) { "j82ajfxK3;2Xe1" }
+ let(:windows_nonadmin_user) { "chefremfile1" }
+ let(:windows_nonadmin_user_password) { "j82ajfxK3;2Xe1" }
include_context "a non-admin Windows user"
before do
@@ -246,8 +246,8 @@ describe Chef::Resource::RemoteFile do
end
context "when the the file is only accessible as a specific alternate identity" do
- let (:windows_nonadmin_user) { "chefremfile2" }
- let (:windows_nonadmin_user_password) { "j82ajfxK3;2Xe2" }
+ let(:windows_nonadmin_user) { "chefremfile2" }
+ let(:windows_nonadmin_user_password) { "j82ajfxK3;2Xe2" }
include_context "a non-admin Windows user"
before do
@@ -279,8 +279,8 @@ describe Chef::Resource::RemoteFile do
end
context "when the resource is accessed using an alternate user's identity with no access to the file" do
- let (:windows_nonadmin_user) { "chefremfile3" }
- let (:windows_nonadmin_user_password) { "j82ajfxK3;2Xe3" }
+ let(:windows_nonadmin_user) { "chefremfile3" }
+ let(:windows_nonadmin_user_password) { "j82ajfxK3;2Xe3" }
include_context "a non-admin Windows user"
let(:remote_user) { windows_nonadmin_user_qualified }
diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb
index 6e0c5a18cb..8a6cf32882 100644
--- a/spec/functional/resource/rpm_spec.rb
+++ b/spec/functional/resource/rpm_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
# run this test only for following platforms.
@@ -26,6 +25,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
include Chef::Mixin::ShellOut
let(:new_resource) do
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
new_resource = Chef::Resource::RpmPackage.new(@pkg_name, run_context)
new_resource.source @pkg_path
new_resource
diff --git a/spec/functional/resource/timezone_spec.rb b/spec/functional/resource/timezone_spec.rb
index d144bea284..d44d5b34a8 100644
--- a/spec/functional/resource/timezone_spec.rb
+++ b/spec/functional/resource/timezone_spec.rb
@@ -21,6 +21,8 @@ describe Chef::Resource::Timezone, :windows_only do
let(:timezone) { "GMT Standard Time" }
def timezone_resource
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+
Chef::Resource::Timezone.new(timezone, run_context)
end
diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb
index 3d75913ed1..3294e1c509 100644
--- a/spec/functional/resource/windows_package_spec.rb
+++ b/spec/functional/resource/windows_package_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
let(:pkg_name) { nil }
diff --git a/spec/functional/resource/windows_path_spec.rb b/spec/functional/resource/windows_path_spec.rb
index 14e4ad8869..b2a3e5f5a4 100644
--- a/spec/functional/resource/windows_path_spec.rb
+++ b/spec/functional/resource/windows_path_spec.rb
@@ -21,6 +21,10 @@ require "spec_helper"
describe Chef::Resource::WindowsPath, :windows_only do
let(:path) { "test_path" }
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
before(:all) do
@old_path = ENV["PATH"].dup
end
diff --git a/spec/functional/resource/windows_security_policy_spec.rb b/spec/functional/resource/windows_security_policy_spec.rb
index cc225eec74..1a6b697bfa 100644
--- a/spec/functional/resource/windows_security_policy_spec.rb
+++ b/spec/functional/resource/windows_security_policy_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/powershell_out"
describe Chef::Resource::WindowsSecurityPolicy, :windows_only do
diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb
index 195a974aa1..4c0c3acb58 100644
--- a/spec/functional/resource/windows_service_spec.rb
+++ b/spec/functional/resource/windows_service_spec.rb
@@ -62,6 +62,10 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_
r
end
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
before do
user_resource.run_action(:create)
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 84993cac0e..196e627272 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -25,12 +25,13 @@ describe Chef::Resource::WindowsTask, :windows_only do
let(:task_name) { "chef-client-functional-test" }
let(:new_resource) { Chef::Resource::WindowsTask.new(task_name) }
let(:windows_task_provider) do
- node = Chef::Node.new
- events = Chef::EventDispatch::Dispatcher.new
- run_context = Chef::RunContext.new(node, {}, events)
Chef::Provider::WindowsTask.new(new_resource, run_context)
end
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
describe "action :create" do
after { delete_task }
context "when command is with arguments" do
diff --git a/spec/functional/resource/windows_user_privilege_spec.rb b/spec/functional/resource/windows_user_privilege_spec.rb
index 115887e3e5..e30971d2e6 100644
--- a/spec/functional/resource/windows_user_privilege_spec.rb
+++ b/spec/functional/resource/windows_user_privilege_spec.rb
@@ -16,7 +16,6 @@
#
require_relative "../../spec_helper"
-require_relative "../../functional/resource/base"
describe Chef::Resource::WindowsUserPrivilege, :windows_only do
let(:principal) { nil }
diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb
index 72e0a295b8..5f902cff17 100644
--- a/spec/functional/resource/yum_package_spec.rb
+++ b/spec/functional/resource/yum_package_spec.rb
@@ -16,7 +16,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
# run this test only for following platforms.
@@ -64,6 +63,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
end
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
let(:package_name) { "chef_rpm" }
let(:yum_package) do
r = Chef::Resource::YumPackage.new(package_name, run_context)
diff --git a/spec/functional/resource/zypper_package_spec.rb b/spec/functional/resource/zypper_package_spec.rb
index 31168d9fe8..e56684b6f8 100644
--- a/spec/functional/resource/zypper_package_spec.rb
+++ b/spec/functional/resource/zypper_package_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/mixin/shell_out"
describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
@@ -52,6 +51,10 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
FileUtils.rm_f "/etc/zypp/repos.d/chef-zypp-localtesting.repo"
end
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
let(:package_name) { "chef_rpm" }
let(:zypper_package) do
r = Chef::Resource::ZypperPackage.new(package_name, run_context)
diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb
index d6dc6d8a08..583440d2b6 100644
--- a/spec/functional/shell_spec.rb
+++ b/spec/functional/shell_spec.rb
@@ -17,7 +17,6 @@
#
require "spec_helper"
-require "functional/resource/base"
require "chef/version"
require "chef/shell"
diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb
index c120132217..b0f2d3af5d 100644
--- a/spec/functional/win32/crypto_spec.rb
+++ b/spec/functional/win32/crypto_spec.rb
@@ -32,7 +32,7 @@ describe "Chef::ReservedNames::Win32::Crypto", :windows_only do
@run_context = Chef::RunContext.new(new_node, {}, events)
end
- let (:plaintext) { "p@assword" }
+ let(:plaintext) { "p@assword" }
it "can be decrypted by powershell" do
encrypted = Chef::ReservedNames::Win32::Crypto.encrypt(plaintext)
diff --git a/spec/integration/knife/cookbook_upload_spec.rb b/spec/integration/knife/cookbook_upload_spec.rb
index d8077ac2c6..79a9efbfb7 100644
--- a/spec/integration/knife/cookbook_upload_spec.rb
+++ b/spec/integration/knife/cookbook_upload_spec.rb
@@ -25,7 +25,7 @@ describe "knife cookbook upload", :workstation do
include_context "default config options"
- let (:cb_dir) { "#{@repository_dir}/cookbooks" }
+ let(:cb_dir) { "#{@repository_dir}/cookbooks" }
when_the_chef_server "is empty" do
when_the_repository "has a cookbook" do
diff --git a/spec/integration/knife/data_bag_from_file_spec.rb b/spec/integration/knife/data_bag_from_file_spec.rb
index ee5757bebd..93801226d0 100644
--- a/spec/integration/knife/data_bag_from_file_spec.rb
+++ b/spec/integration/knife/data_bag_from_file_spec.rb
@@ -24,7 +24,7 @@ describe "knife data bag from file", :workstation do
include_context "default config options"
- let (:db_dir) { "#{@repository_dir}/data_bags" }
+ let(:db_dir) { "#{@repository_dir}/data_bags" }
when_the_chef_server "has an empty data bag" do
before do
diff --git a/spec/integration/knife/environment_from_file_spec.rb b/spec/integration/knife/environment_from_file_spec.rb
index 2eafa5a935..f9d35f4d47 100644
--- a/spec/integration/knife/environment_from_file_spec.rb
+++ b/spec/integration/knife/environment_from_file_spec.rb
@@ -24,7 +24,7 @@ describe "knife environment from file", :workstation do
# include_context "default config options"
- let (:env_dir) { "#{@repository_dir}/environments" }
+ let(:env_dir) { "#{@repository_dir}/environments" }
when_the_chef_server "is empty" do
when_the_repository "has some environments" do
diff --git a/spec/integration/knife/node_from_file_spec.rb b/spec/integration/knife/node_from_file_spec.rb
index c3ecaf4af8..6f7e0780f0 100644
--- a/spec/integration/knife/node_from_file_spec.rb
+++ b/spec/integration/knife/node_from_file_spec.rb
@@ -24,7 +24,7 @@ describe "knife node from file", :workstation do
# include_context "default config options"
- let (:node_dir) { "#{@repository_dir}/nodes" }
+ let(:node_dir) { "#{@repository_dir}/nodes" }
when_the_chef_server "is empty" do
when_the_repository "has some nodes" do
diff --git a/spec/integration/knife/role_from_file_spec.rb b/spec/integration/knife/role_from_file_spec.rb
index 395528937a..4a2912935c 100644
--- a/spec/integration/knife/role_from_file_spec.rb
+++ b/spec/integration/knife/role_from_file_spec.rb
@@ -24,7 +24,7 @@ describe "knife role from file", :workstation do
# include_context "default config options"
- let (:role_dir) { "#{@repository_dir}/roles" }
+ let(:role_dir) { "#{@repository_dir}/roles" }
when_the_chef_server "is empty" do
when_the_repository "has some roles" do
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index b939317c62..7db5599db5 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -1233,6 +1233,10 @@ describe "Recipe DSL methods" do
before { Namer.current_index += 1 }
context "with an LWRP that declares actions" do
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
let(:resource_class) do
Class.new(Chef::Resource::LWRPBase) do
provides :"recipe_dsl_spec#{Namer.current_index}"
diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb
index 52a108a766..dec482f5c9 100644
--- a/spec/integration/recipes/resource_load_spec.rb
+++ b/spec/integration/recipes/resource_load_spec.rb
@@ -119,10 +119,10 @@ describe "Resource.load_current_value" do
end
end
- let (:subresource_name) do
+ let(:subresource_name) do
:"load_current_value_subresource_dsl#{Namer.current_index}"
end
- let (:subresource_class) do
+ let(:subresource_class) do
r = Class.new(resource_class) do
property :y, default: lazy { "default_y #{Namer.incrementing_value}" }
end
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 23e95732c9..26f2b1cc5a 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -19,7 +19,6 @@
#
require "etc"
-require "functional/resource/base"
shared_context "setup correct permissions" do
if windows?
@@ -135,7 +134,7 @@ shared_context "use Windows permissions", :windows_only do
}
end
- let (:write_flag) { 3 }
+ let(:write_flag) { 3 }
RSpec::Matchers.define :have_expected_properties do |mask, type, flags|
match do |ace|
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index abeb1ba4bb..6f816265bf 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -1,5 +1,4 @@
-require "functional/resource/base"
ALL_EXPANDED_PERMISSIONS = ["generic read",
"generic write",
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index 7747524d03..3ccb7b6e37 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -91,7 +91,7 @@ shared_context Chef::Resource::WindowsScript do
end
context "when the guard's architecture is specified as 64-bit" do
- let (:guard_architecture) { :x86_64 }
+ let(:guard_architecture) { :x86_64 }
it "executes a 64-bit guard", :windows64_only do
resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
@@ -100,7 +100,7 @@ shared_context Chef::Resource::WindowsScript do
end
context "when the guard's architecture is specified as 32-bit" do
- let (:guard_architecture) { :i386 }
+ let(:guard_architecture) { :i386 }
it "executes a 32-bit guard" do
resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 509ab15bb6..f624a6ae44 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -484,19 +484,23 @@ shared_examples_for Chef::Provider::File do
it "raises an exception if any verification fails" do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
- provider.new_resource.verify windows? ? "REM" : "true"
- provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
- msg = "Proposed content for #{provider.new_resource.path} failed verification #{windows? ? "cmd.exe /c exit 1" : "false"}"
- expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, /#{msg}/)
+ allow(provider).to receive(:tempfile).and_return(tempfile)
+ provider.new_resource.verify windows? ? "cmd.exe c exit 1" : "false"
+ provider.new_resource.verify.each do |v|
+ allow(v).to receive(:verify).and_return(false)
+ end
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "does not show verification for sensitive resources" do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
- provider.new_resource.verify windows? ? "REM" : "true"
- provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
+ allow(provider).to receive(:tempfile).and_return(tempfile)
provider.new_resource.sensitive true
- msg = "Proposed content for #{provider.new_resource.path} failed verification [sensitive]\nTemporary file moved to #{backupfile}"
- expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, msg)
+ provider.new_resource.verify windows? ? "cmd.exe c exit 1" : "false"
+ provider.new_resource.verify.each do |v|
+ allow(v).to receive(:verify).and_return(false)
+ end
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, /sensitive/)
end
end
end
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 01c506c60a..0824f8b5b3 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -164,6 +164,8 @@ describe Chef::Application::Solo do
end
context "in local mode" do
+ let(:root_path) { windows? ? "C:/var/chef" : "/var/chef" }
+
before do
Chef::Config[:solo_legacy_mode] = false
end
@@ -197,10 +199,10 @@ describe Chef::Application::Solo do
end
it "sets the repo path" do
- expect(Chef::Config).to receive(:find_chef_repo_path).and_return("/var/chef")
+ expect(Chef::Config).to receive(:find_chef_repo_path).and_return(root_path)
app.reconfigure
expect(Chef::Config.key?(:chef_repo_path)).to be_truthy
- expect(Chef::Config[:chef_repo_path]).to eq ("/var/chef")
+ expect(Chef::Config[:chef_repo_path]).to eq (root_path)
end
it "runs chef-client in local mode" do
diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb
index 4f112070d8..848e789d3c 100644
--- a/spec/unit/chef_fs/config_spec.rb
+++ b/spec/unit/chef_fs/config_spec.rb
@@ -203,8 +203,8 @@ describe Chef::ChefFS::Config do
})
end
- let (:path) { "/roles/foo.json" }
- let (:entry) { Entry.new(path) }
+ let(:path) { "/roles/foo.json" }
+ let(:entry) { Entry.new(path) }
it "returns the entry's path if the cwd isn't in the config" do
cfg = Chef::ChefFS::Config.new(config, "/my_repo/cookbooks")
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb
index 29c25e2823..726adf8e50 100644
--- a/spec/unit/chef_fs/diff_spec.rb
+++ b/spec/unit/chef_fs/diff_spec.rb
@@ -20,18 +20,17 @@ require "spec_helper"
require "chef/chef_fs/file_pattern"
require "chef/chef_fs/command_line"
-# Removes the date stamp from the diff and replaces it with ' DATE'
-# example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000"
-# windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012"
-# https://rubular.com/r/5JdtZDqWnZhB9J
-def remove_os_differences(diff)
- diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE')
- diff.gsub(/^@@ -\d(,\d)? \+-?\d(,-?\d)? @@/, "CONTEXT_LINE_NUMBERS")
-end
-
describe "diff", uses_diff: true do
include FileSystemSupport
+ # Removes the date stamp from the diff and replaces it with ' DATE'
+ # example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000"
+ # windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012"
+ def remove_os_differences(diff)
+ diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE')
+ diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS")
+ end
+
context "with two filesystems with all types of difference" do
let(:a) do
memory_fs("a", {
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 831fe9c9b6..34c0a2c548 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -749,9 +749,12 @@ describe Chef::Client do
context "when any directory of cookbook_path contains no cookbook" do
it "raises CookbookNotFound error" do
+ invalid_cookbook_path = windows? ? "C:/path/to/invalid/cookbook_path" : "/path/to/invalid/cookbook_path"
+ msg = "None of the cookbook paths set in Chef::Config[:cookbook_path], [\"#{invalid_cookbook_path}\"], contain any cookbooks"
+
expect do
client.send(:assert_cookbook_path_not_empty, nil)
- end.to raise_error(Chef::Exceptions::CookbookNotFound, 'None of the cookbook paths set in Chef::Config[:cookbook_path], ["/path/to/invalid/cookbook_path"], contain any cookbooks')
+ end.to raise_error(Chef::Exceptions::CookbookNotFound, msg)
end
end
end
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 0762a11771..a1d312836b 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -217,6 +217,8 @@ describe Chef::CookbookSynchronizer do
path: "/tmp/cookbook_a_template_default_tempfile")
end
+ let(:root) { windows? ? "C:/file-cache/cookbooks/cookbook_a" : "/file-cache/cookbooks/cookbook_a" }
+
def setup_common_files_missing_expectations
# Files are not in the cache:
expect(file_cache).to receive(:key?)
@@ -234,7 +236,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request)
@@ -244,7 +246,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_missing_expectations
@@ -262,7 +264,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(server_api).to receive(:streaming_request)
.with("http://chef.example.com/ffffff")
@@ -271,7 +273,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
def setup_common_files_chksum_mismatch_expectations
@@ -292,11 +294,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Current file has fff000, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("fff000").at_least(:once)
# Fetch and copy default.rb attribute file
@@ -308,11 +310,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
# Current file has fff000, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("fff000").at_least(:once)
end
@@ -334,7 +336,7 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
# Fetch and copy apache2.conf template
expect(server_api).to receive(:streaming_request)
@@ -345,16 +347,16 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("fff000")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("fff000")
end
@@ -369,23 +371,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc123, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("abc123").at_least(:once)
# Current file has abc456, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("abc456").at_least(:once)
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_present_expectations
@@ -399,23 +401,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc124, want abc124
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("abc124")
# Current file has abc125, want abc125
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("abc125")
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
describe "#server_api" do
@@ -535,19 +537,19 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return("#{root}/files/default/megaman.conf")
expect(Chef::Log).to receive(:warn)
.with("skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!")
.once
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 7e5ef46d58..2a7ddddd5b 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -240,20 +240,23 @@ describe Chef::DataBag do
it "should raise an error if the configured data_bag_path is invalid" do
file_dir_stub(@paths.first, false)
+ msg = "Data bag path '#{windows? ? "C:/var/chef" : "/var/chef"}/data_bags' not found. Please create this directory."
expect do
Chef::DataBag.load("foo")
- end.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' not found. Please create this directory."
+ end.to raise_error Chef::Exceptions::InvalidDataBagPath, msg
end
end
describe "data bag with string path" do
- it_should_behave_like "data bag in solo mode", "/var/chef/data_bags"
+ it_should_behave_like "data bag in solo mode", "#{windows? ? "C:/var/chef" : "/var/chef"}/data_bags"
end
describe "data bag with array path" do
- it_should_behave_like "data bag in solo mode", ["/var/chef/data_bags", "/var/chef/data_bags_2"]
+ it_should_behave_like "data bag in solo mode", %w{data_bags data_bags_2}.map { |data_bag|
+ "#{windows? ? "C:/var/chef" : "/var/chef"}/#{data_bag}"
+ }
end
end
diff --git a/spec/unit/decorator_spec.rb b/spec/unit/decorator_spec.rb
index d9527b4a0d..e88708bea7 100644
--- a/spec/unit/decorator_spec.rb
+++ b/spec/unit/decorator_spec.rb
@@ -18,37 +18,37 @@
require "spec_helper"
-def impersonates_a(klass)
- it "#is_a?(#{klass}) is true" do
- expect(decorator.is_a?(klass)).to be true
- end
+describe Chef::Decorator do
+ def self.impersonates_a(klass)
+ it "#is_a?(#{klass}) is true" do
+ expect(decorator.is_a?(klass)).to be true
+ end
- it "#is_a?(Chef::Decorator) is true" do
- expect(decorator.is_a?(Chef::Decorator)).to be true
- end
+ it "#is_a?(Chef::Decorator) is true" do
+ expect(decorator.is_a?(Chef::Decorator)).to be true
+ end
- it "#kind_of?(#{klass}) is true" do
- expect(decorator.is_a?(klass)).to be true
- end
+ it "#kind_of?(#{klass}) is true" do
+ expect(decorator.is_a?(klass)).to be true
+ end
- it "#kind_of?(Chef::Decorator) is true" do
- expect(decorator.is_a?(Chef::Decorator)).to be true
- end
+ it "#kind_of?(Chef::Decorator) is true" do
+ expect(decorator.is_a?(Chef::Decorator)).to be true
+ end
- it "#instance_of?(#{klass}) is false" do
- expect(decorator.instance_of?(klass)).to be false
- end
+ it "#instance_of?(#{klass}) is false" do
+ expect(decorator.instance_of?(klass)).to be false
+ end
- it "#instance_of?(Chef::Decorator) is true" do
- expect(decorator.instance_of?(Chef::Decorator)).to be true
- end
+ it "#instance_of?(Chef::Decorator) is true" do
+ expect(decorator.instance_of?(Chef::Decorator)).to be true
+ end
- it "#class is Chef::Decorator" do
- expect(decorator.class).to eql(Chef::Decorator)
+ it "#class is Chef::Decorator" do
+ expect(decorator.class).to eql(Chef::Decorator)
+ end
end
-end
-describe Chef::Decorator do
let(:obj) {}
let(:decorator) { Chef::Decorator.new(obj) }
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 2918a9a65e..93b4a5011c 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -454,7 +454,11 @@ describe Chef::Environment do
expect do
Chef::Environment.load("foo")
- end.to raise_error Chef::Exceptions::InvalidEnvironmentPath, "Environment path '/var/chef/environments' is invalid"
+ end.to raise_error(
+ an_instance_of(Chef::Exceptions::InvalidEnvironmentPath).and having_attributes(
+ message: "Environment path '#{windows? ? "C:/var/chef/environments" : "/var/chef/environments"}' is invalid"
+ )
+ )
end
it "should raise an error if the file does not exist" do
diff --git a/spec/unit/guard_interpreter_spec.rb b/spec/unit/guard_interpreter_spec.rb
index 85850b14a4..82bdb58483 100644
--- a/spec/unit/guard_interpreter_spec.rb
+++ b/spec/unit/guard_interpreter_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::GuardInterpreter do
describe "#for_resource" do
- let (:resource) { Chef::Resource.new("foo") }
+ let(:resource) { Chef::Resource.new("foo") }
it "returns a DefaultGuardInterpreter if the resource has guard_interpreter set to :default" do
resource.guard_interpreter :default
diff --git a/spec/unit/http/api_versions_spec.rb b/spec/unit/http/api_versions_spec.rb
index af0fd16e5e..774e435c41 100644
--- a/spec/unit/http/api_versions_spec.rb
+++ b/spec/unit/http/api_versions_spec.rb
@@ -72,7 +72,7 @@ describe Chef::HTTP::APIVersions do
end
context "with an unacceptable api version" do
- let (:return_value) { "406" }
+ let(:return_value) { "406" }
it "resets the list of supported versions" do
Chef::ServerAPIVersions.instance.set_versions({ "min_version" => 1, "max_version" => 3 })
run_api_version_handler
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 78dd20e2d2..2d1d70cb51 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -83,7 +83,7 @@ describe Chef::Knife::CookbookDownload do
}
end
- let (:cookbook) do
+ let(:cookbook) do
cb = Chef::CookbookVersion.new("foobar")
cb.version = "1.0.0"
cb.manifest = manifest_data
@@ -91,7 +91,7 @@ describe Chef::Knife::CookbookDownload do
end
describe "and no version" do
- let (:manifest_data) { { all_files: [] } }
+ let(:manifest_data) { { all_files: [] } }
it "should determine which version to download" do
expect(@knife).to receive(:determine_version).and_return("1.0.0")
expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb
index 794447c4eb..defc243de3 100644
--- a/spec/unit/knife/cookbook_show_spec.rb
+++ b/spec/unit/knife/cookbook_show_spec.rb
@@ -27,24 +27,24 @@ describe Chef::Knife::CookbookShow do
allow(Chef::CookbookVersion).to receive(:load).and_return(cb)
end
- let (:knife) do
+ let(:knife) do
knife = Chef::Knife::CookbookShow.new
knife.config = {}
knife.name_args = [ "cookbook_name" ]
knife
end
- let (:cb) do
+ let(:cb) do
cb = Chef::CookbookVersion.new("cookbook_name")
cb.manifest = manifest
cb
end
- let (:rest) { double(Chef::ServerAPI) }
+ let(:rest) { double(Chef::ServerAPI) }
- let (:content) { "Example recipe text" }
+ let(:content) { "Example recipe text" }
- let (:manifest) do
+ let(:manifest) do
{
"all_files" => [
{
@@ -68,7 +68,7 @@ describe Chef::Knife::CookbookShow do
end
describe "with 1 argument: versions" do
- let (:response) do
+ let(:response) do
{
"cookbook_name" => {
"url" => "http://url/cookbooks/cookbook_name",
diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb
index e09abaea60..6ebcaf4945 100644
--- a/spec/unit/knife/data_bag_edit_spec.rb
+++ b/spec/unit/knife/data_bag_edit_spec.rb
@@ -95,7 +95,7 @@ describe Chef::Knife::DataBagEdit do
let(:is_encrypted?) { true }
let(:db) { Chef::DataBagItem.from_hash(enc_raw_hash) }
# If the data bag is encrypted, it gets passed to `edit` as a hash. Otherwise, it gets passed as a DataBag
- let (:data_to_edit) { raw_hash }
+ let(:data_to_edit) { raw_hash }
before(:each) do
expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true)
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 29a9945d8f..b0ddf30b28 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -653,14 +653,17 @@ describe "LWRP" do
end
end
- let(:recipe) do
+ let(:run_context) do
cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
cookbook_loader.load_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cookbook_loader)
node = Chef::Node.new
events = Chef::EventDispatch::Dispatcher.new
- run_context = Chef::RunContext.new(node, cookbook_collection, events)
+ Chef::RunContext.new(node, cookbook_collection, events)
+ end
+
+ let(:recipe) do
Chef::Recipe.new("hjk", "test", run_context)
end
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index e6a9186a77..7306332057 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -30,8 +30,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
it "runs a command and returns the shell_out object" do
ret = double("Mixlib::ShellOut")
expect(object).to receive(:shell_out).with(
- "powershell.exe #{flags} -Command \"Get-Process\"",
- {}
+ "powershell.exe #{flags} -Command \"Get-Process\""
).and_return(ret)
expect(object.powershell_out("Get-Process")).to eql(ret)
end
@@ -62,8 +61,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
it "runs a command and returns the shell_out object" do
mixlib_shellout = double("Mixlib::ShellOut")
expect(object).to receive(:shell_out).with(
- "powershell.exe #{flags} -Command \"Get-Process\"",
- {}
+ "powershell.exe #{flags} -Command \"Get-Process\""
).and_return(mixlib_shellout)
expect(mixlib_shellout).to receive(:error!)
expect(object.powershell_out!("Get-Process")).to eql(mixlib_shellout)
diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb
index 2aafcbac23..7eebfd2348 100644
--- a/spec/unit/mixin/powershell_type_coercions_spec.rb
+++ b/spec/unit/mixin/powershell_type_coercions_spec.rb
@@ -25,7 +25,7 @@ class Chef::PSTypeTester
end
describe Chef::Mixin::PowershellTypeCoercions do
- let (:test_class) { Chef::PSTypeTester.new }
+ let(:test_class) { Chef::PSTypeTester.new }
describe "#translate_type" do
it "single quotes a string" do
diff --git a/spec/unit/mixin/subclass_directive_spec.rb b/spec/unit/mixin/subclass_directive_spec.rb
index 65e9306e0f..f7732cc51b 100644
--- a/spec/unit/mixin/subclass_directive_spec.rb
+++ b/spec/unit/mixin/subclass_directive_spec.rb
@@ -31,9 +31,9 @@ class ChildWithoutDirective < SubclassDirectiveParent
end
describe Chef::Mixin::Uris do
- let (:child) { SubclassDirectiveChild.new }
+ let(:child) { SubclassDirectiveChild.new }
- let (:other_child) { ChildWithoutDirective.new }
+ let(:other_child) { ChildWithoutDirective.new }
it "the child instance has the directive set" do
expect(child.behave_differently?).to be true
diff --git a/spec/unit/mixin/unformatter_spec.rb b/spec/unit/mixin/unformatter_spec.rb
index 9498e7f81e..a2fc69000b 100644
--- a/spec/unit/mixin/unformatter_spec.rb
+++ b/spec/unit/mixin/unformatter_spec.rb
@@ -27,8 +27,8 @@ class Chef::UnformatterTest
end
describe Chef::Mixin::Unformatter do
- let (:unformatter) { Chef::UnformatterTest.new }
- let (:message) { "Test Message" }
+ let(:unformatter) { Chef::UnformatterTest.new }
+ let(:message) { "Test Message" }
describe "#write" do
context "with a timestamp" do
diff --git a/spec/unit/mixin/uris_spec.rb b/spec/unit/mixin/uris_spec.rb
index 567da86899..b8b500cb38 100644
--- a/spec/unit/mixin/uris_spec.rb
+++ b/spec/unit/mixin/uris_spec.rb
@@ -24,7 +24,7 @@ class Chef::UrisTest
end
describe Chef::Mixin::Uris do
- let (:uris) { Chef::UrisTest.new }
+ let(:uris) { Chef::UrisTest.new }
describe "#uri_scheme?" do
it "matches 'scheme://foo.com'" do
diff --git a/spec/unit/provider/batch_spec.rb b/spec/unit/provider/batch_spec.rb
index 3ca1334489..80e914beaa 100644
--- a/spec/unit/provider/batch_spec.rb
+++ b/spec/unit/provider/batch_spec.rb
@@ -94,7 +94,7 @@ describe Chef::Provider::Batch do
end
describe "#command" do
- let(:basepath) { "C:\\Windows\\system32" }
+ let(:basepath) { "C:\\Windows\\system32\\" }
let(:interpreter) { File.join(basepath, "cmd.exe") }
before do
diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb
index c8ef82e37a..e5bb436bea 100644
--- a/spec/unit/provider/cron/unix_spec.rb
+++ b/spec/unit/provider/cron/unix_spec.rb
@@ -93,7 +93,7 @@ describe Chef::Provider::Cron::Unix do
end
context "when any other error occurs" do
- let (:exitstatus) { 2 }
+ let(:exitstatus) { 2 }
it "should raise an exception if another error occurs" do
expect do
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index f2030a52c9..8613ce4af4 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -20,15 +20,21 @@ require "chef"
require "spec_helper"
describe Chef::Provider::DscResource do
- let (:events) { Chef::EventDispatch::Dispatcher.new }
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
- let (:resource) { Chef::Resource::DscResource.new("dscresource", run_context) }
- let (:provider) do
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:resource) { Chef::Resource::DscResource.new("dscresource", run_context) }
+ let(:provider) do
Chef::Provider::DscResource.new(resource, run_context)
end
+ let(:node) do
+ node = Chef::Node.new
+ node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
+ node
+ end
+
context "when PowerShell does not support Invoke-DscResource" do
- let (:node) do
+ let(:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "4.0"
node
@@ -45,7 +51,7 @@ describe Chef::Provider::DscResource do
context "when RefreshMode is not set to Disabled" do
context "and the WMF 5 is a preview release" do
- let (:node) do
+ let(:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
@@ -58,7 +64,7 @@ describe Chef::Provider::DscResource do
end
end
context "and the WMF is 5 RTM or newer" do
- let (:node) do
+ let(:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
node
@@ -74,15 +80,15 @@ describe Chef::Provider::DscResource do
end
context "when the LCM supports Invoke-DscResource" do
- let (:node) do
+ let(:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
node
end
- let (:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
- let (:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
- let (:store) { double("ResourceStore", find: resource_records) }
- let (:resource_records) { [] }
+ let(:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
+ let(:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
+ let(:store) { double("ResourceStore", find: resource_records) }
+ let(:resource_records) { [] }
before do
allow(Chef::Util::DSC::ResourceStore).to receive(:instance).and_return(store)
@@ -124,7 +130,7 @@ describe Chef::Provider::DscResource do
end
context "resource name cannot be found" do
- let (:resource_records) { [] }
+ let(:resource_records) { [] }
it "raises ResourceNotFound" do
expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::ResourceNotFound)
@@ -133,7 +139,7 @@ describe Chef::Provider::DscResource do
context "resource name is found" do
context "no module name for resource found" do
- let (:resource_records) { [{}] }
+ let(:resource_records) { [{}] }
it "returns the default dsc resource module" do
expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
@@ -144,7 +150,7 @@ describe Chef::Provider::DscResource do
end
context "a module name for resource is found" do
- let (:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
+ let(:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
it "returns the default dsc resource module" do
expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
@@ -155,7 +161,7 @@ describe Chef::Provider::DscResource do
end
context "multiple resource are found" do
- let (:resource_records) do
+ let(:resource_records) do
[
{ "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
{ "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
@@ -170,10 +176,6 @@ describe Chef::Provider::DscResource do
end
describe "define_resource_requirements" do
- let (:node) do
- set_node_object
- end
-
context "module usage is valid" do
before do
allow(provider).to receive(:module_usage_valid?).and_return(true)
@@ -208,10 +210,6 @@ describe Chef::Provider::DscResource do
end
describe "module_usage_valid?" do
- let (:node) do
- set_node_object
- end
-
context "module_name and module_version both are not provided" do
before do
provider.instance_variable_set(:@module_name, nil)
@@ -262,10 +260,6 @@ describe Chef::Provider::DscResource do
end
describe "module_info_object" do
- let (:node) do
- set_node_object
- end
-
context "module_version is not given" do
before do
provider.instance_variable_set(:@module_version, nil)
@@ -292,10 +286,6 @@ describe Chef::Provider::DscResource do
end
describe "invoke_resource" do
- let (:node) do
- set_node_object
- end
-
let(:cmdlet) { double(run!: nil) }
before(:each) do
@@ -338,9 +328,3 @@ describe Chef::Provider::DscResource do
end
end
end
-
-def set_node_object
- node = Chef::Node.new
- node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
- node
-end
diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb
index 520f784ced..f0a63e0a5b 100644
--- a/spec/unit/provider/dsc_script_spec.rb
+++ b/spec/unit/provider/dsc_script_spec.rb
@@ -23,15 +23,15 @@ require "spec_helper"
describe Chef::Provider::DscScript do
context "when DSC is available" do
- let (:node) do
+ let(:node) do
node = Chef::Node.new
node.automatic[:languages][:powershell][:version] = "4.0"
node
end
- let (:events) { Chef::EventDispatch::Dispatcher.new }
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
- let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
- let (:provider) do
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
+ let(:provider) do
Chef::Provider::DscScript.new(resource, run_context)
end
@@ -145,11 +145,11 @@ describe Chef::Provider::DscScript do
end
context "when Dsc is not available" do
- let (:node) { Chef::Node.new }
- let (:events) { Chef::EventDispatch::Dispatcher.new }
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
- let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
- let (:provider) { Chef::Provider::DscScript.new(resource, run_context) }
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
+ let(:provider) { Chef::Provider::DscScript.new(resource, run_context) }
describe "action_run" do
["1.0", "2.0", "3.0"].each do |version|
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 000d8cebda..80bdb6a230 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Provider::Execute do
let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) }
let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) }
# You will be the same object, I promise.
- @live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute)
+ @live_stream = Chef::EventDispatch::EventsOutputStream.new(Chef::EventDispatch::Dispatcher.new, name: :execute)
let(:opts) do
{
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 078e6109dc..21af554111 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -293,7 +293,7 @@ describe Chef::Provider::Git do
end
end
context "with a timeout set" do
- let (:seconds) { 10 }
+ let(:seconds) { 10 }
before { @resource.timeout(seconds) }
it "clones a repo with amended git options" do
expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds))
@@ -301,7 +301,7 @@ describe Chef::Provider::Git do
end
end
context "with a specific home" do
- let (:override_home) do
+ let(:override_home) do
{ "HOME" => "/home/masterNinja" }
end
let(:overrided_options) do
@@ -337,7 +337,7 @@ describe Chef::Provider::Git do
allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
end
context "with a specific home" do
- let (:override_home) do
+ let(:override_home) do
{ "HOME" => "/home/masterNinja" }
end
let(:overrided_options) do
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 7e3546dcce..c0f6813afd 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -22,9 +22,7 @@ require "ostruct"
describe Chef::Resource::Mdadm do
before(:each) do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
@new_resource = Chef::Resource::Mdadm.new("/dev/md1", run_context)
@new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"]
@provider = @new_resource.provider_for_action(:create)
diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb
index dee49534c3..154e5ba333 100644
--- a/spec/unit/provider/package/openbsd_spec.rb
+++ b/spec/unit/provider/package/openbsd_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Openbsd do
node
end
- let (:provider) do
+ let(:provider) do
events = Chef::EventDispatch::Dispatcher.new
run_context = Chef::RunContext.new(node, {}, events)
Chef::Provider::Package::Openbsd.new(new_resource, run_context)
diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb
index 2e2a3f7763..e44df52e42 100644
--- a/spec/unit/provider/package/pacman_spec.rb
+++ b/spec/unit/provider/package/pacman_spec.rb
@@ -17,13 +17,6 @@
#
require "spec_helper"
-def create_provider_for(name)
- @new_resource = Chef::Resource::Package.new(name)
- provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
- allow(provider).to receive(:shell_out_compacted).and_return(@status)
- provider
-end
-
RSpec.shared_examples "current_resource" do |pkg, version, candidate|
let(:current_resource) { @provider.load_current_resource }
before(:each) do
@@ -45,11 +38,23 @@ RSpec.shared_examples "current_resource" do |pkg, version, candidate|
end
describe Chef::Provider::Package::Pacman do
+ def create_provider_for(name)
+ new_resource = Chef::Resource::Package.new(name)
+ run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ provider = Chef::Provider::Package::Pacman.new(new_resource, run_context)
+
+ pacman_out = <<~PACMAN_OUT
+ extra nano 3.450-1
+ extra emacs 0.12.0-1 [installed]
+ core sed 3.234-2 [installed: 3.234-1]
+ PACMAN_OUT
+
+ allow(provider).to receive(:shell_out_compacted).and_return(double(stdout: pacman_out, exitstatus: 0))
+ provider
+ end
+
before(:each) do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
- @pacman_conf = <<~PACMAN_CONF
+ pacman_conf = <<~PACMAN_CONF
[options]
HoldPkg = pacman glibc
Architecture = auto
@@ -68,15 +73,7 @@ describe Chef::Provider::Package::Pacman do
PACMAN_CONF
allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true)
- allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
-
- pacman_out = <<~PACMAN_OUT
- extra nano 3.450-1
- extra emacs 0.12.0-1 [installed]
- core sed 3.234-2 [installed: 3.234-1]
- PACMAN_OUT
- @status = double(stdout: pacman_out, exitstatus: 0)
-
+ allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(pacman_conf)
end
describe "loading the current resource" do
diff --git a/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb b/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb
index 803f3271df..9ce1151285 100644
--- a/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb
+++ b/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb
@@ -8,7 +8,7 @@ describe Chef::Provider::Package::Windows::RegistryUninstallEntry do
describe "when QuietUninstallString key not present" do
let(:quiet_uninstall_string) { nil }
- let (:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
+ let(:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
it "returns UninstallString key value" do
expect(quiet_uninstall_string_key).to eql "UninstallStringPath"
end
@@ -16,14 +16,14 @@ describe Chef::Provider::Package::Windows::RegistryUninstallEntry do
describe "when QuietUninstallString key present" do
let(:quiet_uninstall_string) { "QuietUninstallString" }
- let (:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
+ let(:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
it "returns QuietUninstallString key value" do
expect(quiet_uninstall_string_key).to eql "QuietUninstallStringPath"
end
end
describe ".find_entries", :windows_only do
- let (:registry_uninstall_entry) { Chef::Provider::Package::Windows::RegistryUninstallEntry }
+ let(:registry_uninstall_entry) { Chef::Provider::Package::Windows::RegistryUninstallEntry }
before(:each) do
allow_any_instance_of(::Win32::Registry).to receive(:open).and_return("::Win32::Registry::HKEY_CURRENT_USER")
end
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index d72d7e8c8e..5652ae6868 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Provider::User::Dscl do
let(:salt) { nil }
let(:iterations) { nil }
- let (:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:node) do
Chef::Node.new.tap do |node|
@@ -39,7 +39,7 @@ describe Chef::Provider::User::Dscl do
end
end
- let (:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:new_resource) do
r = Chef::Resource::User::DsclUser.new("toor", run_context)
diff --git a/spec/unit/provider/windows_env_spec.rb b/spec/unit/provider/windows_env_spec.rb
index 0e6cb02d48..5d14128230 100644
--- a/spec/unit/provider/windows_env_spec.rb
+++ b/spec/unit/provider/windows_env_spec.rb
@@ -20,14 +20,15 @@ require "spec_helper"
describe Chef::Provider::WindowsEnv, :windows_only do
+ let(:run_context) do
+ Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
+ end
+
before do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::WindowsEnv.new("FOO")
@new_resource.value("bar")
@new_resource.user("<System>")
- @provider = Chef::Provider::WindowsEnv.new(@new_resource, @run_context)
+ @provider = Chef::Provider::WindowsEnv.new(@new_resource, run_context)
end
it "assumes the key_name exists by default" do
diff --git a/spec/unit/resource/chef_client_cron_spec.rb b/spec/unit/resource/chef_client_cron_spec.rb
index f1261917a4..b6b28329a9 100644
--- a/spec/unit/resource/chef_client_cron_spec.rb
+++ b/spec/unit/resource/chef_client_cron_spec.rb
@@ -76,13 +76,19 @@ describe Chef::Resource::ChefClientCron do
allow(provider).to receive(:splay_sleep_time).and_return("123")
end
+ let(:root_path) { windows? ? "C:\\chef/client.rb" : "/etc/chef/client.rb" }
+
it "creates a valid command if using all default properties" do
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "uses daemon_options if set" do
resource.daemon_options ["--foo 1", "--bar 2"]
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "uses custom config dir if set" do
@@ -93,27 +99,37 @@ describe Chef::Resource::ChefClientCron do
it "uses custom log files / paths if set" do
resource.log_file_name "my-client.log"
resource.log_directory "/var/log/my-chef/"
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/my-chef/my-client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/my-chef/my-client.log"
+ )
end
it "uses mailto if set" do
resource.mailto "bob@example.com"
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\"")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\""
+ )
end
it "uses custom chef-client binary if set" do
resource.chef_binary_path "/usr/local/bin/chef-client"
- expect(provider.cron_command).to eql("/bin/sleep 123; /usr/local/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "appends to the log file appending if set to false" do
resource.append_log_file false
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb > /var/log/chef/client.log 2>&1")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} > /var/log/chef/client.log 2>&1"
+ )
end
it "sets the license acceptance flag if set" do
resource.accept_chef_license true
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb --chef-license accept -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept -L /var/log/chef/client.log"
+ )
end
end
end
diff --git a/spec/unit/resource/chef_client_systemd_timer_spec.rb b/spec/unit/resource/chef_client_systemd_timer_spec.rb
index b175bb27ec..1866060530 100644
--- a/spec/unit/resource/chef_client_systemd_timer_spec.rb
+++ b/spec/unit/resource/chef_client_systemd_timer_spec.rb
@@ -43,13 +43,16 @@ describe Chef::Resource::ChefClientSystemdTimer do
end
describe "#chef_client_cmd" do
+
+ let(:root_path) { windows? ? "C:\\chef/client.rb" : "/etc/chef/client.rb" }
+
it "creates a valid command if using all default properties" do
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client -c #{root_path}")
end
it "uses daemon_options if set" do
resource.daemon_options ["--foo 1", "--bar 2"]
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --foo 1 --bar 2 -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path}")
end
it "uses custom config dir if set" do
@@ -59,12 +62,12 @@ describe Chef::Resource::ChefClientSystemdTimer do
it "uses custom chef-client binary if set" do
resource.chef_binary_path "/usr/local/bin/chef-client"
- expect(provider.chef_client_cmd).to eql("/usr/local/bin/chef-client -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/usr/local/bin/chef-client -c #{root_path}")
end
it "sets the license acceptance flag if set" do
resource.accept_chef_license true
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --chef-license accept -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --chef-license accept -c #{root_path}")
end
end
end
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index d0e697a1cd..d1fe863891 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -112,7 +112,8 @@ describe Chef::Resource::File::Verification do
end
it "returns true if the command succeeds" do
- v = Chef::Resource::File::Verification.new(parent_resource, "true", {})
+ test_command = platform_specific_verify_command("path")
+ v = Chef::Resource::File::Verification.new(parent_resource, test_command, {})
expect(v.verify(temp_path)).to eq(true)
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 5181414215..7a19e0e8e1 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -1255,19 +1255,36 @@ describe Chef::Resource do
expect(block_value).to eq(original_umask)
end
- it "changes the umask in the block to the set value" do
- resource.umask = "0123"
+ if windows?
+ it "is a no-op on Windows" do
+ resource.umask = "0123"
- block_value = nil
+ block_value = nil
- resource.with_umask do
- block_value = ::File.umask
+ resource.with_umask do
+ block_value = ::File.umask
+ end
+
+ # Format the returned value so a potential error message is easier to understand.
+ actual_value = block_value.to_s(8).rjust(4, "0")
+
+ expect(actual_value).to eq("0000")
end
+ else
+ it "changes the umask in the block to the set value" do
+ resource.umask = "0123"
+
+ block_value = nil
- # Format the returned value so a potential error message is easier to understand.
- actual_value = block_value.to_s(8).rjust(4, "0")
+ resource.with_umask do
+ block_value = ::File.umask
+ end
- expect(actual_value).to eq("0123")
+ # Format the returned value so a potential error message is easier to understand.
+ actual_value = block_value.to_s(8).rjust(4, "0")
+
+ expect(actual_value).to eq("0123")
+ end
end
it "resets the umask afterwards" do
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index c956b31e4e..1db64d3029 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -21,7 +21,7 @@ require "tmpdir"
describe Chef::Util::Backup do
- let (:tempfile) do
+ let(:tempfile) do
Tempfile.new("chef-util-backup-spec-test")
end
diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb
index 1434580f01..73abe41de8 100644
--- a/spec/unit/util/powershell/ps_credential_spec.rb
+++ b/spec/unit/util/powershell/ps_credential_spec.rb
@@ -20,8 +20,8 @@ require "chef"
require "chef/util/powershell/ps_credential"
describe Chef::Util::Powershell::PSCredential do
- let (:username) { "foo" }
- let (:password) { "ThIsIsThEpAsSwOrD" }
+ let(:username) { "foo" }
+ let(:password) { "ThIsIsThEpAsSwOrD" }
context "when username and password are provided" do
let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password) }
diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb
index 2b73981934..2a4b26b2b6 100644
--- a/spec/unit/util/selinux_spec.rb
+++ b/spec/unit/util/selinux_spec.rb
@@ -114,7 +114,7 @@ describe Chef::Util::Selinux do
end
describe "when restorecon binary exists on the system" do
- let (:path) { "/path/to/awesome directory" }
+ let(:path) { "/path/to/awesome directory" }
before do
@restorecon_enabled_path = File.join("/sbin", "restorecon")