Actions
Bug #16196
closedFilter with Image resource type limited by search to compute resource does not work
Difficulty:
trivial
Triaged:
Pull request:
Description
Description¶
When you try to create filter that would limit image permissions limited to some compute resource it fails due to bad reference in ruby model.
I Already have a fix here:
https://github.com/theforeman/foreman/compare/1.12-stable...martin-ducar-gd:1.12-stable
However I can't find proper place where to place relevant test as this is highly specific. So some advice would be appreciated
Reproducer¶
#Change these variables to reflect your instalation ROLE_ID=20 HOST=foreman.example.net AUTH="-u test_user:test_pass" SEARCH="compute_resource = test1" curl --fail $AUTH "https://$HOST/api/v2/permissions?per_page=500" >/dev/null 2>&1 ret=$? VIEW_IMAGES_PERM_ID=$(curl --fail $AUTH "https://$HOST/api/v2/permissions?per_page=500" |grep results |sed -e "s/.*view_images\",\"id\":\([0-9][0-9]*\),.*/\1/g") [ -z $VIEW_IMAGES_PERM_ID ] && ret=1 if [ $ret -eq 0 ]; then curl --fail $AUTH -H "Content-Type: application/json" -X POST --data "{\"filter\": {\"role_id\": $ROLE_ID, \"search\": \"$SEARCH\", \"permission_ids\": [$VIEW_IMAGES_PERM_ID]}}" "https://$HOST/api/v2/filters" else echo "ERROR: failed to get view_images permission id" false fi
Expected result¶
{"id":10,"search":"compute_resource = test1","resource_type":"Image","unlimited?":false,"created_at":"2016-08-19T10:00:00Z","updated_at":"2016-08-19T10:00:00Z","role":{"name":"test_role1","id":20},"permissions":[{"name":"view_images","id":75,"resource_type":"Image"}]}
Actual result¶
{ "error": {"id":null,"errors":{"search":["Invalid search query: relation 'compute_resources' not one of audits, operatingsystem, compute_resource, architecture, hosts "]},"full_messages":["Search Invalid search query: relation 'compute_resources' not one of audits, operatingsystem, compute_resource, architecture, hosts "]} }
Actions