chef 18.2.7-x64-mingw-ucrt → 18.4.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/chef-universal-mingw-ucrt.gemspec +1 -1
  4. data/chef.gemspec +3 -3
  5. data/lib/chef/application/base.rb +2 -0
  6. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  7. data/lib/chef/chef_fs/path_utils.rb +7 -9
  8. data/lib/chef/client.rb +2 -2
  9. data/lib/chef/cookbook/synchronizer.rb +19 -2
  10. data/lib/chef/cookbook_version.rb +1 -1
  11. data/lib/chef/delayed_evaluator.rb +4 -0
  12. data/lib/chef/file_access_control/windows.rb +4 -1
  13. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
  14. data/lib/chef/http/ssl_policies.rb +2 -2
  15. data/lib/chef/mixin/homebrew_user.rb +15 -5
  16. data/lib/chef/monkey_patches/net-http.rb +127 -0
  17. data/lib/chef/node/attribute_collections.rb +10 -1
  18. data/lib/chef/node/immutable_collections.rb +7 -3
  19. data/lib/chef/node/mixin/state_tracking.rb +1 -1
  20. data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
  21. data/lib/chef/node.rb +22 -0
  22. data/lib/chef/provider/launchd.rb +1 -1
  23. data/lib/chef/provider/mount/linux.rb +1 -1
  24. data/lib/chef/provider/mount/mount.rb +5 -5
  25. data/lib/chef/provider/package/apt.rb +11 -2
  26. data/lib/chef/provider/package/chocolatey.rb +239 -18
  27. data/lib/chef/provider/package/zypper.rb +6 -0
  28. data/lib/chef/provider/powershell_script.rb +96 -6
  29. data/lib/chef/provider/remote_file/http.rb +1 -1
  30. data/lib/chef/provider/service/systemd.rb +23 -8
  31. data/lib/chef/provider/service/windows.rb +1 -0
  32. data/lib/chef/provider/service.rb +14 -0
  33. data/lib/chef/provider/user.rb +5 -1
  34. data/lib/chef/provider/yum_repository.rb +1 -1
  35. data/lib/chef/recipe.rb +3 -11
  36. data/lib/chef/resource/_rest_resource.rb +1 -1
  37. data/lib/chef/resource/apt_package.rb +19 -0
  38. data/lib/chef/resource/apt_repository.rb +26 -6
  39. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
  40. data/lib/chef/resource/chocolatey_installer.rb +207 -0
  41. data/lib/chef/resource/chocolatey_package.rb +8 -0
  42. data/lib/chef/resource/homebrew_cask.rb +6 -7
  43. data/lib/chef/resource/homebrew_package.rb +1 -1
  44. data/lib/chef/resource/homebrew_tap.rb +5 -5
  45. data/lib/chef/resource/launchd.rb +5 -1
  46. data/lib/chef/resource/locale.rb +5 -2
  47. data/lib/chef/resource/macos_pkg.rb +111 -0
  48. data/lib/chef/resource/powershell_script.rb +5 -1
  49. data/lib/chef/resource/service.rb +3 -0
  50. data/lib/chef/resource/sudo.rb +37 -2
  51. data/lib/chef/resource/support/ulimit.erb +40 -0
  52. data/lib/chef/resource/user_ulimit.rb +38 -0
  53. data/lib/chef/resource/windows_certificate.rb +1 -1
  54. data/lib/chef/resource/windows_security_policy.rb +2 -2
  55. data/lib/chef/resource.rb +11 -1
  56. data/lib/chef/resources.rb +2 -0
  57. data/lib/chef/version.rb +1 -1
  58. data/lib/chef/win32/security.rb +7 -1
  59. data/spec/data/trusted_certs/example.crt +29 -20
  60. data/spec/data/trusted_certs/example_no_cn.crt +30 -34
  61. data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
  62. data/spec/functional/resource/execute_spec.rb +1 -1
  63. data/spec/functional/resource/windows_certificate_spec.rb +25 -0
  64. data/spec/functional/resource/zypper_package_spec.rb +10 -0
  65. data/spec/unit/client_spec.rb +2 -2
  66. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  67. data/spec/unit/delayed_evaluator_spec.rb +35 -0
  68. data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
  69. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  70. data/spec/unit/node_spec.rb +6 -0
  71. data/spec/unit/provider/apt_repository_spec.rb +17 -7
  72. data/spec/unit/provider/launchd_spec.rb +2 -2
  73. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  74. data/spec/unit/provider/mount/linux_spec.rb +6 -5
  75. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  76. data/spec/unit/provider/package/apt_spec.rb +18 -13
  77. data/spec/unit/provider/package/chocolatey_spec.rb +53 -9
  78. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  79. data/spec/unit/provider/package/zypper_spec.rb +10 -0
  80. data/spec/unit/provider/powershell_script_spec.rb +100 -4
  81. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  82. data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
  83. data/spec/unit/provider/user/linux_spec.rb +10 -0
  84. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  85. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  86. data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
  87. data/spec/unit/resource/macos_pkg_spec.rb +38 -0
  88. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  89. data/spec/unit/resource_spec.rb +86 -0
  90. metadata +29 -16
  91. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
  92. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
  93. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
  94. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
@@ -59,6 +59,41 @@ class Chef
59
59
  nopasswd true
60
60
  end
61
61
  ```
62
+
63
+ **Create command aliases and assign them to a group**
64
+
65
+ ```ruby
66
+ sudo 'webteam' do
67
+ command_aliases [
68
+ {
69
+ 'name': 'WEBTEAM_SYSTEMD_JBOSS',
70
+ 'command_list': [
71
+ '/usr/bin/systemctl start eap7-standalone.service',
72
+ '/usr/bin/systemctl start jbcs-httpd24-httpd.service', \
73
+ '/usr/bin/systemctl stop eap7-standalone.service', \
74
+ '/usr/bin/systemctl stop jbcs-httpd24-httpd.service', \
75
+ '/usr/bin/systemctl restart eap7-standalone.service', \
76
+ '/usr/bin/systemctl restart jbcs-httpd24-httpd.service', \
77
+ '/usr/bin/systemctl --full edit eap7-standalone.service', \
78
+ '/usr/bin/systemctl --full edit jbcs-httpd24-httpd.service', \
79
+ '/usr/bin/systemctl daemon-reload',
80
+ ]
81
+ },
82
+ {
83
+ 'name': 'GENERIC_SYSTEMD',
84
+ 'command_list': [
85
+ '/usr/sbin/systemctl list-unit-files',
86
+ '/usr/sbin/systemctl list-timers', \
87
+ '/usr/sbin/systemctl is-active *', \
88
+ '/usr/sbin/systemctl is-enabled *',
89
+ ]
90
+ }
91
+ ]
92
+ nopasswd true
93
+ users '%webteam'
94
+ commands [ 'WEBTEAM_SYSTEMD_JBOSS', 'GENERIC_SYSTEMD' ]
95
+ end
96
+ ```
62
97
  DOC
63
98
 
64
99
  # According to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
@@ -79,7 +114,7 @@ class Chef
79
114
  coerce: proc { |x| coerce_groups(x) }
80
115
 
81
116
  property :commands, Array,
82
- description: "An array of full paths to commands this sudoer can execute.",
117
+ description: "An array of full paths to commands and/or command aliases this sudoer can execute.",
83
118
  default: ["ALL"]
84
119
 
85
120
  property :host, String,
@@ -110,7 +145,7 @@ class Chef
110
145
  default: []
111
146
 
112
147
  property :command_aliases, Array,
113
- description: "Command aliases that can be used as allowed commands later in the configuration.",
148
+ description: "Command aliases that can be used as allowed commands later in the configuration. The object represents an array of hashes in the following format: `[{'name':'ALIAS1','command_list': [ 'command1', 'command2' ] }, {'name':'Alias2','command_list: [ 'command3', 'command4 arg1 arg2' ]}]`",
114
149
  default: []
115
150
 
116
151
  property :setenv, [TrueClass, FalseClass],
@@ -2,6 +2,18 @@
2
2
 
3
3
  # Limits settings for <%= @ulimit_user %>
4
4
 
5
+ <% unless @as_limit.nil? -%>
6
+ <%= @ulimit_user -%> - as <%= @as_limit %>
7
+ <% else -%><% unless @as_soft_limit.nil? -%><%= @ulimit_user -%> soft as <%= @as_soft_limit %><% end -%>
8
+ <% unless @as_hard_limit.nil? -%><%= @ulimit_user -%> hard as <%= @as_hard_limit %><% end -%>
9
+ <% end -%>
10
+
11
+ <% unless @cpu_limit.nil? -%>
12
+ <%= @ulimit_user -%> - cpu <%= @cpu_limit %>
13
+ <% else -%><% unless @cpu_soft_limit.nil? -%><%= @ulimit_user -%> soft cpu <%= @cpu_soft_limit %><% end -%>
14
+ <% unless @cpu_hard_limit.nil? -%><%= @ulimit_user -%> hard cpu <%= @cpu_hard_limit %><% end -%>
15
+ <% end -%>
16
+
5
17
  <% unless @filehandle_limit.nil? -%>
6
18
  <%= @ulimit_user -%> - nofile <%= @filehandle_limit %>
7
19
  <% else -%><% unless @filehandle_soft_limit.nil? -%><%= @ulimit_user -%> soft nofile <%= @filehandle_soft_limit %><% end -%>
@@ -14,22 +26,50 @@
14
26
  <% unless @process_hard_limit.nil? -%><%= @ulimit_user -%> hard nproc <%= @process_hard_limit %><% end -%>
15
27
  <% end -%>
16
28
 
29
+ <% unless @locks_limit.nil? -%>
30
+ <%= @ulimit_user -%> - locks <%= @locks_limit %>
31
+ <% end -%>
32
+
17
33
  <% unless @memory_limit.nil? -%>
18
34
  <%= @ulimit_user -%> - memlock <%= @memory_limit %>
19
35
  <% end -%>
20
36
 
37
+ <% unless @maxlogins_limit.nil? -%>
38
+ <%= @ulimit_user -%> - maxlogins <%= @maxlogins_limit %>
39
+ <% else -%><% unless @maxlogins_soft_limit.nil? -%><%= @ulimit_user -%> soft maxlogins <%= @maxlogins_soft_limit %><% end -%>
40
+ <% unless @maxlogins_hard_limit.nil? -%><%= @ulimit_user -%> hard maxlogins <%= @maxlogins_hard_limit %><% end -%>
41
+ <% end -%>
42
+
43
+ <% unless @msgqueue_limit.nil? -%>
44
+ <%= @ulimit_user -%> - msgqueue <%= @msgqueue_limit %>
45
+ <% else -%><% unless @msgqueue_soft_limit.nil? -%><%= @ulimit_user -%> soft msgqueue <%= @msgqueue_soft_limit %><% end -%>
46
+ <% unless @msgqueue_hard_limit.nil? -%><%= @ulimit_user -%> hard msgqueue <%= @msgqueue_hard_limit %><% end -%>
47
+ <% end -%>
48
+
21
49
  <% unless @core_limit.nil? -%>
22
50
  <%= @ulimit_user -%> - core <%= @core_limit %>
23
51
  <% else -%><% unless @core_soft_limit.nil? -%><%= @ulimit_user -%> soft core <%= @core_soft_limit %><% end -%>
24
52
  <% unless @core_hard_limit.nil? -%><%= @ulimit_user -%> hard core <%= @core_hard_limit %><% end -%>
25
53
  <% end -%>
26
54
 
55
+ <% unless @sigpending_limit.nil? -%>
56
+ <%= @ulimit_user -%> - sigpending <%= @sigpending_limit %>
57
+ <% else -%><% unless @sigpending_soft_limit.nil? -%><%= @ulimit_user -%> soft sigpending <%= @sigpending_soft_limit %><% end -%>
58
+ <% unless @sigpending_hard_limit.nil? -%><%= @ulimit_user -%> hard sigpending <%= @sigpending_hard_limit %><% end -%>
59
+ <% end -%>
60
+
27
61
  <% unless @stack_limit.nil? -%>
28
62
  <%= @ulimit_user -%> - stack <%= @stack_limit %>
29
63
  <% else -%><% unless @stack_soft_limit.nil? -%><%= @ulimit_user -%> soft stack <%= @stack_soft_limit %><% end -%>
30
64
  <% unless @stack_hard_limit.nil? -%><%= @ulimit_user -%> hard stack <%= @stack_hard_limit %><% end -%>
31
65
  <% end -%>
32
66
 
67
+ <% unless @rss_limit.nil? -%>
68
+ <%= @ulimit_user -%> - rss <%= @rss_limit %>
69
+ <% else -%><% unless @rss_soft_limit.nil? -%><%= @ulimit_user -%> soft rss <%= @rss_soft_limit %><% end -%>
70
+ <% unless @rss_hard_limit.nil? -%><%= @ulimit_user -%> hard rss <%= @rss_hard_limit %><% end -%>
71
+ <% end -%>
72
+
33
73
  <% unless @rtprio_limit.nil? -%>
34
74
  <%= @ulimit_user -%> - rtprio <%= @rtprio_limit %>
35
75
  <% else -%><% unless @rtprio_soft_limit.nil? -%><%= @ulimit_user -%> soft rtprio <%= @rtprio_soft_limit %><% end -%>
@@ -56,19 +56,38 @@ class Chef
56
56
  DOC
57
57
 
58
58
  property :username, String, name_property: true
59
+ property :as_limit, [String, Integer]
60
+ property :as_soft_limit, [String, Integer]
61
+ property :as_hard_limit, [String, Integer]
59
62
  property :filehandle_limit, [String, Integer]
60
63
  property :filehandle_soft_limit, [String, Integer]
61
64
  property :filehandle_hard_limit, [String, Integer]
62
65
  property :process_limit, [String, Integer]
63
66
  property :process_soft_limit, [String, Integer]
64
67
  property :process_hard_limit, [String, Integer]
68
+ property :locks_limit, [String, Integer]
65
69
  property :memory_limit, [String, Integer]
70
+ property :maxlogins_limit, [String, Integer]
71
+ property :maxlogins_soft_limit, [String, Integer]
72
+ property :maxlogins_hard_limit, [String, Integer]
73
+ property :msgqueue_limit, [String, Integer]
74
+ property :msgqueue_soft_limit, [String, Integer]
75
+ property :msgqueue_hard_limit, [String, Integer]
66
76
  property :core_limit, [String, Integer]
67
77
  property :core_soft_limit, [String, Integer]
68
78
  property :core_hard_limit, [String, Integer]
79
+ property :cpu_limit, [String, Integer]
80
+ property :cpu_soft_limit, [String, Integer]
81
+ property :cpu_hard_limit, [String, Integer]
82
+ property :sigpending_limit, [String, Integer]
83
+ property :sigpending_soft_limit, [String, Integer]
84
+ property :sigpending_hard_limit, [String, Integer]
69
85
  property :stack_limit, [String, Integer]
70
86
  property :stack_soft_limit, [String, Integer]
71
87
  property :stack_hard_limit, [String, Integer]
88
+ property :rss_limit, [String, Integer]
89
+ property :rss_soft_limit, [String, Integer]
90
+ property :rss_hard_limit, [String, Integer]
72
91
  property :rtprio_limit, [String, Integer]
73
92
  property :rtprio_soft_limit, [String, Integer]
74
93
  property :rtprio_hard_limit, [String, Integer]
@@ -85,19 +104,38 @@ class Chef
85
104
  sensitive new_resource.sensitive
86
105
  variables(
87
106
  ulimit_user: new_resource.username,
107
+ as_limit: new_resource.as_limit,
108
+ as_soft_limit: new_resource.as_soft_limit,
109
+ as_hard_limit: new_resource.as_hard_limit,
88
110
  filehandle_limit: new_resource.filehandle_limit,
89
111
  filehandle_soft_limit: new_resource.filehandle_soft_limit,
90
112
  filehandle_hard_limit: new_resource.filehandle_hard_limit,
91
113
  process_limit: new_resource.process_limit,
92
114
  process_soft_limit: new_resource.process_soft_limit,
93
115
  process_hard_limit: new_resource.process_hard_limit,
116
+ locks_limit: new_resource.locks_limit,
94
117
  memory_limit: new_resource.memory_limit,
118
+ maxlogins_limit: new_resource.maxlogins_limit,
119
+ maxlogins_soft_limit: new_resource.maxlogins_soft_limit,
120
+ maxlogins_hard_limit: new_resource.maxlogins_hard_limit,
121
+ msgqueue_limit: new_resource.msgqueue_limit,
122
+ msgqueue_soft_limit: new_resource.msgqueue_soft_limit,
123
+ msgqueue_hard_limit: new_resource.msgqueue_hard_limit,
95
124
  core_limit: new_resource.core_limit,
96
125
  core_soft_limit: new_resource.core_soft_limit,
97
126
  core_hard_limit: new_resource.core_hard_limit,
127
+ cpu_limit: new_resource.cpu_limit,
128
+ cpu_soft_limit: new_resource.cpu_soft_limit,
129
+ cpu_hard_limit: new_resource.cpu_hard_limit,
130
+ sigpending_limit: new_resource.sigpending_limit,
131
+ sigpending_soft_limit: new_resource.sigpending_soft_limit,
132
+ sigpending_hard_limit: new_resource.sigpending_hard_limit,
98
133
  stack_limit: new_resource.stack_limit,
99
134
  stack_soft_limit: new_resource.stack_soft_limit,
100
135
  stack_hard_limit: new_resource.stack_hard_limit,
136
+ rss_limit: new_resource.rss_limit,
137
+ rss_soft_limit: new_resource.rss_soft_limit,
138
+ rss_hard_limit: new_resource.rss_hard_limit,
101
139
  rtprio_limit: new_resource.rtprio_limit,
102
140
  rtprio_soft_limit: new_resource.rtprio_soft_limit,
103
141
  rtprio_hard_limit: new_resource.rtprio_hard_limit,
@@ -440,7 +440,7 @@ class Chef
440
440
  def export_cert(cert_obj, output_path:, store_name:, store_location:, pfx_password:)
441
441
  # Delete the cert if it exists on disk already.
442
442
  # We want to ensure we're not randomly loading an old stinky cert.
443
- if ::File.exists?(output_path)
443
+ if ::File.exist?(output_path)
444
444
  ::File.delete(output_path)
445
445
  end
446
446
 
@@ -118,13 +118,13 @@ class Chef
118
118
  file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
119
119
  file.close
120
120
  file_path = file.path.tr("/", "\\")
121
- cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
121
+ cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg \"#{file_path}\" /areas SECURITYPOLICY"
122
122
  else
123
123
  policy_line = "#{security_option} = #{security_value}"
124
124
  file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
125
125
  file.close
126
126
  file_path = file.path.tr("/", "\\")
127
- cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
127
+ cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg \"#{file_path}\" /areas SECURITYPOLICY"
128
128
  end
129
129
  shell_out!(cmd)
130
130
  file.unlink
data/lib/chef/resource.rb CHANGED
@@ -1508,7 +1508,17 @@ class Chef
1508
1508
  dirname = ::File.dirname(partial)
1509
1509
  basename = ::File.basename(partial, ".rb")
1510
1510
  basename = basename[1..] if basename.start_with?("_")
1511
- class_eval IO.read(::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(caller_locations.first.path)))
1511
+
1512
+ # Support recursive `use`
1513
+ callers = caller_locations
1514
+ used_from = if callers.first.label == "use"
1515
+ callers.detect { |caller| caller.label == "class_from_file" }.path
1516
+ else
1517
+ callers.first.path
1518
+ end
1519
+
1520
+ fullpath = ::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(used_from))
1521
+ class_eval IO.read(fullpath)
1512
1522
  end
1513
1523
  end
1514
1524
 
@@ -39,6 +39,7 @@ require_relative "resource/chef_sleep"
39
39
  require_relative "resource/chef_vault_secret"
40
40
  require_relative "resource/chocolatey_config"
41
41
  require_relative "resource/chocolatey_feature"
42
+ require_relative "resource/chocolatey_installer"
42
43
  require_relative "resource/chocolatey_package"
43
44
  require_relative "resource/chocolatey_source"
44
45
  require_relative "resource/cron/cron"
@@ -83,6 +84,7 @@ require_relative "resource/link"
83
84
  require_relative "resource/locale"
84
85
  require_relative "resource/log"
85
86
  require_relative "resource/macports_package"
87
+ require_relative "resource/macos_pkg"
86
88
  require_relative "resource/macos_userdefaults"
87
89
  require_relative "resource/mdadm"
88
90
  require_relative "resource/mount"
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("18.2.7")
26
+ VERSION = Chef::VersionString.new("18.4.2")
27
27
  end
28
28
 
29
29
  #
@@ -721,7 +721,13 @@ class Chef
721
721
  unless LogonUserW(username, domain, password, logon_type, logon_provider, token)
722
722
  Chef::ReservedNames::Win32::Error.raise!
723
723
  end
724
- Token.new(Handle.new(token.read_pointer))
724
+
725
+ # originally this was .read_pointer, but that is interpreted as a non-primitive
726
+ # class (FFI::Pointer) and causes an ArgumentError (Invalid Memory Object) when
727
+ # compared to GetCurrentProcess(), which returns a HANDLE (void *). Since a
728
+ # HANDLE is not a pointer to allocated memory that Ruby C extensions can understand,
729
+ # the Invalid Memory Object error is raised.
730
+ Token.new(Handle.new(token.read_ulong))
725
731
  end
726
732
 
727
733
  def self.test_and_raise_lsa_nt_status(result)
@@ -1,22 +1,31 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDkjCCAnoCCQDihI8kxGYTFTANBgkqhkiG9w0BAQ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RxmGtQdtBi8Gdk3mNMkokSQCVcDWvNhX
30
+ pVFCGya51orBgbWqxbAsIeiv7Pl85edXm8KolJ389xkXqFvX31hme5KnyBhCcRrv
31
+ EZbXRhY3O58t7SlKWVCnx/JmEkJcRJtZaEReF1LbBayExYNnj/sD
36
32
  -----END CERTIFICATE-----
@@ -22,8 +22,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
22
22
  include Chef::Mixin::ShellOut
23
23
 
24
24
  let(:package_name) { "test-A" }
25
- let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
26
25
  let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
26
+ let(:package_list) do
27
+ if provider.query_command == "list"
28
+ # using result of query_command because that indicates which "search" command to use
29
+ # which coincides with the package list output
30
+ proc { shell_out!("choco search -lo #{Array(package_name).join(" ")}").stdout.chomp }
31
+ else
32
+ proc { shell_out!("choco list #{Array(package_name).join(" ")}").stdout.chomp }
33
+ end
34
+ end
27
35
 
28
36
  let(:run_context) do
29
37
  Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
@@ -54,12 +62,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
54
62
  ENV["Path"] = ENV.delete("Path")
55
63
  end
56
64
 
65
+ after(:each) do
66
+ provider.instance_variable_set(:@get_choco_version, nil)
67
+ end
68
+
57
69
  context "installing a package" do
58
70
  after { remove_package }
59
71
 
60
72
  it "installs the latest version" do
61
73
  subject.run_action(:install)
62
- expect(package_list.call).to eq("#{package_name}|2.0")
74
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
63
75
  end
64
76
 
65
77
  it "does not install if already installed" do
@@ -69,19 +81,19 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
69
81
  end
70
82
 
71
83
  it "installs version given" do
72
- subject.version "1.0"
84
+ subject.version "1.0.0"
73
85
  subject.run_action(:install)
74
- expect(package_list.call).to eq("#{package_name}|1.0")
86
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
75
87
  end
76
88
 
77
89
  it "installs new version if one is already installed" do
78
- subject.version "1.0"
90
+ subject.version "1.0.0"
79
91
  subject.run_action(:install)
80
- expect(package_list.call).to eq("#{package_name}|1.0")
92
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
81
93
 
82
- subject.version "2.0"
94
+ subject.version "2.0.0"
83
95
  subject.run_action(:install)
84
- expect(package_list.call).to eq("#{package_name}|2.0")
96
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
85
97
  end
86
98
 
87
99
  context "installing multiple packages" do
@@ -89,7 +101,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
89
101
 
90
102
  it "installs both packages" do
91
103
  subject.run_action(:install)
92
- expect(package_list.call).to eq("test-A|2.0\r\ntest-B|1.0")
104
+ expect(package_list.call).to match(/^test-A|2.0.0\r\ntest-B|1.0.0$/)
93
105
  end
94
106
  end
95
107
 
@@ -101,13 +113,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
101
113
  it "installs with an option as a string" do
102
114
  subject.options "--force --confirm"
103
115
  subject.run_action(:install)
104
- expect(package_list.call).to eq("#{package_name}|2.0")
116
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
105
117
  end
106
118
 
107
119
  it "installs with multiple options as a string" do
108
120
  subject.options "--force --confirm"
109
121
  subject.run_action(:install)
110
- expect(package_list.call).to eq("#{package_name}|2.0")
122
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
111
123
  end
112
124
 
113
125
  context "when multiple options passed as string" do
@@ -137,7 +149,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
137
149
  it "installs with multiple options as an array" do
138
150
  subject.options [ "--force", "--confirm" ]
139
151
  subject.run_action(:install)
140
- expect(package_list.call).to eq("#{package_name}|2.0")
152
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
141
153
  end
142
154
  end
143
155
 
@@ -145,24 +157,24 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
145
157
  after { remove_package }
146
158
 
147
159
  it "upgrades to a specific version" do
148
- subject.version "1.0"
160
+ subject.version "1.0.0"
149
161
  subject.run_action(:install)
150
- expect(package_list.call).to eq("#{package_name}|1.0")
162
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
151
163
 
152
- subject.version "1.5"
164
+ subject.version "1.5.0"
153
165
  subject.run_action(:upgrade)
154
- expect(package_list.call).to eq("#{package_name}|1.5")
166
+ expect(package_list.call).to match(/^#{package_name}|1.5.0$/)
155
167
  end
156
168
 
157
169
  it "upgrades to the latest version if no version given" do
158
- subject.version "1.0"
170
+ subject.version "1.0.0"
159
171
  subject.run_action(:install)
160
- expect(package_list.call).to eq("#{package_name}|1.0")
172
+ expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
161
173
 
162
174
  subject2 = Chef::Resource::ChocolateyPackage.new("test-A", run_context)
163
175
  subject2.source package_source
164
176
  subject2.run_action(:upgrade)
165
- expect(package_list.call).to eq("#{package_name}|2.0")
177
+ expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
166
178
  end
167
179
  end
168
180
 
@@ -170,7 +182,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
170
182
  it "removes an installed package" do
171
183
  subject.run_action(:install)
172
184
  remove_package
173
- expect(package_list.call).to eq("")
185
+ expect(package_list.call).to match(/0 packages installed/)
174
186
  end
175
187
  end
176
188
 
@@ -62,7 +62,7 @@ describe Chef::Resource::Execute do
62
62
  end
63
63
 
64
64
  describe "when parent resource sets :cwd" do
65
- let(:guard) { %{ruby -e 'exit 1 unless File.exists?("./nested.json")'} }
65
+ let(:guard) { %{ruby -e 'exit 1 unless File.exist?("./nested.json")'} }
66
66
 
67
67
  it "guard inherits :cwd from resource and runs" do
68
68
  resource.cwd CHEF_SPEC_DATA
@@ -56,6 +56,30 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
56
56
  let(:store) { "Chef-Functional-Test" }
57
57
  let(:store_name) { "MY" }
58
58
  let(:store_location) { "LocalMachine" }
59
+ let(:test_cert_body) do
60
+ <<~CERT
61
+ -----BEGIN CERTIFICATE-----
62
+ MIIDQTCCAimgAwIBAgIQX3zqNCJbsKlEvzCz3Z9aNDANBgkqhkiG9w0BAQsFADAh
63
+ MR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVzdHMuY29tMCAXDTIwMDMwNTEwMjcw
64
+ NVoYDzIxMjAwMzA1MTAzNzA2WjAhMR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVz
65
+ dHMuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtuYKDb6woWIH
66
+ HPPOrcVpgJFVxbkjgk+tsYwbIiqR9jtRaKE6nM/awOgn9/dFF4k8KB8Em0sUx7Vq
67
+ J3YhK2N2cAacgP2Frqqf5znpNBBOg968RoZzGx0EiXFvLsqC4y8ggApWTbMXPRk4
68
+ 1a7GlpUpSqI3y5cLeEbzwGQKu8I1I+v7P2fTlnJPHarM7sBbL8bieukkFHYu78iV
69
+ u1wpKOCCfs5DTmJu8WN+z1Mar9vyrWMBlt2wBBgNHPz5mcXUzJHTzaI/D9RGgBgF
70
+ V0IkNqISx/IzR62jjj2g6MgTH4G/0mM6O5sxduM4yGmWZNZpVzh0yMLgH619MZlj
71
+ SMQIN3U/SQIDAQABo3MwcTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB
72
+ BQUHAwIGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFnd3dy5kdW1teWNoZWZ0ZXN0cy5j
73
+ b20wHQYDVR0OBBYEFHwS3gs03m6RcpR+66u4OqGiZdYnMA0GCSqGSIb3DQEBCwUA
74
+ A4IBAQCFHqMjHUfBZahIsKHQIcFCbC1NFh1ZHlJKZzrRBRwRzX19OttHGMyLpDd6
75
+ tM9Ac6LLR8S4QIWg+HF3IrkN+vfTRDZAccj+tIwBRstmdsEz/rAJ79Vb/00mXZQx
76
+ 0FPiBDR3hE7On2oo24DU8kJP3v6TrunwtIomVGqrrkwZzvxqyW+WJMB2shGNFw5J
77
+ mKYBiiXsHl4Bi7V4zhXssrLp877sqpNLeXloXBmAlT39SwQTP9ImZaV5R6udqlvo
78
+ Gfgm5PH/WeK6MV3n5ik0v1rS0LwR2o82WlIB6a4iSEbzY3qSLsWOwt8o5QjAVzCR
79
+ tNdbdS3U8nrG73iA2clmF57ARQWC
80
+ -----END CERTIFICATE-----
81
+ CERT
82
+ end
59
83
  let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
60
84
  let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
61
85
  let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
@@ -128,6 +152,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
128
152
  end
129
153
 
130
154
  it "can add a certificate from a valid url" do
155
+ stub_request(:get, download_cert_url).to_return(body: test_cert_body)
131
156
  resource.source = download_cert_url
132
157
  resource.run_action(:create)
133
158
 
@@ -189,6 +189,15 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
189
189
  expect(zypper_package.updated_by_last_action?).to be true
190
190
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
191
191
  end
192
+
193
+ context "Package doesn't exist" do
194
+ let(:package_name) { "nonexistent_repo" }
195
+ it "does nothing if the package is not installed" do
196
+ zypper_package.run_action(:remove)
197
+ expect(zypper_package.updated_by_last_action?).to be false
198
+ end
199
+
200
+ end
192
201
  end
193
202
 
194
203
  context "with no available version" do
@@ -259,6 +268,7 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
259
268
  expect(shell_out("zypper locks | grep chef_rpm_provides").stdout.chomp).not_to match("chef_rpm_provides")
260
269
  end
261
270
  end
271
+
262
272
  def remove_package
263
273
  pkg_to_remove = Chef::Resource::ZypperPackage.new(package_name, run_context)
264
274
  pkg_to_remove.run_action(:remove)
@@ -119,8 +119,8 @@ shared_context "a client run" do
119
119
  # Make sure Client#register thinks the client key doesn't
120
120
  # exist, so it tries to register and create one.
121
121
  allow(Chef::HTTP::Authenticator).to receive(:detect_certificate_key).with(fqdn).and_return(false)
122
- allow(File).to receive(:exists?).and_call_original
123
- expect(File).to receive(:exists?)
122
+ allow(File).to receive(:exist?).and_call_original
123
+ expect(File).to receive(:exist?)
124
124
  .with(Chef::Config[:client_key])
125
125
  .exactly(:once)
126
126
  .and_return(api_client_exists?)