summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-27 13:40:07 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-27 13:40:07 -0800
commit6fcbc7717b697e83c71b9dcaec773f0317e4a9e0 (patch)
treeb36455c94b25097ce1a3aa1f9dca97c736170e5e /spec
parent66fec7ca44d2a4609eedc474701fb00ce583f410 (diff)
parentbfc3c5c9ae3bc6038c93bbe5bcc3eede29d18212 (diff)
downloadchef-6fcbc7717b697e83c71b9dcaec773f0317e4a9e0.tar.gz
Merge pull request #2823 from chef/lcg/merges
Lcg/merges
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/file_content_management/deploy_strategies_spec.rb11
-rw-r--r--spec/functional/knife/exec_spec.rb4
-rw-r--r--spec/functional/resource/user/useradd_spec.rb23
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb12
-rw-r--r--spec/integration/knife/download_spec.rb2
-rw-r--r--spec/integration/solo/solo_spec.rb3
-rw-r--r--spec/spec_helper.rb7
-rw-r--r--spec/support/platform_helpers.rb12
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb24
-rw-r--r--spec/unit/provider/user_spec.rb2
-rw-r--r--spec/unit/util/diff_spec.rb12
-rw-r--r--spec/unit/util/path_helper_spec.rb12
12 files changed, 40 insertions, 84 deletions
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