diff options
Diffstat (limited to 'spec/unit/knife/configure_spec.rb')
-rw-r--r-- | spec/unit/knife/configure_spec.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 89874cfdf9..6c1d98c2f5 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Configure do before do @@ -11,7 +11,7 @@ describe Chef::Knife::Configure do @out = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@out) - @knife.config[:config_file] = '/home/you/.chef/knife.rb' + @knife.config[:config_file] = "/home/you/.chef/knife.rb" @in = StringIO.new("\n" * 7) allow(@knife.ui).to receive(:stdin).and_return(@in) @@ -58,11 +58,11 @@ describe Chef::Knife::Configure do it "should not ask the user for the clientname they want for the new client if -i and --node_name are specified" do @knife.config[:initial] = true - @knife.config[:node_name] = 'testnode' + @knife.config[:node_name] = "testnode" allow(Etc).to receive(:getlogin).and_return("a-new-user") @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter a name for the new user")) - expect(@knife.new_client_name).to eq('testnode') + expect(@knife.new_client_name).to eq("testnode") end it "asks the user for the existing API username or clientname if -i is not specified" do @@ -76,21 +76,21 @@ describe Chef::Knife::Configure do @knife.config[:initial] = true @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the existing admin name: [admin]")) - expect(@knife.admin_client_name).to eq('admin') + expect(@knife.admin_client_name).to eq("admin") end it "should not ask the user for the existing admin client's name if -i and --admin-client_name are specified" do @knife.config[:initial] = true - @knife.config[:admin_client_name] = 'my-webui' + @knife.config[:admin_client_name] = "my-webui" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin:")) - expect(@knife.admin_client_name).to eq('my-webui') + expect(@knife.admin_client_name).to eq("my-webui") end it "should not ask the user for the existing admin client's name if -i is not specified" do @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin: [admin]")) - expect(@knife.admin_client_name).not_to eq('admin') + expect(@knife.admin_client_name).not_to eq("admin") end it "asks the user for the location of the existing admin key if -i is specified" do @@ -106,13 +106,13 @@ describe Chef::Knife::Configure do it "should not ask the user for the location of the existing admin key if -i and --admin_client_key are specified" do @knife.config[:initial] = true - @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem' + @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the location of the existing admin client's private key:")) if windows? expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$} else - expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem') + expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem") end end @@ -129,20 +129,20 @@ describe Chef::Knife::Configure do it "asks the user for the location of a chef repo" do @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the path to a chef repository (or leave blank):")) - expect(@knife.chef_repo).to eq('') + expect(@knife.chef_repo).to eq("") end it "asks the users for the name of the validation client" do @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the validation clientname: [chef-validator]")) - expect(@knife.validation_client_name).to eq('chef-validator') + expect(@knife.validation_client_name).to eq("chef-validator") end it "should not ask the users for the name of the validation client if --validation_client_name is specified" do - @knife.config[:validation_client_name] = 'my-validator' + @knife.config[:validation_client_name] = "my-validator" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the validation clientname:")) - expect(@knife.validation_client_name).to eq('my-validator') + expect(@knife.validation_client_name).to eq("my-validator") end it "asks the users for the location of the validation key" do @@ -156,45 +156,45 @@ describe Chef::Knife::Configure do end it "should not ask the users for the location of the validation key if --validation_key is specified" do - @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem' + @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the location of the validation key:")) if windows? expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$} else - expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem') + expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem") end end it "should not ask the user for anything if -i and all other properties are specified" do @knife.config[:initial] = true - @knife.config[:chef_server_url] = 'http://localhost:5000' - @knife.config[:node_name] = 'testnode' - @knife.config[:admin_client_name] = 'my-webui' - @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem' - @knife.config[:validation_client_name] = 'my-validator' - @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem' - @knife.config[:repository] = '' - @knife.config[:client_key] = '/home/you/a-new-user.pem' - allow(Etc).to receive(:getlogin).and_return('a-new-user') + @knife.config[:chef_server_url] = "http://localhost:5000" + @knife.config[:node_name] = "testnode" + @knife.config[:admin_client_name] = "my-webui" + @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem" + @knife.config[:validation_client_name] = "my-validator" + @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem" + @knife.config[:repository] = "" + @knife.config[:client_key] = "/home/you/a-new-user.pem" + allow(Etc).to receive(:getlogin).and_return("a-new-user") @knife.ask_user_for_config expect(@out.string).to match(/\s*/) - expect(@knife.new_client_name).to eq('testnode') - expect(@knife.chef_server).to eq('http://localhost:5000') - expect(@knife.admin_client_name).to eq('my-webui') + expect(@knife.new_client_name).to eq("testnode") + expect(@knife.chef_server).to eq("http://localhost:5000") + expect(@knife.admin_client_name).to eq("my-webui") if windows? expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$} expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$} expect(@knife.new_client_key).to match %r{^[A-Za-z]:/home/you/a-new-user\.pem$} else - expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem') - expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem') - expect(@knife.new_client_key).to eq('/home/you/a-new-user.pem') + expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem") + expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem") + expect(@knife.new_client_key).to eq("/home/you/a-new-user.pem") end - expect(@knife.validation_client_name).to eq('my-validator') - expect(@knife.chef_repo).to eq('') + expect(@knife.validation_client_name).to eq("my-validator") + expect(@knife.chef_repo).to eq("") end it "writes the new data to a config file" do @@ -205,7 +205,7 @@ describe Chef::Knife::Configure do expect(FileUtils).to receive(:mkdir_p).with("/home/you/.chef") config_file = StringIO.new expect(::File).to receive(:open).with("/home/you/.chef/knife.rb", "w").and_yield config_file - @knife.config[:repository] = '/home/you/chef-repo' + @knife.config[:repository] = "/home/you/chef-repo" @knife.run expect(config_file.string).to match(/^node_name[\s]+'#{Etc.getlogin}'$/) expect(config_file.string).to match(%r{^client_key[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$}) |