Skip to content

Commit

Permalink
Merge pull request #779 from agrare/remote_console_ticket_vim_string
Browse files Browse the repository at this point in the history
Ensure Remote Console tickets aren't VimStrings
  • Loading branch information
Fryguy committed Jan 14, 2022
2 parents 6ab0209 + fc37e55 commit c031f88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ def remote_console_acquire_ticket_queue(protocol, userid)
def remote_console_vmrc_acquire_ticket(_userid = nil, _originating_server = nil)
validate_remote_console_acquire_ticket("vmrc")
ticket = ext_management_system.remote_console_vmrc_acquire_ticket
{:ticket => ticket, :remote_url => build_vmrc_url(ticket), :proto => 'remote'}

{
:ticket => ticket.to_s, # Ensure ticket is a basic String not a VimString
:remote_url => build_vmrc_url(ticket),
:proto => 'remote'
}
end

def validate_remote_console_vmrc_support
Expand All @@ -66,11 +71,11 @@ def remote_console_webmks_acquire_ticket(userid, originating_server = nil)
:vm_id => id,
:ssl => true,
:protocol => 'webmks',
:secret => ticket['ticket'],
:secret => ticket['ticket'].to_s, # Ensure ticket is a basic String not a VimString
:url_secret => SecureRandom.hex,
}

SystemConsole.launch_proxy_if_not_local(console_args, originating_server, ticket['host'], ticket['port'].to_i)
SystemConsole.launch_proxy_if_not_local(console_args, originating_server, ticket['host'].to_s, ticket['port'].to_i)
end

def validate_remote_console_webmks_support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@
EvmSpecHelper.create_guid_miq_server_zone
ems.update(:ipaddress => '192.168.252.14', :hostname => '192.168.252.14')
auth = FactoryBot.create(:authentication,
:userid => 'dev1',
:password => 'dev1pass',
:authtype => 'console')
:userid => 'dev1',
:password => 'dev1pass',
:authtype => 'console')
ems.authentications = [auth]
ticket = VCR.use_cassette(described_class.name.underscore) do
vm.remote_console_vmrc_acquire_ticket
end

expect(ticket).to have_key(:ticket)
expect(ticket[:ticket]).to match(/^[0-9\-A-Z]{40}$/)
expect(ticket[:ticket]).to be_instance_of(String) # Ensure that VimStrings aren't returned
end

it 'with vm off' do
Expand Down

0 comments on commit c031f88

Please sign in to comment.