summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-04-28 16:28:52 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-04-28 16:28:52 -0700
commit450ee3767c58c297e884e24cf5796a6a16818d6e (patch)
treefd34fdd59289cc5944f53da83d4cfefc8b3ee586
parent52328f2e7d6d73690c023843f887604dbcba1d14 (diff)
downloadchef-450ee3767c58c297e884e24cf5796a6a16818d6e.tar.gz
Fix more ruby 2.7 warning logspamlcg/more-ruby-27-logging-suppression
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/provider/execute.rb2
-rw-r--r--lib/chef/provider/package/freebsd/base.rb3
-rw-r--r--spec/functional/resource/remote_file_spec.rb2
-rw-r--r--spec/integration/knife/raw_spec.rb8
-rw-r--r--spec/integration/knife/redirection_spec.rb4
-rw-r--r--spec/support/shared/functional/http.rb4
-rw-r--r--spec/support/shared/unit/mock_shellout.rb2
-rw-r--r--spec/unit/mixin/shell_out_spec.rb56
-rw-r--r--spec/unit/provider/apt_repository_spec.rb54
-rw-r--r--spec/unit/provider/zypper_repository_spec.rb34
-rw-r--r--spec/unit/provider_resolver_spec.rb4
11 files changed, 84 insertions, 89 deletions
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index e4fc1ee9ea..4ae1e794fc 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -49,7 +49,7 @@ class Chef
converge_by("execute #{description}") do
begin
- shell_out!(command, opts)
+ shell_out!(command, **opts)
rescue Mixlib::ShellOut::ShellCommandFailed
if sensitive?
ex = Mixlib::ShellOut::ShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb
index 70ca3f4a98..2805200516 100644
--- a/lib/chef/provider/package/freebsd/base.rb
+++ b/lib/chef/provider/package/freebsd/base.rb
@@ -58,7 +58,8 @@ class Chef
def makefile_variable_value(variable, dir = nil)
options = dir ? { cwd: dir } : {}
- make_v = shell_out!("make", "-V", variable, options.merge!(env: nil, returns: [0, 1]))
+ options.merge!(env: nil, returns: [0, 1])
+ make_v = shell_out!("make", "-V", variable, **options)
make_v.exitstatus == 0 ? make_v.stdout.strip.split($OUTPUT_RECORD_SEPARATOR).first : nil # $\ is the line separator, i.e. newline.
end
end
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 89a937d47e..3e38842280 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -112,7 +112,7 @@ describe Chef::Resource::RemoteFile do
SSLPrivateKey: key,
RequestTimeout: 1 }
- start_tiny_server(server_opts)
+ start_tiny_server(**server_opts)
end
after(:all) do
diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb
index 7e563d5d25..ba26def473 100644
--- a/spec/integration/knife/raw_spec.rb
+++ b/spec/integration/knife/raw_spec.rb
@@ -214,8 +214,8 @@ describe "knife raw", :workstation do
end
context "When a server returns raw json" do
- def start_tiny_server(server_opts = {})
- @server = TinyServer::Manager.new(server_opts)
+ def start_tiny_server(**server_opts)
+ @server = TinyServer::Manager.new(**server_opts)
@server.start
@api = TinyServer::API.instance
@api.clear
@@ -256,8 +256,8 @@ describe "knife raw", :workstation do
end
context "When a server returns text" do
- def start_tiny_server(server_opts = {})
- @server = TinyServer::Manager.new(server_opts)
+ def start_tiny_server(**server_opts)
+ @server = TinyServer::Manager.new(**server_opts)
@server.start
@api = TinyServer::API.instance
@api.clear
diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb
index 2574ac3bf0..34d5fe6efc 100644
--- a/spec/integration/knife/redirection_spec.rb
+++ b/spec/integration/knife/redirection_spec.rb
@@ -25,8 +25,8 @@ describe "redirection", :workstation do
include IntegrationSupport
include KnifeSupport
- def start_tiny_server(real_chef_server_url, server_opts = {})
- @server = TinyServer::Manager.new(server_opts)
+ def start_tiny_server(real_chef_server_url, **server_opts)
+ @server = TinyServer::Manager.new(**server_opts)
@server.start
@api = TinyServer::API.instance
@api.clear
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index e4632b0909..ffe52e2148 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -35,11 +35,11 @@ module ChefHTTPShared
content
end
- def start_tiny_server(server_opts = {})
+ def start_tiny_server(**server_opts)
nyan_uncompressed_size = File::Stat.new(nyan_uncompressed_filename).size
nyan_compressed_size = File::Stat.new(nyan_compressed_filename).size
- @server = TinyServer::Manager.new(server_opts)
+ @server = TinyServer::Manager.new(**server_opts)
@server.start
@api = TinyServer::API.instance
@api.clear
diff --git a/spec/support/shared/unit/mock_shellout.rb b/spec/support/shared/unit/mock_shellout.rb
index dac51be798..0ea8f64c4d 100644
--- a/spec/support/shared/unit/mock_shellout.rb
+++ b/spec/support/shared/unit/mock_shellout.rb
@@ -23,7 +23,7 @@
class MockShellout
module RSpec
def mock_shellout_command(command, **result)
- allow(::Mixlib::ShellOut).to receive(:new).with(command, anything).and_return MockShellout.new(result)
+ allow(::Mixlib::ShellOut).to receive(:new).with(command, anything).and_return MockShellout.new(**result)
end
end
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index f2b0295bf6..8c0790a2c4 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -57,42 +57,40 @@ describe Chef::Mixin::ShellOut do
describe "and environment is an option" do
it "should not change environment language settings when they are set to nil" do
options = { environment: { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil, env_path => nil } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, **options).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should not change environment language settings when they are set to non-nil" do
options = { environment: { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8", env_path => "foo:bar:baz" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, **options).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should set environment language settings to the configured internal locale when they are not present" do
options = { environment: { "HOME" => "/Users/morty" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
environment: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should not mutate the options hash when it adds language settings" do
options = { environment: { "HOME" => "/Users/morty" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
environment: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
expect(options[:environment].key?("LC_ALL")).to be false
end
end
@@ -100,42 +98,40 @@ describe Chef::Mixin::ShellOut do
describe "and env is an option" do
it "should not change env when langauge options are set to nil" do
options = { env: { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil, env_path => nil } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, **options).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should not change env when language options are set to non-nil" do
options = { env: { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8", env_path => "foo:bar:baz" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, options).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, **options).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should set environment language settings to the configured internal locale when they are not present" do
options = { env: { "HOME" => "/Users/morty" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
env: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
it "should not mutate the options hash when it adds language settings" do
options = { env: { "HOME" => "/Users/morty" } }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
env: {
"HOME" => "/Users/morty",
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
expect(options[:env].key?("LC_ALL")).to be false
end
end
@@ -143,30 +139,28 @@ describe Chef::Mixin::ShellOut do
describe "and no env/environment option is present" do
it "should set environment language settings to the configured internal locale" do
options = { user: "morty" }
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
user: "morty",
environment: {
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
- shell_out_obj.send(method, cmd, options)
+ }).and_return(retobj)
+ shell_out_obj.send(method, cmd, **options)
end
end
end
describe "when the last argument is not a Hash" do
it "should set environment language settings to the configured internal locale" do
- expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd, {
+ expect(Chef::Mixin::ShellOut).to receive(:shell_out_command).with(cmd,
environment: {
"LC_ALL" => Chef::Config[:internal_locale],
"LANG" => Chef::Config[:internal_locale],
"LANGUAGE" => Chef::Config[:internal_locale],
env_path => sanitized_path,
- },
- }).and_return(retobj)
+ }).and_return(retobj)
shell_out_obj.send(method, cmd)
end
end
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index 7fefa49eb4..aa2fb770c7 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -18,33 +18,33 @@
require "spec_helper"
-# Now we are using the option --with-colons that works across old os versions
-# as well as the latest (16.10). This for both `apt-key` and `gpg` commands
-#
-# Output of the command:
-# => apt-key adv --list-public-keys --with-fingerprint --with-colons
-APT_KEY_FINGER = <<~EOF.freeze
- tru:t:1:1488924856:0:3:1:5
- pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC:
- fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:
- sub:-:2048:16:251BEFF479164387:2004-09-12::::::e:
- pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC:
- fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451:
- pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC:
- fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32:
- pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC:
- fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092:
-EOF
-
-# Output of the command:
-# => gpg --with-fingerprint --with-colons [FILE]
-GPG_FINGER = <<~EOF.freeze
- pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository:
- fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD:
- sub:-:2048:16:84080586D1CA74A1:2009-04-22::::
-EOF
-
describe "Chef::Provider::AptRepository" do
+ # Now we are using the option --with-colons that works across old os versions
+ # as well as the latest (16.10). This for both `apt-key` and `gpg` commands
+ #
+ # Output of the command:
+ # => apt-key adv --list-public-keys --with-fingerprint --with-colons
+ APT_KEY_FINGER = <<~EOF.freeze
+ tru:t:1:1488924856:0:3:1:5
+ pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC:
+ fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:
+ sub:-:2048:16:251BEFF479164387:2004-09-12::::::e:
+ pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC:
+ fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451:
+ pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC:
+ fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32:
+ pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC:
+ fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092:
+ EOF
+
+ # Output of the command:
+ # => gpg --with-fingerprint --with-colons [FILE]
+ APG_GPG_FINGER = <<~EOF.freeze
+ pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository:
+ fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD:
+ sub:-:2048:16:84080586D1CA74A1:2009-04-22::::
+ EOF
+
let(:node) { Chef::Node.new }
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
@@ -61,7 +61,7 @@ describe "Chef::Provider::AptRepository" do
end
let(:gpg_finger) do
- double("shell_out", stdout: GPG_FINGER, exitstatus: 0, error?: false)
+ double("shell_out", stdout: APG_GPG_FINGER, exitstatus: 0, error?: false)
end
let(:gpg_shell_out_success) do
diff --git a/spec/unit/provider/zypper_repository_spec.rb b/spec/unit/provider/zypper_repository_spec.rb
index 724a29dc2b..83ed83d297 100644
--- a/spec/unit/provider/zypper_repository_spec.rb
+++ b/spec/unit/provider/zypper_repository_spec.rb
@@ -18,22 +18,22 @@
require "spec_helper"
-# Output of the command:
-# => rpm -qa gpg-pubkey*
-RPM_KEYS = <<~EOF.freeze
- gpg-pubkey-307e3d54-4be01a65
- gpg-pubkey-3dbdc284-53674dd4
-EOF
-
-# Output of the command:
-# => gpg --with-fingerprint [FILE]
-GPG_FINGER = <<~EOF.freeze
- pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14]
- Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
- uid nginx signing key <signing-key@nginx.com>
-EOF
-
describe Chef::Provider::ZypperRepository do
+ # Output of the command:
+ # => rpm -qa gpg-pubkey*
+ ZYPPER_RPM_KEYS = <<~EOF.freeze
+ gpg-pubkey-307e3d54-4be01a65
+ gpg-pubkey-3dbdc284-53674dd4
+ EOF
+
+ # Output of the command:
+ # => gpg --with-fingerprint [FILE]
+ ZYPPER_GPG_FINGER = <<~EOF.freeze
+ pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14]
+ Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
+ uid nginx signing key <signing-key@nginx.com>
+ EOF
+
let(:new_resource) { Chef::Resource::ZypperRepository.new("Nginx Repository") }
let(:logger) { double("Mixlib::Log::Child").as_null_object }
let(:provider) do
@@ -45,11 +45,11 @@ describe Chef::Provider::ZypperRepository do
end
let(:rpm_key_finger) do
- double("shell_out", stdout: RPM_KEYS, exitstatus: 0, error?: false)
+ double("shell_out", stdout: ZYPPER_RPM_KEYS, exitstatus: 0, error?: false)
end
let(:gpg_finger) do
- double("shell_out", stdout: GPG_FINGER, exitstatus: 0, error?: false)
+ double("shell_out", stdout: ZYPPER_GPG_FINGER, exitstatus: 0, error?: false)
end
it "responds to load_current_resource" do
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index 25ac51a34d..bc58ce6ba5 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -874,8 +874,8 @@ describe Chef::ProviderResolver do
end
# If there is no filter, we're as deep as we need to go
unless filter
- on_platform test.delete(:platform), test do
- expect_providers(expected)
+ on_platform test.delete(:platform), **test do
+ expect_providers(**expected)
end
end
end