chef 17.4.38-universal-mingw32 → 17.7.22-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -75,19 +75,19 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
75
75
  def create_deletable_keys
76
76
  # create them both 32-bit and 64-bit
77
77
  [ 0x0100, 0x0200 ].each do |flag|
78
- hive_class.create(key_parent + '\Opscode', Win32::Registry::KEY_WRITE | flag)
79
- hive_class.open(key_parent + '\Opscode', Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
78
+ hive_class.create(key_parent + "\\Opscode", Win32::Registry::KEY_WRITE | flag)
79
+ hive_class.open(key_parent + "\\Opscode", Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
80
80
  reg["Color", Win32::Registry::REG_SZ] = "Orange"
81
81
  reg.write("Opscode", Win32::Registry::REG_MULTI_SZ, %w{Seattle Washington})
82
82
  reg["AKA", Win32::Registry::REG_SZ] = "OC"
83
83
  end
84
- hive_class.create(key_parent + '\ReportKey', Win32::Registry::KEY_WRITE | flag)
85
- hive_class.open(key_parent + '\ReportKey', Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
84
+ hive_class.create(key_parent + "\\ReportKey", Win32::Registry::KEY_WRITE | flag)
85
+ hive_class.open(key_parent + "\\ReportKey", Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
86
86
  reg["ReportVal4", Win32::Registry::REG_SZ] = "report4"
87
87
  reg["ReportVal5", Win32::Registry::REG_SZ] = "report5"
88
88
  end
89
- hive_class.create(key_parent + '\OpscodeWhyRun', Win32::Registry::KEY_WRITE | flag)
90
- hive_class.open(key_parent + '\OpscodeWhyRun', Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
89
+ hive_class.create(key_parent + "\\OpscodeWhyRun", Win32::Registry::KEY_WRITE | flag)
90
+ hive_class.open(key_parent + "\\OpscodeWhyRun", Win32::Registry::KEY_ALL_ACCESS | flag) do |reg|
91
91
  reg["BriskWalk", Win32::Registry::REG_SZ] = "is good for health"
92
92
  end
93
93
  end
@@ -188,13 +188,13 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
188
188
  end
189
189
 
190
190
  it "creates subkey if parent exists" do
191
- @new_resource.key(reg_child + '\OpscodeTest')
191
+ @new_resource.key(reg_child + "\\OpscodeTest")
192
192
  @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }])
193
193
  @new_resource.recursive(false)
194
194
  @new_resource.run_action(:create)
195
195
 
196
- expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true)
197
- expect(@registry.value_exists?(reg_child + '\OpscodeTest', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
196
+ expect(@registry.key_exists?(reg_child + "\\OpscodeTest")).to eq(true)
197
+ expect(@registry.value_exists?(reg_child + "\\OpscodeTest", { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
198
198
  end
199
199
 
200
200
  it "raises an error if action create and parent does not exist and recursive is set to false" do
@@ -258,20 +258,20 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
258
258
  @registry.architecture = :machine
259
259
  end
260
260
  it "creates a key in a 32-bit registry that is not viewable in 64-bit" do
261
- @new_resource.key(reg_child + '\Atraxi' )
261
+ @new_resource.key(reg_child + "\\Atraxi" )
262
262
  @new_resource.values([{ name: "OC", type: :string, data: "Data" }])
263
263
  @new_resource.recursive(true)
264
264
  @new_resource.architecture(:i386)
265
265
  @new_resource.run_action(:create)
266
266
  @registry.architecture = :i386
267
- expect(@registry.data_exists?(reg_child + '\Atraxi', { name: "OC", type: :string, data: "Data" })).to eq(true)
267
+ expect(@registry.data_exists?(reg_child + "\\Atraxi", { name: "OC", type: :string, data: "Data" })).to eq(true)
268
268
  @registry.architecture = :x86_64
269
- expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false)
269
+ expect(@registry.key_exists?(reg_child + "\\Atraxi")).to eq(false)
270
270
  end
271
271
  end
272
272
 
273
273
  it "prepares the reporting data for action :create" do
274
- @new_resource.key(reg_child + '\Ood')
274
+ @new_resource.key(reg_child + "\\Ood")
275
275
  @new_resource.values([{ name: "ReportingVal1", type: :string, data: "report1" }, { name: "ReportingVal2", type: :string, data: "report2" }])
276
276
  @new_resource.recursive(true)
277
277
  @new_resource.run_action(:create)
@@ -280,7 +280,7 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
280
280
  expect(@report["action"]).to eq("end")
281
281
  expect(@report["resources"][0]["type"]).to eq("registry_key")
282
282
  expect(@report["resources"][0]["name"]).to eq(resource_name)
283
- expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood')
283
+ expect(@report["resources"][0]["id"]).to eq(reg_child + "\\Ood")
284
284
  expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal1", type: :string, data: "report1" },
285
285
  { name: "ReportingVal2", type: :string, data: "report2" }])
286
286
  expect(@report["resources"][0]["before"][:values]).to eq([])
@@ -295,48 +295,48 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
295
295
  end
296
296
 
297
297
  it "does not raise an exception if the keys do not exist but recursive is set to false" do
298
- @new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius')
298
+ @new_resource.key(reg_child + "\\Slitheen\\Raxicoricofallapatorius")
299
299
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
300
300
  @new_resource.recursive(false)
301
301
  @new_resource.run_action(:create) # should not raise_error
302
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
303
- expect(@registry.key_exists?(reg_child + '\Slitheen\Raxicoricofallapatorius')).to eq(false)
302
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
303
+ expect(@registry.key_exists?(reg_child + "\\Slitheen\\Raxicoricofallapatorius")).to eq(false)
304
304
  end
305
305
 
306
306
  it "does not create key if the action is create" do
307
- @new_resource.key(reg_child + '\Slitheen')
307
+ @new_resource.key(reg_child + "\\Slitheen")
308
308
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
309
309
  @new_resource.recursive(false)
310
310
  @new_resource.run_action(:create)
311
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
311
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
312
312
  end
313
313
 
314
314
  it "does not raise an exception if the action create and type key missing in values hash" do
315
- @new_resource.key(reg_child + '\Slitheen')
315
+ @new_resource.key(reg_child + "\\Slitheen")
316
316
  @new_resource.values([{ name: "BriskWalk", data: "my_data" }])
317
317
  @new_resource.run_action(:create) # should not raise_error
318
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
318
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
319
319
  end
320
320
 
321
321
  it "does not raise an exception if the action create and data key missing in values hash" do
322
- @new_resource.key(reg_child + '\Slitheen')
322
+ @new_resource.key(reg_child + "\\Slitheen")
323
323
  @new_resource.values([{ name: "BriskWalk", type: :string }])
324
324
  @new_resource.run_action(:create) # should not raise_error
325
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
325
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
326
326
  end
327
327
 
328
328
  it "does not raise an exception if the action create and only name key present in values hash" do
329
- @new_resource.key(reg_child + '\Slitheen')
329
+ @new_resource.key(reg_child + "\\Slitheen")
330
330
  @new_resource.values([{ name: "BriskWalk" }])
331
331
  @new_resource.run_action(:create) # should not raise_error
332
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
332
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
333
333
  end
334
334
 
335
335
  it "does not raise an exception if the action create and all keys are present in values hash" do
336
- @new_resource.key(reg_child + '\Slitheen')
336
+ @new_resource.key(reg_child + "\\Slitheen")
337
337
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }])
338
338
  @new_resource.run_action(:create) # should not raise_error
339
- expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
339
+ expect(@registry.key_exists?(reg_child + "\\Slitheen")).to eq(false)
340
340
  end
341
341
  end
342
342
  end
@@ -374,17 +374,17 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
374
374
  end
375
375
 
376
376
  it "creates subkey if parent exists" do
377
- @new_resource.key(reg_child + '\Pyrovile')
377
+ @new_resource.key(reg_child + "\\Pyrovile")
378
378
  @new_resource.values([{ name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} }])
379
379
  @new_resource.recursive(false)
380
380
  @new_resource.run_action(:create_if_missing)
381
381
 
382
- expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true)
383
- expect(@registry.value_exists?(reg_child + '\Pyrovile', { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
382
+ expect(@registry.key_exists?(reg_child + "\\Pyrovile")).to eq(true)
383
+ expect(@registry.value_exists?(reg_child + "\\Pyrovile", { name: "Chef", type: :multi_string, data: %w{OpscodeOrange Rules} })).to eq(true)
384
384
  end
385
385
 
386
386
  it "raises an error if action create and parent does not exist and recursive is set to false" do
387
- @new_resource.key(reg_child + '\Sontaran\Sontar')
387
+ @new_resource.key(reg_child + "\\Sontaran\\Sontar")
388
388
  @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
389
389
  @new_resource.recursive(false)
390
390
  expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
@@ -415,28 +415,28 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
415
415
  end
416
416
 
417
417
  it "creates missing keys if action create and parent does not exist and recursive is set to true" do
418
- @new_resource.key(reg_child + '\Sontaran\Sontar')
418
+ @new_resource.key(reg_child + "\\Sontaran\\Sontar")
419
419
  @new_resource.values([{ name: "OC", type: :string, data: "MissingData" }])
420
420
  @new_resource.recursive(true)
421
421
  @new_resource.run_action(:create_if_missing)
422
422
 
423
- expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true)
424
- expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', { name: "OC", type: :string, data: "MissingData" })).to eq(true)
423
+ expect(@registry.key_exists?(reg_child + "\\Sontaran\\Sontar")).to eq(true)
424
+ expect(@registry.value_exists?(reg_child + "\\Sontaran\\Sontar", { name: "OC", type: :string, data: "MissingData" })).to eq(true)
425
425
  end
426
426
 
427
427
  it "creates key with multiple value as specified" do
428
- @new_resource.key(reg_child + '\Adipose')
428
+ @new_resource.key(reg_child + "\\Adipose")
429
429
  @new_resource.values([{ name: "one", type: :string, data: "1" }, { name: "two", type: :string, data: "2" }, { name: "three", type: :string, data: "3" }])
430
430
  @new_resource.recursive(true)
431
431
  @new_resource.run_action(:create_if_missing)
432
432
 
433
433
  @new_resource.each_value do |value|
434
- expect(@registry.value_exists?(reg_child + '\Adipose', value)).to eq(true)
434
+ expect(@registry.value_exists?(reg_child + "\\Adipose", value)).to eq(true)
435
435
  end
436
436
  end
437
437
 
438
438
  it "prepares the reporting data for :create_if_missing" do
439
- @new_resource.key(reg_child + '\Judoon')
439
+ @new_resource.key(reg_child + "\\Judoon")
440
440
  @new_resource.values([{ name: "ReportingVal3", type: :string, data: "report3" }])
441
441
  @new_resource.recursive(true)
442
442
  @new_resource.run_action(:create_if_missing)
@@ -445,7 +445,7 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
445
445
  expect(@report["action"]).to eq("end")
446
446
  expect(@report["resources"][0]["type"]).to eq("registry_key")
447
447
  expect(@report["resources"][0]["name"]).to eq(resource_name)
448
- expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon')
448
+ expect(@report["resources"][0]["id"]).to eq(reg_child + "\\Judoon")
449
449
  expect(@report["resources"][0]["after"][:values]).to eq([{ name: "ReportingVal3", type: :string, data: "report3" }])
450
450
  expect(@report["resources"][0]["before"][:values]).to eq([])
451
451
  expect(@report["resources"][0]["result"]).to eq("create_if_missing")
@@ -459,48 +459,48 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
459
459
  end
460
460
 
461
461
  it "does not raise an exception if the keys do not exist but recursive is set to false" do
462
- @new_resource.key(reg_child + '\Zygons\Zygor')
462
+ @new_resource.key(reg_child + "\\Zygons\\Zygor")
463
463
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
464
464
  @new_resource.recursive(false)
465
465
  @new_resource.run_action(:create_if_missing) # should not raise_error
466
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
467
- expect(@registry.key_exists?(reg_child + '\Zygons\Zygor')).to eq(false)
466
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
467
+ expect(@registry.key_exists?(reg_child + "\\Zygons\\Zygor")).to eq(false)
468
468
  end
469
469
 
470
470
  it "does nothing if the action is create_if_missing" do
471
- @new_resource.key(reg_child + '\Zygons')
471
+ @new_resource.key(reg_child + "\\Zygons")
472
472
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
473
473
  @new_resource.recursive(false)
474
474
  @new_resource.run_action(:create_if_missing)
475
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
475
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
476
476
  end
477
477
 
478
478
  it "does not raise an exception if the action create_if_missing and type key missing in values hash" do
479
- @new_resource.key(reg_child + '\Zygons')
479
+ @new_resource.key(reg_child + "\\Zygons")
480
480
  @new_resource.values([{ name: "BriskWalk", data: "my_data" }])
481
481
  @new_resource.run_action(:create_if_missing) # should not raise_error
482
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
482
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
483
483
  end
484
484
 
485
485
  it "does not raise an exception if the action create_if_missing and data key missing in values hash" do
486
- @new_resource.key(reg_child + '\Zygons')
486
+ @new_resource.key(reg_child + "\\Zygons")
487
487
  @new_resource.values([{ name: "BriskWalk", type: :string }])
488
488
  @new_resource.run_action(:create_if_missing) # should not raise_error
489
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
489
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
490
490
  end
491
491
 
492
492
  it "does not raise an exception if the action create_if_missing and only name key present in values hash" do
493
- @new_resource.key(reg_child + '\Zygons')
493
+ @new_resource.key(reg_child + "\\Zygons")
494
494
  @new_resource.values([{ name: "BriskWalk" }])
495
495
  @new_resource.run_action(:create_if_missing) # should not raise_error
496
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
496
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
497
497
  end
498
498
 
499
499
  it "does not raise an exception if the action create_if_missing and all keys are present in values hash" do
500
- @new_resource.key(reg_child + '\Zygons')
500
+ @new_resource.key(reg_child + "\\Zygons")
501
501
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "my_data" }])
502
502
  @new_resource.run_action(:create_if_missing) # should not raise_error
503
- expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
503
+ expect(@registry.key_exists?(reg_child + "\\Zygons")).to eq(false)
504
504
  end
505
505
  end
506
506
  end
@@ -512,61 +512,61 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
512
512
  end
513
513
 
514
514
  it "takes no action if the specified key path does not exist in the system" do
515
- expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
515
+ expect(@registry.key_exists?(reg_parent + "\\Osirian")).to eq(false)
516
516
 
517
- @new_resource.key(reg_parent + '\Osirian')
517
+ @new_resource.key(reg_parent + "\\Osirian")
518
518
  @new_resource.recursive(false)
519
519
  @new_resource.run_action(:delete)
520
520
 
521
- expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
521
+ expect(@registry.key_exists?(reg_parent + "\\Osirian")).to eq(false)
522
522
  end
523
523
 
524
524
  it "takes no action if the key exists but the value does not" do
525
- expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
525
+ expect(@registry.data_exists?(reg_parent + "\\Opscode", { name: "Color", type: :string, data: "Orange" })).to eq(true)
526
526
 
527
- @new_resource.key(reg_parent + '\Opscode')
527
+ @new_resource.key(reg_parent + "\\Opscode")
528
528
  @new_resource.values([{ name: "LooksLike", type: :multi_string, data: %w{SeattleGrey OCOrange} }])
529
529
  @new_resource.recursive(false)
530
530
  @new_resource.run_action(:delete)
531
531
 
532
- expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
532
+ expect(@registry.data_exists?(reg_parent + "\\Opscode", { name: "Color", type: :string, data: "Orange" })).to eq(true)
533
533
  end
534
534
 
535
535
  it "deletes only specified values under a key path" do
536
- @new_resource.key(reg_parent + '\Opscode')
536
+ @new_resource.key(reg_parent + "\\Opscode")
537
537
  @new_resource.values([{ name: "Opscode", type: :multi_string, data: %w{Seattle Washington} }, { name: "AKA", type: :string, data: "OC" }])
538
538
  @new_resource.recursive(false)
539
539
  @new_resource.run_action(:delete)
540
540
 
541
- expect(@registry.data_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(true)
542
- expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "AKA", type: :string, data: "OC" })).to eq(false)
543
- expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Opscode", type: :multi_string, data: %w{Seattle Washington} })).to eq(false)
541
+ expect(@registry.data_exists?(reg_parent + "\\Opscode", { name: "Color", type: :string, data: "Orange" })).to eq(true)
542
+ expect(@registry.value_exists?(reg_parent + "\\Opscode", { name: "AKA", type: :string, data: "OC" })).to eq(false)
543
+ expect(@registry.value_exists?(reg_parent + "\\Opscode", { name: "Opscode", type: :multi_string, data: %w{Seattle Washington} })).to eq(false)
544
544
  end
545
545
 
546
546
  it "it deletes the values with the same name irrespective of it type and data" do
547
- @new_resource.key(reg_parent + '\Opscode')
547
+ @new_resource.key(reg_parent + "\\Opscode")
548
548
  @new_resource.values([{ name: "Color", type: :multi_string, data: %w{Black Orange} }])
549
549
  @new_resource.recursive(false)
550
550
  @new_resource.run_action(:delete)
551
551
 
552
- expect(@registry.value_exists?(reg_parent + '\Opscode', { name: "Color", type: :string, data: "Orange" })).to eq(false)
552
+ expect(@registry.value_exists?(reg_parent + "\\Opscode", { name: "Color", type: :string, data: "Orange" })).to eq(false)
553
553
  end
554
554
 
555
555
  it "prepares the reporting data for action :delete" do
556
- @new_resource.key(reg_parent + '\ReportKey')
556
+ @new_resource.key(reg_parent + "\\ReportKey")
557
557
  @new_resource.values([{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])
558
558
  @new_resource.recursive(true)
559
559
  @new_resource.run_action(:delete)
560
560
 
561
561
  @report = @resource_reporter.prepare_run_data
562
562
 
563
- expect(@registry.value_exists?(reg_parent + '\ReportKey', [{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])).to eq(false)
563
+ expect(@registry.value_exists?(reg_parent + "\\ReportKey", [{ name: "ReportVal4", type: :string, data: "report4" }, { name: "ReportVal5", type: :string, data: "report5" }])).to eq(false)
564
564
 
565
565
  expect(@report["action"]).to eq("end")
566
566
  expect(@report["resources"].count).to eq(1)
567
567
  expect(@report["resources"][0]["type"]).to eq("registry_key")
568
568
  expect(@report["resources"][0]["name"]).to eq(resource_name)
569
- expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
569
+ expect(@report["resources"][0]["id"]).to eq(reg_parent + "\\ReportKey")
570
570
  expect(@report["resources"][0]["before"][:values]).to eq([{ name: "ReportVal4", type: :string, data: "report4" },
571
571
  { name: "ReportVal5", type: :string, data: "report5" }])
572
572
  # Not testing for after values to match since after -> new_resource values.
@@ -580,12 +580,12 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
580
580
  Chef::Config[:why_run] = true
581
581
  end
582
582
  it "does nothing if the action is delete" do
583
- @new_resource.key(reg_parent + '\OpscodeWhyRun')
583
+ @new_resource.key(reg_parent + "\\OpscodeWhyRun")
584
584
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
585
585
  @new_resource.recursive(false)
586
586
  @new_resource.run_action(:delete)
587
587
 
588
- expect(@registry.key_exists?(reg_parent + '\OpscodeWhyRun')).to eq(true)
588
+ expect(@registry.key_exists?(reg_parent + "\\OpscodeWhyRun")).to eq(true)
589
589
  end
590
590
  end
591
591
  end
@@ -597,21 +597,21 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
597
597
  end
598
598
 
599
599
  it "takes no action if the specified key path does not exist in the system" do
600
- expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
600
+ expect(@registry.key_exists?(reg_parent + "\\Osirian")).to eq(false)
601
601
 
602
- @new_resource.key(reg_parent + '\Osirian')
602
+ @new_resource.key(reg_parent + "\\Osirian")
603
603
  @new_resource.recursive(false)
604
604
  @new_resource.run_action(:delete_key)
605
605
 
606
- expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
606
+ expect(@registry.key_exists?(reg_parent + "\\Osirian")).to eq(false)
607
607
  end
608
608
 
609
609
  it "deletes key if it has no subkeys and recursive == false" do
610
- @new_resource.key(reg_parent + '\OpscodeTest')
610
+ @new_resource.key(reg_parent + "\\OpscodeTest")
611
611
  @new_resource.recursive(false)
612
612
  @new_resource.run_action(:delete_key)
613
613
 
614
- expect(@registry.key_exists?(reg_parent + '\OpscodeTest')).to eq(false)
614
+ expect(@registry.key_exists?(reg_parent + "\\OpscodeTest")).to eq(false)
615
615
  end
616
616
 
617
617
  it "raises an exception if the key has subkeys and recursive == false" do
@@ -621,22 +621,22 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
621
621
  end
622
622
 
623
623
  it "ignores the values under a key" do
624
- @new_resource.key(reg_parent + '\OpscodeIgnoredValues')
624
+ @new_resource.key(reg_parent + "\\OpscodeIgnoredValues")
625
625
  # @new_resource.values([{:name=>"DontExist", :type=>:string, :data=>"These will be ignored anyways"}])
626
626
  @new_resource.recursive(true)
627
627
  @new_resource.run_action(:delete_key)
628
628
  end
629
629
 
630
630
  it "deletes the key if it has subkeys and recursive == true" do
631
- @new_resource.key(reg_parent + '\Opscode')
631
+ @new_resource.key(reg_parent + "\\Opscode")
632
632
  @new_resource.recursive(true)
633
633
  @new_resource.run_action(:delete_key)
634
634
 
635
- expect(@registry.key_exists?(reg_parent + '\Opscode')).to eq(false)
635
+ expect(@registry.key_exists?(reg_parent + "\\Opscode")).to eq(false)
636
636
  end
637
637
 
638
638
  it "prepares the reporting data for action :delete_key" do
639
- @new_resource.key(reg_parent + '\ReportKey')
639
+ @new_resource.key(reg_parent + "\\ReportKey")
640
640
  @new_resource.recursive(true)
641
641
  @new_resource.run_action(:delete_key)
642
642
 
@@ -644,7 +644,7 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
644
644
  expect(@report["action"]).to eq("end")
645
645
  expect(@report["resources"][0]["type"]).to eq("registry_key")
646
646
  expect(@report["resources"][0]["name"]).to eq(resource_name)
647
- expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
647
+ expect(@report["resources"][0]["id"]).to eq(reg_parent + "\\ReportKey")
648
648
  # Not testing for before or after values to match since
649
649
  # after -> new_resource.values and
650
650
  # before -> current_resource.values
@@ -658,18 +658,18 @@ describe Chef::Resource::RegistryKey, :windows_only, broken: true do
658
658
  end
659
659
 
660
660
  it "does not throw an exception if the key has subkeys but recursive is set to false" do
661
- @new_resource.key(reg_parent + '\OpscodeWhyRun')
661
+ @new_resource.key(reg_parent + "\\OpscodeWhyRun")
662
662
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
663
663
  @new_resource.recursive(false)
664
664
  @new_resource.run_action(:delete_key)
665
665
  end
666
666
  it "does nothing if the action is delete_key" do
667
- @new_resource.key(reg_parent + '\OpscodeWhyRun')
667
+ @new_resource.key(reg_parent + "\\OpscodeWhyRun")
668
668
  @new_resource.values([{ name: "BriskWalk", type: :string, data: "is good for health" }])
669
669
  @new_resource.recursive(false)
670
670
  @new_resource.run_action(:delete_key)
671
671
 
672
- expect(@registry.key_exists?(reg_parent + '\OpscodeWhyRun')).to eq(true)
672
+ expect(@registry.key_exists?(reg_parent + "\\OpscodeWhyRun")).to eq(true)
673
673
  end
674
674
  end
675
675
  end
@@ -28,14 +28,14 @@ describe "Chef::Win32::Registry", :windows_only do
28
28
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch"
29
29
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\B®anch"
30
30
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch\\Flower"
31
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root', Win32::Registry::KEY_ALL_ACCESS) do |reg|
31
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root", Win32::Registry::KEY_ALL_ACCESS) do |reg|
32
32
  reg["RootType1", Win32::Registry::REG_SZ] = "fibrous"
33
33
  reg.write("Roots", Win32::Registry::REG_MULTI_SZ, ["strong roots", "healthy tree"])
34
34
  end
35
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch', Win32::Registry::KEY_ALL_ACCESS) do |reg|
35
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Branch", Win32::Registry::KEY_ALL_ACCESS) do |reg|
36
36
  reg["Strong", Win32::Registry::REG_SZ] = "bird nest"
37
37
  end
38
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch\\Flower', Win32::Registry::KEY_ALL_ACCESS) do |reg|
38
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Branch\\Flower", Win32::Registry::KEY_ALL_ACCESS) do |reg|
39
39
  reg["Petals", Win32::Registry::REG_MULTI_SZ] = %w{Pink Delicate}
40
40
  end
41
41
 
@@ -297,7 +297,7 @@ describe "Chef::Win32::Registry", :windows_only do
297
297
  describe "delete_value" do
298
298
  before(:all) do
299
299
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk\\Peck\\Woodpecker"
300
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Trunk\\Peck\\Woodpecker', Win32::Registry::KEY_ALL_ACCESS) do |reg|
300
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Trunk\\Peck\\Woodpecker", Win32::Registry::KEY_ALL_ACCESS) do |reg|
301
301
  reg["Peter", Win32::Registry::REG_SZ] = "Tiny"
302
302
  end
303
303
  end
@@ -324,11 +324,11 @@ describe "Chef::Win32::Registry", :windows_only do
324
324
  describe "delete_key" do
325
325
  before(:all) do
326
326
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch\\Fruit"
327
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch\\Fruit', Win32::Registry::KEY_ALL_ACCESS) do |reg|
327
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Branch\\Fruit", Win32::Registry::KEY_ALL_ACCESS) do |reg|
328
328
  reg["Apple", Win32::Registry::REG_MULTI_SZ] = %w{Red Juicy}
329
329
  end
330
330
  ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk\\Peck\\Woodpecker"
331
- ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Trunk\\Peck\\Woodpecker', Win32::Registry::KEY_ALL_ACCESS) do |reg|
331
+ ::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Trunk\\Peck\\Woodpecker", Win32::Registry::KEY_ALL_ACCESS) do |reg|
332
332
  reg["Peter", Win32::Registry::REG_SZ] = "Tiny"
333
333
  end
334
334
  end
@@ -519,12 +519,12 @@ describe "Chef::Win32::Registry", :windows_only do
519
519
  end
520
520
  # 64-bit
521
521
  ::Win32::Registry::HKEY_LOCAL_MACHINE.create("Software\\Root\\Mauve", ::Win32::Registry::KEY_ALL_ACCESS | 0x0100)
522
- ::Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\\Root\\Mauve', Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg|
522
+ ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software\\Root\\Mauve", Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg|
523
523
  reg["Alert", Win32::Registry::REG_SZ] = "Universal"
524
524
  end
525
525
  # 32-bit
526
526
  ::Win32::Registry::HKEY_LOCAL_MACHINE.create("Software\\Root\\Poosh", ::Win32::Registry::KEY_ALL_ACCESS | 0x0200)
527
- ::Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\\Root\\Poosh', Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg|
527
+ ::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software\\Root\\Poosh", Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg|
528
528
  reg["Status", Win32::Registry::REG_SZ] = "Lost"
529
529
  end
530
530
  end
@@ -80,4 +80,64 @@ describe "chef-client with compliance phase" do
80
80
  expect(result["status"]).to eq("passed")
81
81
  end
82
82
  end
83
+
84
+ when_the_repository "has a compliance segment" do
85
+ let(:report_file) { path_to("report_file.json") }
86
+
87
+ before do
88
+ directory "cookbooks/x" do
89
+ directory "compliance" do
90
+ directory "profiles/my_profile" do
91
+ file "inspec.yml", <<~FILE
92
+ ---
93
+ name: my-profile
94
+ FILE
95
+
96
+ directory "controls" do
97
+ file "my_control.rb", <<~FILE
98
+ control "my control" do
99
+ describe Dir.home do
100
+ it { should be_kind_of String }
101
+ end
102
+ end
103
+ FILE
104
+ end
105
+ end
106
+ end
107
+ file "attributes/default.rb", <<~FILE
108
+ default['audit']['reporter'] = "json-file"
109
+ default['audit']['json_file'] = {
110
+ "location" => "#{report_file}"
111
+ }
112
+ FILE
113
+ file "recipes/default.rb", <<~FILE
114
+ include_profile ".*::.*"
115
+ FILE
116
+ end
117
+ file "config/client.rb", <<~EOM
118
+ local_mode true
119
+ cookbook_path "#{path_to("cookbooks")}"
120
+ log_level :warn
121
+ EOM
122
+ end
123
+
124
+ it "should complete with success" do
125
+ result = shell_out!("#{chef_client} -c \"#{path_to("config/client.rb")}\" -r 'recipe[x]'", cwd: chef_dir)
126
+ result.error!
127
+
128
+ inspec_report = JSON.parse(File.read(report_file))
129
+ expect(inspec_report["profiles"].length).to eq(1)
130
+
131
+ profile = inspec_report["profiles"].first
132
+ expect(profile["name"]).to eq("my-profile")
133
+ expect(profile["controls"].length).to eq(1)
134
+
135
+ control = profile["controls"].first
136
+ expect(control["id"]).to eq("my control")
137
+ expect(control["results"].length).to eq(1)
138
+
139
+ result = control["results"].first
140
+ expect(result["status"]).to eq("passed")
141
+ end
142
+ end
83
143
  end
data/spec/spec_helper.rb CHANGED
@@ -68,6 +68,7 @@ end
68
68
  require "spec/support/local_gems" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
69
69
 
70
70
  # Explicitly require spec helpers that need to load first
71
+ require "spec/support/ruby_installer"
71
72
  require "spec/support/platform_helpers"
72
73
  require "spec/support/shared/unit/mock_shellout"
73
74
 
@@ -186,6 +187,8 @@ RSpec.configure do |config|
186
187
  config.filter_run_excluding not_rhel7: true if rhel7?
187
188
  config.filter_run_excluding not_intel_64bit: true if intel_64bit?
188
189
 
190
+ config.filter_run_excluding libarchive_loading_broken: true if aix? || amazon_linux? || rhel7?
191
+
189
192
  # these let us use chef: ">= 13" or ruby: "~> 2.0.0" or any other Gem::Dependency-style constraint
190
193
  config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION)
191
194
  config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION)
@@ -163,6 +163,10 @@ def aix?
163
163
  RUBY_PLATFORM.include?("aix")
164
164
  end
165
165
 
166
+ def amazon_linux?
167
+ ohai[:platform_family] == "amazon"
168
+ end
169
+
166
170
  def wpar?
167
171
  !((ohai[:virtualization] || {})[:wpar_no].nil?)
168
172
  end