Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #14330 - Provide option in hammer to change display type... #3363

Closed
wants to merge 1 commit into from

Conversation

adamruzicka
Copy link
Contributor

...for libvirt compute resource


test "should not update display_type for non-Libvirt compute resource" do
cr = compute_resources(:openstack)
put :update, { :id => cr.id, :compute_resource => { :display_type => 'SPICE' } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is silently failing, as it's missing an assert_response :success (ditto the ones above, actually). The difference between it and set_console_password is that the latter has a no-op method in ComputeResource, while display_type doesn't so it'll fail with an unknown method/attr error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed - not sure why github didn't hide this comment already

@dLobatog
Copy link
Member

@adamruzicka Thanks for this fix! It works fine, however, can you validate the user input is correct and add a test for it?

I just tried curl -H "Content-Type: application/json" -X PUT -u admin:changeme http://localhost:3000/api/v2/compute_resources/3 -d '{ "compute_resource" : { "display_type": "hiadam" } }' and it changed the display_type to hiadam which is not valid and may cause issues.

test "should not update display_type for non-Libvirt compute resource" do
cr = compute_resources(:openstack)
put :update, { :id => cr.id, :compute_resource => { :display_type => 'SPICE' } }
assert_response :error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an internal server error isn't it? Not a bad request response. Shouldn't it have the same behaviour as set_console_password?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed

@adamruzicka
Copy link
Contributor Author

@dLobatog good point, fixed it.

@@ -262,6 +262,15 @@ def set_console_password=(setpw)
self.attrs[:setpw] = nil
end

# this method is overwritten for Libvirt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this method is only used in libvirt, why do you include it here? You can also put the attr_accessible just in the Libvirt model

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make setting display_type behave in a same way as setting set_console_password (successfully do nothing when you try to update the attribute on unsupported resource)

@dLobatog
Copy link
Member

dLobatog commented Apr 5, 2016

Merged as e52bc50, thanks @adamruzicka!

@dLobatog dLobatog closed this Apr 5, 2016
@adamruzicka adamruzicka deleted the fix/14330 branch April 5, 2016 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants