From d8c632cdd96648838eb98e78ae22d80b06cb04c5 Mon Sep 17 00:00:00 2001 From: Mukta Date: Thu, 16 May 2013 18:47:43 +0530 Subject: [PATCH] Updated the tests for ssh key support in linux --- spec/unit/azure_server_create_spec.rb | 43 +++++++++++++++------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/spec/unit/azure_server_create_spec.rb b/spec/unit/azure_server_create_spec.rb index cb10588..becc156 100644 --- a/spec/unit/azure_server_create_spec.rb +++ b/spec/unit/azure_server_create_spec.rb @@ -168,25 +168,30 @@ describe "for bootstrap protocol ssh:" do @bootstrap.should_receive(:run) @server_instance.run end - it "check if ssh-key set correctly" do - Chef::Config[:knife][:ssh_password] = '' - Chef::Config[:knife][:identity_file] = 'ssh_key' - @server_instance.should_receive(:is_image_windows?).and_return(false) - @server_params = @server_instance.create_server_def - @server_params[:os_type].should == 'Linux' - @server_params[:identity_file].should == 'ssh_key' - @server_params[:ssh_user].should == 'ssh_user' - @server_params[:bootstrap_proto].should == 'ssh' - @server_params[:hosted_service_name].should == 'service001' - end - it "successful bootstrap with ssh key" do - @server_instance.should_receive(:is_image_windows?).exactly(3).times.and_return(false) - @bootstrap = Chef::Knife::Bootstrap.new - Chef::Knife::Bootstrap.stub(:new).and_return(@bootstrap) - @bootstrap.should_receive(:run) - @server_instance.connection.certificates.stub(:generateCertificateData).and_return("cert_data") - @server_instance.connection.certificates.should_receive(:create) - @server_instance.run + + context "ssh key" do + before do + Chef::Config[:knife][:ssh_password] = '' + Chef::Config[:knife][:identity_file] = 'ssh_key' + end + it "check if ssh-key set correctly" do + @server_instance.should_receive(:is_image_windows?).and_return(false) + @server_params = @server_instance.create_server_def + @server_params[:os_type].should == 'Linux' + @server_params[:identity_file].should == 'ssh_key' + @server_params[:ssh_user].should == 'ssh_user' + @server_params[:bootstrap_proto].should == 'ssh' + @server_params[:hosted_service_name].should == 'service001' + end + it "successful bootstrap with ssh key" do + @server_instance.should_receive(:is_image_windows?).exactly(3).times.and_return(false) + @bootstrap = Chef::Knife::Bootstrap.new + Chef::Knife::Bootstrap.stub(:new).and_return(@bootstrap) + @bootstrap.should_receive(:run) + @server_instance.connection.certificates.stub(:generateCertificateData).and_return("cert_data") + @server_instance.connection.certificates.should_receive(:create) + @server_instance.run + end end context "bootstrap"