chef 16.8.9-universal-mingw32 → 16.9.29-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -4
  3. data/README.md +1 -1
  4. data/chef.gemspec +11 -2
  5. data/lib/chef/compliance/default_attributes.rb +5 -1
  6. data/lib/chef/compliance/fetcher/automate.rb +2 -2
  7. data/lib/chef/compliance/fetcher/chef_server.rb +2 -2
  8. data/lib/chef/compliance/reporter/automate.rb +1 -2
  9. data/lib/chef/compliance/reporter/chef_server_automate.rb +4 -2
  10. data/lib/chef/compliance/runner.rb +53 -39
  11. data/lib/chef/http/ssl_policies.rb +27 -14
  12. data/lib/chef/knife/core/formatting_options.rb +49 -0
  13. data/lib/chef/knife/core/node_presenter.rb +0 -25
  14. data/lib/chef/knife/core/status_presenter.rb +1 -26
  15. data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
  16. data/lib/chef/knife/node_show.rb +2 -1
  17. data/lib/chef/knife/search.rb +2 -1
  18. data/lib/chef/knife/ssh.rb +2 -0
  19. data/lib/chef/knife/status.rb +8 -11
  20. data/lib/chef/policy_builder/policyfile.rb +1 -1
  21. data/lib/chef/provider/package.rb +53 -19
  22. data/lib/chef/provider/package/dnf.rb +39 -12
  23. data/lib/chef/provider/package/dnf/dnf_helper.py +18 -5
  24. data/lib/chef/provider/package/dnf/python_helper.rb +6 -6
  25. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  26. data/lib/chef/provider/yum_repository.rb +2 -2
  27. data/lib/chef/resource/chef_gem.rb +2 -2
  28. data/lib/chef/resource/cron/cron_d.rb +1 -0
  29. data/lib/chef/resource/file.rb +1 -1
  30. data/lib/chef/resource/gem_package.rb +2 -2
  31. data/lib/chef/resource/homebrew_cask.rb +3 -3
  32. data/lib/chef/resource/http_request.rb +1 -1
  33. data/lib/chef/resource/locale.rb +1 -1
  34. data/lib/chef/resource/mdadm.rb +2 -2
  35. data/lib/chef/resource/osx_profile.rb +7 -7
  36. data/lib/chef/resource/remote_directory.rb +1 -1
  37. data/lib/chef/resource/ruby.rb +1 -5
  38. data/lib/chef/resource/ruby_block.rb +1 -1
  39. data/lib/chef/resource/user/windows_user.rb +5 -0
  40. data/lib/chef/resource/windows_certificate.rb +2 -12
  41. data/lib/chef/resource/yum_repository.rb +5 -0
  42. data/lib/chef/shell.rb +32 -1
  43. data/lib/chef/version.rb +1 -1
  44. data/spec/data/rubygems.org/latest_specs.4.8.gz +0 -0
  45. data/spec/data/rubygems.org/nonexistent_gem +0 -0
  46. data/spec/data/rubygems.org/sexp_processor +0 -0
  47. data/spec/data/rubygems.org/sexp_processor-4.15.1.gemspec.rz +0 -0
  48. data/spec/data/ssl/binary/chef-rspec-der.cert +0 -0
  49. data/spec/data/ssl/binary/chef-rspec-der.key +0 -0
  50. data/spec/functional/resource/dnf_package_spec.rb +319 -16
  51. data/spec/functional/resource/ohai_spec.rb +2 -10
  52. data/spec/functional/resource/windows_certificate_spec.rb +204 -384
  53. data/spec/spec_helper.rb +1 -1
  54. data/spec/unit/compliance/runner_spec.rb +60 -7
  55. data/spec/unit/http/ssl_policies_spec.rb +106 -78
  56. data/spec/unit/knife/bootstrap_spec.rb +5 -17
  57. data/spec/unit/knife/core/status_presenter_spec.rb +54 -0
  58. data/spec/unit/mixin/openssl_helper_spec.rb +0 -7
  59. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  60. data/spec/unit/provider/package/rubygems_spec.rb +39 -7
  61. data/spec/unit/resource/user/windows_user_spec.rb +36 -0
  62. metadata +32 -14
  63. data/spec/data/trusted_certs_empty/.gitkeep +0 -0
  64. data/spec/data/trusted_certs_empty/README.md +0 -1
  65. data/spec/scripts/ssl-serve.rb +0 -47
@@ -49,7 +49,7 @@ class Chef
49
49
 
50
50
  To install a gem while #{ChefUtils::Dist::Infra::PRODUCT} is configuring the node (the converge phase), set the `compile_time` property to `false`:
51
51
  ```ruby
52
- chef_gem 'right_aws' do
52
+ chef_gem 'loofah' do
53
53
  compile_time false
54
54
  action :install
55
55
  end
@@ -57,7 +57,7 @@ class Chef
57
57
 
58
58
  To install a gem while the resource collection is being built (the compile phase), set the `compile_time` property to `true`:
59
59
  ```ruby
60
- chef_gem 'right_aws' do
60
+ chef_gem 'loofah' do
61
61
  compile_time true
62
62
  action :install
63
63
  end
@@ -160,6 +160,7 @@ class Chef
160
160
  source ::File.expand_path("../support/cron.d.erb", __dir__)
161
161
  local true
162
162
  mode new_resource.mode
163
+ sensitive new_resource.sensitive
163
164
  variables(
164
165
  name: sanitized_name,
165
166
  predefined_value: new_resource.predefined_value,
@@ -32,7 +32,7 @@ class Chef
32
32
 
33
33
  provides :file
34
34
 
35
- description "Use the **file** resource to manage files directly on a node."
35
+ description "Use the **file** resource to manage files directly on a node. Note: Use the **cookbook_file** resource to copy a file from a cookbook's `/files` directory. Use the **template** resource to create a file based on a template in a cookbook's `/templates` directory. And use the **remote_file** resource to transfer a file to a node from a remote location."
36
36
 
37
37
  if ChefUtils.windows?
38
38
  # Use Windows rights instead of standard *nix permissions
@@ -44,8 +44,8 @@ class Chef
44
44
  **Install a gem file from the local file system**
45
45
 
46
46
  ```ruby
47
- gem_package 'right_aws' do
48
- source '/tmp/right_aws-1.11.0.gem'
47
+ gem_package 'loofah' do
48
+ source '/tmp/loofah-2.7.0.gem'
49
49
  action :install
50
50
  end
51
51
  ```
@@ -60,7 +60,7 @@ class Chef
60
60
 
61
61
  unless casked?
62
62
  converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
63
- shell_out!("#{new_resource.homebrew_path} cask install #{new_resource.cask_name} #{new_resource.options}",
63
+ shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
64
64
  user: new_resource.owner,
65
65
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
66
66
  cwd: ::Dir.home(new_resource.owner))
@@ -75,7 +75,7 @@ class Chef
75
75
 
76
76
  if casked?
77
77
  converge_by("uninstall cask #{new_resource.cask_name}") do
78
- shell_out!("#{new_resource.homebrew_path} cask uninstall #{new_resource.cask_name}",
78
+ shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
79
79
  user: new_resource.owner,
80
80
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
81
81
  cwd: ::Dir.home(new_resource.owner))
@@ -93,7 +93,7 @@ class Chef
93
93
  # @return [Boolean]
94
94
  def casked?
95
95
  unscoped_name = new_resource.cask_name.split("/").last
96
- shell_out!("#{new_resource.homebrew_path} cask list 2>/dev/null",
96
+ shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
97
97
  user: new_resource.owner,
98
98
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
99
99
  cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
@@ -26,7 +26,7 @@ class Chef
26
26
 
27
27
  provides :http_request
28
28
 
29
- description "Use the **http_request** resource to send an HTTP request (GET, PUT, POST, DELETE, HEAD, or OPTIONS) with an arbitrary message. This resource is often useful when custom callbacks are necessary."
29
+ description "Use the **http_request** resource to send an HTTP request (`GET`, `PUT`, `POST`, `DELETE`, `HEAD`, or `OPTIONS`) with an arbitrary message. This resource is often useful when custom callbacks are necessary."
30
30
 
31
31
  default_action :get
32
32
  allowed_actions :get, :patch, :put, :post, :delete, :head, :options
@@ -125,7 +125,7 @@ class Chef
125
125
  # @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
126
126
  #
127
127
  def generate_locales
128
- shell_out!("locale-gen #{unavailable_locales.join(" ")}")
128
+ shell_out!("locale-gen #{unavailable_locales.join(" ")}", timeout: 1800)
129
129
  end
130
130
 
131
131
  # Sets the system locale for the current computer.
@@ -36,7 +36,7 @@ class Chef
36
36
 
37
37
  property :chunk, Integer,
38
38
  default: 16,
39
- description: "The chunk size. This property should not be used for a RAID 1 mirrored pair (i.e. when the level property is set to 1)."
39
+ description: "The chunk size. This property should not be used for a RAID 1 mirrored pair (i.e. when the `level` property is set to `1`)."
40
40
 
41
41
  property :devices, Array,
42
42
  default: lazy { [] },
@@ -63,7 +63,7 @@ class Chef
63
63
  description: "An optional property to specify the name of the RAID device if it differs from the resource block's name."
64
64
 
65
65
  property :layout, String,
66
- description: "The RAID5 parity algorithm. Possible values: left-asymmetric (or la), left-symmetric (or ls), right-asymmetric (or ra), or right-symmetric (or rs)."
66
+ description: "The RAID5 parity algorithm. Possible values: `left-asymmetric` (or `la`), `left-symmetric` (or ls), `right-asymmetric` (or `ra`), or `right-symmetric` (or `rs`)."
67
67
 
68
68
  action_class do
69
69
  def load_current_resource
@@ -65,13 +65,13 @@ class Chef
65
65
  {
66
66
  'mcx_preference_settings' => {
67
67
  'idleTime' => 0,
68
- }
69
- }
70
- ]
71
- }
72
- }
73
- }
74
- ]
68
+ },
69
+ },
70
+ ],
71
+ },
72
+ },
73
+ },
74
+ ],
75
75
  }
76
76
 
77
77
  osx_profile 'Install screensaver profile' do
@@ -29,7 +29,7 @@ class Chef
29
29
 
30
30
  provides :remote_directory
31
31
 
32
- description "Use the **remote_directory** resource to incrementally transfer a directory from a cookbook to a node. The director that is copied from the cookbook should be located under COOKBOOK_NAME/files/default/REMOTE_DIRECTORY. The remote_directory resource will obey file specificity."
32
+ description "Use the **remote_directory** resource to incrementally transfer a directory from a cookbook to a node. The directory that is copied from the cookbook should be located under `COOKBOOK_NAME/files/default/REMOTE_DIRECTORY`. The `remote_directory` resource will obey file specificity."
33
33
 
34
34
  default_action :create
35
35
  allowed_actions :create, :create_if_missing, :delete
@@ -25,11 +25,7 @@ class Chef
25
25
 
26
26
  provides :ruby
27
27
 
28
- description "Use the **ruby** resource to execute scripts using the Ruby interpreter. This"\
29
- " resource may also use any of the actions and properties that are available"\
30
- " to the **execute** resource. Commands that are executed with this resource are (by"\
31
- " their nature) not idempotent, as they are typically unique to the environment"\
32
- " in which they are run. Use `not_if` and `only_if` to guard this resource for idempotence."
28
+ description "Use the **ruby** resource to execute scripts using the Ruby interpreter. This resource may also use any of the actions and properties that are available to the **execute** resource. Commands that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the environment in which they are run. Use `not_if` and `only_if` to guard this resource for idempotence."
33
29
 
34
30
  def initialize(name, run_context = nil)
35
31
  super
@@ -28,7 +28,7 @@ class Chef
28
28
 
29
29
  provides :ruby_block, target_mode: true
30
30
 
31
- description "Use the **ruby_block** resource to execute Ruby code during a #{ChefUtils::Dist::Infra::PRODUCT} run. Ruby code in the ruby_block resource is evaluated with other resources during convergence, whereas Ruby code outside of a ruby_block resource is evaluated before other resources, as the recipe is compiled."
31
+ description "Use the **ruby_block** resource to execute Ruby code during a #{ChefUtils::Dist::Infra::PRODUCT} run. Ruby code in the `ruby_block` resource is evaluated with other resources during convergence, whereas Ruby code outside of a `ruby_block` resource is evaluated before other resources, as the recipe is compiled."
32
32
 
33
33
  default_action :run
34
34
  allowed_actions :create, :run
@@ -29,6 +29,11 @@ class Chef
29
29
  property :full_name, String,
30
30
  description: "The full name of the user.",
31
31
  introduced: "14.6"
32
+
33
+ # Override the property from the parent class to coerce to integer.
34
+ property :uid, [ String, Integer, NilClass ], # nil for backwards compat
35
+ description: "The numeric user identifier.",
36
+ coerce: proc { |n| n && Integer(n) rescue n }
32
37
  end
33
38
  end
34
39
  end
@@ -69,7 +69,7 @@ class Chef
69
69
  description: "The password to access the source if it is a pfx file."
70
70
 
71
71
  property :private_key_acl, Array,
72
- description: "An array of 'domain\account' entries to be granted read-only access to the certificate's private key. Not idempotent."
72
+ description: "An array of 'domain\\account' entries to be granted read-only access to the certificate's private key. Not idempotent."
73
73
 
74
74
  property :store_name, String,
75
75
  description: "The certificate store to manipulate.",
@@ -309,11 +309,7 @@ class Chef
309
309
  # @raise [OpenSSL::PKCS12::PKCS12Error] When incorrect password is provided for PFX certificate
310
310
  #
311
311
  def fetch_cert_object(ext)
312
- contents = if binary_cert?
313
- ::File.binread(new_resource.source)
314
- else
315
- ::File.read(new_resource.source)
316
- end
312
+ contents = ::File.binread(new_resource.source)
317
313
 
318
314
  case ext
319
315
  when ".pfx"
@@ -330,12 +326,6 @@ class Chef
330
326
  end
331
327
  end
332
328
 
333
- # @return [Boolean] Whether the certificate file is binary encoded or not
334
- #
335
- def binary_cert?
336
- shell_out!("file -b --mime-encoding #{new_resource.source}").stdout.strip == "binary"
337
- end
338
-
339
329
  # Imports the certificate object into cert store
340
330
  #
341
331
  # @param cert_objs [OpenSSL::X509::Certificate] Object containing certificate's attributes
@@ -50,6 +50,11 @@ class Chef
50
50
 
51
51
  # http://linux.die.net/man/5/yum.conf as well as
52
52
  # http://dnf.readthedocs.io/en/latest/conf_ref.html
53
+ property :reposdir, String,
54
+ description: "The directory where the Yum repository files should be stored",
55
+ default: "/etc/yum.repos.d/",
56
+ introduced: "16.9"
57
+
53
58
  property :baseurl, [String, Array],
54
59
  description: "URL to the directory where the Yum repository's `repodata` directory lives. Can be an `http://`, `https://` or a `ftp://` URLs. You can specify multiple URLs in one `baseurl` statement."
55
60
 
@@ -25,6 +25,7 @@ require "pp" unless defined?(PP)
25
25
  require "etc" unless defined?(Etc)
26
26
  require "mixlib/cli" unless defined?(Mixlib::CLI)
27
27
  require "chef-utils/dist" unless defined?(ChefUtils::Dist)
28
+ require "chef-config/mixin/dot_d"
28
29
 
29
30
  require_relative "../chef"
30
31
  require_relative "version"
@@ -211,6 +212,7 @@ module Shell
211
212
 
212
213
  class Options
213
214
  include Mixlib::CLI
215
+ include ChefConfig::Mixin::DotD
214
216
 
215
217
  def self.footer(text = nil)
216
218
  @footer = text if text
@@ -341,15 +343,44 @@ module Shell
341
343
  # We have to nuke ARGV to make sure irb's option parser never sees it.
342
344
  # otherwise, IRB complains about command line switches it doesn't recognize.
343
345
  ARGV.clear
346
+
347
+ # This code should not exist.
348
+ # We should be using Application::Client and then calling load_config_file
349
+ # which does all this properly. However this will do for now.
344
350
  config[:config_file] = config_file_for_shell_mode(environment)
345
351
  config_msg = config[:config_file] || "none (standalone session)"
346
352
  puts "loading configuration: #{config_msg}"
347
- Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exist?(config[:config_file]) && File.readable?(config[:config_file])
353
+
354
+ # load the config (if we have one)
355
+ if !config[:config_file].nil?
356
+ if File.exist?(config[:config_file]) && File.readable?(config[:config_file])
357
+ Chef::Config.from_file(config[:config_file])
358
+ end
359
+
360
+ # even if we couldn't load that, we need to tell Chef::Config what
361
+ # the file was so it sets confdir and d_dir and such properly
362
+ Chef::Config[:config_file] = config[:config_file]
363
+
364
+ # now attempt to load any relevant dot-dirs
365
+ load_dot_d(Chef::Config[:client_d_dir]) if Chef::Config[:client_d_dir]
366
+ end
367
+
368
+ # finally merge command-line options in
348
369
  Chef::Config.merge!(config)
349
370
  end
350
371
 
351
372
  private
352
373
 
374
+ # shamelessly lifted from application.rb
375
+ def apply_config(config_content, config_file_path)
376
+ Chef::Config.from_string(config_content, config_file_path)
377
+ rescue Exception => error
378
+ logger.fatal("Configuration error #{error.class}: #{error.message}")
379
+ filtered_trace = error.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
380
+ filtered_trace.each { |line| logger.fatal(" " + line ) }
381
+ raise Chef::Exceptions::ConfigurationError.new("Aborting due to error in '#{config_file_path}': #{error}")
382
+ end
383
+
353
384
  def config_file_for_shell_mode(environment)
354
385
  dot_chef_dir = Chef::Util::PathHelper.home(".chef")
355
386
  if config[:config_file]
@@ -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("16.8.9")
26
+ VERSION = Chef::VersionString.new("16.9.29")
27
27
  end
28
28
 
29
29
  #
@@ -91,7 +91,6 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
91
91
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
92
92
  dnf_package.run_action(:install)
93
93
  expect(dnf_package.updated_by_last_action?).to be false
94
- expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
95
94
  end
96
95
 
97
96
  it "does not install twice" do
@@ -128,6 +127,105 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
128
127
  end
129
128
  end
130
129
 
130
+ context "expanded idempotency checks with version variants" do
131
+ %w{1.10 1* 1.10-1 1*-1 1.10-* 1*-* 0:1.10 0:1* 0:1.10-1 0:1*-1 *:1.10-* *:1*-*}.each do |vstring|
132
+ it "installs the rpm when #{vstring} is in the package_name" do
133
+ flush_cache
134
+ dnf_package.package_name("chef_rpm-#{vstring}")
135
+ dnf_package.run_action(:install)
136
+ expect(dnf_package.updated_by_last_action?).to be true
137
+ end
138
+
139
+ it "is idempotent when #{vstring} is in the package_name" do
140
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
141
+ dnf_package.package_name("chef_rpm-#{vstring}")
142
+ dnf_package.run_action(:install)
143
+ expect(dnf_package.updated_by_last_action?).to be false
144
+ end
145
+
146
+ it "installs the rpm when #{vstring} is in the version property" do
147
+ flush_cache
148
+ dnf_package.package_name("chef_rpm")
149
+ dnf_package.version(vstring)
150
+ dnf_package.run_action(:install)
151
+ expect(dnf_package.updated_by_last_action?).to be true
152
+ end
153
+
154
+ it "is idempotent when #{vstring} is in the version property" do
155
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
156
+ dnf_package.package_name("chef_rpm")
157
+ dnf_package.version(vstring)
158
+ dnf_package.run_action(:install)
159
+ expect(dnf_package.updated_by_last_action?).to be false
160
+ end
161
+
162
+ it "upgrades the rpm when #{vstring} is in the package_name" do
163
+ flush_cache
164
+ dnf_package.package_name("chef_rpm-#{vstring}")
165
+ dnf_package.run_action(:upgrade)
166
+ expect(dnf_package.updated_by_last_action?).to be true
167
+ end
168
+
169
+ it "is idempotent when #{vstring} is in the package_name" do
170
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
171
+ dnf_package.package_name("chef_rpm-#{vstring}")
172
+ dnf_package.run_action(:upgrade)
173
+ expect(dnf_package.updated_by_last_action?).to be false
174
+ end
175
+
176
+ it "upgrades the rpm when #{vstring} is in the version property" do
177
+ flush_cache
178
+ dnf_package.package_name("chef_rpm")
179
+ dnf_package.version(vstring)
180
+ dnf_package.run_action(:upgrade)
181
+ expect(dnf_package.updated_by_last_action?).to be true
182
+ end
183
+
184
+ it "is idempotent when #{vstring} is in the version property" do
185
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
186
+ dnf_package.package_name("chef_rpm")
187
+ dnf_package.version(vstring)
188
+ dnf_package.run_action(:upgrade)
189
+ expect(dnf_package.updated_by_last_action?).to be false
190
+ end
191
+ end
192
+
193
+ %w{1.2 1* 1.2-1 1*-1 1.2-* 1*-* 0:1.2 0:1* 0:1.2-1 0:1*-1 *:1.2-* *:1*-*}.each do |vstring|
194
+ it "is idempotent when #{vstring} is in the version property and there is a candidate version" do
195
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
196
+ dnf_package.package_name("chef_rpm")
197
+ dnf_package.version(vstring)
198
+ dnf_package.run_action(:install)
199
+ expect(dnf_package.updated_by_last_action?).to be false
200
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
201
+ end
202
+ end
203
+
204
+ %w{1.2 1.2-1 1.2-* 0:1.2 0:1.2-1 *:1.2-*}.each do |vstring|
205
+ it "is idempotent when #{vstring} is in the version property on upgrade and it doesn't match the candidate version" do
206
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
207
+ dnf_package.package_name("chef_rpm")
208
+ dnf_package.version(vstring)
209
+ dnf_package.run_action(:upgrade)
210
+ expect(dnf_package.updated_by_last_action?).to be false
211
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
212
+ end
213
+ end
214
+
215
+ %w{1* 1*-1 1*-* 0:1* 0:1*-1 *:1*-*}.each do |vstring|
216
+ it "upgrades when #{vstring} is in the version property on upgrade and it matches the candidate version" do
217
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
218
+ dnf_package.package_name("chef_rpm")
219
+ dnf_package.version(vstring)
220
+ dnf_package.run_action(:upgrade)
221
+ expect(dnf_package.updated_by_last_action?).to be true
222
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
223
+ dnf_package.run_action(:upgrade)
224
+ expect(dnf_package.updated_by_last_action?).to be false
225
+ end
226
+ end
227
+ end
228
+
131
229
  context "with versions or globs in the name" do
132
230
  it "works with a version" do
133
231
  flush_cache
@@ -135,6 +233,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
135
233
  dnf_package.run_action(:install)
136
234
  expect(dnf_package.updated_by_last_action?).to be true
137
235
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
236
+ dnf_package.run_action(:install)
237
+ expect(dnf_package.updated_by_last_action?).to be false
138
238
  end
139
239
 
140
240
  it "works with an older version" do
@@ -143,6 +243,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
143
243
  dnf_package.run_action(:install)
144
244
  expect(dnf_package.updated_by_last_action?).to be true
145
245
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
246
+ dnf_package.run_action(:install)
247
+ expect(dnf_package.updated_by_last_action?).to be false
146
248
  end
147
249
 
148
250
  it "works with an evra" do
@@ -151,6 +253,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
151
253
  dnf_package.run_action(:install)
152
254
  expect(dnf_package.updated_by_last_action?).to be true
153
255
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
256
+ dnf_package.run_action(:install)
257
+ expect(dnf_package.updated_by_last_action?).to be false
154
258
  end
155
259
 
156
260
  it "works with version and release" do
@@ -159,6 +263,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
159
263
  dnf_package.run_action(:install)
160
264
  expect(dnf_package.updated_by_last_action?).to be true
161
265
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
266
+ dnf_package.run_action(:install)
267
+ expect(dnf_package.updated_by_last_action?).to be false
162
268
  end
163
269
 
164
270
  it "works with a version glob" do
@@ -167,6 +273,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
167
273
  dnf_package.run_action(:install)
168
274
  expect(dnf_package.updated_by_last_action?).to be true
169
275
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
276
+ dnf_package.run_action(:install)
277
+ expect(dnf_package.updated_by_last_action?).to be false
170
278
  end
171
279
 
172
280
  it "works with a name glob + version glob" do
@@ -175,6 +283,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
175
283
  dnf_package.run_action(:install)
176
284
  expect(dnf_package.updated_by_last_action?).to be true
177
285
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
286
+ dnf_package.run_action(:install)
287
+ expect(dnf_package.updated_by_last_action?).to be false
178
288
  end
179
289
 
180
290
  it "upgrades when the installed version does not match the version string" do
@@ -183,6 +293,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
183
293
  dnf_package.run_action(:install)
184
294
  expect(dnf_package.updated_by_last_action?).to be true
185
295
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}")
296
+ dnf_package.run_action(:install)
297
+ expect(dnf_package.updated_by_last_action?).to be false
186
298
  end
187
299
 
188
300
  it "downgrades when the installed version is higher than the package_name version" do
@@ -191,6 +303,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
191
303
  dnf_package.run_action(:install)
192
304
  expect(dnf_package.updated_by_last_action?).to be true
193
305
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
306
+ dnf_package.run_action(:install)
307
+ expect(dnf_package.updated_by_last_action?).to be false
194
308
  end
195
309
  end
196
310
 
@@ -203,6 +317,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
203
317
  dnf_package.run_action(:install)
204
318
  expect(dnf_package.updated_by_last_action?).to be true
205
319
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
320
+ dnf_package.run_action(:install)
321
+ expect(dnf_package.updated_by_last_action?).to be false
206
322
  end
207
323
 
208
324
  it "matches with a glob" do
@@ -212,6 +328,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
212
328
  dnf_package.run_action(:install)
213
329
  expect(dnf_package.updated_by_last_action?).to be true
214
330
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
331
+ dnf_package.run_action(:install)
332
+ expect(dnf_package.updated_by_last_action?).to be false
215
333
  end
216
334
 
217
335
  it "matches the vr" do
@@ -221,6 +339,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
221
339
  dnf_package.run_action(:install)
222
340
  expect(dnf_package.updated_by_last_action?).to be true
223
341
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
342
+ dnf_package.run_action(:install)
343
+ expect(dnf_package.updated_by_last_action?).to be false
224
344
  end
225
345
 
226
346
  it "matches the evr" do
@@ -230,6 +350,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
230
350
  dnf_package.run_action(:install)
231
351
  expect(dnf_package.updated_by_last_action?).to be true
232
352
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
353
+ dnf_package.run_action(:install)
354
+ expect(dnf_package.updated_by_last_action?).to be false
233
355
  end
234
356
 
235
357
  it "matches with a vr glob", :rhel_gte_8 do
@@ -239,6 +361,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
239
361
  dnf_package.run_action(:install)
240
362
  expect(dnf_package.updated_by_last_action?).to be true
241
363
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
364
+ dnf_package.run_action(:install)
365
+ expect(dnf_package.updated_by_last_action?).to be false
242
366
  end
243
367
 
244
368
  it "matches with an evr glob", :rhel_gte_8 do
@@ -248,6 +372,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
248
372
  dnf_package.run_action(:install)
249
373
  expect(dnf_package.updated_by_last_action?).to be true
250
374
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
375
+ dnf_package.run_action(:install)
376
+ expect(dnf_package.updated_by_last_action?).to be false
251
377
  end
252
378
  end
253
379
 
@@ -260,6 +386,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
260
386
  dnf_package.run_action(:install)
261
387
  expect(dnf_package.updated_by_last_action?).to be true
262
388
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
389
+ dnf_package.run_action(:install)
390
+ expect(dnf_package.updated_by_last_action?).to be false
263
391
  end
264
392
  end
265
393
 
@@ -270,6 +398,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
270
398
  dnf_package.run_action(:install)
271
399
  expect(dnf_package.updated_by_last_action?).to be true
272
400
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
401
+ dnf_package.run_action(:install)
402
+ expect(dnf_package.updated_by_last_action?).to be false
273
403
  end
274
404
 
275
405
  it "installs with 32-bit arch in the name" do
@@ -278,6 +408,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
278
408
  dnf_package.run_action(:install)
279
409
  expect(dnf_package.updated_by_last_action?).to be true
280
410
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
411
+ dnf_package.run_action(:install)
412
+ expect(dnf_package.updated_by_last_action?).to be false
281
413
  end
282
414
 
283
415
  it "installs with 64-bit arch in the property" do
@@ -287,6 +419,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
287
419
  dnf_package.run_action(:install)
288
420
  expect(dnf_package.updated_by_last_action?).to be true
289
421
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
422
+ dnf_package.run_action(:install)
423
+ expect(dnf_package.updated_by_last_action?).to be false
290
424
  end
291
425
 
292
426
  it "installs with 32-bit arch in the property" do
@@ -296,6 +430,30 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
296
430
  dnf_package.run_action(:install)
297
431
  expect(dnf_package.updated_by_last_action?).to be true
298
432
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
433
+ dnf_package.run_action(:install)
434
+ expect(dnf_package.updated_by_last_action?).to be false
435
+ end
436
+
437
+ it "installs when the 32-bit arch is in the name and the version is in the property" do
438
+ flush_cache
439
+ dnf_package.package_name("chef_rpm.i686")
440
+ dnf_package.version("1.10-1")
441
+ dnf_package.run_action(:install)
442
+ expect(dnf_package.updated_by_last_action?).to be true
443
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
444
+ dnf_package.run_action(:install)
445
+ expect(dnf_package.updated_by_last_action?).to be false
446
+ end
447
+
448
+ it "installs when the 64-bit arch is in the name and the version is in the property" do
449
+ flush_cache
450
+ dnf_package.package_name("chef_rpm.#{pkg_arch}")
451
+ dnf_package.version("1.10-1")
452
+ dnf_package.run_action(:install)
453
+ expect(dnf_package.updated_by_last_action?).to be true
454
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
455
+ dnf_package.run_action(:install)
456
+ expect(dnf_package.updated_by_last_action?).to be false
299
457
  end
300
458
  end
301
459
 
@@ -306,6 +464,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
306
464
  dnf_package.run_action(:install)
307
465
  expect(dnf_package.updated_by_last_action?).to be true
308
466
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
467
+ dnf_package.run_action(:install)
468
+ expect(dnf_package.updated_by_last_action?).to be false
309
469
  end
310
470
 
311
471
  it "when it is met, it does nothing" do
@@ -330,6 +490,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
330
490
  dnf_package.run_action(:install)
331
491
  expect(dnf_package.updated_by_last_action?).to be true
332
492
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
493
+ dnf_package.run_action(:install)
494
+ expect(dnf_package.updated_by_last_action?).to be false
333
495
  end
334
496
 
335
497
  it "when it is not met by an installed rpm, it upgrades" do
@@ -338,6 +500,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
338
500
  dnf_package.run_action(:install)
339
501
  expect(dnf_package.updated_by_last_action?).to be true
340
502
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
503
+ dnf_package.run_action(:install)
504
+ expect(dnf_package.updated_by_last_action?).to be false
341
505
  end
342
506
 
343
507
  it "with an equality constraint, when it is not met by an installed rpm, it upgrades" do
@@ -346,6 +510,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
346
510
  dnf_package.run_action(:install)
347
511
  expect(dnf_package.updated_by_last_action?).to be true
348
512
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
513
+ dnf_package.run_action(:install)
514
+ expect(dnf_package.updated_by_last_action?).to be false
349
515
  end
350
516
 
351
517
  it "with an equality constraint, when it is met by an installed rpm, it does nothing" do
@@ -382,6 +548,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
382
548
  dnf_package.run_action(:install)
383
549
  expect(dnf_package.updated_by_last_action?).to be true
384
550
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
551
+ dnf_package.run_action(:install)
552
+ expect(dnf_package.updated_by_last_action?).to be false
385
553
  end
386
554
 
387
555
  it "with a less than constraint, when the install version matches, it does nothing" do
@@ -398,6 +566,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
398
566
  dnf_package.run_action(:install)
399
567
  expect(dnf_package.updated_by_last_action?).to be true
400
568
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
569
+ dnf_package.run_action(:install)
570
+ expect(dnf_package.updated_by_last_action?).to be false
401
571
  end
402
572
  end
403
573
 
@@ -424,6 +594,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
424
594
  dnf_package.run_action(:install)
425
595
  expect(dnf_package.updated_by_last_action?).to be true
426
596
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
597
+ dnf_package.run_action(:install)
598
+ expect(dnf_package.updated_by_last_action?).to be false
427
599
  end
428
600
 
429
601
  it "installs the package when the name is a path to a file" do
@@ -432,6 +604,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
432
604
  dnf_package.run_action(:install)
433
605
  expect(dnf_package.updated_by_last_action?).to be true
434
606
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
607
+ dnf_package.run_action(:install)
608
+ expect(dnf_package.updated_by_last_action?).to be false
435
609
  end
436
610
 
437
611
  it "downgrade on a local file with allow_downgrade true works" do
@@ -441,6 +615,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
441
615
  dnf_package.run_action(:install)
442
616
  expect(dnf_package.updated_by_last_action?).to be true
443
617
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
618
+ dnf_package.run_action(:install)
619
+ expect(dnf_package.updated_by_last_action?).to be false
444
620
  end
445
621
 
446
622
  it "does not downgrade the package with :install" do
@@ -475,15 +651,6 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
475
651
  expect(dnf_package.updated_by_last_action?).to be false
476
652
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
477
653
  end
478
-
479
- it "is idempotent when the package is already installed and there is a version string with arch" do
480
- preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
481
- dnf_package.version "1.2-1.#{pkg_arch}"
482
- dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
483
- dnf_package.run_action(:install)
484
- expect(dnf_package.updated_by_last_action?).to be false
485
- expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
486
- end
487
654
  end
488
655
 
489
656
  context "with no available version" do
@@ -502,6 +669,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
502
669
  dnf_package.run_action(:install)
503
670
  expect(dnf_package.updated_by_last_action?).to be true
504
671
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
672
+ dnf_package.run_action(:install)
673
+ expect(dnf_package.updated_by_last_action?).to be false
505
674
  end
506
675
  end
507
676
 
@@ -513,6 +682,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
513
682
  expect(dnf_package.updated_by_last_action?).to be true
514
683
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
515
684
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
685
+ dnf_package.run_action(:install)
686
+ expect(dnf_package.updated_by_last_action?).to be false
516
687
  end
517
688
 
518
689
  it "does nothing if both are installed" do
@@ -530,6 +701,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
530
701
  expect(dnf_package.updated_by_last_action?).to be true
531
702
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
532
703
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
704
+ dnf_package.run_action(:install)
705
+ expect(dnf_package.updated_by_last_action?).to be false
533
706
  end
534
707
 
535
708
  it "installs the first rpm if the second is installed" do
@@ -539,6 +712,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
539
712
  expect(dnf_package.updated_by_last_action?).to be true
540
713
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
541
714
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
715
+ dnf_package.run_action(:install)
716
+ expect(dnf_package.updated_by_last_action?).to be false
542
717
  end
543
718
 
544
719
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -550,6 +725,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
550
725
  expect(dnf_package.updated_by_last_action?).to be true
551
726
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
552
727
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
728
+ dnf_package.run_action(:install)
729
+ expect(dnf_package.updated_by_last_action?).to be false
553
730
  end
554
731
 
555
732
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -561,6 +738,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
561
738
  expect(dnf_package.updated_by_last_action?).to be true
562
739
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
563
740
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
741
+ dnf_package.run_action(:install)
742
+ expect(dnf_package.updated_by_last_action?).to be false
564
743
  end
565
744
 
566
745
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -572,6 +751,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
572
751
  expect(dnf_package.updated_by_last_action?).to be true
573
752
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
574
753
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
754
+ dnf_package.run_action(:install)
755
+ expect(dnf_package.updated_by_last_action?).to be false
575
756
  end
576
757
 
577
758
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -597,6 +778,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
597
778
  dnf_package.run_action(:install)
598
779
  expect(dnf_package.updated_by_last_action?).to be true
599
780
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
781
+ dnf_package.run_action(:install)
782
+ expect(dnf_package.updated_by_last_action?).to be false
600
783
  end
601
784
 
602
785
  it "should work to enable a disabled repo" do
@@ -608,6 +791,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
608
791
  dnf_package.run_action(:install)
609
792
  expect(dnf_package.updated_by_last_action?).to be true
610
793
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
794
+ dnf_package.run_action(:install)
795
+ expect(dnf_package.updated_by_last_action?).to be false
611
796
  end
612
797
 
613
798
  it "when an idempotent install action is run, does not leave repos disabled" do
@@ -628,6 +813,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
628
813
  dnf_package.run_action(:install)
629
814
  expect(dnf_package.updated_by_last_action?).to be true
630
815
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
816
+ dnf_package.run_action(:install)
817
+ expect(dnf_package.updated_by_last_action?).to be false
631
818
  end
632
819
  end
633
820
  end
@@ -640,6 +827,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
640
827
  dnf_package.run_action(:install)
641
828
  expect(dnf_package.updated_by_last_action?).to be true
642
829
  expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
830
+ dnf_package.run_action(:install)
831
+ expect(dnf_package.updated_by_last_action?).to be false
643
832
  end
644
833
 
645
834
  it "throws a deprecation warning with allow_downgrade" do
@@ -647,10 +836,12 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
647
836
  expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
648
837
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
649
838
  dnf_package.version("1.2")
650
- dnf_package.run_action(:install)
651
839
  dnf_package.allow_downgrade true
840
+ dnf_package.run_action(:install)
652
841
  expect(dnf_package.updated_by_last_action?).to be true
653
842
  expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
843
+ dnf_package.run_action(:install)
844
+ expect(dnf_package.updated_by_last_action?).to be false
654
845
  end
655
846
  end
656
847
 
@@ -663,6 +854,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
663
854
  dnf_package.run_action(:upgrade)
664
855
  expect(dnf_package.updated_by_last_action?).to be true
665
856
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
857
+ dnf_package.run_action(:upgrade)
858
+ expect(dnf_package.updated_by_last_action?).to be false
666
859
  end
667
860
 
668
861
  it "installs the package when the name is a path to a file" do
@@ -671,6 +864,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
671
864
  dnf_package.run_action(:upgrade)
672
865
  expect(dnf_package.updated_by_last_action?).to be true
673
866
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
867
+ dnf_package.run_action(:upgrade)
868
+ expect(dnf_package.updated_by_last_action?).to be false
674
869
  end
675
870
 
676
871
  it "downgrades the package when allow_downgrade is true" do
@@ -679,6 +874,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
679
874
  dnf_package.run_action(:upgrade)
680
875
  expect(dnf_package.updated_by_last_action?).to be true
681
876
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
877
+ dnf_package.run_action(:upgrade)
878
+ expect(dnf_package.updated_by_last_action?).to be false
682
879
  end
683
880
 
684
881
  it "upgrades the package" do
@@ -687,6 +884,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
687
884
  dnf_package.run_action(:upgrade)
688
885
  expect(dnf_package.updated_by_last_action?).to be true
689
886
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
887
+ dnf_package.run_action(:upgrade)
888
+ expect(dnf_package.updated_by_last_action?).to be false
690
889
  end
691
890
 
692
891
  it "is idempotent when the package is already installed" do
@@ -715,32 +914,104 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
715
914
  dnf_package.run_action(:upgrade)
716
915
  expect(dnf_package.updated_by_last_action?).to be true
717
916
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
917
+ dnf_package.run_action(:upgrade)
918
+ expect(dnf_package.updated_by_last_action?).to be false
718
919
  end
719
920
  end
720
921
 
721
922
  context "version pinning" do
722
- it "with an equality pin in the name it upgrades a prior package" do
923
+ it "with a full version pin it installs a later package" do
723
924
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
724
- dnf_package.package_name("chef_rpm-1.10")
925
+ dnf_package.package_name("chef_rpm")
926
+ dnf_package.version("1.10-1")
725
927
  dnf_package.run_action(:upgrade)
726
928
  expect(dnf_package.updated_by_last_action?).to be true
727
929
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
930
+ dnf_package.run_action(:upgrade)
931
+ expect(dnf_package.updated_by_last_action?).to be false
728
932
  end
729
933
 
730
- it "with a prco equality pin in the name it upgrades a prior package" do
934
+ it "with a full version pin in the name it downgrades the package" do
935
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
936
+ dnf_package.package_name("chef_rpm")
937
+ dnf_package.version("1.2-1")
938
+ dnf_package.run_action(:upgrade)
939
+ expect(dnf_package.updated_by_last_action?).to be true
940
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
941
+ dnf_package.run_action(:upgrade)
942
+ expect(dnf_package.updated_by_last_action?).to be false
943
+ end
944
+
945
+ it "with a partial (no release) version pin it installs a later package" do
731
946
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
732
- dnf_package.package_name("chef_rpm = 1.10")
947
+ dnf_package.package_name("chef_rpm")
948
+ dnf_package.version("1.10")
949
+ dnf_package.run_action(:upgrade)
950
+ expect(dnf_package.updated_by_last_action?).to be true
951
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
952
+ dnf_package.run_action(:upgrade)
953
+ expect(dnf_package.updated_by_last_action?).to be false
954
+ end
955
+
956
+ it "with a partial (no release) version pin in the name it downgrades the package" do
957
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
958
+ dnf_package.package_name("chef_rpm")
959
+ dnf_package.version("1.2")
960
+ dnf_package.run_action(:upgrade)
961
+ expect(dnf_package.updated_by_last_action?).to be true
962
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
963
+ dnf_package.run_action(:upgrade)
964
+ expect(dnf_package.updated_by_last_action?).to be false
965
+ end
966
+
967
+ it "with a full version pin it installs a later package" do
968
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
969
+ dnf_package.package_name("chef_rpm-1.10-1")
970
+ dnf_package.run_action(:upgrade)
971
+ expect(dnf_package.updated_by_last_action?).to be true
972
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
973
+ dnf_package.run_action(:upgrade)
974
+ expect(dnf_package.updated_by_last_action?).to be false
975
+ end
976
+
977
+ it "with a full version pin in the name it downgrades the package" do
978
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
979
+ dnf_package.package_name("chef_rpm-1.2-1")
980
+ dnf_package.run_action(:upgrade)
981
+ expect(dnf_package.updated_by_last_action?).to be true
982
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
983
+ dnf_package.run_action(:upgrade)
984
+ expect(dnf_package.updated_by_last_action?).to be false
985
+ end
986
+
987
+ it "with a partial (no release) version pin it installs a later package" do
988
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
989
+ dnf_package.package_name("chef_rpm-1.10")
733
990
  dnf_package.run_action(:upgrade)
734
991
  expect(dnf_package.updated_by_last_action?).to be true
735
992
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
993
+ dnf_package.run_action(:upgrade)
994
+ expect(dnf_package.updated_by_last_action?).to be false
736
995
  end
737
996
 
738
- it "with an equality pin in the name it downgrades a later package" do
997
+ it "with a partial (no release) version pin in the name it downgrades the package" do
739
998
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
740
999
  dnf_package.package_name("chef_rpm-1.2")
741
1000
  dnf_package.run_action(:upgrade)
742
1001
  expect(dnf_package.updated_by_last_action?).to be true
743
1002
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
1003
+ dnf_package.run_action(:upgrade)
1004
+ expect(dnf_package.updated_by_last_action?).to be false
1005
+ end
1006
+
1007
+ it "with a prco equality pin in the name it upgrades a prior package" do
1008
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
1009
+ dnf_package.package_name("chef_rpm = 1.10")
1010
+ dnf_package.run_action(:upgrade)
1011
+ expect(dnf_package.updated_by_last_action?).to be true
1012
+ expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
1013
+ dnf_package.run_action(:upgrade)
1014
+ expect(dnf_package.updated_by_last_action?).to be false
744
1015
  end
745
1016
 
746
1017
  it "with a prco equality pin in the name it downgrades a later package" do
@@ -749,6 +1020,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
749
1020
  dnf_package.run_action(:upgrade)
750
1021
  expect(dnf_package.updated_by_last_action?).to be true
751
1022
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
1023
+ dnf_package.run_action(:upgrade)
1024
+ expect(dnf_package.updated_by_last_action?).to be false
752
1025
  end
753
1026
 
754
1027
  it "with a > pin in the name and no rpm installed it installs" do
@@ -757,6 +1030,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
757
1030
  dnf_package.run_action(:upgrade)
758
1031
  expect(dnf_package.updated_by_last_action?).to be true
759
1032
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
1033
+ dnf_package.run_action(:upgrade)
1034
+ expect(dnf_package.updated_by_last_action?).to be false
760
1035
  end
761
1036
 
762
1037
  it "with a < pin in the name and no rpm installed it installs" do
@@ -765,6 +1040,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
765
1040
  dnf_package.run_action(:upgrade)
766
1041
  expect(dnf_package.updated_by_last_action?).to be true
767
1042
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
1043
+ dnf_package.run_action(:upgrade)
1044
+ expect(dnf_package.updated_by_last_action?).to be false
768
1045
  end
769
1046
 
770
1047
  it "with a > pin in the name and matching rpm installed it does nothing" do
@@ -789,6 +1066,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
789
1066
  dnf_package.run_action(:upgrade)
790
1067
  expect(dnf_package.updated_by_last_action?).to be true
791
1068
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
1069
+ dnf_package.run_action(:upgrade)
1070
+ expect(dnf_package.updated_by_last_action?).to be false
792
1071
  end
793
1072
 
794
1073
  it "with a < pin in the name and non-matching rpm installed it downgrades" do
@@ -797,6 +1076,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
797
1076
  dnf_package.run_action(:upgrade)
798
1077
  expect(dnf_package.updated_by_last_action?).to be true
799
1078
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
1079
+ dnf_package.run_action(:upgrade)
1080
+ expect(dnf_package.updated_by_last_action?).to be false
800
1081
  end
801
1082
  end
802
1083
  end
@@ -833,6 +1114,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
833
1114
  dnf_package.run_action(:remove)
834
1115
  expect(dnf_package.updated_by_last_action?).to be true
835
1116
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1117
+ dnf_package.run_action(:remove)
1118
+ expect(dnf_package.updated_by_last_action?).to be false
836
1119
  end
837
1120
 
838
1121
  it "removes the package if the i686 package is installed", :intel_64bit do
@@ -841,6 +1124,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
841
1124
  dnf_package.run_action(:remove)
842
1125
  expect(dnf_package.updated_by_last_action?).to be true
843
1126
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1127
+ dnf_package.run_action(:remove)
1128
+ expect(dnf_package.updated_by_last_action?).to be false
844
1129
  end
845
1130
 
846
1131
  it "removes the package if the prior version i686 package is installed", :intel_64bit do
@@ -849,6 +1134,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
849
1134
  dnf_package.run_action(:remove)
850
1135
  expect(dnf_package.updated_by_last_action?).to be true
851
1136
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1137
+ dnf_package.run_action(:remove)
1138
+ expect(dnf_package.updated_by_last_action?).to be false
852
1139
  end
853
1140
  end
854
1141
 
@@ -866,6 +1153,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
866
1153
  dnf_package.run_action(:remove)
867
1154
  expect(dnf_package.updated_by_last_action?).to be true
868
1155
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1156
+ dnf_package.run_action(:remove)
1157
+ expect(dnf_package.updated_by_last_action?).to be false
869
1158
  end
870
1159
 
871
1160
  it "removes the package if the prior version package is installed" do
@@ -873,6 +1162,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
873
1162
  dnf_package.run_action(:remove)
874
1163
  expect(dnf_package.updated_by_last_action?).to be true
875
1164
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1165
+ dnf_package.run_action(:remove)
1166
+ expect(dnf_package.updated_by_last_action?).to be false
876
1167
  end
877
1168
 
878
1169
  it "does nothing if the i686 package is installed" do
@@ -897,6 +1188,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
897
1188
  dnf_package.run_action(:remove)
898
1189
  expect(dnf_package.updated_by_last_action?).to be true
899
1190
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
1191
+ dnf_package.run_action(:remove)
1192
+ expect(dnf_package.updated_by_last_action?).to be false
900
1193
  end
901
1194
  end
902
1195
 
@@ -907,6 +1200,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
907
1200
  dnf_package.run_action(:remove)
908
1201
  expect(dnf_package.updated_by_last_action?).to be true
909
1202
  expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
1203
+ dnf_package.run_action(:remove)
1204
+ expect(dnf_package.updated_by_last_action?).to be false
910
1205
  end
911
1206
  end
912
1207
  end
@@ -926,6 +1221,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
926
1221
  dnf_package.run_action(:lock)
927
1222
  expect(dnf_package.updated_by_last_action?).to be true
928
1223
  expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
1224
+ dnf_package.run_action(:lock)
1225
+ expect(dnf_package.updated_by_last_action?).to be false
929
1226
  end
930
1227
 
931
1228
  it "does not lock if its already locked" do
@@ -944,6 +1241,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
944
1241
  dnf_package.run_action(:unlock)
945
1242
  expect(dnf_package.updated_by_last_action?).to be true
946
1243
  expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
1244
+ dnf_package.run_action(:unlock)
1245
+ expect(dnf_package.updated_by_last_action?).to be false
947
1246
  end
948
1247
 
949
1248
  it "does not unlock an already locked rpm" do
@@ -960,6 +1259,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
960
1259
  dnf_package.run_action(:lock)
961
1260
  expect(dnf_package.updated_by_last_action?).to be true
962
1261
  expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
1262
+ dnf_package.run_action(:lock)
1263
+ expect(dnf_package.updated_by_last_action?).to be false
963
1264
  end
964
1265
 
965
1266
  it "check that we can unlock based on provides" do
@@ -969,6 +1270,8 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
969
1270
  dnf_package.run_action(:unlock)
970
1271
  expect(dnf_package.updated_by_last_action?).to be true
971
1272
  expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
1273
+ dnf_package.run_action(:unlock)
1274
+ expect(dnf_package.updated_by_last_action?).to be false
972
1275
  end
973
1276
  end
974
1277
  end