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

EMS Cloud Refresh is missing #428

Merged
merged 4 commits into from Sep 5, 2018
Merged

EMS Cloud Refresh is missing #428

merged 4 commits into from Sep 5, 2018

Conversation

juliancheal
Copy link
Member

@juliancheal juliancheal commented Jul 23, 2018

When a user role only allows cloud and not infra refresh, that user
is denied refreshing as we only check for infra refresh.

Fixes BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1602413

This shows the roles defined:
screen shot 2018-07-23 at 17 50 39

@juliancheal
Copy link
Member Author

juliancheal commented Jul 23, 2018

Even with ems_cloud_refresh added, we still need additional checks. As I believe just by having either ems_cloud_refresh or ems_infra_refresh in a users role, they can perform refreshes over all Provider types, which may not be the desired outcome.

@juliancheal
Copy link
Member Author

@miq-bot assign @gtanzillo

@juliancheal
Copy link
Member Author

@gtanzillo I need to add some tests to confirm/deny my comment
#428 (comment), but apart from that, this'll fix the BZ.

@juliancheal
Copy link
Member Author

juliancheal commented Jul 23, 2018

Also I don't like where I've added ems_cloud_refresh, I would prefer a separate ems_cloud_* section.

And the same could be true for other provider types too.

@juliancheal
Copy link
Member Author

@miq-bot add_label bug, gaprindashvili/yes

config/api.yml Outdated
@@ -2073,6 +2073,8 @@
:identifier: ems_infra_new
- :name: edit
:identifier: ems_infra_edit
- :name: refresh
:identifier: ems_cloud_refresh
Copy link
Member

Choose a reason for hiding this comment

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

I've not seen multiple "names" in the list before, so I'm not sure what happens... Is there an example of this elsewhere in the file? @abellotti ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Fryguy Yeah exactly, I just put it there "for now" so it was easier for me tbh to comment out ems_infra_refresh during testing 😂

@juliancheal
Copy link
Member Author

@Fryguy @abellotti I've moved the cloud refresh lines now.

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

LGTM 👍 @abellotti, you ok with merging this?

@abellotti
Copy link
Member

We need tests.

@juliancheal
Copy link
Member Author

@abellotti Good reminder thanks. I assume there are existing tests I can look at to create new ones for this. Do you know what/where those tests are?

Sorry I'm still learning the API :)

config/api.yml Outdated
@@ -2081,6 +2081,8 @@
:identifier: ems_infra_edit
- :name: resume
:identifier: ems_infra_edit
- :name: refresh
Copy link
Member

Choose a reason for hiding this comment

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

this is off, we already have a refresh action, maybe your intent was to add the identifier to the refresh above on line 2076, similar to what query does to allow for 2 identifiers. so they can so a refresh if they have the ems_infra_refresh or ems_cloud_refresh role. In which case we have the refresh test, we could add another test to make sure refresh works with ems_cloud_refresh too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved to here after a comment by Jason. Should I put it underneath identifier: ems_infra_refresh

Yes my intent was to allow a user to refresh if they have either ems_infra_refresh or ems_cloud_refresh role

Copy link
Member

Choose a reason for hiding this comment

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

yes please, that's the intent of the multiple identifiers in the actions list (user must have at least one such role).

@@ -935,6 +948,17 @@ def failed_auth_action(id)
expect_single_action_result(failed_auth_action(provider.id.to_s).symbolize_keys)
end

it "supports cloud provider refresh" do
api_basic_authorize collection_action_identifier(:providers, :refresh)
Copy link
Member

Choose a reason for hiding this comment

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

I think for this we want the specific identifier, maybe api_basic_authorize('ems_cloud_refresh')

@@ -935,6 +948,17 @@ def failed_auth_action(id)
expect_single_action_result(failed_auth_action(provider.id.to_s).symbolize_keys)
end

it "supports cloud provider refresh" do
api_basic_authorize 'ems_cloud_refresh', collection_action_identifier(:providers, :refresh)
Copy link
Member Author

Choose a reason for hiding this comment

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

Does this look right @abellotti?

Copy link
Member

Choose a reason for hiding this comment

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

If we're just testing the cloud refresh, we only want to test the ems_cloud_refresh identifier so probably drop the , collection_action_identifier(:providers, :refresh).

Julian Cheal added 3 commits August 30, 2018 11:47
When a user role only allows cloud and not infra refresh, that user
is denied refreshing as we only check for infra refresh.
@juliancheal
Copy link
Member Author

@gtanzillo The issues breaking the API repo have been fixed, so this is now green, if @abellotti agrees, should we merge this?

@juliancheal
Copy link
Member Author

Ping @gtanzillo

@gtanzillo
Copy link
Member

@abellotti You good with merging?

@miq-bot
Copy link
Member

miq-bot commented Sep 5, 2018

Checked commits https://github.com/juliancheal/manageiq-api/compare/8fba92b1f01b253902411d2abfc7e5ced4d09120~...55df8349b68d728db4f3c508b54ccc3404eae893 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@juliancheal
Copy link
Member Author

@abellotti @gtanzillo change made, all green ❇️

@abellotti
Copy link
Member

Thanks @juliancheal for the update, LGTM!! 👍

@gtanzillo gtanzillo added this to the Sprint 94 Ending Sept 10, 2018 milestone Sep 5, 2018
@gtanzillo gtanzillo merged commit 889483e into ManageIQ:master Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants