diff options
author | snehaldwivedi <sdwivedi@msystechnologies.com> | 2021-02-15 21:30:28 -0800 |
---|---|---|
committer | snehaldwivedi <sdwivedi@msystechnologies.com> | 2021-02-16 02:45:13 -0800 |
commit | 6a3587867d17b9d8d5d8ea0f9279c3e522f0ea71 (patch) | |
tree | 5117e08efc39ac07c1adcf19e6161c0947ee9711 /spec | |
parent | 8f32723295c4ef04724270a4d6e4b77e5caf7b3a (diff) | |
download | chef-6a3587867d17b9d8d5d8ea0f9279c3e522f0ea71.tar.gz |
Revert "Updated rest object URL and removed api_version 1"
This reverts commit 182d83672e231c470e0b33ed777306a72a6bd76a.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/org_delete_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/org_edit_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/knife/org_list_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/org_show_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/knife/user_create_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/knife/user_edit_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/knife/user_password_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/knife/user_show_spec.rb | 19 |
8 files changed, 43 insertions, 40 deletions
diff --git a/spec/unit/knife/org_delete_spec.rb b/spec/unit/knife/org_delete_spec.rb index b82c144116..94c224f1e6 100644 --- a/spec/unit/knife/org_delete_spec.rb +++ b/spec/unit/knife/org_delete_spec.rb @@ -21,7 +21,7 @@ require "chef/org" describe Chef::Knife::OrgDelete do - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before :each do @knife = Chef::Knife::OrgDelete.new @@ -32,9 +32,9 @@ 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_root]).and_return(rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(@knife.ui).to receive(:confirm).with("Do you want to delete the organization #{@org_name}") - expect(rest).to receive(:delete).with("organizations/#{@org_name}") + expect(root_rest).to receive(:delete).with("organizations/#{@org_name}") expect(@knife.ui).to receive(:output) @knife.run end diff --git a/spec/unit/knife/org_edit_spec.rb b/spec/unit/knife/org_edit_spec.rb index 7a99f1355a..3badaf5168 100644 --- a/spec/unit/knife/org_edit_spec.rb +++ b/spec/unit/knife/org_edit_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::OrgEdit do let(:knife) { Chef::Knife::OrgEdit.new } - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before :each do Chef::Knife::OrgEdit.load_deps @@ -31,12 +31,12 @@ describe Chef::Knife::OrgEdit do end it "loads and edits the organisation" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) original_data = { "org_name" => "my_org" } data = { "org_name" => "my_org1" } - expect(rest).to receive(:get).with("organizations/foobar").and_return(original_data) + expect(root_rest).to receive(:get).with("organizations/foobar").and_return(original_data) expect(knife).to receive(:edit_hash).with(original_data).and_return(data) - expect(rest).to receive(:put).with("organizations/foobar", data) + expect(root_rest).to receive(:put).with("organizations/foobar", data) knife.run end diff --git a/spec/unit/knife/org_list_spec.rb b/spec/unit/knife/org_list_spec.rb index 05fb289e6b..1c6fb956af 100644 --- a/spec/unit/knife/org_list_spec.rb +++ b/spec/unit/knife/org_list_spec.rb @@ -20,7 +20,7 @@ require "chef/org" describe Chef::Knife::OrgList do - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } let(:orgs) do { @@ -33,8 +33,8 @@ 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_root]).and_return(rest) - allow(rest).to receive(:get).with("organizations").and_return(orgs) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + allow(root_rest).to receive(:get).with("organizations").and_return(orgs) end describe "with no arguments" do diff --git a/spec/unit/knife/org_show_spec.rb b/spec/unit/knife/org_show_spec.rb index 033bf6f14e..6a6260273f 100644 --- a/spec/unit/knife/org_show_spec.rb +++ b/spec/unit/knife/org_show_spec.rb @@ -21,24 +21,24 @@ require "chef/org" describe Chef::Knife::OrgShow do - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before :each do @knife = Chef::Knife::OrgShow.new @org_name = "foobar" @knife.name_args << @org_name @org = double("Chef::Org") - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(rest) - allow(@org).to receive(:rest).and_return(rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + allow(@org).to receive(:root_rest).and_return(root_rest) end it "should load the organisation" do - expect(rest).to receive(:get).with("organizations/#{@org_name}") + expect(root_rest).to receive(:get).with("organizations/#{@org_name}") @knife.run end it "should pretty print the output organisation" do - expect(rest).to receive(:get).with("organizations/#{@org_name}") + expect(root_rest).to receive(:get).with("organizations/#{@org_name}") expect(@knife.ui).to receive(:output) @knife.run end diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb index d763debad1..ec221fb8c0 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -40,6 +40,8 @@ describe Chef::Knife::UserCreate do allow(knife.ui).to receive(:warn) end + let(:chef_root_rest_v0) { double("Chef::ServerAPI") } + context "when USERNAME isn't specified" do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do @@ -84,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).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 @@ -100,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.username).to eq("some_user") @@ -133,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.create_key).to be_falsey @@ -142,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.create_key).to be_truthy @@ -157,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.public_key).to eq("some_key") @@ -166,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) expect(root_rest).to receive(:post).and_return(@user) knife.run expect(knife.user.public_key).to be_nil @@ -178,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_root ]).and_return(root_rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).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 17f2e2e2d3..1467d05af3 100644 --- a/spec/unit/knife/user_edit_spec.rb +++ b/spec/unit/knife/user_edit_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Chef::Knife::UserEdit do let(:knife) { Chef::Knife::UserEdit.new } - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before(:each) do @stderr = StringIO.new @@ -38,10 +38,10 @@ 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_root]).and_return(rest) - expect(rest).to receive(:get).with("users/my_user2").and_return(data) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).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(rest).to receive(:put).with("users/my_user2", edited_data).and_return(result) + expect(root_rest).to receive(:put).with("users/my_user2", edited_data).and_return(result) knife.run end diff --git a/spec/unit/knife/user_password_spec.rb b/spec/unit/knife/user_password_spec.rb index 3994ef57cb..853e21cd6d 100644 --- a/spec/unit/knife/user_password_spec.rb +++ b/spec/unit/knife/user_password_spec.rb @@ -23,14 +23,14 @@ Chef::Knife::UserDelete.load_deps describe Chef::Knife::UserPassword do - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before :each do @knife = Chef::Knife::UserPassword.new @user_name = "foobar" @password = "abc123" @user = double("Chef::User") - allow(@user).to receive(:rest).and_return(rest) + allow(@user).to receive(:root_rest).and_return(root_rest) @key = "You don't come into cooking to get rich - Ramsay" end @@ -43,9 +43,9 @@ 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_root]).and_return(rest) - expect(@user.rest).to receive(:get).with("users/#{@user_name}").and_return(result) - expect(@user.rest).to receive(:put).with("users/#{@user_name}", result) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).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}.") @knife.run diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb index 9780b6a340..941592cb56 100644 --- a/spec/unit/knife/user_show_spec.rb +++ b/spec/unit/knife/user_show_spec.rb @@ -24,13 +24,14 @@ Chef::Knife::UserShow.load_deps describe Chef::Knife::UserShow do let(:knife) { Chef::Knife::UserShow.new } let(:user_mock) { double("user_mock") } - let(:rest) { double("Chef::ServerAPI") } + let(:root_rest) { double("Chef::ServerAPI") } before :each do @user_name = "foobar" @password = "abc123" @user = double("Chef::User") - allow(@user).to receive(:rest).and_return(rest) + allow(@user).to receive(:root_rest).and_return(root_rest) + # allow(Chef::User).to receive(:new).and_return(@user) @key = "You don't come into cooking to get rich - Ramsay" end @@ -41,14 +42,14 @@ describe Chef::Knife::UserShow do end it "should load the user" do - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(rest) - expect(@user.rest).to receive(:get).with("users/my_user") + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).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_root]).and_return(rest) - expect(@user.rest).to receive(:get).with("users/my_user") + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) + expect(@user.root_rest).to receive(:get).with("users/my_user") expect(knife).to receive(:format_for_display) knife.run end @@ -80,10 +81,10 @@ describe Chef::Knife::UserShow do result = { "organizations" => [] } knife.config[:with_orgs] = true - expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(rest) + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], { api_version: "1" }).and_return(root_rest) allow(@org).to receive(:[]).with("organization").and_return({ "name" => "test" }) - expect(@user.rest).to receive(:get).with("users/#{@user_name}").and_return(result) - expect(@user.rest).to receive(:get).with("users/#{@user_name}/organizations").and_return(orgs) + 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) knife.run end end |