Skip to content

Commit

Permalink
Merge branch 'bz_1507165_disallow_console_if_no_console_credentials_a…
Browse files Browse the repository at this point in the history
…re_defined' into '5.8.z'

Return console unsupported if no console creds

See merge request !1

https://bugzilla.redhat.com/show_bug.cgi?id=1536537
  • Loading branch information
Fryguy authored and root committed Feb 28, 2018
1 parent 1a5246f commit 0bea4db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def console_supported?(type)
def validate_remote_console_acquire_ticket(protocol, options = {})
raise(MiqException::RemoteConsoleNotSupportedError, "#{protocol} remote console requires the vm to be registered with a management system.") if ext_management_system.nil?

raise(MiqException::RemoteConsoleNotSupportedError, "remote console requires console credentials") if ext_management_system.authentication_type(:console).nil?

options[:check_if_running] = true unless options.key?(:check_if_running)
raise(MiqException::RemoteConsoleNotSupportedError, "#{protocol} remote console requires the vm to be running.") if options[:check_if_running] && state != "on"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
end

context '#validate_remote_console_webmks_support' do
before do
ems.authentications << FactoryGirl.create(:authentication, :authtype => :console, :userid => "root", :password => "vmware")
end

it 'normal case' do
ems.update_attribute(:api_version, '6.0')
expect(vm.validate_remote_console_webmks_support).to be_truthy
Expand Down Expand Up @@ -121,7 +125,7 @@
auth = FactoryGirl.create(:authentication,
:userid => 'dev1',
:password => 'dev1pass',
:authtype => 'default')
:authtype => 'console')
ems.authentications = [auth]
ticket = VCR.use_cassette(described_class.name.underscore) do
vm.remote_console_vmrc_acquire_ticket
Expand All @@ -143,6 +147,10 @@
end

context '#validate_remote_console_vmrc_support' do
before do
ems.authentications << FactoryGirl.create(:authentication, :authtype => :console, :userid => "root", :password => "vmware")
end

it 'normal case' do
expect(vm.validate_remote_console_vmrc_support).to be_truthy
end
Expand Down Expand Up @@ -178,6 +186,7 @@
let(:server) { double('MiqServer') }

before(:each) do
ems.authentications << FactoryGirl.create(:authentication, :authtype => :console, :userid => "root", :password => "vmware")
allow(server).to receive_messages(:id => 1)
allow(MiqServer).to receive_messages(:my_server => server)
end
Expand Down
9 changes: 2 additions & 7 deletions spec/models/manageiq/providers/vmware/infra_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,10 @@
ems.authentications << FactoryGirl.create(:authentication, :userid => "root", :password => "vmware")
end

it "uses the default credentials" do
it "raises an exception" do
require 'VMwareWebService/MiqVim'

vim = mock_vim_broker_connection

expect(MiqVim).to receive(:new).with(ems.hostname, "root", "vmware").and_return(vim)
expect(vim).to receive(:acquireCloneTicket)

ems.remote_console_vmrc_acquire_ticket
expect { ems.remote_console_vmrc_acquire_ticket }.to raise_error "no console credentials defined"
end
end
end
Expand Down

0 comments on commit 0bea4db

Please sign in to comment.