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

Tags policy permissions #2738

Merged
merged 13 commits into from
Jul 4, 2024
Merged

Tags policy permissions #2738

merged 13 commits into from
Jul 4, 2024

Conversation

CDimonaco
Copy link
Member

Description

Permissions on tags creation/delete
Recording 2024-07-03 at 12 56 49

Abilities

  • all:host_tags - All operations on host tags
  • all:cluster_tags - All operations on cluster tags
  • all:database_tags - All operations on database tags
  • all:sap_systems_tags - All operations on sap_systems tags

The Tags component prevent the click on delete/add tag functionality when the abilities are not compatible with the one configured in the component.

How was this tested?

Automated tests

@CDimonaco CDimonaco added enhancement New feature or request elixir Pull requests that update Elixir code labels Jul 3, 2024
@CDimonaco CDimonaco requested review from arbulu89 and EMaksy July 3, 2024 10:57
@CDimonaco CDimonaco self-assigned this Jul 3, 2024
@CDimonaco CDimonaco force-pushed the tags_policy_permissions branch from e83f663 to 92ef013 Compare July 3, 2024 11:07
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Great work!
Just some few comments (some are personal opinions).
Besides that 2 things:

  • In the acceptance criteria, we have the entry of remove cross from existing tags, which you didn't implement. We can merge now, and wait to see what @jagabomb says. Changing in next PR is simple

  • I don't really like the tendency of adding new "corner case" tests (like this, the forbidden disabled scenario), in the top of the test files. The test files should have some logical order. In my opinion, the normal or even first written tests should be on top, and the new ones after that. I find it pretty "ilogical" to add the new test cases on the top of the file, when they are the last things we implemented. My OCD I guess hehe

lib/trento/tags/policy.ex Outdated Show resolved Hide resolved
test/trento/tags/policy_test.exs Outdated Show resolved Hide resolved
test/trento/tags/policy_test.exs Show resolved Hide resolved
@@ -13,31 +13,6 @@ defmodule TrentoWeb.V1.HostControllerTest do
setup :setup_api_spec_v1
setup :setup_user

describe "forbidden routes" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this change. I have already done it in other PR, and it will conflict otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

@CDimonaco I mean, you didn't do any change here as far as I see, just move the describe to the bottom, which I did in the latest PR i merged some minutes ago

test/trento_web/controllers/v1/tags_controller_test.exs Outdated Show resolved Hide resolved
@@ -16,6 +16,9 @@ const middlewares = [];
const mockStore = configureStore(middlewares);

export const defaultInitialState = {
user: {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will conflict with my PR as well 🙈

assets/js/pages/ClusterDetails/ClustersList.test.jsx Outdated Show resolved Hide resolved
assets/js/common/Tags/Tags.jsx Outdated Show resolved Hide resolved
assets/js/common/Tags/Tags.jsx Show resolved Hide resolved
@CDimonaco CDimonaco force-pushed the tags_policy_permissions branch from f6e29aa to aeafe74 Compare July 3, 2024 14:41
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Thank you!
PD: We will need to create some ordering standard at some point. You are moving all the props I put at the bottom to the top XD

@@ -13,31 +13,6 @@ defmodule TrentoWeb.V1.HostControllerTest do
setup :setup_api_spec_v1
setup :setup_user

describe "forbidden routes" do
Copy link
Contributor

Choose a reason for hiding this comment

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

@CDimonaco I mean, you didn't do any change here as far as I see, just move the describe to the bottom, which I did in the latest PR i merged some minutes ago

test/trento_web/controllers/v1/host_controller_test.exs Outdated Show resolved Hide resolved
assets/js/pages/DatabasesOverview/DatabasesOverview.jsx Outdated Show resolved Hide resolved
assets/js/pages/HostsList/HostsList.test.jsx Outdated Show resolved Hide resolved
@CDimonaco CDimonaco force-pushed the tags_policy_permissions branch from aeafe74 to 3500cd9 Compare July 3, 2024 15:11
@CDimonaco CDimonaco force-pushed the tags_policy_permissions branch from 3500cd9 to 2f5e6bf Compare July 3, 2024 15:19
@CDimonaco CDimonaco merged commit b9414b7 into main Jul 4, 2024
25 of 26 checks passed
@CDimonaco CDimonaco deleted the tags_policy_permissions branch July 4, 2024 07:43
Copy link
Member

@EMaksy EMaksy left a comment

Choose a reason for hiding this comment

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

Lgtm!

);

expect(screen.queryByText('Add Tag')).toHaveClass('opacity-50');
// grab the X
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comment !

@@ -183,4 +188,60 @@ defmodule TrentoWeb.V1.TagsControllerTest do
assert 404 == conn.status
end
end

describe "forbidden actions" do
test "should not return forbidden on any controller action if the user have the right ability for the tag resource",
Copy link
Member

Choose a reason for hiding this comment

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

I guess it is a typo if the user have --> if the user has

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants