-
Notifications
You must be signed in to change notification settings - Fork 897
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
Return correct resource hrefs #14549
Return correct resource hrefs #14549
Conversation
# Ensures hrefs are consistent with those of the collection they were requested from | ||
return reftype if collection_class.descendants.include?(rclass) || collection_class == rclass | ||
|
||
collection_config.name_for_klass(rclass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collection_config.name_for_klass(rclass) || reftype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if above too can't be combined as:
return reftype if collection_class == rclass
collection_config.name_for_subclass(rclass) || reftype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work with the provider_class parameter ?
GET /api/vms?collection_class=ManageIQ::Providers::CloudManager::Vm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abellotti it works with the collection_class
parameter
collection_class = collection_class(type) | ||
|
||
# Ensures hrefs are consistent with those of the collection they were requested from | ||
return reftype if collection_class.descendants.include?(rclass) || collection_class == rclass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jntullo can you switch those 2 tests, collection_class == rclass would be more common, so we'd improve the performance here.
@@ -390,6 +390,7 @@ def init_st(service_template, resource_action) | |||
|
|||
it "supports single order request" do | |||
api_basic_authorize subcollection_action_identifier(:service_catalogs, :service_templates, :order) | |||
order_request["href"] = /service_requests/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be replaced by line 400 below with something like:
expect_single_resource_query(order_request.merge("href" => a_string_matching(service_requests_url)))
though I'm not sure if a_string_matching works with that method. maybe just.
expect_single_resource_query(order_request.merge("href" => /service_requests/) )
Thanks
return retype is no name for klass
Checked commit jntullo@760c5e2 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Thanks @jntullo for fixing this !! 😍 |
Return correct resource hrefs (cherry picked from commit fbb84f2)
Fine backport details:
|
@jntullo @abellotti will it be a problem backporting this to Euwe? |
@simaishi there are some conflicts, I will create a separate PR for Euwe |
@jntullo thank you - please remove the |
@miq_bot remove_label conflict PR: #15238 |
Backported to Euwe via #15238 |
This PR fixes a bug where the hrefs being returned do not match those of the collection they were requested from.
For a
service request
retrieved via/api/requests/:id
, the resource is being returned with:On the collection,
GET /api/requests?expand=resources
returns inconsistent hrefs, ie:This change ensures that all hrefs from
GET /api/requests?expand=resources
will be consistent:and that the call to
GET /api/requests/:id
will also return a matching href:for any subclass of
MiqRequest
Additional tests for service catalogs and tenant quotas were added to ensure that the correct href is being returned when it is a different object than the requested resource
@miq-bot add_label bug, api
@miq-bot assign @abellotti