chef 17.4.38-universal-mingw32 → 17.7.22-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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/chef.gemspec +3 -0
  4. data/lib/chef/application/base.rb +11 -1
  5. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  6. data/lib/chef/chef_fs/path_utils.rb +1 -1
  7. data/lib/chef/client.rb +1 -2
  8. data/lib/chef/compliance/input.rb +115 -0
  9. data/lib/chef/compliance/input_collection.rb +139 -0
  10. data/lib/chef/compliance/profile.rb +122 -0
  11. data/lib/chef/compliance/profile_collection.rb +109 -0
  12. data/lib/chef/compliance/runner.rb +47 -5
  13. data/lib/chef/compliance/waiver.rb +115 -0
  14. data/lib/chef/compliance/waiver_collection.rb +143 -0
  15. data/lib/chef/data_collector/run_end_message.rb +1 -1
  16. data/lib/chef/dsl/compliance.rb +38 -0
  17. data/lib/chef/dsl/reader_helpers.rb +51 -0
  18. data/lib/chef/dsl/reboot_pending.rb +1 -1
  19. data/lib/chef/dsl/recipe.rb +4 -2
  20. data/lib/chef/dsl/secret.rb +2 -4
  21. data/lib/chef/dsl/universal.rb +2 -0
  22. data/lib/chef/event_dispatch/base.rb +44 -2
  23. data/lib/chef/exceptions.rb +10 -0
  24. data/lib/chef/formatters/doc.rb +46 -0
  25. data/lib/chef/http/basic_client.rb +15 -7
  26. data/lib/chef/http.rb +7 -3
  27. data/lib/chef/provider/cron.rb +4 -1
  28. data/lib/chef/provider/file.rb +2 -0
  29. data/lib/chef/provider/git.rb +1 -1
  30. data/lib/chef/provider/ifconfig/debian.rb +1 -1
  31. data/lib/chef/provider/link.rb +2 -2
  32. data/lib/chef/provider/registry_key.rb +3 -2
  33. data/lib/chef/provider/remote_file/http.rb +1 -1
  34. data/lib/chef/provider/subversion.rb +5 -5
  35. data/lib/chef/provider/template.rb +1 -1
  36. data/lib/chef/resource/archive_file.rb +17 -14
  37. data/lib/chef/resource/chef_client_scheduled_task.rb +45 -2
  38. data/lib/chef/resource/chocolatey_config.rb +14 -14
  39. data/lib/chef/resource/chocolatey_feature.rb +1 -1
  40. data/lib/chef/resource/chocolatey_source.rb +24 -2
  41. data/lib/chef/resource/directory.rb +1 -1
  42. data/lib/chef/resource/file/verification/json.rb +50 -0
  43. data/lib/chef/resource/file/verification/yaml.rb +52 -0
  44. data/lib/chef/resource/habitat_install.rb +3 -3
  45. data/lib/chef/resource/inspec_input.rb +127 -0
  46. data/lib/chef/resource/inspec_waiver.rb +184 -0
  47. data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
  48. data/lib/chef/resource/kernel_module.rb +27 -2
  49. data/lib/chef/resource/macos_userdefaults.rb +43 -128
  50. data/lib/chef/resource/mount.rb +1 -1
  51. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  52. data/lib/chef/resource/powershell_package_source.rb +234 -70
  53. data/lib/chef/resource/registry_key.rb +36 -48
  54. data/lib/chef/resource/remote_file.rb +98 -2
  55. data/lib/chef/resource/timezone.rb +2 -2
  56. data/lib/chef/resource/user_ulimit.rb +1 -0
  57. data/lib/chef/resource/windows_auto_run.rb +1 -1
  58. data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
  59. data/lib/chef/resource/windows_printer.rb +1 -1
  60. data/lib/chef/resource/windows_uac.rb +3 -1
  61. data/lib/chef/resource/windows_update_settings.rb +3 -3
  62. data/lib/chef/resource/windows_user_privilege.rb +1 -1
  63. data/lib/chef/resource.rb +1 -1
  64. data/lib/chef/resource_reporter.rb +1 -1
  65. data/lib/chef/resources.rb +2 -0
  66. data/lib/chef/run_context/cookbook_compiler.rb +112 -28
  67. data/lib/chef/run_context.rb +31 -1
  68. data/lib/chef/secret_fetcher/akeyless_vault.rb +57 -0
  69. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +1 -1
  70. data/lib/chef/secret_fetcher/azure_key_vault.rb +63 -9
  71. data/lib/chef/secret_fetcher/base.rb +1 -1
  72. data/lib/chef/secret_fetcher/hashi_vault.rb +100 -0
  73. data/lib/chef/secret_fetcher.rb +8 -3
  74. data/lib/chef/version.rb +1 -1
  75. data/lib/chef/win32/version.rb +2 -1
  76. data/spec/data/archive_file/test_archive.tar.gz +0 -0
  77. data/spec/functional/dsl/reboot_pending_spec.rb +3 -3
  78. data/spec/functional/dsl/registry_helper_spec.rb +1 -1
  79. data/spec/functional/resource/archive_file_spec.rb +87 -0
  80. data/spec/functional/resource/dsc_script_spec.rb +2 -2
  81. data/spec/functional/resource/group_spec.rb +5 -1
  82. data/spec/functional/resource/link_spec.rb +8 -0
  83. data/spec/functional/resource/macos_userdefaults_spec.rb +119 -0
  84. data/spec/functional/resource/powershell_package_source_spec.rb +5 -6
  85. data/spec/functional/resource/registry_spec.rb +81 -81
  86. data/spec/functional/win32/registry_spec.rb +8 -8
  87. data/spec/integration/compliance/compliance_spec.rb +60 -0
  88. data/spec/spec_helper.rb +3 -0
  89. data/spec/support/platform_helpers.rb +4 -0
  90. data/spec/support/ruby_installer.rb +51 -0
  91. data/spec/unit/compliance/input_spec.rb +104 -0
  92. data/spec/unit/compliance/profile_spec.rb +120 -0
  93. data/spec/unit/compliance/waiver_spec.rb +104 -0
  94. data/spec/unit/data_collector_spec.rb +24 -1
  95. data/spec/unit/dsl/reboot_pending_spec.rb +1 -1
  96. data/spec/unit/http/basic_client_spec.rb +30 -0
  97. data/spec/unit/http_spec.rb +8 -2
  98. data/spec/unit/mixin/default_paths_spec.rb +1 -1
  99. data/spec/unit/mixin/securable_spec.rb +3 -3
  100. data/spec/unit/provider/cron_spec.rb +45 -0
  101. data/spec/unit/provider/link_spec.rb +13 -7
  102. data/spec/unit/provider/package/rubygems_spec.rb +5 -5
  103. data/spec/unit/provider/package/windows_spec.rb +1 -1
  104. data/spec/unit/provider/registry_key_spec.rb +4 -4
  105. data/spec/unit/provider/remote_file/http_spec.rb +10 -0
  106. data/spec/unit/provider/service/windows_spec.rb +5 -5
  107. data/spec/unit/provider/subversion_spec.rb +4 -4
  108. data/spec/unit/provider/template_spec.rb +2 -2
  109. data/spec/unit/provider/windows_env_spec.rb +1 -1
  110. data/spec/unit/provider/zypper_repository_spec.rb +1 -1
  111. data/spec/unit/resource/archive_file_spec.rb +414 -3
  112. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +69 -0
  113. data/spec/unit/resource/chocolatey_config_spec.rb +1 -1
  114. data/spec/unit/resource/chocolatey_feature_spec.rb +1 -1
  115. data/spec/unit/resource/chocolatey_source_spec.rb +1 -1
  116. data/spec/unit/resource/file/verification/json_spec.rb +72 -0
  117. data/spec/unit/resource/file/verification/yaml_spec.rb +67 -0
  118. data/spec/unit/resource/inspec_input_spec.rb +300 -0
  119. data/spec/unit/resource/inspec_waiver_spec.rb +312 -0
  120. data/spec/unit/resource/kernel_module_spec.rb +2 -1
  121. data/spec/unit/resource/macos_user_defaults_spec.rb +36 -96
  122. data/spec/unit/resource/mount_spec.rb +10 -0
  123. data/spec/unit/resource/powershell_package_source_spec.rb +63 -62
  124. data/spec/unit/resource/registry_key_spec.rb +10 -10
  125. data/spec/unit/resource/user_ulimit_spec.rb +14 -1
  126. data/spec/unit/resource/windows_auto_run_spec.rb +1 -1
  127. data/spec/unit/resource/windows_feature_powershell_spec.rb +1 -1
  128. data/spec/unit/resource/windows_firewall_rule_spec.rb +2 -2
  129. data/spec/unit/resource/windows_task_spec.rb +3 -3
  130. data/spec/unit/resource_reporter_spec.rb +2 -2
  131. data/spec/unit/resource_spec.rb +5 -0
  132. data/spec/unit/secret_fetcher/akeyless_vault_spec.rb +37 -0
  133. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +99 -20
  134. data/spec/unit/secret_fetcher/hashi_vault_spec.rb +80 -0
  135. data/spec/unit/util/backup_spec.rb +1 -1
  136. data/spec/unit/win32/registry_spec.rb +3 -3
  137. data/tasks/rspec.rb +2 -1
  138. metadata +75 -6
@@ -20,51 +20,130 @@
20
20
  require_relative "../../spec_helper"
21
21
  require "chef/secret_fetcher"
22
22
  require "chef/secret_fetcher/azure_key_vault"
23
+ require "net/http/responses"
23
24
 
24
25
  describe Chef::SecretFetcher::AzureKeyVault do
25
- let(:config) { { vault: "my_vault" } }
26
+ let(:config) { { vault: "my-vault" } }
26
27
  let(:fetcher) { Chef::SecretFetcher::AzureKeyVault.new(config, nil) }
28
+ let(:secrets_response_body) { '{ "value" : "my secret value" }' }
29
+ let(:secrets_response_mock) do
30
+ rm = Net::HTTPSuccess.new("1.0", "400", "OK")
31
+ allow(rm).to receive(:body).and_return(secrets_response_body)
32
+ rm
33
+ end
34
+ let(:token_response_body) { %Q({"access_token":"#{access_token}","client_id":"#{client_id}","expires_in":"86294","expires_on":"1627761860","ext_expires_in":"86399","not_before":"1627675160","resource":"https://vault.azure.net","token_type":"Bearer"}) }
35
+ let(:access_token) { "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyIsImtpZCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiJodHRwczovL3ZhdWx0LmF6dXJlLm5ldCIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2E5ZTY2ZDhkLTA1ZTAtNGMwMC1iOWRkLWM0Yjc3M2U5MWNhNi8iLCJpYXQiOjE2Mjc2NzUxNjAsIm5iZiI6MTYyNzY3NTE2MCwiZXhwIjoxNjI3NzYxODYwLCJhaW8iOiJFMlpnWUhCWGplaTdWS214eEh6bjdoSWpNZFlMQUE9PSIsImFwcGlkIjoiNjU2Mjc1MjEtMzYzYi00ZDk2LTkyMTctMjcIsIm9pZCI6IjNiZjI1NjVhLWY4NWQtNDBiNy1hZWJkLTNlZDA1ZDA0N2FmNiIsInJoIjoiMC5BUk1BalczbXFlQUZBRXk1M2NTM2Mta2NwaUYxWW1VN05wWk5raGNuRGpuZEwxb1RBQUEuIiwic3ViIjoiM2JmMjU2NWEtZjg1ZC00MGI3LWFlYmQtM2VkMDVkMDQ3YWY2IiwidGlkIjoiYTllNjZkOGQtMDVlMC00YzAwLWI5ZGQtYzRiNzczZTkxY2E2IiwidXRpIjoibXlzeHpSRTV3ay1ibTFlYkNqc09BQSIsInZlciI6IjEuMCIsInhtc19taXJpZCI6Ii9zdWJzY3JpcHRpb25zLzYzNDJkZDZkLTc1NTQtNDJjOS04NTM2LTdkZmU3MmY1MWZhZC9yZXNvdXJjZWdyb3Vwcy9pbWFnZS1waXBlbGluZS1ydW5uZXItcWEtZWFzdHVzMi1yZy9wcm92aWRlcnMvTWljcm9zb2Z0Lk1hbmFnZWRJZGVudGl0eS91c2VyQXNzaWduZWRJZGVudGl0aWVzL2ltYWdlLXBpcGVsaW5lLXJ1bm5lci1xYS1lYXN0dXMyLW1pIn0.BquzjN6d0g4zlvkbkdVwNEfRxIXSmxYwCHMk6UG3iza2fVioiOrcoP4Cp9P5--AB4G_CAhIXaP7YIZs3mq05QiDjSvkVAM0t67UPGhEr66sNXkV72iZBnKca_auh6EHsjPfxeVHkE1wdrsncrYdKhzgO4IAj8Jg4N5qjcE2q-OkliadmEuTwrhPhq" }
36
+ let(:token_response_mock) do
37
+ rm = Net::HTTPSuccess.new("1.0", "400", "OK")
38
+ allow(rm).to receive(:body).and_return(token_response_body)
39
+ rm
40
+ end
41
+ let(:client_id) { SecureRandom.uuid }
42
+ let(:http_mock) { instance_double("Net::HTTP", :use_ssl= => nil) }
43
+ let(:token_uri) { URI.parse("http://169.254.169.254/metadata/identity/oauth2/token") }
44
+ let(:vault_name) { "my-vault" }
45
+ let(:secret_name) { "my-secret" }
46
+ let(:vault_secret_uri) { URI.parse("https://#{vault_name}.vault.azure.net/secrets/#{secret_name}/?api-version=7.2") }
47
+
48
+ before do
49
+ # Cache these up front so we can pass into allow statements without hitting:
50
+ # URI received :parse with unexpected arguments
51
+ token_uri
52
+ vault_secret_uri
53
+ end
54
+
55
+ before do
56
+ allow(Net::HTTP).to receive(:new).and_return(http_mock)
57
+ allow(URI).to receive(:parse).with("http://169.254.169.254/metadata/identity/oauth2/token").and_return(token_uri)
58
+ allow(URI).to receive(:parse).with("https://#{vault_name}.vault.azure.net/secrets/#{secret_name}/?api-version=7.2").and_return(vault_secret_uri)
59
+ allow(http_mock).to receive(:get).with(token_uri, { "Metadata" => "true" }).and_return(token_response_mock)
60
+ allow(http_mock).to receive(:get).with(vault_secret_uri, { "Authorization" => "Bearer #{access_token}", "Content-Type" => "application/json" }).and_return(secrets_response_mock)
61
+ end
62
+
63
+ describe "#validate!" do
64
+ it "raises error when more than one is provided: :object_id, :client_id, :mi_res_id" do
65
+ expect { Chef::SecretFetcher::AzureKeyVault.new({ object_id: "abc", client_id: "abc", mi_res_id: "abc" }, nil).validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
66
+ expect { Chef::SecretFetcher::AzureKeyVault.new({ object_id: "abc", client_id: "abc" }, nil).validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
67
+ expect { Chef::SecretFetcher::AzureKeyVault.new({ object_id: "abc", mi_res_id: "abc" }, nil).validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
68
+ expect { Chef::SecretFetcher::AzureKeyVault.new({ client_id: "abc", mi_res_id: "abc" }, nil).validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
69
+ end
70
+ end
27
71
 
28
- context "when performing a fetch" do
29
- let(:body) { '{ "value" : "my secret value" }' }
30
- let(:response_mock) { double("response", body: body) }
31
- let(:http_mock) { double("http", :get => response_mock, :use_ssl= => nil) }
72
+ describe "#fetch_token" do
73
+ context "when Net::HTTPBadRequest is returned and the error description contains \"Identity not found\"" do
74
+ let(:token_response_mock) { Net::HTTPBadRequest.new("1.0", "400", "Bad Request") }
75
+
76
+ before do
77
+ allow(fetcher).to receive(:fetch_token).and_call_original
78
+ allow(token_response_mock).to receive(:body).and_return('{"error":"invalid_request","error_description":"Identity not found"}')
79
+ end
32
80
 
33
- before do
34
- allow(fetcher).to receive(:fetch_token).and_return "a token"
35
- allow(Net::HTTP).to receive(:new).and_return(http_mock)
81
+ it "raises Chef::Exceptions::Secret::Azure::IdentityNotFound" do
82
+ expect { fetcher.send(:fetch_token) }.to raise_error(Chef::Exceptions::Secret::Azure::IdentityNotFound)
83
+ end
36
84
  end
37
85
 
38
- context "and vault name is only provided in the secret name" do
39
- let(:body) { '{ "value" : "my secret value" }' }
86
+ context "when :object_id is provided" do
87
+ let(:object_id) { SecureRandom.uuid }
88
+ let(:config) { { vault: "my-vault", object_id: object_id } }
89
+
90
+ it "adds client_id to request params" do
91
+ fetcher.send(:fetch_token)
92
+ expect(token_uri.query).to match(/object_id=#{object_id}/)
93
+ end
94
+ end
95
+
96
+ context "when :client_id is provided" do
97
+ let(:config) { { vault: "my-vault", client_id: client_id } }
98
+
99
+ it "adds client_id to request params" do
100
+ fetcher.send(:fetch_token)
101
+ expect(token_uri.query).to match(/client_id=#{client_id}/)
102
+ end
103
+ end
104
+
105
+ context "when :mi_res_id is provided" do
106
+ let(:mi_res_id) { SecureRandom.uuid }
107
+ let(:config) { { vault: "my-vault", mi_res_id: mi_res_id } }
108
+
109
+ it "adds client_id to request params" do
110
+ fetcher.send(:fetch_token)
111
+ expect(token_uri.query).to match(/mi_res_id=#{mi_res_id}/)
112
+ end
113
+ end
114
+ end
115
+
116
+ describe "#fetch" do
117
+ context "when vault name is only provided in the secret name" do
118
+ let(:secrets_response_body) { '{ "value" : "my secret value" }' }
40
119
  let(:config) { {} }
41
120
  it "fetches the value" do
42
- expect(fetcher.fetch("my_vault/value")).to eq "my secret value"
121
+ expect(fetcher.fetch("my-vault/my-secret")).to eq "my secret value"
43
122
  end
44
123
  end
45
124
 
46
- context "and vault name is not provided in the secret name" do
125
+ context "when vault name is not provided in the secret name" do
47
126
  context "and vault name is not provided in config" do
48
127
  let(:config) { {} }
49
128
  it "raises a ConfigurationInvalid exception" do
50
- expect { fetcher.fetch("value") }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
129
+ expect { fetcher.fetch("my-secret") }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
51
130
  end
52
131
  end
53
132
 
54
133
  context "and vault name is provided in config" do
55
- let(:config) { { vault: "my_vault" } }
134
+ let(:config) { { vault: "my-vault" } }
56
135
  it "fetches the value" do
57
- expect(fetcher.fetch("value")).to eq "my secret value"
136
+ expect(fetcher.fetch("my-secret")).to eq "my secret value"
58
137
  end
59
138
  end
60
139
  end
61
- context "and an error response is received in the body" do
62
- let(:config) { { vault: "my_vault" } }
63
- let(:body) { '{ "error" : { "code" : 404, "message" : "secret not found" } }' }
140
+
141
+ context "when an error response is received in the response body" do
142
+ let(:config) { { vault: "my-vault" } }
143
+ let(:secrets_response_body) { '{ "error" : { "code" : 404, "message" : "secret not found" } }' }
64
144
  it "raises FetchFailed" do
65
- expect { fetcher.fetch("value") }.to raise_error(Chef::Exceptions::Secret::FetchFailed)
145
+ expect { fetcher.fetch("my-secret") }.to raise_error(Chef::Exceptions::Secret::FetchFailed)
66
146
  end
67
147
  end
68
148
  end
69
149
  end
70
-
@@ -0,0 +1,80 @@
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 "../../spec_helper"
20
+ require "chef/secret_fetcher/hashi_vault"
21
+
22
+ describe Chef::SecretFetcher::HashiVault do
23
+ let(:node) { {} }
24
+ let(:run_context) { double("run_context", node: node) }
25
+
26
+ context "when validating provided HashiVault configuration" do
27
+ it "raises ConfigurationInvalid when the :auth_method is not valid" do
28
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :invalid, vault_addr: "https://vault.example.com:8200" }, run_context)
29
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid, /:auth_method/)
30
+ end
31
+
32
+ it "raises ConfigurationInvalid when the vault_addr is not provided" do
33
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :iam_role, role_name: "example-role" }, run_context)
34
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
35
+ end
36
+
37
+ context "and using auth_method: :iam_role" do
38
+ it "raises ConfigurationInvalid when the role_name is not provided" do
39
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :iam_role, vault_addr: "https://vault.example.com:8200" }, run_context)
40
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
41
+ end
42
+
43
+ it "obtains a token via AWS IAM auth to allow the gem to do its own validations when all required config is provided" do
44
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :iam_role, vault_addr: "https://vault.example.com:8200", role_name: "example-role" }, run_context)
45
+ allow(Aws::InstanceProfileCredentials).to receive(:new).and_return instance_double(Aws::InstanceProfileCredentials)
46
+ auth_double = instance_double(Vault::Authenticate)
47
+ expect(auth_double).to receive(:aws_iam)
48
+ allow(Vault).to receive(:auth).and_return(auth_double)
49
+ fetcher.validate!
50
+ end
51
+ end
52
+
53
+ context "and using auth_method: :token" do
54
+ it "raises ConfigurationInvalid when no token is provided" do
55
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :token, vault_addr: "https://vault.example.com:8200" }, run_context)
56
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
57
+ end
58
+
59
+ it "authenticates using the token during validation when all configuration is correct" do
60
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :token, token: "t.1234abcd", vault_addr: "https://vault.example.com:8200" }, run_context)
61
+ auth = instance_double(Vault::Authenticate)
62
+ auth_double = instance_double(Vault::Authenticate)
63
+ expect(auth_double).to receive(:token)
64
+ allow(Vault).to receive(:auth).and_return(auth_double)
65
+ fetcher.validate!
66
+ end
67
+ end
68
+ end
69
+
70
+ context "when fetching a secret from Hashi Vault" do
71
+ it "raises an FetchFailed message when no secret is returned due to invalid engine path" do
72
+ fetcher = Chef::SecretFetcher::HashiVault.new( { auth_method: :invalid, vault_addr: "https://vault.example.com:8200" }, run_context)
73
+ logical_double = instance_double(Vault::Logical)
74
+ expect(logical_double).to receive(:read).and_return nil
75
+ expect(Vault).to receive(:logical).and_return(logical_double)
76
+ expect { fetcher.do_fetch("anything", nil) }.to raise_error(Chef::Exceptions::Secret::FetchFailed)
77
+ end
78
+ end
79
+ end
80
+
@@ -132,7 +132,7 @@ describe Chef::Util::Backup do
132
132
  end
133
133
 
134
134
  it "uses the configured Chef::Config[:file_backup_path] and strips the drive on windows" do
135
- expect(@backup).to receive(:path).and_return('c:\\a\\b\\c.txt')
135
+ expect(@backup).to receive(:path).and_return("c:\\a\\b\\c.txt")
136
136
  Chef::Config[:file_backup_path] = 'c:\backupdir'
137
137
  expect(@backup.send(:backup_path)).to match(%r|^c:\\backupdir[\\/]+a\\b\\c.txt.chef-\d{14}.\d{6}$|)
138
138
  end
@@ -23,12 +23,12 @@ describe Chef::Win32::Registry do
23
23
 
24
24
  let(:value1) { { name: "one", type: :string, data: "1" } }
25
25
  let(:value1_upcase_name) { { name: "ONE", type: :string, data: "1" } }
26
- let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
27
- let(:key) { 'Software\OpscodeNumbers' }
26
+ let(:key_path) { "HKCU\\Software\\OpscodeNumbers" }
27
+ let(:key) { "Software\\OpscodeNumbers" }
28
28
  let(:key_parent) { "Software" }
29
29
  let(:key_to_delete) { "OpscodeNumbers" }
30
30
  let(:sub_key) { "OpscodePrimes" }
31
- let(:missing_key_path) { 'HKCU\Software' }
31
+ let(:missing_key_path) { "HKCU\\Software" }
32
32
  let(:registry) { Chef::Win32::Registry.new }
33
33
  let(:hive_mock) { double("::Win32::Registry::HKEY_CURRENT_USER") }
34
34
  let(:reg_mock) { double("reg") }
data/tasks/rspec.rb CHANGED
@@ -30,7 +30,8 @@ begin
30
30
  puts "--- Running #{gem} specs"
31
31
  Bundler.with_unbundled_env do
32
32
  puts "Executing tests in #{Dir.pwd}:"
33
- sh("bundle install --jobs=3 --retry=3 --path=../vendor/bundle")
33
+ sh("bundle config set --local path 'vendor/bundle'")
34
+ sh("bundle install --jobs=3 --retry=3")
34
35
  sh("bundle exec rake spec")
35
36
  end
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.4.38
4
+ version: 17.7.22
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 17.4.38
19
+ version: 17.7.22
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 17.4.38
26
+ version: 17.7.22
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 17.4.38
33
+ version: 17.7.22
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 17.4.38
40
+ version: 17.7.22
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -426,6 +426,20 @@ dependencies:
426
426
  - - "<"
427
427
  - !ruby/object:Gem::Version
428
428
  version: '3.0'
429
+ - !ruby/object:Gem::Dependency
430
+ name: corefoundation
431
+ requirement: !ruby/object:Gem::Requirement
432
+ requirements:
433
+ - - "~>"
434
+ - !ruby/object:Gem::Version
435
+ version: 0.3.4
436
+ type: :runtime
437
+ prerelease: false
438
+ version_requirements: !ruby/object:Gem::Requirement
439
+ requirements:
440
+ - - "~>"
441
+ - !ruby/object:Gem::Version
442
+ version: 0.3.4
429
443
  - !ruby/object:Gem::Dependency
430
444
  name: proxifier
431
445
  requirement: !ruby/object:Gem::Requirement
@@ -440,6 +454,20 @@ dependencies:
440
454
  - - "~>"
441
455
  - !ruby/object:Gem::Version
442
456
  version: '1.0'
457
+ - !ruby/object:Gem::Dependency
458
+ name: aws-sdk-s3
459
+ requirement: !ruby/object:Gem::Requirement
460
+ requirements:
461
+ - - "~>"
462
+ - !ruby/object:Gem::Version
463
+ version: '1.91'
464
+ type: :runtime
465
+ prerelease: false
466
+ version_requirements: !ruby/object:Gem::Requirement
467
+ requirements:
468
+ - - "~>"
469
+ - !ruby/object:Gem::Version
470
+ version: '1.91'
443
471
  - !ruby/object:Gem::Dependency
444
472
  name: aws-sdk-secretsmanager
445
473
  requirement: !ruby/object:Gem::Requirement
@@ -454,6 +482,20 @@ dependencies:
454
482
  - - "~>"
455
483
  - !ruby/object:Gem::Version
456
484
  version: '1.46'
485
+ - !ruby/object:Gem::Dependency
486
+ name: vault
487
+ requirement: !ruby/object:Gem::Requirement
488
+ requirements:
489
+ - - "~>"
490
+ - !ruby/object:Gem::Version
491
+ version: '0.16'
492
+ type: :runtime
493
+ prerelease: false
494
+ version_requirements: !ruby/object:Gem::Requirement
495
+ requirements:
496
+ - - "~>"
497
+ - !ruby/object:Gem::Version
498
+ version: '0.16'
457
499
  - !ruby/object:Gem::Dependency
458
500
  name: win32-api
459
501
  requirement: !ruby/object:Gem::Requirement
@@ -1366,12 +1408,18 @@ files:
1366
1408
  - lib/chef/compliance/default_attributes.rb
1367
1409
  - lib/chef/compliance/fetcher/automate.rb
1368
1410
  - lib/chef/compliance/fetcher/chef_server.rb
1411
+ - lib/chef/compliance/input.rb
1412
+ - lib/chef/compliance/input_collection.rb
1413
+ - lib/chef/compliance/profile.rb
1414
+ - lib/chef/compliance/profile_collection.rb
1369
1415
  - lib/chef/compliance/reporter/automate.rb
1370
1416
  - lib/chef/compliance/reporter/chef_server_automate.rb
1371
1417
  - lib/chef/compliance/reporter/cli.rb
1372
1418
  - lib/chef/compliance/reporter/compliance_enforcer.rb
1373
1419
  - lib/chef/compliance/reporter/json_file.rb
1374
1420
  - lib/chef/compliance/runner.rb
1421
+ - lib/chef/compliance/waiver.rb
1422
+ - lib/chef/compliance/waiver_collection.rb
1375
1423
  - lib/chef/config.rb
1376
1424
  - lib/chef/config_fetcher.rb
1377
1425
  - lib/chef/constants.rb
@@ -1411,6 +1459,7 @@ files:
1411
1459
  - lib/chef/dsl.rb
1412
1460
  - lib/chef/dsl/chef_vault.rb
1413
1461
  - lib/chef/dsl/cheffish.rb
1462
+ - lib/chef/dsl/compliance.rb
1414
1463
  - lib/chef/dsl/data_query.rb
1415
1464
  - lib/chef/dsl/declare_resource.rb
1416
1465
  - lib/chef/dsl/definitions.rb
@@ -1418,6 +1467,7 @@ files:
1418
1467
  - lib/chef/dsl/include_recipe.rb
1419
1468
  - lib/chef/dsl/platform_introspection.rb
1420
1469
  - lib/chef/dsl/powershell.rb
1470
+ - lib/chef/dsl/reader_helpers.rb
1421
1471
  - lib/chef/dsl/reboot_pending.rb
1422
1472
  - lib/chef/dsl/recipe.rb
1423
1473
  - lib/chef/dsl/registry_helper.rb
@@ -1760,7 +1810,9 @@ files:
1760
1810
  - lib/chef/resource/execute.rb
1761
1811
  - lib/chef/resource/file.rb
1762
1812
  - lib/chef/resource/file/verification.rb
1813
+ - lib/chef/resource/file/verification/json.rb
1763
1814
  - lib/chef/resource/file/verification/systemd_unit.rb
1815
+ - lib/chef/resource/file/verification/yaml.rb
1764
1816
  - lib/chef/resource/freebsd_package.rb
1765
1817
  - lib/chef/resource/gem_package.rb
1766
1818
  - lib/chef/resource/group.rb
@@ -1781,6 +1833,8 @@ files:
1781
1833
  - lib/chef/resource/hostname.rb
1782
1834
  - lib/chef/resource/http_request.rb
1783
1835
  - lib/chef/resource/ifconfig.rb
1836
+ - lib/chef/resource/inspec_input.rb
1837
+ - lib/chef/resource/inspec_waiver.rb
1784
1838
  - lib/chef/resource/inspec_waiver_file_entry.rb
1785
1839
  - lib/chef/resource/ips_package.rb
1786
1840
  - lib/chef/resource/kernel_module.rb
@@ -1928,10 +1982,12 @@ files:
1928
1982
  - lib/chef/scan_access_control.rb
1929
1983
  - lib/chef/search/query.rb
1930
1984
  - lib/chef/secret_fetcher.rb
1985
+ - lib/chef/secret_fetcher/akeyless_vault.rb
1931
1986
  - lib/chef/secret_fetcher/aws_secrets_manager.rb
1932
1987
  - lib/chef/secret_fetcher/azure_key_vault.rb
1933
1988
  - lib/chef/secret_fetcher/base.rb
1934
1989
  - lib/chef/secret_fetcher/example.rb
1990
+ - lib/chef/secret_fetcher/hashi_vault.rb
1935
1991
  - lib/chef/server_api.rb
1936
1992
  - lib/chef/server_api_versions.rb
1937
1993
  - lib/chef/shell.rb
@@ -2060,6 +2116,7 @@ files:
2060
2116
  - spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages
2061
2117
  - spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb
2062
2118
  - spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
2119
+ - spec/data/archive_file/test_archive.tar.gz
2063
2120
  - spec/data/bad-config.rb
2064
2121
  - spec/data/bootstrap/encrypted_data_bag_secret
2065
2122
  - spec/data/bootstrap/no_proxy.erb
@@ -2444,6 +2501,7 @@ files:
2444
2501
  - spec/functional/resource/aix_service_spec.rb
2445
2502
  - spec/functional/resource/aixinit_service_spec.rb
2446
2503
  - spec/functional/resource/apt_package_spec.rb
2504
+ - spec/functional/resource/archive_file_spec.rb
2447
2505
  - spec/functional/resource/bash_spec.rb
2448
2506
  - spec/functional/resource/batch_spec.rb
2449
2507
  - spec/functional/resource/bff_spec.rb
@@ -2464,6 +2522,7 @@ files:
2464
2522
  - spec/functional/resource/launchd_spec.rb
2465
2523
  - spec/functional/resource/link_spec.rb
2466
2524
  - spec/functional/resource/locale_spec.rb
2525
+ - spec/functional/resource/macos_userdefaults_spec.rb
2467
2526
  - spec/functional/resource/mount_spec.rb
2468
2527
  - spec/functional/resource/msu_package_spec.rb
2469
2528
  - spec/functional/resource/ohai_spec.rb
@@ -2548,6 +2607,7 @@ files:
2548
2607
  - spec/support/platforms/prof/win32.rb
2549
2608
  - spec/support/platforms/win32/spec_service.rb
2550
2609
  - spec/support/recipe_dsl_helper.rb
2610
+ - spec/support/ruby_installer.rb
2551
2611
  - spec/support/shared/context/config.rb
2552
2612
  - spec/support/shared/context/win32.rb
2553
2613
  - spec/support/shared/functional/diff_disabled.rb
@@ -2608,10 +2668,13 @@ files:
2608
2668
  - spec/unit/client_spec.rb
2609
2669
  - spec/unit/compliance/fetcher/automate_spec.rb
2610
2670
  - spec/unit/compliance/fetcher/chef_server_spec.rb
2671
+ - spec/unit/compliance/input_spec.rb
2672
+ - spec/unit/compliance/profile_spec.rb
2611
2673
  - spec/unit/compliance/reporter/automate_spec.rb
2612
2674
  - spec/unit/compliance/reporter/chef_server_automate_spec.rb
2613
2675
  - spec/unit/compliance/reporter/compliance_enforcer_spec.rb
2614
2676
  - spec/unit/compliance/runner_spec.rb
2677
+ - spec/unit/compliance/waiver_spec.rb
2615
2678
  - spec/unit/config_fetcher_spec.rb
2616
2679
  - spec/unit/config_spec.rb
2617
2680
  - spec/unit/cookbook/chefignore_spec.rb
@@ -2898,7 +2961,9 @@ files:
2898
2961
  - spec/unit/resource/dsc_resource_spec.rb
2899
2962
  - spec/unit/resource/dsc_script_spec.rb
2900
2963
  - spec/unit/resource/execute_spec.rb
2964
+ - spec/unit/resource/file/verification/json_spec.rb
2901
2965
  - spec/unit/resource/file/verification/systemd_unit_spec.rb
2966
+ - spec/unit/resource/file/verification/yaml_spec.rb
2902
2967
  - spec/unit/resource/file/verification_spec.rb
2903
2968
  - spec/unit/resource/file_spec.rb
2904
2969
  - spec/unit/resource/freebsd_package_spec.rb
@@ -2912,7 +2977,9 @@ files:
2912
2977
  - spec/unit/resource/hostname_spec.rb
2913
2978
  - spec/unit/resource/http_request_spec.rb
2914
2979
  - spec/unit/resource/ifconfig_spec.rb
2980
+ - spec/unit/resource/inspec_input_spec.rb
2915
2981
  - spec/unit/resource/inspec_waiver_file_entry_spec.rb
2982
+ - spec/unit/resource/inspec_waiver_spec.rb
2916
2983
  - spec/unit/resource/ips_package_spec.rb
2917
2984
  - spec/unit/resource/kernel_module_spec.rb
2918
2985
  - spec/unit/resource/ksh_spec.rb
@@ -3039,8 +3106,10 @@ files:
3039
3106
  - spec/unit/runner_spec.rb
3040
3107
  - spec/unit/scan_access_control_spec.rb
3041
3108
  - spec/unit/search/query_spec.rb
3109
+ - spec/unit/secret_fetcher/akeyless_vault_spec.rb
3042
3110
  - spec/unit/secret_fetcher/aws_secrets_manager_spec.rb
3043
3111
  - spec/unit/secret_fetcher/azure_key_vault_spec.rb
3112
+ - spec/unit/secret_fetcher/hashi_vault_spec.rb
3044
3113
  - spec/unit/secret_fetcher_spec.rb
3045
3114
  - spec/unit/server_api_spec.rb
3046
3115
  - spec/unit/server_api_versions_spec.rb