chef 17.4.25-universal-mingw32 → 17.6.18-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/chef.gemspec +2 -0
  4. data/lib/chef/application/base.rb +11 -1
  5. data/lib/chef/client.rb +1 -2
  6. data/lib/chef/compliance/input.rb +115 -0
  7. data/lib/chef/compliance/input_collection.rb +139 -0
  8. data/lib/chef/compliance/profile.rb +122 -0
  9. data/lib/chef/compliance/profile_collection.rb +109 -0
  10. data/lib/chef/compliance/reporter/automate.rb +1 -1
  11. data/lib/chef/compliance/runner.rb +48 -6
  12. data/lib/chef/compliance/waiver.rb +115 -0
  13. data/lib/chef/compliance/waiver_collection.rb +143 -0
  14. data/lib/chef/dsl/compliance.rb +38 -0
  15. data/lib/chef/dsl/reader_helpers.rb +51 -0
  16. data/lib/chef/dsl/recipe.rb +4 -2
  17. data/lib/chef/dsl/secret.rb +2 -4
  18. data/lib/chef/dsl/universal.rb +2 -0
  19. data/lib/chef/event_dispatch/base.rb +44 -2
  20. data/lib/chef/formatters/doc.rb +60 -13
  21. data/lib/chef/formatters/minimal.rb +6 -5
  22. data/lib/chef/http/basic_client.rb +15 -7
  23. data/lib/chef/http.rb +12 -8
  24. data/lib/chef/provider/file.rb +2 -0
  25. data/lib/chef/provider/link.rb +2 -2
  26. data/lib/chef/provider/registry_key.rb +3 -2
  27. data/lib/chef/provider/remote_file/http.rb +1 -1
  28. data/lib/chef/provider/template.rb +1 -1
  29. data/lib/chef/resource/archive_file.rb +17 -14
  30. data/lib/chef/resource/chef_client_scheduled_task.rb +45 -2
  31. data/lib/chef/resource/chocolatey_config.rb +13 -13
  32. data/lib/chef/resource/execute.rb +2 -2
  33. data/lib/chef/resource/file/verification/json.rb +50 -0
  34. data/lib/chef/resource/file/verification/yaml.rb +52 -0
  35. data/lib/chef/resource/inspec_input.rb +127 -0
  36. data/lib/chef/resource/inspec_waiver.rb +184 -0
  37. data/lib/chef/resource/mount.rb +1 -1
  38. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  39. data/lib/chef/resource/powershell_package_source.rb +234 -70
  40. data/lib/chef/resource/registry_key.rb +36 -48
  41. data/lib/chef/resource/remote_file.rb +98 -2
  42. data/lib/chef/resource/timezone.rb +2 -2
  43. data/lib/chef/resource/user_ulimit.rb +1 -0
  44. data/lib/chef/resource/windows_printer.rb +1 -1
  45. data/lib/chef/resource/windows_uac.rb +3 -1
  46. data/lib/chef/resource/windows_user_privilege.rb +1 -1
  47. data/lib/chef/resource.rb +1 -1
  48. data/lib/chef/resources.rb +2 -0
  49. data/lib/chef/run_context/cookbook_compiler.rb +112 -28
  50. data/lib/chef/run_context.rb +31 -1
  51. data/lib/chef/secret_fetcher/akeyless_vault.rb +57 -0
  52. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +1 -1
  53. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  54. data/lib/chef/secret_fetcher/base.rb +1 -1
  55. data/lib/chef/secret_fetcher/hashi_vault.rb +100 -0
  56. data/lib/chef/secret_fetcher.rb +8 -2
  57. data/lib/chef/version.rb +1 -1
  58. data/lib/chef/win32/version.rb +2 -1
  59. data/spec/data/archive_file/test_archive.tar.gz +0 -0
  60. data/spec/functional/resource/archive_file_spec.rb +87 -0
  61. data/spec/functional/resource/group_spec.rb +5 -1
  62. data/spec/functional/resource/link_spec.rb +8 -0
  63. data/spec/functional/resource/powershell_package_source_spec.rb +5 -6
  64. data/spec/integration/compliance/compliance_spec.rb +60 -0
  65. data/spec/spec_helper.rb +3 -0
  66. data/spec/support/platform_helpers.rb +4 -0
  67. data/spec/support/ruby_installer.rb +51 -0
  68. data/spec/unit/compliance/input_spec.rb +104 -0
  69. data/spec/unit/compliance/profile_spec.rb +120 -0
  70. data/spec/unit/compliance/waiver_spec.rb +104 -0
  71. data/spec/unit/formatters/doc_spec.rb +1 -1
  72. data/spec/unit/http/basic_client_spec.rb +30 -0
  73. data/spec/unit/http_spec.rb +8 -2
  74. data/spec/unit/provider/link_spec.rb +13 -7
  75. data/spec/unit/provider/remote_file/http_spec.rb +10 -0
  76. data/spec/unit/provider/template_spec.rb +2 -2
  77. data/spec/unit/resource/archive_file_spec.rb +414 -3
  78. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +69 -0
  79. data/spec/unit/resource/file/verification/json_spec.rb +72 -0
  80. data/spec/unit/resource/file/verification/yaml_spec.rb +67 -0
  81. data/spec/unit/resource/inspec_input_spec.rb +300 -0
  82. data/spec/unit/resource/inspec_waiver_spec.rb +312 -0
  83. data/spec/unit/resource/mount_spec.rb +10 -0
  84. data/spec/unit/resource/powershell_package_source_spec.rb +63 -62
  85. data/spec/unit/resource/user_ulimit_spec.rb +14 -1
  86. data/spec/unit/secret_fetcher/akeyless_vault_spec.rb +37 -0
  87. data/spec/unit/secret_fetcher/hashi_vault_spec.rb +80 -0
  88. data/tasks/rspec.rb +2 -1
  89. metadata +60 -6
@@ -33,14 +33,15 @@ describe Chef::Resource::PowershellPackageSource do
33
33
  expect(resource.action).to eql([:register])
34
34
  end
35
35
 
36
- it "supports :register and :unregister actions" do
36
+ it "supports :register, :set and :unregister actions" do
37
37
  expect { resource.action :register }.not_to raise_error
38
+ expect { resource.action :set }.not_to raise_error
38
39
  expect { resource.action :unregister }.not_to raise_error
39
40
  end
40
41
 
41
42
  it "the url property accepts strings" do
42
- resource.url("https://mygallery.company.co/api/v2/")
43
- expect(resource.url).to eql("https://mygallery.company.co/api/v2/")
43
+ resource.source_location("https://mygallery.company.co/api/v2/")
44
+ expect(resource.source_location).to eql("https://mygallery.company.co/api/v2/")
44
45
  end
45
46
 
46
47
  it "the trusted property accepts true and false" do
@@ -54,7 +55,7 @@ describe Chef::Resource::PowershellPackageSource do
54
55
  expect(resource.trusted).to eql(false)
55
56
  end
56
57
 
57
- it "provider_name accepts 'Programs', 'msi', 'NuGet', 'msu', 'PowerShellGet', 'psl', 'chocolatey'" do
58
+ it "provider_name accepts 'Programs', 'msi', 'NuGet', 'msu', 'PowerShellGet', 'psl', 'chocolatey', 'winget'" do
58
59
  expect { resource.provider_name("Programs") }.not_to raise_error
59
60
  expect { resource.provider_name("msi") }.not_to raise_error
60
61
  expect { resource.provider_name("NuGet") }.not_to raise_error
@@ -62,6 +63,7 @@ describe Chef::Resource::PowershellPackageSource do
62
63
  expect { resource.provider_name("PowerShellGet") }.not_to raise_error
63
64
  expect { resource.provider_name("psl") }.not_to raise_error
64
65
  expect { resource.provider_name("chocolatey") }.not_to raise_error
66
+ expect { resource.provider_name("winget") }.not_to raise_error
65
67
  end
66
68
 
67
69
  it "the publish_location property accepts strings" do
@@ -70,75 +72,76 @@ describe Chef::Resource::PowershellPackageSource do
70
72
  end
71
73
 
72
74
  it "the script_source_location property accepts strings" do
73
- resource.publish_location("https://mygallery.company.co/api/v2/scripts")
74
- expect(resource.publish_location).to eql("https://mygallery.company.co/api/v2/scripts")
75
+ resource.script_source_location("https://mygallery.company.co/api/v2/scripts")
76
+ expect(resource.script_source_location).to eql("https://mygallery.company.co/api/v2/scripts")
75
77
  end
76
78
 
77
79
  it "the script_publish_location property accepts strings" do
78
- resource.publish_location("https://mygallery.company.co/api/v2/scripts")
79
- expect(resource.publish_location).to eql("https://mygallery.company.co/api/v2/scripts")
80
+ resource.script_publish_location("https://mygallery.company.co/api/v2/scripts")
81
+ expect(resource.script_publish_location).to eql("https://mygallery.company.co/api/v2/scripts")
80
82
  end
81
83
 
82
84
  describe "#build_ps_repository_command" do
83
85
  before do
84
86
  resource.source_name("MyGallery")
85
- resource.url("https://mygallery.company.co/api/v2/")
87
+ resource.source_location("https://github.com/chef/powershell_test")
88
+ resource.provider_name("PowerShellGet")
86
89
  end
87
90
 
88
91
  context "#register" do
89
92
  it "builds a minimal command" do
90
- expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' | Out-Null")
93
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' | Out-Null")
91
94
  end
92
95
 
93
96
  it "builds a command with trusted set to true" do
94
97
  resource.trusted(true)
95
- expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Trusted' | Out-Null")
98
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Trusted' | Out-Null")
96
99
  end
97
100
 
98
101
  it "builds a command with a publish location" do
99
- resource.publish_location("https://mygallery.company.co/api/v2/package")
100
- expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -PublishLocation 'https://mygallery.company.co/api/v2/package' | Out-Null")
102
+ resource.publish_location("https://github.com/chef/powershell_test/package")
103
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -PublishLocation 'https://github.com/chef/powershell_test/package' | Out-Null")
101
104
  end
102
105
 
103
106
  it "builds a command with a script source location" do
104
- resource.script_source_location("https://mygallery.company.co/api/v2/scripts")
105
- expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://mygallery.company.co/api/v2/scripts' | Out-Null")
107
+ resource.script_source_location("https://github.com/chef/powershell_test/scripts")
108
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://github.com/chef/powershell_test/scripts' | Out-Null")
106
109
  end
107
110
 
108
111
  it "builds a command with a script publish location" do
109
- resource.script_publish_location("https://mygallery.company.co/api/v2/scripts/package")
110
- expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://mygallery.company.co/api/v2/scripts/package' | Out-Null")
112
+ resource.script_publish_location("https://github.com/chef/powershell_test/scripts/package")
113
+ expect(provider.build_ps_repository_command("Register", resource)).to eql("Register-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://github.com/chef/powershell_test/scripts/package' | Out-Null")
111
114
  end
112
115
  end
113
116
 
114
117
  context "#set" do
115
118
  it "builds a minimal command" do
116
- expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' | Out-Null")
119
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' | Out-Null")
117
120
  end
118
121
 
119
122
  it "builds a command to change the url" do
120
- resource.url("https://othergallery.company.co/api/v2/")
123
+ resource.source_location("https://othergallery.company.co/api/v2/")
121
124
  expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://othergallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' | Out-Null")
122
125
  end
123
126
 
124
127
  it "builds a command with trusted set to true" do
125
128
  resource.trusted(true)
126
- expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Trusted' | Out-Null")
129
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Trusted' | Out-Null")
127
130
  end
128
131
 
129
132
  it "builds a command with a publish location" do
130
- resource.publish_location("https://mygallery.company.co/api/v2/package")
131
- expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -PublishLocation 'https://mygallery.company.co/api/v2/package' | Out-Null")
133
+ resource.publish_location("https://github.com/chef/powershell_test/package")
134
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -PublishLocation 'https://github.com/chef/powershell_test/package' | Out-Null")
132
135
  end
133
136
 
134
137
  it "builds a command with a script source location" do
135
- resource.script_source_location("https://mygallery.company.co/api/v2/scripts")
136
- expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://mygallery.company.co/api/v2/scripts' | Out-Null")
138
+ resource.script_source_location("https://github.com/chef/powershell_test/scripts")
139
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -ScriptSourceLocation 'https://github.com/chef/powershell_test/scripts' | Out-Null")
137
140
  end
138
141
 
139
142
  it "builds a command with a script publish location" do
140
- resource.script_publish_location("https://mygallery.company.co/api/v2/scripts/package")
141
- expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://mygallery.company.co/api/v2/' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://mygallery.company.co/api/v2/scripts/package' | Out-Null")
143
+ resource.script_publish_location("https://github.com/chef/powershell_test/scripts/package")
144
+ expect(provider.build_ps_repository_command("Set", resource)).to eql("Set-PSRepository -Name 'MyGallery' -SourceLocation 'https://github.com/chef/powershell_test' -InstallationPolicy 'Untrusted' -ScriptPublishLocation 'https://github.com/chef/powershell_test/scripts/package' | Out-Null")
142
145
  end
143
146
  end
144
147
  end
@@ -146,74 +149,72 @@ describe Chef::Resource::PowershellPackageSource do
146
149
  describe "#build_package_source_command" do
147
150
  before do
148
151
  resource.source_name("NuGet")
149
- resource.url("http://nuget.org/api/v2/")
152
+ resource.source_location("http://nuget.org/api/v2/")
150
153
  end
151
154
 
152
155
  context "#register" do
153
156
  it "builds a minimal command" do
154
- expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$false -ProviderName 'NuGet' | Out-Null")
157
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -ProviderName 'NuGet' | Out-Null")
155
158
  end
156
159
 
157
160
  it "builds a command with trusted set to true" do
158
161
  resource.trusted(true)
159
- expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$true -ProviderName 'NuGet' | Out-Null")
162
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted -ProviderName 'NuGet' | Out-Null")
160
163
  end
161
164
 
162
165
  it "builds a command with a different provider" do
163
166
  resource.source_name("choco")
164
- resource.url("https://chocolatey.org/api/v2/")
167
+ resource.source_location("https://chocolatey.org/api/v2/")
165
168
  resource.provider_name("chocolatey")
166
- expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -Trusted:$false -ProviderName 'chocolatey' | Out-Null")
169
+ expect(provider.build_package_source_command("Register", resource)).to eql("Register-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -ProviderName 'chocolatey' | Out-Null")
167
170
  end
168
171
  end
169
172
 
170
173
  context "#set" do
171
174
  it "builds a minimal command" do
172
- expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$false -ProviderName 'NuGet' | Out-Null")
175
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -ProviderName 'NuGet' | Out-Null")
173
176
  end
174
177
 
175
178
  it "builds a command to change the url" do
176
- resource.url("https://nuget.company.co/api/v2/")
177
- expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'https://nuget.company.co/api/v2/' -Trusted:$false -ProviderName 'NuGet' | Out-Null")
179
+ resource.source_location("https://nuget.company.co/api/v2/")
180
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'https://nuget.company.co/api/v2/' -ProviderName 'NuGet' | Out-Null")
178
181
  end
179
182
 
180
183
  it "builds a command with trusted set to true" do
181
184
  resource.trusted(true)
182
- expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted:$true -ProviderName 'NuGet' | Out-Null")
185
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'NuGet' -Location 'http://nuget.org/api/v2/' -Trusted -ProviderName 'NuGet' | Out-Null")
183
186
  end
184
187
 
185
188
  it "builds a command with a different provider" do
186
189
  resource.source_name("choco")
187
- resource.url("https://chocolatey.org/api/v2/")
190
+ resource.source_location("https://chocolatey.org/api/v2/")
188
191
  resource.provider_name("chocolatey")
189
- expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -Trusted:$false -ProviderName 'chocolatey' | Out-Null")
192
+ expect(provider.build_package_source_command("Set", resource)).to eql("Set-PackageSource -Name 'choco' -Location 'https://chocolatey.org/api/v2/' -ProviderName 'chocolatey' | Out-Null")
190
193
  end
191
194
  end
192
195
  end
193
196
 
194
- describe "#psrepository_cmdlet_appropriate?" do
195
- it "returns true if the provider_name is 'PowerShellGet'" do
196
- resource.provider_name("PowerShellGet")
197
- expect(provider.psrepository_cmdlet_appropriate?).to eql(true)
198
- end
199
-
200
- it "returns false if the provider_name is something else" do
201
- resource.provider_name("NuGet")
202
- expect(provider.psrepository_cmdlet_appropriate?).to eql(false)
203
- end
204
- end
205
-
206
- describe "#package_source_exists?" do
207
- it "returns true if it exists" do
208
- allow(provider).to receive(:powershell_exec!).with("(Get-PackageSource -Name 'MyGallery' -ErrorAction SilentlyContinue).Name").and_return(double("powershell_exec!", result: "MyGallery\r\n"))
209
- resource.source_name("MyGallery")
210
- expect(provider.package_source_exists?).to eql(true)
211
- end
212
-
213
- it "returns false if it doesn't exist" do
214
- allow(provider).to receive(:powershell_exec!).with("(Get-PackageSource -Name 'MyGallery' -ErrorAction SilentlyContinue).Name").and_return(double("powershell_exec!", result: ""))
215
- resource.source_name("MyGallery")
216
- expect(provider.package_source_exists?).to eql(false)
217
- end
218
- end
197
+ # describe "get_package_source_details" do
198
+ # before do
199
+ # resource.source_name("MyGallery")
200
+ # resource.source_location("http://nuget.org/api/v2/")
201
+ # provider.build_package_source_command("Register", resource)
202
+ # end
203
+
204
+ # # stub a call to the package_source_details
205
+ # expect(provider).to receive(:get_package_source_details).and_return("PackageSource")
206
+ # it "returns packagesource if it exists" do
207
+ # # dbl = double("testing PackageSource")
208
+ # # let(source_name)
209
+ # # # allow(provider).to receive(:powershell_exec!).with("(Get-PackageSource -Name 'MyGallery' -ErrorAction SilentlyContinue).Name").and_return(double("powershell_exec!", result: "PackageSource"))
210
+ # # resource.source_name("MyGallery")
211
+ # expect(provider.get_package_source_details.result).to eql("PackageSource")
212
+ # end
213
+
214
+ # it "returns unregistered if it doesn't exist" do
215
+ # # allow(provider).to receive(:powershell_exec!).with("(Get-PackageSource -Name 'Foo' -ErrorAction SilentlyContinue).Name").and_return(double("powershell_exec!", result: ""))
216
+ # resource.source_name("Foo")
217
+ # expect(provider.get_package_source_details.result).to eql("Unregistered")
218
+ # end
219
+ # end
219
220
  end
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
-
21
20
  describe Chef::Resource::UserUlimit do
22
21
  let(:node) { Chef::Node.new }
23
22
  let(:events) { Chef::EventDispatch::Dispatcher.new }
@@ -50,4 +49,18 @@ describe Chef::Resource::UserUlimit do
50
49
  expect { resource.action :create }.not_to raise_error
51
50
  expect { resource.action :delete }.not_to raise_error
52
51
  end
52
+
53
+ describe "sensitive attribute" do
54
+ context "should be insensitive by default" do
55
+ it { expect(resource.sensitive).to(be_falsey) }
56
+ end
57
+
58
+ context "when set" do
59
+ before { resource.sensitive(true) }
60
+
61
+ it "should be set on the resource" do
62
+ expect(resource.sensitive).to(be_truthy)
63
+ end
64
+ end
65
+ end
53
66
  end
@@ -0,0 +1,37 @@
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/akeyless_vault"
21
+
22
+ describe Chef::SecretFetcher::AKeylessVault do
23
+ let(:node) { {} }
24
+ let(:run_context) { double("run_context", node: node) }
25
+
26
+ context "when validating provided AKeyless Vault configuration" do
27
+ it "raises ConfigurationInvalid when :secret_access_key is not provided" do
28
+ fetcher = Chef::SecretFetcher::AKeylessVault.new( { access_id: "provided" }, run_context)
29
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid, /:secret_access_key/)
30
+ end
31
+
32
+ it "raises ConfigurationInvalid when :access_key_id is not provided" do
33
+ fetcher = Chef::SecretFetcher::AKeylessVault.new( { access_key: "provided" }, run_context)
34
+ expect { fetcher.validate! }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid, /:access_key_id/)
35
+ end
36
+ end
37
+ end
@@ -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
+
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.25
4
+ version: 17.6.18
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-23 00:00:00.000000000 Z
11
+ date: 2021-10-01 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.25
19
+ version: 17.6.18
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.25
26
+ version: 17.6.18
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.25
33
+ version: 17.6.18
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.25
40
+ version: 17.6.18
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -440,6 +440,20 @@ dependencies:
440
440
  - - "~>"
441
441
  - !ruby/object:Gem::Version
442
442
  version: '1.0'
443
+ - !ruby/object:Gem::Dependency
444
+ name: aws-sdk-s3
445
+ requirement: !ruby/object:Gem::Requirement
446
+ requirements:
447
+ - - "~>"
448
+ - !ruby/object:Gem::Version
449
+ version: '1.91'
450
+ type: :runtime
451
+ prerelease: false
452
+ version_requirements: !ruby/object:Gem::Requirement
453
+ requirements:
454
+ - - "~>"
455
+ - !ruby/object:Gem::Version
456
+ version: '1.91'
443
457
  - !ruby/object:Gem::Dependency
444
458
  name: aws-sdk-secretsmanager
445
459
  requirement: !ruby/object:Gem::Requirement
@@ -454,6 +468,20 @@ dependencies:
454
468
  - - "~>"
455
469
  - !ruby/object:Gem::Version
456
470
  version: '1.46'
471
+ - !ruby/object:Gem::Dependency
472
+ name: vault
473
+ requirement: !ruby/object:Gem::Requirement
474
+ requirements:
475
+ - - "~>"
476
+ - !ruby/object:Gem::Version
477
+ version: '0.16'
478
+ type: :runtime
479
+ prerelease: false
480
+ version_requirements: !ruby/object:Gem::Requirement
481
+ requirements:
482
+ - - "~>"
483
+ - !ruby/object:Gem::Version
484
+ version: '0.16'
457
485
  - !ruby/object:Gem::Dependency
458
486
  name: win32-api
459
487
  requirement: !ruby/object:Gem::Requirement
@@ -1366,12 +1394,18 @@ files:
1366
1394
  - lib/chef/compliance/default_attributes.rb
1367
1395
  - lib/chef/compliance/fetcher/automate.rb
1368
1396
  - lib/chef/compliance/fetcher/chef_server.rb
1397
+ - lib/chef/compliance/input.rb
1398
+ - lib/chef/compliance/input_collection.rb
1399
+ - lib/chef/compliance/profile.rb
1400
+ - lib/chef/compliance/profile_collection.rb
1369
1401
  - lib/chef/compliance/reporter/automate.rb
1370
1402
  - lib/chef/compliance/reporter/chef_server_automate.rb
1371
1403
  - lib/chef/compliance/reporter/cli.rb
1372
1404
  - lib/chef/compliance/reporter/compliance_enforcer.rb
1373
1405
  - lib/chef/compliance/reporter/json_file.rb
1374
1406
  - lib/chef/compliance/runner.rb
1407
+ - lib/chef/compliance/waiver.rb
1408
+ - lib/chef/compliance/waiver_collection.rb
1375
1409
  - lib/chef/config.rb
1376
1410
  - lib/chef/config_fetcher.rb
1377
1411
  - lib/chef/constants.rb
@@ -1411,6 +1445,7 @@ files:
1411
1445
  - lib/chef/dsl.rb
1412
1446
  - lib/chef/dsl/chef_vault.rb
1413
1447
  - lib/chef/dsl/cheffish.rb
1448
+ - lib/chef/dsl/compliance.rb
1414
1449
  - lib/chef/dsl/data_query.rb
1415
1450
  - lib/chef/dsl/declare_resource.rb
1416
1451
  - lib/chef/dsl/definitions.rb
@@ -1418,6 +1453,7 @@ files:
1418
1453
  - lib/chef/dsl/include_recipe.rb
1419
1454
  - lib/chef/dsl/platform_introspection.rb
1420
1455
  - lib/chef/dsl/powershell.rb
1456
+ - lib/chef/dsl/reader_helpers.rb
1421
1457
  - lib/chef/dsl/reboot_pending.rb
1422
1458
  - lib/chef/dsl/recipe.rb
1423
1459
  - lib/chef/dsl/registry_helper.rb
@@ -1760,7 +1796,9 @@ files:
1760
1796
  - lib/chef/resource/execute.rb
1761
1797
  - lib/chef/resource/file.rb
1762
1798
  - lib/chef/resource/file/verification.rb
1799
+ - lib/chef/resource/file/verification/json.rb
1763
1800
  - lib/chef/resource/file/verification/systemd_unit.rb
1801
+ - lib/chef/resource/file/verification/yaml.rb
1764
1802
  - lib/chef/resource/freebsd_package.rb
1765
1803
  - lib/chef/resource/gem_package.rb
1766
1804
  - lib/chef/resource/group.rb
@@ -1781,6 +1819,8 @@ files:
1781
1819
  - lib/chef/resource/hostname.rb
1782
1820
  - lib/chef/resource/http_request.rb
1783
1821
  - lib/chef/resource/ifconfig.rb
1822
+ - lib/chef/resource/inspec_input.rb
1823
+ - lib/chef/resource/inspec_waiver.rb
1784
1824
  - lib/chef/resource/inspec_waiver_file_entry.rb
1785
1825
  - lib/chef/resource/ips_package.rb
1786
1826
  - lib/chef/resource/kernel_module.rb
@@ -1928,10 +1968,12 @@ files:
1928
1968
  - lib/chef/scan_access_control.rb
1929
1969
  - lib/chef/search/query.rb
1930
1970
  - lib/chef/secret_fetcher.rb
1971
+ - lib/chef/secret_fetcher/akeyless_vault.rb
1931
1972
  - lib/chef/secret_fetcher/aws_secrets_manager.rb
1932
1973
  - lib/chef/secret_fetcher/azure_key_vault.rb
1933
1974
  - lib/chef/secret_fetcher/base.rb
1934
1975
  - lib/chef/secret_fetcher/example.rb
1976
+ - lib/chef/secret_fetcher/hashi_vault.rb
1935
1977
  - lib/chef/server_api.rb
1936
1978
  - lib/chef/server_api_versions.rb
1937
1979
  - lib/chef/shell.rb
@@ -2060,6 +2102,7 @@ files:
2060
2102
  - spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages
2061
2103
  - spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb
2062
2104
  - spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
2105
+ - spec/data/archive_file/test_archive.tar.gz
2063
2106
  - spec/data/bad-config.rb
2064
2107
  - spec/data/bootstrap/encrypted_data_bag_secret
2065
2108
  - spec/data/bootstrap/no_proxy.erb
@@ -2444,6 +2487,7 @@ files:
2444
2487
  - spec/functional/resource/aix_service_spec.rb
2445
2488
  - spec/functional/resource/aixinit_service_spec.rb
2446
2489
  - spec/functional/resource/apt_package_spec.rb
2490
+ - spec/functional/resource/archive_file_spec.rb
2447
2491
  - spec/functional/resource/bash_spec.rb
2448
2492
  - spec/functional/resource/batch_spec.rb
2449
2493
  - spec/functional/resource/bff_spec.rb
@@ -2548,6 +2592,7 @@ files:
2548
2592
  - spec/support/platforms/prof/win32.rb
2549
2593
  - spec/support/platforms/win32/spec_service.rb
2550
2594
  - spec/support/recipe_dsl_helper.rb
2595
+ - spec/support/ruby_installer.rb
2551
2596
  - spec/support/shared/context/config.rb
2552
2597
  - spec/support/shared/context/win32.rb
2553
2598
  - spec/support/shared/functional/diff_disabled.rb
@@ -2608,10 +2653,13 @@ files:
2608
2653
  - spec/unit/client_spec.rb
2609
2654
  - spec/unit/compliance/fetcher/automate_spec.rb
2610
2655
  - spec/unit/compliance/fetcher/chef_server_spec.rb
2656
+ - spec/unit/compliance/input_spec.rb
2657
+ - spec/unit/compliance/profile_spec.rb
2611
2658
  - spec/unit/compliance/reporter/automate_spec.rb
2612
2659
  - spec/unit/compliance/reporter/chef_server_automate_spec.rb
2613
2660
  - spec/unit/compliance/reporter/compliance_enforcer_spec.rb
2614
2661
  - spec/unit/compliance/runner_spec.rb
2662
+ - spec/unit/compliance/waiver_spec.rb
2615
2663
  - spec/unit/config_fetcher_spec.rb
2616
2664
  - spec/unit/config_spec.rb
2617
2665
  - spec/unit/cookbook/chefignore_spec.rb
@@ -2898,7 +2946,9 @@ files:
2898
2946
  - spec/unit/resource/dsc_resource_spec.rb
2899
2947
  - spec/unit/resource/dsc_script_spec.rb
2900
2948
  - spec/unit/resource/execute_spec.rb
2949
+ - spec/unit/resource/file/verification/json_spec.rb
2901
2950
  - spec/unit/resource/file/verification/systemd_unit_spec.rb
2951
+ - spec/unit/resource/file/verification/yaml_spec.rb
2902
2952
  - spec/unit/resource/file/verification_spec.rb
2903
2953
  - spec/unit/resource/file_spec.rb
2904
2954
  - spec/unit/resource/freebsd_package_spec.rb
@@ -2912,7 +2962,9 @@ files:
2912
2962
  - spec/unit/resource/hostname_spec.rb
2913
2963
  - spec/unit/resource/http_request_spec.rb
2914
2964
  - spec/unit/resource/ifconfig_spec.rb
2965
+ - spec/unit/resource/inspec_input_spec.rb
2915
2966
  - spec/unit/resource/inspec_waiver_file_entry_spec.rb
2967
+ - spec/unit/resource/inspec_waiver_spec.rb
2916
2968
  - spec/unit/resource/ips_package_spec.rb
2917
2969
  - spec/unit/resource/kernel_module_spec.rb
2918
2970
  - spec/unit/resource/ksh_spec.rb
@@ -3039,8 +3091,10 @@ files:
3039
3091
  - spec/unit/runner_spec.rb
3040
3092
  - spec/unit/scan_access_control_spec.rb
3041
3093
  - spec/unit/search/query_spec.rb
3094
+ - spec/unit/secret_fetcher/akeyless_vault_spec.rb
3042
3095
  - spec/unit/secret_fetcher/aws_secrets_manager_spec.rb
3043
3096
  - spec/unit/secret_fetcher/azure_key_vault_spec.rb
3097
+ - spec/unit/secret_fetcher/hashi_vault_spec.rb
3044
3098
  - spec/unit/secret_fetcher_spec.rb
3045
3099
  - spec/unit/server_api_spec.rb
3046
3100
  - spec/unit/server_api_versions_spec.rb