From 0570757936debabc9401b22784f6781e3892e21e Mon Sep 17 00:00:00 2001 From: snehaldwivedi Date: Tue, 16 Feb 2021 02:44:09 -0800 Subject: To remove verison v1 for root_rest object Signed-off-by: snehaldwivedi --- lib/chef/knife.rb | 2 +- spec/unit/knife/org_delete_spec.rb | 2 +- spec/unit/knife/org_edit_spec.rb | 2 +- spec/unit/knife/org_list_spec.rb | 2 +- spec/unit/knife/org_show_spec.rb | 2 +- spec/unit/knife/user_create_spec.rb | 14 +++++++------- spec/unit/knife/user_edit_spec.rb | 2 +- spec/unit/knife/user_password_spec.rb | 2 +- spec/unit/knife/user_show_spec.rb | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index a5ed415fee..d277e51105 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -665,7 +665,7 @@ class Chef def root_rest @root_rest ||= begin require_relative "server_api" - Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "1" }) + Chef::ServerAPI.new(Chef::Config[:chef_server_root]) end end end diff --git a/spec/unit/knife/org_delete_spec.rb b/spec/unit/knife/org_delete_spec.rb index 94c224f1e6..baa102f8c8 100644 --- a/spec/unit/knife/org_delete_spec.rb +++ b/spec/unit/knife/org_delete_spec.rb @@ -32,7 +32,7 @@ describe Chef::Knife::OrgDelete do end it "should confirm that you want to delete and then delete organizations" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(root_rest) expect(@knife.ui).to receive(:confirm).with("Do you want to delete the organization #{@org_name}") expect(root_rest).to receive(:delete).with("organizations/#{@org_name}") expect(@knife.ui).to receive(:output) diff --git a/spec/unit/knife/org_edit_spec.rb b/spec/unit/knife/org_edit_spec.rb index 3badaf5168..05339e8f21 100644 --- a/spec/unit/knife/org_edit_spec.rb +++ b/spec/unit/knife/org_edit_spec.rb @@ -31,7 +31,7 @@ describe Chef::Knife::OrgEdit do end it "loads and edits the organisation" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) original_data = { "org_name" => "my_org" } data = { "org_name" => "my_org1" } expect(root_rest).to receive(:get).with("organizations/foobar").and_return(original_data) diff --git a/spec/unit/knife/org_list_spec.rb b/spec/unit/knife/org_list_spec.rb index 1c6fb956af..de77b4b0c7 100644 --- a/spec/unit/knife/org_list_spec.rb +++ b/spec/unit/knife/org_list_spec.rb @@ -33,7 +33,7 @@ describe Chef::Knife::OrgList do before :each do @org = double("Chef::Org") @knife = Chef::Knife::OrgList.new - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) allow(root_rest).to receive(:get).with("organizations").and_return(orgs) end diff --git a/spec/unit/knife/org_show_spec.rb b/spec/unit/knife/org_show_spec.rb index 6a6260273f..2f5246dd84 100644 --- a/spec/unit/knife/org_show_spec.rb +++ b/spec/unit/knife/org_show_spec.rb @@ -28,7 +28,7 @@ describe Chef::Knife::OrgShow do @org_name = "foobar" @knife.name_args << @org_name @org = double("Chef::Org") - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) allow(@org).to receive(:root_rest).and_return(root_rest) end diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb index ec221fb8c0..c69a668f7e 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -86,7 +86,7 @@ describe Chef::Knife::UserCreate do end it "creates an user" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) expect(knife.ui).to receive(:ask).with("Please enter the user's password: ", echo: false).and_return("password") knife.run @@ -102,7 +102,7 @@ describe Chef::Knife::UserCreate do end it "sets all the mandatory fields" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.username).to eq("some_user") @@ -135,7 +135,7 @@ describe Chef::Knife::UserCreate do end it "does not set user.create_key" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.create_key).to be_falsey @@ -144,7 +144,7 @@ describe Chef::Knife::UserCreate do context "when --prevent-keygen is not passed" do it "sets user.create_key to true" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.create_key).to be_truthy @@ -159,7 +159,7 @@ describe Chef::Knife::UserCreate do end it "sets user.public_key" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.public_key).to eq("some_key") @@ -168,7 +168,7 @@ describe Chef::Knife::UserCreate do context "when --user-key is not passed" do it "does not set user.public_key" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.public_key).to be_nil @@ -180,7 +180,7 @@ describe Chef::Knife::UserCreate do before :each do @user = double("Chef::User") - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) @key = "You don't come into cooking to get rich - Ramsay" allow(@user).to receive(:[]).with("private_key").and_return(@key) diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb index 1467d05af3..2fde328c0c 100644 --- a/spec/unit/knife/user_edit_spec.rb +++ b/spec/unit/knife/user_edit_spec.rb @@ -38,7 +38,7 @@ describe Chef::Knife::UserEdit do @key = "You don't come into cooking to get rich - Ramsay" allow(result).to receive(:[]).with("private_key").and_return(@key) - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(root_rest).to receive(:get).with("users/my_user2").and_return(data) expect(knife).to receive(:get_updated_user).with(data).and_return(edited_data) expect(root_rest).to receive(:put).with("users/my_user2", edited_data).and_return(result) diff --git a/spec/unit/knife/user_password_spec.rb b/spec/unit/knife/user_password_spec.rb index 853e21cd6d..098597a14c 100644 --- a/spec/unit/knife/user_password_spec.rb +++ b/spec/unit/knife/user_password_spec.rb @@ -43,7 +43,7 @@ describe Chef::Knife::UserPassword do result = { "password" => [], "recovery_authentication_enabled" => true } allow(@user).to receive(:[]).with("organization") - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(@user.root_rest).to receive(:get).with("users/#{@user_name}").and_return(result) expect(@user.root_rest).to receive(:put).with("users/#{@user_name}", result) expect(@knife.ui).to receive(:msg).with("Authentication info updated for #{@user_name}.") diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb index 941592cb56..30742d8c21 100644 --- a/spec/unit/knife/user_show_spec.rb +++ b/spec/unit/knife/user_show_spec.rb @@ -42,13 +42,13 @@ describe Chef::Knife::UserShow do end it "should load the user" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(@user.root_rest).to receive(:get).with("users/my_user") knife.run end it "loads and displays the user" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) expect(@user.root_rest).to receive(:get).with("users/my_user") expect(knife).to receive(:format_for_display) knife.run @@ -81,7 +81,7 @@ describe Chef::Knife::UserShow do result = { "organizations" => [] } knife.config[:with_orgs] = true - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest) allow(@org).to receive(:[]).with("organization").and_return({ "name" => "test" }) expect(@user.root_rest).to receive(:get).with("users/#{@user_name}").and_return(result) expect(@user.root_rest).to receive(:get).with("users/#{@user_name}/organizations").and_return(orgs) -- cgit v1.2.1