diff options
30 files changed, 91 insertions, 176 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c204d6b365..08d28b59ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,16 @@ add ability to fetch recipes like in chef-solo when using local-mode * [**Jan**](https://github.com/habermann24) FIX data_bag_item.rb:161: warning: circular argument reference - data_bag +* [**David Radcliffe**](https://github.com/dwradcliffe) + add banner for knife serve command +* [**Yukihiko Sawanobori**](https://github.com/sawanoboly) + use Chef::JSONCompat.parse for file_contents +* [**Xabier de Zuazo**] (https://github.com/zuazo) + Remove some simple Ruby 1.8 and 1.9 code +* [**Xabier de Zuazo**] (https://github.com/zuazo) + Remove all RSpec test filters related to Ruby 1.8 and 1.9 +* [**Xabier de Zuazo**] (https://github.com/zuazo) + Fix knife cookbook upload messages ### Chef Contributions * ruby 1.9.3 support is dropped @@ -53,6 +63,8 @@ * Add --proxy-auth option to `knife raw` * added Chef::Org model class for Chef Organizations in Chef 12 Server * `powershell_script` should now correctly get the exit code for scripts that it runs. See [Issue 2348](https://github.com/chef/chef/issues/2348) +* Useradd functional tests fail randomly +* Add comments to trusted_certs_content ## 12.0.3 * [**Phil Dibowitz**](https://github.com/jaymzh): diff --git a/lib/chef/encrypted_data_bag_item/assertions.rb b/lib/chef/encrypted_data_bag_item/assertions.rb index 0f9416e7b6..ab93f46c10 100644 --- a/lib/chef/encrypted_data_bag_item/assertions.rb +++ b/lib/chef/encrypted_data_bag_item/assertions.rb @@ -44,9 +44,6 @@ class Chef::EncryptedDataBagItem end def assert_aead_requirements_met!(algorithm) - unless OpenSSL::Cipher.method_defined?(:auth_data=) - raise EncryptedDataBagRequirementsFailure, "The used Encrypted Data Bags version requires Ruby >= 2.0" - end unless OpenSSL::Cipher.ciphers.include?(algorithm) raise EncryptedDataBagRequirementsFailure, "The used Encrypted Data Bags version requires an OpenSSL version with \"#{algorithm}\" algorithm support" end diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb index c172a406d8..9f43f14311 100644 --- a/lib/chef/event_dispatch/dispatcher.rb +++ b/lib/chef/event_dispatch/dispatcher.rb @@ -25,11 +25,9 @@ class Chef # Define a method that will be forwarded to all def self.def_forwarding_method(method_name) - class_eval(<<-END_OF_METHOD, __FILE__, __LINE__) - def #{method_name}(*args) - @subscribers.each {|s| s.#{method_name}(*args)} - end - END_OF_METHOD + define_method(method_name) do |*args| + @subscribers.each { |s| s.send(method_name, *args) } + end end (Base.instance_methods - Object.instance_methods).each do |method_name| diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index f7fee023de..60db34c8d0 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -49,6 +49,8 @@ class Chef @secret end + # Contains commands and content, see trusted_certs_content + # TODO: Rename to trusted_certs_script def trusted_certs @trusted_certs ||= trusted_certs_content end @@ -159,6 +161,9 @@ CONFIG end private + + # Returns a string for copying the trusted certificates on the workstation to the system being bootstrapped + # This string should contain both the commands necessary to both create the files, as well as their content def trusted_certs_content content = "" if @chef_config[:trusted_certs_dir] diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb index 870177e0be..84918e2ef2 100644 --- a/lib/chef/knife/serve.rb +++ b/lib/chef/knife/serve.rb @@ -4,6 +4,9 @@ require 'chef/local_mode' class Chef class Knife class Serve < Knife + + banner 'knife serve (options)' + option :repo_mode, :long => '--repo-mode MODE', :description => "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything" diff --git a/lib/chef/mixin/command/windows.rb b/lib/chef/mixin/command/windows.rb index e3d0cfdb18..0147d58039 100644 --- a/lib/chef/mixin/command/windows.rb +++ b/lib/chef/mixin/command/windows.rb @@ -18,11 +18,7 @@ # limitations under the License. # -if RUBY_VERSION =~ /^1\.8/ - require 'win32/open3' -else - require 'open3' -end +require 'open3' class Chef module Mixin diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index f77703f21a..aaedf0b9ba 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -111,13 +111,7 @@ class Chef # equivalent to something like: # def rights(permissions=nil, principals=nil, args_hash=nil) - define_method(name) do |*args| - # Ruby 1.8 compat: default the arguments - permissions = args.length >= 1 ? args[0] : nil - principals = args.length >= 2 ? args[1] : nil - args_hash = args.length >= 3 ? args[2] : nil - raise ArgumentError.new("wrong number of arguments (#{args.length} for 3)") if args.length >= 4 - + define_method(name) do |permissions=nil, principals=nil, args_hash=nil| rights = self.instance_variable_get("@#{name.to_s}".to_sym) unless permissions.nil? input = { diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index ae23336581..d705a9e7be 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -23,18 +23,6 @@ class Chef module Mixin module Template - # A compatibility wrapper around IO.binread so it works on Ruby 1.8.7. - # -- - # Used in the TemplateContext class, but that method namespace is shared - # with user code, so we want to avoid adding methods there when possible. - def self.binread(file) - if IO.respond_to?(:binread) - IO.binread(file) - else - File.open(file, "rb") {|f| f.read } - end - end - # == ChefContext # ChefContext was previously used to mix behavior into Erubis::Context so # that it would be available to templates. This behavior has now moved to @@ -105,11 +93,11 @@ class Chef partial_context._extend_modules(@_extension_modules) template_location = @template_finder.find(partial_name, options) - _render_template(Mixin::Template.binread(template_location), partial_context) + _render_template(IO.binread(template_location), partial_context) end def render_template(template_location) - _render_template(Mixin::Template.binread(template_location), self) + _render_template(IO.binread(template_location), self) end def render_template_from_string(template) diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 80f5ac4f8d..9d8738f637 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -138,11 +138,9 @@ class Chef :values, :values_at, :zip].each do |delegated_method| - class_eval(<<-METHOD_DEFN) - def #{delegated_method}(*args, &block) - merged_attributes.send(:#{delegated_method}, *args, &block) - end - METHOD_DEFN + define_method(delegated_method) do |*args, &block| + merged_attributes.send(delegated_method, *args, &block) + end end # return the cookbook level default attribute component diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 333f4864c6..b912904534 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -61,12 +61,10 @@ class Chef # also invalidate the cached merged_attributes on the root # Node::Attribute object. MUTATOR_METHODS.each do |mutator| - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator}(*args, &block) - root.reset_cache(root.top_level_breadcrumb) - super - end - METHOD_DEFN + define_method(mutator) do |*args, &block| + root.reset_cache(root.top_level_breadcrumb) + super(*args, &block) + end end attr_reader :root @@ -126,12 +124,10 @@ class Chef # also invalidate the cached `merged_attributes` on the root Attribute # object. MUTATOR_METHODS.each do |mutator| - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator}(*args, &block) - root.reset_cache(root.top_level_breadcrumb) - super - end - METHOD_DEFN + define_method(mutator) do |*args, &block| + root.reset_cache(root.top_level_breadcrumb) + super(*args, &block) + end end def initialize(root, data={}) diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 56b8fed3b7..0e2800641a 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -75,12 +75,9 @@ class Chef # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" DISALLOWED_MUTATOR_METHODS.each do |mutator_method_name| - # Ruby 1.8 blocks can't have block arguments, so we must use string eval: - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator_method_name}(*args, &block) - raise Exceptions::ImmutableAttributeModification - end - METHOD_DEFN + define_method(mutator_method_name) do |*args, &block| + raise Exceptions::ImmutableAttributeModification + end end # For elements like Fixnums, true, nil... @@ -164,12 +161,9 @@ class Chef # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" DISALLOWED_MUTATOR_METHODS.each do |mutator_method_name| - # Ruby 1.8 blocks can't have block arguments, so we must use string eval: - class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) - def #{mutator_method_name}(*args, &block) + define_method(mutator_method_name) do |*args, &block| raise Exceptions::ImmutableAttributeModification end - METHOD_DEFN end def method_missing(symbol, *args) diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index e554dc7f2f..f6ac72448e 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -67,7 +67,7 @@ class Chef @current_resource.shell(user_info.shell) @current_resource.password(user_info.passwd) - if @new_resource.comment && user_info.gecos.respond_to?(:force_encoding) + if @new_resource.comment user_info.gecos.force_encoding(@new_resource.comment.encoding) end @current_resource.comment(user_info.gecos) diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 3dc0ae409b..3e9d119cee 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -931,14 +931,8 @@ class Chef run_context.notifies_delayed(Notification.new(resource_spec, action, self)) end - if Module.method(:const_defined?).arity == 1 - def self.strict_const_defined?(const) - const_defined?(const) - end - else - def self.strict_const_defined?(const) - const_defined?(const, false) - end + def self.strict_const_defined?(const) + const_defined?(const, false) end class << self diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb index 20d177f507..0a1253780c 100644 --- a/lib/chef/resource/lwrp_base.rb +++ b/lib/chef/resource/lwrp_base.rb @@ -73,16 +73,7 @@ class Chef # Define an attribute on this resource, including optional validation # parameters. def self.attribute(attr_name, validation_opts={}) - # Ruby 1.8 doesn't support default arguments to blocks, but we have to - # use define_method with a block to capture +validation_opts+. - # Workaround this by defining two methods :( - class_eval(<<-SHIM, __FILE__, __LINE__) - def #{attr_name}(arg=nil) - _set_or_return_#{attr_name}(arg) - end - SHIM - - define_method("_set_or_return_#{attr_name.to_s}".to_sym) do |arg| + define_method(attr_name) do |arg=nil| set_or_return(attr_name.to_sym, arg, validation_opts) end end diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 8c9607ee07..67a9e6a418 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -102,9 +102,8 @@ class Chef # # ==== Method Arguments: # Helper methods can also take arguments. The syntax available for - # argument specification will be dependent on ruby version. Ruby 1.8 only - # supports a subset of the argument specification syntax available for - # method definition, whereas 1.9 supports the full syntax. + # argument specification supports full syntax available for method + # definition. # # Continuing the above example of simplifying attribute access, we can # define a helper to look up app-specific attributes like this: diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index bb1bf28ad7..fc54506407 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -198,7 +198,7 @@ ERROR_MESSAGE end # An Array of all recipes that have been loaded. This is stored internally - # as a Hash, so ordering is not preserved when using ruby 1.8. + # as a Hash, so ordering is predictable. # # Recipe names are given in fully qualified form, e.g., the recipe "nginx" # will be given as "nginx::default" @@ -209,7 +209,7 @@ ERROR_MESSAGE end # An Array of all attributes files that have been loaded. Stored internally - # using a Hash, so order is not preserved on ruby 1.8. + # using a Hash, so order is predictable. # # Attribute file names are given in fully qualified form, e.g., # "nginx::default" instead of "nginx". diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb index 3117484a71..c2dc6e045c 100644 --- a/lib/chef/util/diff.rb +++ b/lib/chef/util/diff.rb @@ -176,10 +176,7 @@ class Chef end def encode_diff_for_json(diff_str) - if Object.const_defined? :Encoding - diff_str.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?') - end - return diff_str + diff_str.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?') end end diff --git a/lib/chef/util/path_helper.rb b/lib/chef/util/path_helper.rb index 26c9c76fe5..a5485a864b 100644 --- a/lib/chef/util/path_helper.rb +++ b/lib/chef/util/path_helper.rb @@ -101,9 +101,6 @@ class Chef # Produces a comparable path. def self.canonical_path(path, add_prefix=true) - # Rather than find an equivalent for File.absolute_path on 1.8.7, just bail out - raise NotImplementedError, "This feature is not supported on Ruby versions < 1.9" if RUBY_VERSION.to_f < 1.9 - # First remove extra separators and resolve any relative paths abs_path = File.absolute_path(path) diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb index bcd171eb73..03a6c504c1 100644 --- a/spec/functional/file_content_management/deploy_strategies_spec.rb +++ b/spec/functional/file_content_management/deploy_strategies_spec.rb @@ -20,15 +20,6 @@ require 'spec_helper' shared_examples_for "a content deploy strategy" do - # Ruby 1.8 has no binread - def binread(file) - if IO.respond_to?(:binread) - IO.binread(file) - else - IO.read(file) - end - end - def normalize_mode(mode_int) ( mode_int & 07777).to_s(8) end @@ -160,7 +151,7 @@ shared_examples_for "a content deploy strategy" do it "updates the target with content from staged" do content_deployer.deploy(staging_file_path, target_file_path) - expect(binread(target_file_path)).to eq(staging_file_content) + expect(IO.binread(target_file_path)).to eq(staging_file_content) end context "when the owner of the target file is not the owner of the staging file", :requires_root do diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb index 0a9177b5e8..6262094a9f 100644 --- a/spec/functional/knife/exec_spec.rb +++ b/spec/functional/knife/exec_spec.rb @@ -41,9 +41,7 @@ describe Chef::Knife::Exec do @server.stop end - skip "executes a script in the context of the chef-shell main context", :ruby_18_only - - it "executes a script in the context of the chef-shell main context", :ruby_gte_19_only do + it "executes a script in the context of the chef-shell main context" do @node = Chef::Node.new @node.name("ohai-world") response = {"rows" => [@node],"start" => 0,"total" => 1} diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb index 6b962c19aa..3cef705a69 100644 --- a/spec/functional/resource/user/useradd_spec.rb +++ b/spec/functional/resource/user/useradd_spec.rb @@ -82,12 +82,25 @@ describe Chef::Provider::User::Useradd, metadata do end after do - begin - pw_entry # will raise if the user doesn't exist - shell_out!("userdel", "-r", username, :returns => [0,12]) - rescue UserNotFound - # nothing to remove + max_retries = 3 + while max_retries > 0 + begin + pw_entry # will raise if the user doesn't exist + status = shell_out!("userdel", "-r", username, :returns => [0,8,12]) + + # Error code 8 during userdel indicates that the user is logged in. + # This occurs randomly because the accounts daemon holds a lock due to which userdel fails. + # The work around is to retry userdel for 3 times. + break if status.exitstatus != 8 + + sleep 1 + max_retries = max_retries -1 + rescue UserNotFound + break + end end + + statur.error! if max_retries == 0 end let(:node) do diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb index eb02db5384..c1f2c7134f 100644 --- a/spec/integration/knife/chef_fs_data_store_spec.rb +++ b/spec/integration/knife/chef_fs_data_store_spec.rb @@ -138,6 +138,7 @@ EOM context 'PUT /TYPE/NAME' do before do file 'empty.json', {} + file 'dummynode.json', { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} file 'rolestuff.json', '{"description":"hi there","name":"x"}' file 'cookbooks_to_upload/x/metadata.rb', cookbook_x_100_metadata_rb end @@ -165,9 +166,10 @@ EOM knife('list --local /environments').should_succeed "/environments/x.json\n" end - it 'knife raw -z -i empty.json -m PUT /nodes/x' do - knife("raw -z -i #{path_to('empty.json')} -m PUT /nodes/x").should_succeed( /"x"/ ) + it 'knife raw -z -i dummynode.json -m PUT /nodes/x' do + knife("raw -z -i #{path_to('dummynode.json')} -m PUT /nodes/x").should_succeed( /"x"/ ) knife('list --local /nodes').should_succeed "/nodes/x.json\n" + knife('show -z /nodes/x.json --verbose').should_succeed /"bar"/ end it 'knife raw -z -i empty.json -m PUT /roles/x' do @@ -196,6 +198,7 @@ EOM context 'POST /TYPE/NAME' do before do file 'empty.json', { 'name' => 'z' } + file 'dummynode.json', { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} file 'empty_x.json', { 'name' => 'x' } file 'empty_id.json', { 'id' => 'z' } file 'rolestuff.json', '{"description":"hi there","name":"x"}' @@ -231,9 +234,10 @@ EOM knife('list --local /environments').should_succeed "/environments/z.json\n" end - it 'knife raw -z -i empty.json -m POST /nodes' do - knife("raw -z -i #{path_to('empty.json')} -m POST /nodes").should_succeed( /uri/ ) + it 'knife raw -z -i dummynode.json -m POST /nodes' do + knife("raw -z -i #{path_to('dummynode.json')} -m POST /nodes").should_succeed( /uri/ ) knife('list --local /nodes').should_succeed "/nodes/z.json\n" + knife('show -z /nodes/z.json').should_succeed /"bar"/ end it 'knife raw -z -i empty.json -m POST /roles' do diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index cf1e4fcf0f..c87e6fe20a 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -1069,7 +1069,7 @@ EOM end when_the_repository 'is empty' do - it 'knife download /cookbooks/x signs all requests', :ruby_gte_19_only do + it 'knife download /cookbooks/x signs all requests' do # Check that BasicClient.request() always gets called with X-OPS-USERID original_new = Chef::HTTP::BasicClient.method(:new) diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index cc9ba1abb2..41f5f5506f 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -83,8 +83,7 @@ end EOM end - # Ruby 1.8.7 doesn't have Process.spawn :( - it "while running solo concurrently", :ruby_gte_19_only => true do + it "while running solo concurrently" do file 'config/solo.rb', <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 995be5060b..b87736efef 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -124,11 +124,7 @@ RSpec.configure do |config| config.filter_run_excluding :aix_only => true unless aix? config.filter_run_excluding :supports_cloexec => true unless supports_cloexec? config.filter_run_excluding :selinux_only => true unless selinux_enabled? - config.filter_run_excluding :ruby_18_only => true unless ruby_18? - config.filter_run_excluding :ruby_19_only => true unless ruby_19? - config.filter_run_excluding :ruby_gte_19_only => true unless ruby_gte_19? config.filter_run_excluding :ruby_20_only => true unless ruby_20? - config.filter_run_excluding :ruby_gte_20_only => true unless ruby_gte_20? # chef_gte_XX_only and chef_lt_XX_only pair up correctly with the same XX # number. please conserve this pattern & resist filling out all the operators config.filter_run_excluding :chef_gte_13_only => true unless chef_gte_13? @@ -137,9 +133,8 @@ RSpec.configure do |config| config.filter_run_excluding :requires_root_or_running_windows => true unless (root? || windows?) config.filter_run_excluding :requires_unprivileged_user => true if root? config.filter_run_excluding :uses_diff => true unless has_diff? - config.filter_run_excluding :ruby_gte_20_and_openssl_gte_101 => true unless (ruby_gte_20? && openssl_gte_101?) + config.filter_run_excluding :openssl_gte_101 => true unless openssl_gte_101? config.filter_run_excluding :openssl_lt_101 => true unless openssl_lt_101? - config.filter_run_excluding :ruby_lt_20 => true unless ruby_lt_20? config.filter_run_excluding :aes_256_gcm_only => true unless aes_256_gcm? config.filter_run_excluding :broken => true diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 959580c953..a412fe38e1 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -6,10 +6,6 @@ class ShellHelpers extend Chef::Mixin::ShellOut end -def ruby_gte_20? - RUBY_VERSION.to_f >= 2.0 -end - def ruby_lt_20? !ruby_gte_20? end @@ -30,14 +26,6 @@ def ruby_20? !!(RUBY_VERSION =~ /^2.0/) end -def ruby_19? - !!(RUBY_VERSION =~ /^1.9/) -end - -def ruby_18? - !!(RUBY_VERSION =~ /^1.8/) -end - def windows? !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) end diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 14afea507c..0a4306727b 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -124,14 +124,6 @@ describe Chef::EncryptedDataBagItem::Encryptor do context "on unsupported platforms" do let(:aead_algorithm) { Chef::EncryptedDataBagItem::AEAD_ALGORITHM } - it "throws an error warning about the Ruby version if it has no GCM support" do - # Force OpenSSL with AEAD support - allow(OpenSSL::Cipher).to receive(:ciphers).and_return([ aead_algorithm ]) - # Ruby without AEAD support - expect(OpenSSL::Cipher).to receive(:method_defined?).with(:auth_data=).and_return(false) - expect { encryptor }.to raise_error(Chef::EncryptedDataBagItem::EncryptedDataBagRequirementsFailure, /requires Ruby/) - end - it "throws an error warning about the OpenSSL version if it has no GCM support" do # Force Ruby with AEAD support allow(OpenSSL::Cipher).to receive(:method_defined?).with(:auth_data=).and_return(true) @@ -140,14 +132,6 @@ describe Chef::EncryptedDataBagItem::Encryptor do expect { encryptor }.to raise_error(Chef::EncryptedDataBagItem::EncryptedDataBagRequirementsFailure, /requires an OpenSSL/) end - context "on platforms with old Ruby", :ruby_lt_20 do - - it "throws an error warning about the Ruby version" do - expect { encryptor }.to raise_error(Chef::EncryptedDataBagItem::EncryptedDataBagRequirementsFailure, /requires Ruby/) - end - - end # context on platforms with old Ruby - context "on platforms with old OpenSSL", :openssl_lt_101 do it "throws an error warning about the OpenSSL version" do @@ -214,14 +198,6 @@ describe Chef::EncryptedDataBagItem::Decryptor do } end - context "on platforms with old Ruby", :ruby_lt_20 do - - it "throws an error warning about the Ruby version" do - expect { decryptor }.to raise_error(Chef::EncryptedDataBagItem::EncryptedDataBagRequirementsFailure, /requires Ruby/) - end - - end # context on platforms with old Ruby - context "on platforms with old OpenSSL", :openssl_lt_101 do it "throws an error warning about the OpenSSL version" do diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index 44434794e7..381168647b 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -91,7 +91,7 @@ describe Chef::Provider::User do expect(@current_resource.username).to eq(@new_resource.username) end - it "should change the encoding of gecos to the encoding of the new resource", :ruby_gte_19_only do + it "should change the encoding of gecos to the encoding of the new resource" do @pw_user.gecos.force_encoding('ASCII-8BIT') @provider.load_current_resource expect(@provider.current_resource.comment.encoding).to eq(@new_resource.comment.encoding) diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index ea226f1c04..b0a57a32c0 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -105,7 +105,7 @@ shared_examples_for "a diff util" do end end - describe "when the default external encoding is UTF-8", :ruby_gte_19_only do + describe "when the default external encoding is UTF-8" do before do @saved_default_external = Encoding.default_external @@ -170,7 +170,7 @@ shared_examples_for "a diff util" do end - describe "when the default external encoding is Latin-1", :ruby_gte_19_only do + describe "when the default external encoding is Latin-1" do before do @saved_default_external = Encoding.default_external @@ -234,7 +234,7 @@ shared_examples_for "a diff util" do end end - describe "when the default external encoding is Shift_JIS", :ruby_gte_19_only do + describe "when the default external encoding is Shift_JIS" do before do @saved_default_external = Encoding.default_external @@ -411,7 +411,7 @@ shared_examples_for "a diff util" do end end - describe "when the default external encoding is UTF-8", :ruby_gte_19_only do + describe "when the default external encoding is UTF-8" do before do @saved_default_external = Encoding.default_external @@ -456,7 +456,7 @@ shared_examples_for "a diff util" do end - describe "when the default external encoding is Latin-1", :ruby_gte_19_only do + describe "when the default external encoding is Latin-1" do before do @saved_default_external = Encoding.default_external @@ -500,7 +500,7 @@ shared_examples_for "a diff util" do end end - describe "when the default external encoding is Shift-JIS", :ruby_gte_19_only do + describe "when the default external encoding is Shift-JIS" do before do @saved_default_external = Encoding.default_external diff --git a/spec/unit/util/path_helper_spec.rb b/spec/unit/util/path_helper_spec.rb index 4df4b9b1ff..5756c29b90 100644 --- a/spec/unit/util/path_helper_spec.rb +++ b/spec/unit/util/path_helper_spec.rb @@ -189,16 +189,8 @@ describe Chef::Util::PathHelper do end context "not on windows", :unix_only do - context "ruby is at least 1.9", :ruby_gte_19_only do - it "returns a canonical path" do - expect(PathHelper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default")).to eq("/etc/apache.d/sites-available/default") - end - end - - context "ruby is less than 1.9", :ruby_18_only do - it "returns a canonical path" do - expect { PathHelper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default") }.to raise_error(NotImplementedError) - end + it "returns a canonical path" do + expect(PathHelper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default")).to eq("/etc/apache.d/sites-available/default") end end end |