Revision f30caf97
Added by Julien Pivotto about 9 years ago
test/functional/api/v2/hosts_controller_test.rb | ||
---|---|---|
assert_equal 'A stub failure', JSON.parse(response.body)['error']['errors']['foo'].first
|
||
end
|
||
|
||
test 'non-admin user with power_host permission can boot a vm' do
|
||
@bmchost = FactoryGirl.create(:host, :managed)
|
||
FactoryGirl.create(:nic_bmc, :host => @bmchost)
|
||
ProxyAPI::BMC.any_instance.stubs(:power).with(:action => 'status').returns("on")
|
||
role = FactoryGirl.create(:role, :name => 'power_hosts')
|
||
role.add_permissions!(['power_hosts'])
|
||
api_user = FactoryGirl.create(:user)
|
||
api_user.update_attribute :roles, [role]
|
||
as_user(api_user) do
|
||
put :power, { :id => @bmchost.to_param, :power_action => 'status' }
|
||
end
|
||
assert_response :success
|
||
assert @response.body =~ /on/
|
||
end
|
||
|
||
context 'BMC proxy operations' do
|
||
setup :initialize_proxy_ops
|
||
|
Also available in: Unified diff
Fixes #8812 - Pass model type so search_for is called on Host
At least on version 1.6.1, the absence of this second parameter leads to a
runtime crash when it's time to validate if the current user (non-admin) is
allowed to perform a power operation on given a host via the APIv2.
The root cause of the crash is basically that search_for is called on
Host::Base by app/services/authorizer.rb:50.
(cherry picked from commit e02a2ff23dfec7361c688b469461cc1e926bba23)