summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-02-12 17:46:59 -0800
committerTim Smith <tsmith84@gmail.com>2020-02-12 19:29:44 -0800
commit19163410401c224dfaba82d288482528773f530e (patch)
tree38c7b4e7751ac361fef553af83d600ffc61a56eb
parent60931752176e409b25e90d853376e5d8ee9d500f (diff)
downloadchef-19163410401c224dfaba82d288482528773f530e.tar.gz
Add a Kitchen Test for chef_vault_secret
Pulled from the cookbook. I also sprinkled some chef-utils usage on the existing test. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb32
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/default.rb6
-rw-r--r--spec/unit/resource/chef_vault_secret_spec.rb2
3 files changed, 37 insertions, 3 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb b/kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb
new file mode 100644
index 0000000000..504a91da2b
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/chef-vault.rb
@@ -0,0 +1,32 @@
+#
+# Cookbook:: end_to_end
+# Recipe:: chef-vault
+#
+# Copyright:: 2020, Chef Software, Inc.
+#
+
+chef_data_bag 'creds'
+
+openssl_rsa_private_key '/root/bob_bobberson.pem' do
+ key_length 2048
+ action :create
+end
+
+chef_client 'bob_bobberson' do
+ source_key_path '/root/bob_bobberson.pem'
+end
+
+chef_node 'bob_bobberson'
+
+chef_vault_secret 'super_secret_1' do
+ data_bag 'creds'
+ raw_data('auth' => '1234')
+ admins 'bob_bobberson'
+ search '*:*'
+end
+
+chef_vault_secret 'super_secret_2' do
+ data_bag 'creds'
+ raw_data('auth' => '4321')
+ admins 'bob_bobberson'
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
index 0af35f8c7a..6202efcc68 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
@@ -2,7 +2,7 @@
# Cookbook:: end_to_end
# Recipe:: default
#
-# Copyright:: 2014-2019, Chef Software Inc.
+# Copyright:: 2014-2020, Chef Software Inc.
#
hostname "chef-bk-ci.chef.io"
@@ -33,7 +33,7 @@ yum_repository "epel" do
gpgkey "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-#{node["platform_version"].to_i}"
gpgcheck true
mirrorlist "https://mirrors.fedoraproject.org/metalink?repo=epel-#{node["platform_version"].to_i}&arch=$basearch"
- only_if { platform_family?("rhel") }
+ only_if { rhel? }
end
build_essential do
@@ -118,4 +118,6 @@ end
end
end
+include_recipe "::chef-vault" unless includes_recipe?("end_to_end::chef-vault")
+
include_recipe "::tests"
diff --git a/spec/unit/resource/chef_vault_secret_spec.rb b/spec/unit/resource/chef_vault_secret_spec.rb
index 5190785de7..79b3bf8996 100644
--- a/spec/unit/resource/chef_vault_secret_spec.rb
+++ b/spec/unit/resource/chef_vault_secret_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Resource::ChefVaultSecret do
end
it "id is the name property" do
- expect(resource.id).to eql(foo)
+ expect(resource.id).to eql("foo")
end
it "supports :create, :create_if_missing, and :delete actions" do