diff options
author | danielsdeleo <dan@opscode.com> | 2012-12-17 15:21:39 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-12-18 14:49:17 -0800 |
commit | 2de707d27251f38790a71043843749a570302aaf (patch) | |
tree | a7573b11f438a37c7afbdb1bed80383625906ff9 /spec/unit/api_client_spec.rb | |
parent | 8e6c56dbbcddda8635dff0eee09f762f755ddd65 (diff) | |
download | chef-2de707d27251f38790a71043843749a570302aaf.tar.gz |
[CHEF-3689] refactor REST API client instantiation
Diffstat (limited to 'spec/unit/api_client_spec.rb')
-rw-r--r-- | spec/unit/api_client_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index 1ed2cae67f..b47df6ad5c 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -142,6 +142,36 @@ describe Chef::ApiClient do end + describe "with correctly configured API credentials" do + before do + Chef::Config[:node_name] = "silent-bob" + Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA) + Chef::Config[:validation_client_name] = "test-validator" + Chef::Config[:validation_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA) + end + + after do + Chef::Config[:node_name] = nil + Chef::Config[:client_key] = nil + end + + let :private_key_data do + File.open(Chef::Config[:client_key], "rb") {|f| f.read.chomp } + end + + it "has an HTTP client configured with default credentials" do + @client.http_api.should be_a_kind_of(Chef::REST) + @client.http_api.client_name.should == "silent-bob" + @client.http_api.signing_key.to_s.should == private_key_data + end + + it "has an HTTP client configured with validator credentials" do + @client.http_api_as_validator.should be_a_kind_of(Chef::REST) + @client.http_api_as_validator.client_name.should == "test-validator" + @client.http_api_as_validator.signing_key.should == private_key_data + end + end + describe "when requesting a new key" do before do @http_client = mock("Chef::REST mock") |