summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-05 15:50:29 -0800
committerGitHub <noreply@github.com>2018-03-05 15:50:29 -0800
commit47ef0b7b224500e5f35727a5f3bbb291e83ff2cf (patch)
tree5284f3269120868edf294281fefec66c8102f76f
parent4994aa6b92c20fa59a872365755b54dad6054e33 (diff)
parentc506bf3a6c5d428e524661464c676f97964d1032 (diff)
downloadchef-47ef0b7b224500e5f35727a5f3bbb291e83ff2cf.tar.gz
Merge pull request #6953 from chef/fix_apt_repo
Avoid compile time error in apt_repository
-rw-r--r--lib/chef/provider/apt_repository.rb12
-rw-r--r--spec/unit/provider/apt_repository_spec.rb12
2 files changed, 1 insertions, 23 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index 1909ed8034..6bbb052792 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -119,15 +119,6 @@ class Chef
end.compact
end
- # see if the keyfile is invalid such as a text file that is not actually a gpg key
- # @param [String] keyfile the path to the keyfile
- #
- # @return [Boolean] is the key file invalid
- def keyfile_is_invalid?(keyfile)
- so = shell_out("gpg #{keyfile}")
- so.error?
- end
-
# validate the key against the apt keystore to see if that version is expired
# @param [String] key
#
@@ -210,10 +201,9 @@ class Chef
mode "0644"
sensitive new_resource.sensitive
action :create
+ verify "gpg %{path}"
end
- raise "The key #{cached_keyfile} is invalid and cannot be used to verify an apt repository." if keyfile_is_invalid?(cached_keyfile)
-
declare_resource(:execute, "apt-key add #{cached_keyfile}") do
sensitive new_resource.sensitive
action :run
diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb
index ca85831a06..d881d01124 100644
--- a/spec/unit/provider/apt_repository_spec.rb
+++ b/spec/unit/provider/apt_repository_spec.rb
@@ -251,16 +251,4 @@ C5986B4F1257FFA86632CBA746181433FBB75451
expect(provider.build_repo("ppa:chef/main", "unstable", "main", false, nil)).to eql(target)
end
end
-
- describe "#keyfile_is_invalid?" do
- it "returns true if the file is invalid" do
- expect(provider).to receive(:shell_out).and_return(gpg_shell_out_failure)
- expect(provider.keyfile_is_invalid?("/foo/bar.key")).to be_truthy
- end
-
- it "returns false if the file is valid" do
- expect(provider).to receive(:shell_out).and_return(gpg_shell_out_success)
- expect(provider.keyfile_is_invalid?("/foo/bar.key")).to be_falsey
- end
- end
end