summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorNimesh-Msys <nimesh.patni@msystechnologies.com>2019-02-12 15:57:15 +0530
committerNimesh-Msys <nimesh.patni@msystechnologies.com>2019-02-12 15:57:15 +0530
commit0afdf28c1ff0522b534cdc325cfc84bda97436a0 (patch)
treea5ff2a2e09c8f2d276ba824ebf0b266ab68bae14 /spec/functional
parentab964df45ad41621a2133a30de113a4cddacaca2 (diff)
downloadchef-0afdf28c1ff0522b534cdc325cfc84bda97436a0.tar.gz
Windows Certificate: Add support to import Base 64 encoded CER certificates
- Till now, cer certificates were only considered to be in binary format (DER) - They can also be base-64 encoded(PEM) - We should only append "inform DER" only if it is a binary certificate, otherwise, default ("inform PEM") would support base64 encoded certificates. - Added test caes - Ensured Chef style Signed-off-by: Nimesh-Msys <nimesh.patni@msystechnologies.com>
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/windows_certificate_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb
index f60b63ade9..a9ed99d318 100644
--- a/spec/functional/resource/windows_certificate_spec.rb
+++ b/spec/functional/resource/windows_certificate_spec.rb
@@ -60,6 +60,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do
let(:store) { "Chef-Functional-Test" }
let(:certificate_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "windows_certificates")) }
let(:cer_path) { File.join(certificate_path, "test.cer") }
+ let(:base64_path) { File.join(certificate_path, "base64_test.cer") }
let(:pem_path) { File.join(certificate_path, "test.pem") }
let(:pfx_path) { File.join(certificate_path, "test.pfx") }
let(:out_path) { File.join(certificate_path, "testout.pem") }
@@ -174,6 +175,21 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do
end
end
+ context "Adds Base64 Encoded CER" do
+ before do
+ win_certificate.source = base64_path
+ win_certificate.run_action(:create)
+ end
+ it "Imports certificate into store" do
+ expect(no_of_certificates).to eq(1)
+ end
+ it "Idempotent: Does not converge while adding again" do
+ win_certificate.run_action(:create)
+ expect(no_of_certificates).to eq(1)
+ expect(win_certificate).not_to be_updated_by_last_action
+ end
+ end
+
context "Adds PEM" do
before do
win_certificate.source = pem_path