summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2012-11-02 10:51:54 -0700
committerBryan McLellan <btm@opscode.com>2012-11-20 13:06:03 -0800
commit6a3afe5b6cff92187ac61c356ab3a9161ed29c06 (patch)
treea651aa4750b760eb47c808b82c56efa20fdbd6ef
parent647f7c9f835f890ba210a85de1ca776da4a5cfba (diff)
downloadchef-6a3afe5b6cff92187ac61c356ab3a9161ed29c06.tar.gz
CHEF-3568: expand path in validation_key for bootstrap
Allows ~ in path. Some day we should probably expand paths in Chef::Config. Also expand encrypted data bag secret while we're in there.
-rw-r--r--chef/lib/chef/knife/core/bootstrap_context.rb4
-rw-r--r--chef/spec/unit/knife/core/bootstrap_context_spec.rb7
2 files changed, 9 insertions, 2 deletions
diff --git a/chef/lib/chef/knife/core/bootstrap_context.rb b/chef/lib/chef/knife/core/bootstrap_context.rb
index 71dc008d39..dd41d8e596 100644
--- a/chef/lib/chef/knife/core/bootstrap_context.rb
+++ b/chef/lib/chef/knife/core/bootstrap_context.rb
@@ -47,11 +47,11 @@ class Chef
end
def validation_key
- IO.read(@chef_config[:validation_key])
+ IO.read(File.expand_path(@chef_config[:validation_key]))
end
def encrypted_data_bag_secret
- IO.read(@chef_config[:encrypted_data_bag_secret])
+ IO.read(File.expand_path(@chef_config[:encrypted_data_bag_secret]))
end
def config_content
diff --git a/chef/spec/unit/knife/core/bootstrap_context_spec.rb b/chef/spec/unit/knife/core/bootstrap_context_spec.rb
index f8a58484a5..ecd0e7fda1 100644
--- a/chef/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/chef/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -56,6 +56,13 @@ describe Chef::Knife::Core::BootstrapContext do
@context.validation_key.should == IO.read(File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'))
end
+ it "reads the validation key when it contains a ~" do
+ IO.should_receive(:read).with("#{ENV['HOME']}/my.key")
+ @chef_config = {:validation_key => '~/my.key'}
+ @context = Chef::Knife::Core::BootstrapContext.new(@config, @run_list, @chef_config)
+ @context.validation_key
+ end
+
it "generates the config file data" do
expected=<<-EXPECTED
log_level :info