summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <john.mccrae@progress.com>2021-04-14 13:07:10 -0700
committerJohn McCrae <jmccrae@chef.io>2021-04-20 11:59:07 -0700
commit290820a155412009f4a30549720fee049087a046 (patch)
tree0469fffb992f4453e3e4076363e2eb2958675831
parent144bb93c4cdddc4dd02d661c628e4e4505750a16 (diff)
downloadchef-290820a155412009f4a30549720fee049087a046.tar.gz
correcting style errors
Signed-off-by: John McCrae <john.mccrae@progress.com>
-rw-r--r--lib/chef/resource/windows_certificate.rb23
-rw-r--r--omnibus/Gemfile.lock55
-rw-r--r--spec/functional/resource/windows_certificate_spec.rb2
3 files changed, 12 insertions, 68 deletions
diff --git a/lib/chef/resource/windows_certificate.rb b/lib/chef/resource/windows_certificate.rb
index 3ab18d4f66..0055365f1c 100644
--- a/lib/chef/resource/windows_certificate.rb
+++ b/lib/chef/resource/windows_certificate.rb
@@ -80,7 +80,7 @@ class Chef
description: "Use the `CurrentUser` store instead of the default `LocalMachine` store. Note: Prior to #{ChefUtils::Dist::Infra::CLIENT}. 16.10 this property was ignored.",
default: false
- deprecated_property_alias :cert_path, :output_path, 'The cert_path property was renamed output_path in the 17.0 release of this cookbook. Please update your cookbooks to use the new property name.'
+ deprecated_property_alias :cert_path, :output_path, "The cert_path property was renamed output_path in the 17.0 release of this cookbook. Please update your cookbooks to use the new property name."
# lazy used to set default value of sensitive to true if password is set
property :sensitive, [TrueClass, FalseClass],
@@ -140,7 +140,7 @@ class Chef
end
action :fetch, description: "Fetches a certificate." do
- if !new_resource.output_path
+ unless new_resource.output_path
raise Chef::Exceptions::ResourceNotFound, "You must include an output_path parameter when calling the fetch action"
end
@@ -178,7 +178,7 @@ class Chef
store.add(cert_obj)
end
- def add_pfx_cert(path) #expecting a path object here.
+ def add_pfx_cert(path)
exportable = new_resource.exportable ? 1 : 0
store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
store.add_pfx(path, new_resource.pfx_password, exportable)
@@ -200,11 +200,11 @@ class Chef
end
def fetch_key
- require "openssl"
+ require "openssl" unless defined?(OpenSSL)
file_name = ::File.basename(new_resource.output_path, ::File.extname(new_resource.output_path))
directory = ::File.dirname(new_resource.output_path)
pfx_file = file_name + ".pfx"
- new_pfx_output_path = ::File.join(Chef::FileCache.create_cache_path('pfx_files'), pfx_file)
+ new_pfx_output_path = ::File.join(Chef::FileCache.create_cache_path("pfx_files"), pfx_file)
powershell_exec(pfx_ps_cmd(resolve_thumbprint(new_resource.source), store_location: ps_cert_location, store_name: new_resource.store_name, output_path: new_pfx_output_path, password: new_resource.pfx_password ))
pkcs12 = OpenSSL::PKCS12.new(::File.binread(new_pfx_output_path), new_resource.pfx_password)
f = ::File.open(new_resource.output_path, "w")
@@ -219,12 +219,11 @@ class Chef
if type == "file"
::File.extname(file_name)
elsif type == "url"
- require 'open-uri'
+ require "open-uri" unless defined?(OpenURI)
uri = URI.parse(file_name)
output_file = ::File.basename(uri.path)
::File.extname(output_file)
end
-
end
def get_file_name(path_name)
@@ -233,20 +232,19 @@ class Chef
if type == "file"
::File.extname(path_name)
elsif type == "url"
- require 'open-uri'
+ require "open-uri" unless defined?(OpenURI)
uri = URI.parse(path_name)
::File.basename(uri.path)
end
-
end
# did I get passed a file, a url, or a mistake?
def url_or_file?(source)
- require 'uri'
+ require "uri" unless defined?(URI)
uri = URI.parse(source)
- if source == uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
+ if source == uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
"url"
elsif ::File.file?(source)
"file"
@@ -269,6 +267,7 @@ class Chef
def resolve_thumbprint(thumbprint)
return thumbprint if valid_thumbprint?(thumbprint)
+
powershell_exec!(get_thumbprint(new_resource.store_name, ps_cert_location, new_resource.source)).result
end
@@ -393,7 +392,7 @@ class Chef
raise Chef::Exceptions::FileNotFound, message
end
elsif type == "url"
- require 'uri'
+ require "uri" unless defined?(URI)
uri = URI(new_resource.source)
state = uri.is_a?(URI::HTTP) && !uri.host.nil? ? true : false
if state
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index e2ca090957..78e29375ed 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -18,11 +18,7 @@ GIT
GIT
remote: https://github.com/chef/omnibus-software
-<<<<<<< HEAD
revision: 810a6c469aefab77a577e222317e796159ee81ca
-=======
- revision: 8d91dc6a566aba77c864678680d4142561b2f655
->>>>>>> 919f31634b... updated the gems to reflect the correct version of win32-certstore to use
branch: master
specs:
omnibus-software (4.0.0)
@@ -105,57 +101,6 @@ GEM
tty-screen (~> 0.6)
tty-table (~> 0.11)
uuidtools (>= 2.1.5, < 3.0)
-<<<<<<< HEAD
-=======
- chef (16.13.16-universal-mingw32)
- addressable
- bcrypt_pbkdf (~> 1.1)
- bundler (>= 1.10)
- chef-config (= 16.13.16)
- chef-utils (= 16.13.16)
- chef-vault
- chef-zero (>= 14.0.11)
- diff-lcs (>= 1.2.4, < 1.4.0)
- ed25519 (~> 1.2)
- erubis (~> 2.7)
- ffi (>= 1.9.25)
- ffi-libarchive (~> 1.0, >= 1.0.3)
- ffi-yajl (~> 2.2)
- highline (>= 1.6.9, < 3)
- iniparse (~> 1.4)
- inspec-core (~> 4.23)
- iso8601 (>= 0.12.1, < 0.14)
- license-acceptance (>= 1.0.5, < 3)
- mixlib-archive (>= 0.4, < 2.0)
- mixlib-authentication (>= 2.1, < 4)
- mixlib-cli (>= 2.1.1, < 3.0)
- mixlib-log (>= 2.0.3, < 4.0)
- mixlib-shellout (>= 3.1.1, < 4.0)
- net-sftp (>= 2.1.2, < 4.0)
- net-ssh (>= 5.1, < 7)
- net-ssh-multi (~> 1.2, >= 1.2.1)
- ohai (~> 16.0)
- pastel
- plist (~> 3.2)
- proxifier (~> 1.0)
- syslog-logger (~> 1.6)
- train-core (~> 3.2, >= 3.2.28)
- train-winrm (>= 0.2.5)
- tty-prompt (~> 0.21)
- tty-screen (~> 0.6)
- tty-table (~> 0.11)
- uuidtools (>= 2.1.5, < 3.0)
- win32-api (~> 1.5.3)
- win32-certstore (~> 0.5.0)
- win32-event (~> 0.6.1)
- win32-eventlog (= 0.6.3)
- win32-mmap (~> 0.4.1)
- win32-mutex (~> 0.4.2)
- win32-process (~> 0.9)
- win32-service (>= 2.1.5, < 3.0)
- win32-taskscheduler (~> 2.0)
- wmi-lite (~> 1.0)
->>>>>>> 919f31634b... updated the gems to reflect the correct version of win32-certstore to use
chef-cleanroom (1.0.2)
chef-config (16.13.16)
addressable
diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb
index 07a52ed3b0..aaa31f0bdd 100644
--- a/spec/functional/resource/windows_certificate_spec.rb
+++ b/spec/functional/resource/windows_certificate_spec.rb
@@ -234,7 +234,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
resource.run_action(:create)
end
- it "succeeds with the main certificate's thumbprint", :focus do
+ it "succeeds with the main certificate's thumbprint" do
expect(Chef::Log).to receive(:info).with("Certificate is valid")
resource.source = p7b_thumbprint