-
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
[api] Add support for Cloud Volume Delete action #15097
[api] Add support for Cloud Volume Delete action #15097
Conversation
This would have to be a queued Delete operation. @miq-bot add_label wip |
7a7a9c2
to
7c17a6c
Compare
config/api.yml
Outdated
:resource_actions: | ||
:get: | ||
- :name: read | ||
:identifier: cloud_volume | ||
:post: | ||
- :name: query |
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.
This doesn't seem like part of this PR - was this ne cessary?
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.
Yes, you're right, not related to this PR.
I have removed it.
@@ -477,10 +477,17 @@ | |||
:post: | |||
- :name: query | |||
:identifier: cloud_volume_show_list | |||
- :name: delete |
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 see there's a test below but I don't think it covers the bulk delete you've added here - can you add one?
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.
The only reason I have the delete
here is to avoid the below error.
That's the only purpose it serves.
Failures:
1) Cloud Volumes API can delete cloud volumes through POST
Failure/Error:
Api::ApiConfig.collections[type][selection][method]
.detect { |spec| spec[:name] == action.to_s }[:identifier]
NoMethodError:
undefined method `[]' for nil:NilClass
# ./spec/support/api_helper.rb:113:in `action_identifier'
# ./spec/support/api_helper.rb:117:in `collection_action_identifier'
# ./spec/requests/api/cloud_volumes_spec.rb:51:in `block (2 levels) in <top (required)>'
I have also tried using
api_basic_authorize action_identifier(:cloud_volumes, :delete, :resource_actions, :post)
but that requires the delete
in collection_actions
as well.
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.
@imtayadeway What do you think of the above?
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.
@AparnaKarve I think I confused myself :) This is correct - it's the one below that's not covered by a test
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.
The resource_actions
delete
which is under post
is covered by a test.
And that would be the test for it https://github.com/ManageIQ/manageiq/pull/15097/files#diff-3eaddeceef284aecbf30c2f57658d722R52
@AparnaKarve can you also add some tests to ensure that RBAC will kick you out if not authorized? Otherwise LGTM! |
7c17a6c
to
6906207
Compare
config/api.yml
Outdated
@@ -468,7 +468,7 @@ | |||
:identifier: cloud_volume | |||
:options: | |||
- :collection | |||
:verbs: *gp | |||
:verbs: *gpppd |
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 think you only need gpd
here....
Since you're adding the 'd' - can you add tests for deleting via DELETE using the collection/member routes, and that RBAC is enforced for both of these too? I have a feeling this may require some more configuration (i.e. adding an explicit entry for delete with the appropriate identifier for each)
899b46e
to
c5ab5ef
Compare
0ef853a
to
44b99c0
Compare
@imtayadeway Thanks for all your input so far. |
|
||
cloud_volume1 = FactoryGirl.create(:cloud_volume, :ext_management_system => aws, :name => "CloudVolume1") | ||
|
||
api_basic_authorize action_identifier(:cloud_volumes, :delete) |
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.
This needs to be action_identifier(:cloud_volumes, :delete, :resource_actions, :delete)
- which I think does not exist (yet). Can you add that also confirm that we reject DELETES for users that don't have the appropriate role?
|
||
cloud_volume1 = FactoryGirl.create(:cloud_volume, :ext_management_system => aws, :name => "CloudVolume1") | ||
|
||
api_basic_authorize action_identifier(:cloud_volumes, :delete) |
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.
Similarly action_identifier(:cloud_volumes, :delete, :collection_actions, :delete)
+ test for rejection
@AparnaKarve this is looking great, I just have a couple of suggestions above |
44b99c0
to
2006899
Compare
api_basic_authorize collection_action_identifier(:cloud_volumes, :delete, :post) | ||
|
||
expected = { | ||
'results' => [ |
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.
We may not be able to guarantee the order here, so you may want to use a_collection_containing_exactly()
over []
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.
LGTM with just one more comment above. Thanks! 🎈
@imtayadeway I just happened to notice this Thank you for requesting specs for all possible DELETE cases :) |
@miq-bot remove_label wip |
@abellotti Please review/merge. Thanks. |
config/api.yml
Outdated
@@ -477,10 +477,21 @@ | |||
:post: | |||
- :name: query | |||
:identifier: cloud_volume_show_list | |||
- :name: delete | |||
:identifier: cloud_volume_delete | |||
:delete: |
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.
we don't expose DELETE method on the collection itself, so this is not consistent with the others. DELETE targets should be fully identified by the URL itself, even though the standard does not prohibit it, some other vendors just ignore the body. Let's stick to POST for bulk delete unless this is an issue. Thanks.
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 I have removed the DELETE method on the collection and the related specs (6ca849f). Please review. Thanks.
6135763
to
6ca849f
Compare
Checked commits AparnaKarve/manageiq@47a9e32~...6ca849f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Thanks @AparnaKarve for the enhancement. LGTM!! 👍 |
Added support for deleting Cloud Volumes via POST.
/cc @abellotti