summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2018-07-11 13:01:43 -0700
committerNoah Kantrowitz <noah@coderanger.net>2018-07-11 13:01:43 -0700
commite28dd582903cb9846a718e00749ac218df563d42 (patch)
treef0babdc04e17a9bbd816ed3f3890dcec605aa3f2
parent61765d9d13793912f2032dce1fcdf092ef07d700 (diff)
downloadchef-e28dd582903cb9846a718e00749ac218df563d42.tar.gz
A few more test cases.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--spec/integration/knife/config_list_profiles_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/integration/knife/config_list_profiles_spec.rb b/spec/integration/knife/config_list_profiles_spec.rb
index ccc0045081..e261d3883f 100644
--- a/spec/integration/knife/config_list_profiles_spec.rb
+++ b/spec/integration/knife/config_list_profiles_spec.rb
@@ -113,6 +113,33 @@ EOH
EOH
end
+ context 'with a non-default active profile' do
+ let(:cmd_args) { %w{--profile prod} }
+ before { file('.chef/credentials', <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+
+ [prod]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/prod"
+
+ [qa]
+ client_name = "qauser"
+ client_key = "~/src/qauser.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to eq <<-EOH.gsub(/#/, '') }
+ Profile Client Key Server #
+----------------------------------------------------------------------------------#
+ default testuser ~/.chef/testkey.pem https://example.com/organizations/testorg#
+*prod testuser ~/.chef/testkey.pem https://example.com/organizations/prod #
+ qa qauser ~/src/qauser.pem https://example.com/organizations/testorg#
+EOH
+ end
+
context 'with a minimal profile' do
before { file('.chef/credentials', <<~EOH) }
[default]
@@ -133,4 +160,29 @@ EOH
*default https://example.com/organizations/testorg#
EOH
end
+
+ context "with --format=json" do
+ let(:cmd_args) { %w{--format=json node_name} }
+ before { file('.chef/credentials', <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+
+ [prod]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/prod"
+
+ [qa]
+ client_name = "qauser"
+ client_key = "~/src/qauser.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { expect(JSON.parse(subject)).to eq [
+ {"profile" => "default", "active" => true, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/testorg"},
+ {"profile" => "prod", "active" => false, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/prod"},
+ {"profile" => "qa", "active" => false, "client_name" => "qauser", "client_key" => path_to("src/qauser.pem"), "server_url" => "https://example.com/organizations/testorg"},
+ ] }
+ end
end