chef 17.1.35-universal-mingw32 → 17.4.38-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -4
  3. data/chef.gemspec +1 -0
  4. data/lib/chef/action_collection.rb +6 -26
  5. data/lib/chef/application/base.rb +15 -0
  6. data/lib/chef/application.rb +4 -2
  7. data/lib/chef/client.rb +7 -1
  8. data/lib/chef/compliance/default_attributes.rb +5 -3
  9. data/lib/chef/compliance/reporter/automate.rb +1 -1
  10. data/lib/chef/compliance/runner.rb +16 -2
  11. data/lib/chef/cookbook_version.rb +26 -4
  12. data/lib/chef/data_collector/run_end_message.rb +1 -1
  13. data/lib/chef/data_collector.rb +0 -1
  14. data/lib/chef/deprecated.rb +14 -4
  15. data/lib/chef/dsl/render_helpers.rb +44 -0
  16. data/lib/chef/dsl/secret.rb +64 -0
  17. data/lib/chef/dsl/toml.rb +116 -0
  18. data/lib/chef/dsl/universal.rb +5 -0
  19. data/lib/chef/dsl.rb +1 -0
  20. data/lib/chef/event_dispatch/base.rb +2 -1
  21. data/lib/chef/exceptions.rb +23 -0
  22. data/lib/chef/formatters/doc.rb +14 -13
  23. data/lib/chef/formatters/error_mapper.rb +2 -2
  24. data/lib/chef/formatters/minimal.rb +6 -5
  25. data/lib/chef/handler/slow_report.rb +66 -0
  26. data/lib/chef/handler.rb +46 -8
  27. data/lib/chef/http.rb +5 -5
  28. data/lib/chef/json_compat.rb +1 -1
  29. data/lib/chef/node.rb +20 -19
  30. data/lib/chef/policy_builder/policyfile.rb +88 -45
  31. data/lib/chef/provider/execute.rb +1 -1
  32. data/lib/chef/provider/file.rb +2 -2
  33. data/lib/chef/provider/group/dscl.rb +1 -1
  34. data/lib/chef/provider/launchd.rb +6 -6
  35. data/lib/chef/provider/lwrp_base.rb +1 -1
  36. data/lib/chef/provider/package/habitat.rb +168 -0
  37. data/lib/chef/provider/package/powershell.rb +5 -0
  38. data/lib/chef/provider/subversion.rb +4 -4
  39. data/lib/chef/provider/support/yum_repo.erb +1 -1
  40. data/lib/chef/provider/support/zypper_repo.erb +4 -2
  41. data/lib/chef/provider/systemd_unit.rb +17 -16
  42. data/lib/chef/provider/user/mac.rb +3 -3
  43. data/lib/chef/provider/yum_repository.rb +27 -43
  44. data/lib/chef/provider/zypper_repository.rb +30 -34
  45. data/lib/chef/provider.rb +26 -1
  46. data/lib/chef/provider_resolver.rb +8 -2
  47. data/lib/chef/providers.rb +1 -0
  48. data/lib/chef/resource/alternatives.rb +5 -5
  49. data/lib/chef/resource/apt_preference.rb +2 -2
  50. data/lib/chef/resource/apt_repository.rb +2 -2
  51. data/lib/chef/resource/apt_update.rb +4 -4
  52. data/lib/chef/resource/build_essential.rb +1 -1
  53. data/lib/chef/resource/chef_client_config.rb +10 -5
  54. data/lib/chef/resource/chef_client_cron.rb +3 -3
  55. data/lib/chef/resource/chef_client_launchd.rb +3 -3
  56. data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
  57. data/lib/chef/resource/chef_client_systemd_timer.rb +3 -3
  58. data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
  59. data/lib/chef/resource/chef_handler.rb +2 -2
  60. data/lib/chef/resource/chef_sleep.rb +1 -1
  61. data/lib/chef/resource/chef_vault_secret.rb +2 -2
  62. data/lib/chef/resource/chocolatey_feature.rb +2 -2
  63. data/lib/chef/resource/chocolatey_source.rb +1 -1
  64. data/lib/chef/resource/cron/cron_d.rb +4 -6
  65. data/lib/chef/resource/cron_access.rb +1 -1
  66. data/lib/chef/resource/dmg_package.rb +1 -1
  67. data/lib/chef/resource/dsc_resource.rb +1 -1
  68. data/lib/chef/resource/execute.rb +5 -5
  69. data/lib/chef/resource/gem_package.rb +2 -1
  70. data/lib/chef/resource/group.rb +4 -4
  71. data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
  72. data/lib/chef/resource/habitat/habitat_package.rb +129 -0
  73. data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
  74. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
  75. data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
  76. data/lib/chef/resource/habitat_config.rb +107 -0
  77. data/lib/chef/resource/habitat_install.rb +247 -0
  78. data/lib/chef/resource/habitat_service.rb +451 -0
  79. data/lib/chef/resource/habitat_user_toml.rb +92 -0
  80. data/lib/chef/resource/homebrew_cask.rb +18 -7
  81. data/lib/chef/resource/homebrew_package.rb +1 -1
  82. data/lib/chef/resource/homebrew_tap.rb +4 -3
  83. data/lib/chef/resource/homebrew_update.rb +2 -2
  84. data/lib/chef/resource/hostname.rb +49 -7
  85. data/lib/chef/resource/inspec_waiver_file_entry.rb +8 -7
  86. data/lib/chef/resource/kernel_module.rb +6 -6
  87. data/lib/chef/resource/launchd.rb +3 -3
  88. data/lib/chef/resource/locale.rb +1 -1
  89. data/lib/chef/resource/lwrp_base.rb +1 -1
  90. data/lib/chef/resource/macos_userdefaults.rb +2 -2
  91. data/lib/chef/resource/ohai_hint.rb +2 -6
  92. data/lib/chef/resource/openbsd_package.rb +17 -0
  93. data/lib/chef/resource/openssl_dhparam.rb +1 -2
  94. data/lib/chef/resource/openssl_ec_private_key.rb +1 -3
  95. data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
  96. data/lib/chef/resource/openssl_rsa_private_key.rb +1 -3
  97. data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
  98. data/lib/chef/resource/openssl_x509_certificate.rb +1 -4
  99. data/lib/chef/resource/openssl_x509_crl.rb +1 -3
  100. data/lib/chef/resource/openssl_x509_request.rb +1 -3
  101. data/lib/chef/resource/osx_profile.rb +3 -3
  102. data/lib/chef/resource/plist.rb +1 -1
  103. data/lib/chef/resource/powershell_package_source.rb +2 -4
  104. data/lib/chef/resource/reboot.rb +38 -9
  105. data/lib/chef/resource/remote_directory.rb +2 -2
  106. data/lib/chef/resource/remote_file.rb +1 -1
  107. data/lib/chef/resource/rhsm_errata.rb +0 -2
  108. data/lib/chef/resource/rhsm_errata_level.rb +1 -5
  109. data/lib/chef/resource/rhsm_repo.rb +15 -0
  110. data/lib/chef/resource/rhsm_subscription.rb +5 -5
  111. data/lib/chef/resource/ruby_block.rb +100 -0
  112. data/lib/chef/resource/scm/subversion.rb +1 -1
  113. data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
  114. data/lib/chef/resource/sudo.rb +2 -6
  115. data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
  116. data/lib/chef/resource/support/client.erb +8 -1
  117. data/lib/chef/resource/support/sup.toml.erb +179 -0
  118. data/lib/chef/resource/swap_file.rb +2 -6
  119. data/lib/chef/resource/sysctl.rb +2 -2
  120. data/lib/chef/resource/systemd_unit.rb +3 -3
  121. data/lib/chef/resource/timezone.rb +1 -1
  122. data/lib/chef/resource/user_ulimit.rb +2 -2
  123. data/lib/chef/resource/windows_ad_join.rb +2 -2
  124. data/lib/chef/resource/windows_audit_policy.rb +2 -2
  125. data/lib/chef/resource/windows_auto_run.rb +2 -2
  126. data/lib/chef/resource/windows_certificate.rb +1 -1
  127. data/lib/chef/resource/windows_defender.rb +163 -0
  128. data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
  129. data/lib/chef/resource/windows_dfs_folder.rb +2 -2
  130. data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
  131. data/lib/chef/resource/windows_dns_record.rb +2 -2
  132. data/lib/chef/resource/windows_dns_zone.rb +2 -2
  133. data/lib/chef/resource/windows_feature.rb +3 -3
  134. data/lib/chef/resource/windows_feature_dism.rb +3 -5
  135. data/lib/chef/resource/windows_feature_powershell.rb +3 -3
  136. data/lib/chef/resource/windows_firewall_profile.rb +2 -2
  137. data/lib/chef/resource/windows_firewall_rule.rb +20 -6
  138. data/lib/chef/resource/windows_font.rb +1 -1
  139. data/lib/chef/resource/windows_pagefile.rb +103 -64
  140. data/lib/chef/resource/windows_path.rb +2 -2
  141. data/lib/chef/resource/windows_printer.rb +80 -61
  142. data/lib/chef/resource/windows_printer_port.rb +48 -65
  143. data/lib/chef/resource/windows_security_policy.rb +2 -2
  144. data/lib/chef/resource/windows_share.rb +2 -2
  145. data/lib/chef/resource/windows_shortcut.rb +1 -1
  146. data/lib/chef/resource/windows_task.rb +1 -1
  147. data/lib/chef/resource/windows_uac.rb +3 -5
  148. data/lib/chef/resource/windows_update_settings.rb +259 -0
  149. data/lib/chef/resource/windows_user_privilege.rb +2 -2
  150. data/lib/chef/resource/windows_workgroup.rb +2 -2
  151. data/lib/chef/resource/yum_package.rb +11 -15
  152. data/lib/chef/resource/zypper_package.rb +4 -4
  153. data/lib/chef/resource/zypper_repository.rb +28 -8
  154. data/lib/chef/resource.rb +13 -17
  155. data/lib/chef/resource_inspector.rb +6 -2
  156. data/lib/chef/resource_reporter.rb +0 -1
  157. data/lib/chef/resources.rb +12 -1
  158. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
  159. data/lib/chef/secret_fetcher/azure_key_vault.rb +78 -0
  160. data/lib/chef/secret_fetcher/base.rb +76 -0
  161. data/lib/chef/secret_fetcher/example.rb +46 -0
  162. data/lib/chef/secret_fetcher.rb +55 -0
  163. data/lib/chef/version.rb +1 -1
  164. data/spec/functional/mixin/from_file_spec.rb +1 -1
  165. data/spec/functional/resource/windows_hostname_spec.rb +91 -0
  166. data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
  167. data/spec/integration/compliance/compliance_spec.rb +1 -0
  168. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  169. data/spec/integration/recipes/resource_action_spec.rb +6 -6
  170. data/spec/support/shared/unit/provider/file.rb +2 -8
  171. data/spec/unit/compliance/runner_spec.rb +46 -2
  172. data/spec/unit/cookbook_version_spec.rb +52 -0
  173. data/spec/unit/data_collector_spec.rb +47 -1
  174. data/spec/unit/dsl/render_helpers_spec.rb +102 -0
  175. data/spec/unit/dsl/secret_spec.rb +71 -0
  176. data/spec/unit/formatters/doc_spec.rb +1 -1
  177. data/spec/unit/handler_spec.rb +8 -2
  178. data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
  179. data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
  180. data/spec/unit/provider/apt_update_spec.rb +3 -1
  181. data/spec/unit/provider/mount/aix_spec.rb +1 -1
  182. data/spec/unit/provider/package/powershell_spec.rb +74 -12
  183. data/spec/unit/provider/zypper_repository_spec.rb +3 -10
  184. data/spec/unit/provider_spec.rb +23 -0
  185. data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
  186. data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
  187. data/spec/unit/resource/systemd_unit_spec.rb +1 -1
  188. data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
  189. data/spec/unit/resource/windows_defender_spec.rb +71 -0
  190. data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
  191. data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
  192. data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
  193. data/spec/unit/resource/zypper_repository_spec.rb +1 -1
  194. data/spec/unit/resource_spec.rb +19 -8
  195. data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
  196. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +70 -0
  197. data/spec/unit/secret_fetcher_spec.rb +82 -0
  198. metadata +55 -7
@@ -0,0 +1,76 @@
1
+ #
2
+ # Author:: Marc Paradise (<marc@chef.io>)
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "../exceptions"
20
+
21
+ class Chef
22
+ # == Chef::SecretFetcher
23
+ # An abstract base class that defines the methods required to implement
24
+ # a Secret Fetcher.
25
+ class SecretFetcher
26
+ class Base
27
+ attr_reader :config
28
+ # Note that this is only available in the context of a recipe.
29
+ # Since that's the only place it's intended to be used, that's probably OK.
30
+ attr_reader :run_context
31
+
32
+ # Initialize a new SecretFetcher::Base
33
+ #
34
+ # @param config [Hash] Configuration hash. Expected configuration keys and values
35
+ # will vary based on implementation, and are validated in `validate!`.
36
+ def initialize(config, run_context)
37
+ @config = config
38
+ @run_context = run_context
39
+ end
40
+
41
+ # Fetch the named secret by invoking implementation-specific [Chef::SecretFetcher::Base#do_fetch]
42
+ #
43
+ # @param name [Object] the name or identifier of the secret.
44
+ # @param version [Object] Optional version of the secret to fetch.
45
+ # @note - the name parameter will probably see a narrowing of type as we learn more about different integrations.
46
+ # @return [Object] the fetched secret
47
+ # @raise [Chef::Exceptions::Secret::MissingSecretName] when secret name is not provided
48
+ # @raise [Chef::Exceptions::Secret::FetchFailed] when the underlying attempt to fetch the secret fails.
49
+ def fetch(name, version = nil)
50
+ raise Chef::Exceptions::Secret::MissingSecretName.new if name.to_s == ""
51
+
52
+ do_fetch(name, version)
53
+ end
54
+
55
+ # Validate that the instance is correctly configured.
56
+ # @raise [Chef::Exceptions::Secret::ConfigurationInvalid] if it is not.
57
+ def validate!; end
58
+
59
+ # Called to fetch the secret identified by 'identifer'. Implementations
60
+ # should expect that `validate!` has been invoked before `do_fetch`.
61
+ #
62
+ # @param identifier [Object] Unique identifier of the secret to be retrieved.
63
+ # When invoked via DSL, this is pre-verified to be not nil/not empty string.
64
+ # The expected data type and form can vary by implementation.
65
+ # @param version [Object] Optional version of the secret to be retrieved. If not
66
+ # provided, implementations are expected to fetch the most recent version of the
67
+ # secret by default.
68
+ #
69
+ # @return [Object] The secret as returned from the implementation. The data type
70
+ # will vary implementation.
71
+ #
72
+ # @raise [Chef::Exceptions::Secret::FetchFailed] if the secret could not be fetched
73
+ def do_fetch(identifier, version); raise NotImplementedError.new; end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Marc Paradise (<marc@chef.io>)
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "base"
20
+
21
+ class Chef
22
+ # == Chef::SecretFetcher::Example
23
+ # A simple implementation of a secrets fetcher.
24
+ # It expects to be initialized with a hash of
25
+ # keys and secret values.
26
+ #
27
+ # Usage Example:
28
+ #
29
+ # fetcher = SecretFetcher.for_service(:example, "secretkey1" => { "secret" => "lives here" })
30
+ # fetcher.fetch("secretkey1")
31
+ class SecretFetcher
32
+ class Example < Base
33
+ def validate!
34
+ if config.class != Hash
35
+ raise Chef::Exceptions::Secret::ConfigurationInvalid.new("The Example fetcher requires a hash of secrets")
36
+ end
37
+ end
38
+
39
+ def do_fetch(identifier, version)
40
+ raise Chef::Exceptions::Secret::FetchFailed.new("Secret #{identifier}) not found.") unless config.key?(identifier)
41
+
42
+ config[identifier]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,55 @@
1
+ #
2
+ # Author:: Marc Paradise (<marc@chef.io>)
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "exceptions"
20
+
21
+ class Chef
22
+ class SecretFetcher
23
+
24
+ SECRET_FETCHERS = %i{example aws_secrets_manager azure_key_vault}.freeze
25
+
26
+ # Returns a configured and validated instance
27
+ # of a [Chef::SecretFetcher::Base] for the given
28
+ # service and configuration.
29
+ #
30
+ # @param service [Symbol] the identifier for the service that will support this request. Must be in
31
+ # SECRET_FETCHERS
32
+ # @param config [Hash] configuration that the secrets service requires
33
+ # @param run_context [Chef::RunContext] the run context this is being invoked from
34
+ def self.for_service(service, config, run_context)
35
+ fetcher = case service
36
+ when :example
37
+ require_relative "secret_fetcher/example"
38
+ Chef::SecretFetcher::Example.new(config, run_context)
39
+ when :aws_secrets_manager
40
+ require_relative "secret_fetcher/aws_secrets_manager"
41
+ Chef::SecretFetcher::AWSSecretsManager.new(config, run_context)
42
+ when :azure_key_vault
43
+ require_relative "secret_fetcher/azure_key_vault"
44
+ Chef::SecretFetcher::AzureKeyVault.new(config, run_context)
45
+ when nil, ""
46
+ raise Chef::Exceptions::Secret::MissingFetcher.new(SECRET_FETCHERS)
47
+ else
48
+ raise Chef::Exceptions::Secret::InvalidFetcherService.new("Unsupported secret service: #{service}", SECRET_FETCHERS)
49
+ end
50
+ fetcher.validate!
51
+ fetcher
52
+ end
53
+ end
54
+ end
55
+
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("17.1.35")
26
+ VERSION = Chef::VersionString.new("17.4.38")
27
27
  end
28
28
 
29
29
  #
@@ -33,7 +33,7 @@ describe Chef::Mixin::FromFile do
33
33
  end
34
34
 
35
35
  class ClassTestData
36
- class <<self
36
+ class << self
37
37
  include Chef::Mixin::FromFile
38
38
 
39
39
  def a(a = nil)
@@ -0,0 +1,91 @@
1
+ # Author: John McCrae (john.mccrae@progress.com)
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/mixin/powershell_exec"
20
+ require "chef/resource/hostname"
21
+
22
+ describe Chef::Resource::Hostname, :windows_only do
23
+ include Chef::Mixin::PowershellExec
24
+
25
+ def get_domain_status
26
+ powershell_exec!("(Get-WmiObject -Class Win32_ComputerSystem).PartofDomain").result
27
+ end
28
+
29
+ let(:new_hostname) { "New-Hostname" }
30
+ let(:local_domain_user) { "'mydomain\\Groucho'" }
31
+ let(:local_domain_password) { "'P@ssw0rd'" }
32
+ let(:local_windows_reboot) { false }
33
+ let(:domain_status) { get_domain_status }
34
+
35
+ let(:run_context) do
36
+ node = Chef::Node.new
37
+ node.consume_external_attrs(OHAI_SYSTEM.data, {}) # node[:languages][:powershell][:version]
38
+ node.automatic["os"] = "windows"
39
+ node.automatic["platform"] = "windows"
40
+ node.automatic["platform_version"] = "6.1"
41
+ node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
42
+ empty_events = Chef::EventDispatch::Dispatcher.new
43
+ Chef::RunContext.new(node, {}, empty_events)
44
+ end
45
+
46
+ subject do
47
+ new_resource = Chef::Resource::Hostname.new("oldhostname", run_context)
48
+ new_resource.hostname = "Grendel"
49
+ new_resource.windows_reboot = false
50
+ new_resource
51
+ end
52
+
53
+ describe "Changing machine names" do
54
+ context "The system can be renamed without a user or password when in a Workgroup" do
55
+ let(:hostname) { "Cucumber" }
56
+ it "does change" do
57
+ subject.run_action(:set)
58
+ expect(subject).to be_updated_by_last_action
59
+ end
60
+ end
61
+
62
+ describe "Mocking being joined to a domain" do
63
+ before do
64
+ allow(subject).to receive(:is_domain_joined?) { true }
65
+ end
66
+ context "the system gets renamed when in a domain" do
67
+ let(:hostname) { "Gherkin" }
68
+ it "does change the domain account" do
69
+ subject.windows_reboot true
70
+ subject.domain_user local_domain_user
71
+ subject.domain_password local_domain_password
72
+ subject.run_action(:set)
73
+ expect(subject).to be_updated_by_last_action
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "testing for error handling" do
79
+ before do
80
+ allow(subject).to receive(:is_domain_joined?) { true }
81
+ end
82
+ context "when a node is renamed while in a domain" do
83
+ it "and fails because of missing credentials" do
84
+ subject.windows_reboot true
85
+ subject.domain_user local_domain_user
86
+ expect { subject.run_action(:set) }.to raise_error(RuntimeError)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,98 @@
1
+ # Author: John McCrae (john.mccrae@progress.com)
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/mixin/powershell_exec"
20
+
21
+ describe Chef::Resource::WindowsPagefile, :windows_only do
22
+ include Chef::Mixin::PowershellExec
23
+
24
+ let(:c_path) { "c:\\" }
25
+ let(:e_path) { "e:\pagefile.sys" }
26
+
27
+ let(:run_context) do
28
+ node = Chef::Node.new
29
+ node.consume_external_attrs(OHAI_SYSTEM.data, {}) # node[:languages][:powershell][:version]
30
+ node.automatic["os"] = "windows"
31
+ node.automatic["platform"] = "windows"
32
+ node.automatic["platform_version"] = "6.1"
33
+ node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported
34
+ empty_events = Chef::EventDispatch::Dispatcher.new
35
+ Chef::RunContext.new(node, {}, empty_events)
36
+ end
37
+
38
+ subject do
39
+ new_resource = Chef::Resource::WindowsPagefile.new("pagefile", run_context)
40
+ new_resource
41
+ end
42
+
43
+ describe "Setting Up Pagefile Management" do
44
+ context "Disable Automatic Management" do
45
+ it "Disables Automatic Management" do
46
+ subject.path c_path
47
+ subject.automatic_managed false
48
+ subject.run_action(:set)
49
+ expect(subject).to be_updated_by_last_action
50
+ end
51
+
52
+ it "Enable Automatic Management " do
53
+ subject.path c_path
54
+ subject.automatic_managed true
55
+ subject.run_action(:set)
56
+ expect(subject).to be_updated_by_last_action
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "Creating a new Pagefile" do
62
+ context "Create new pagefile" do
63
+ it "Creates a new pagefile on a different drive that doesn't exist" do
64
+ subject.path e_path
65
+ expect { subject.run_action(:set) }.to raise_error(RuntimeError)
66
+ end
67
+ end
68
+
69
+ context "Update a pagefile" do
70
+ it "Changes a pagefile to use custom sizes" do
71
+ subject.path c_path
72
+ subject.initial_size 20000
73
+ subject.maximum_size 80000
74
+ subject.run_action(:set)
75
+ expect(subject).to be_updated_by_last_action
76
+ end
77
+ end
78
+ end
79
+
80
+ describe "Deleting a Pagefile and Resetting to Automatically Managed" do
81
+ context "delete the pagefile on disk" do
82
+ it "deletes the pagefile located at the given path" do
83
+ subject.path c_path
84
+ subject.run_action(:delete)
85
+ expect(subject).to be_updated_by_last_action
86
+ end
87
+ end
88
+
89
+ context "Re-enable automatic management of pagefiles" do
90
+ it "Enable Automatic Management " do
91
+ subject.path c_path
92
+ subject.automatic_managed true
93
+ subject.run_action(:set)
94
+ expect(subject).to be_updated_by_last_action
95
+ end
96
+ end
97
+ end
98
+ end
@@ -47,6 +47,7 @@ describe "chef-client with compliance phase" do
47
47
  {
48
48
  "audit": {
49
49
  "compliance_phase": true,
50
+ "reporter": "json-file",
50
51
  "json_file": {
51
52
  "location": "#{report_file}"
52
53
  },
@@ -19,7 +19,7 @@ describe "Recipe DSL methods" do
19
19
  provides :base_thingy
20
20
  default_action :create
21
21
 
22
- class<<self
22
+ class << self
23
23
  attr_accessor :created_name
24
24
  attr_accessor :created_resource
25
25
  attr_accessor :created_provider
@@ -9,7 +9,7 @@ class NoActionJackson < Chef::Resource
9
9
  @foo
10
10
  end
11
11
 
12
- class <<self
12
+ class << self
13
13
  attr_accessor :action_was
14
14
  end
15
15
  end
@@ -17,7 +17,7 @@ end
17
17
  class WeirdActionJackson < Chef::Resource
18
18
  provides :weird_action_jackson
19
19
 
20
- class <<self
20
+ class << self
21
21
  attr_accessor :action_was
22
22
  end
23
23
 
@@ -176,7 +176,7 @@ module ResourceActionSpec
176
176
  @blarghle
177
177
  end
178
178
 
179
- class <<self
179
+ class << self
180
180
  attr_accessor :ran_action
181
181
  attr_accessor :succeeded
182
182
  attr_accessor :ruby_block_converged
@@ -284,7 +284,7 @@ module ResourceActionSpec
284
284
  @bar = "#{value}alope" if value
285
285
  @bar
286
286
  end
287
- class <<self
287
+ class << self
288
288
  attr_accessor :load_current_resource_ran
289
289
  attr_accessor :jackalope_ran
290
290
  end
@@ -354,8 +354,8 @@ module ResourceActionSpec
354
354
  end
355
355
 
356
356
  it "allows overridden action to have a description separate from the action defined in the base resource" do
357
- expect(ActionJackson.action_description(:test1)).to eql "Original description"
358
- expect(ActionJackalope.action_description(:test1)).to eql "An old action with a new description"
357
+ expect(ActionJackson.new("ActionJackson", nil).action_description(:test1)).to eql "Original description"
358
+ expect(ActionJackalope.new("ActionJackalope", nil).action_description(:test1)).to eql "An old action with a new description"
359
359
  end
360
360
 
361
361
  it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do