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

Add roles CLI #9211

Merged
merged 2 commits into from
Oct 9, 2024
Merged

Add roles CLI #9211

merged 2 commits into from
Oct 9, 2024

Conversation

leovalais
Copy link
Contributor

closes #8744

@leovalais leovalais requested a review from a team as a code owner October 4, 2024 15:31
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Oct 4, 2024
@leovalais leovalais requested review from Khoyo and flomonster October 4, 2024 15:32
@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 2.77778% with 105 lines in your changes missing coverage. Please review.

Project coverage is 38.54%. Comparing base (a1345d2) to head (5e12ec7).
Report is 11 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/client/roles.rs 0.00% 95 Missing ⚠️
editoast/editoast_authz/src/authorizer.rs 0.00% 5 Missing ⚠️
editoast/editoast_authz/src/builtin_role.rs 16.66% 5 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #9211      +/-   ##
============================================
- Coverage     38.58%   38.54%   -0.05%     
  Complexity     2242     2242              
============================================
  Files          1285     1286       +1     
  Lines         97808    97911     +103     
  Branches       3254     3254              
============================================
- Hits          37737    37735       -2     
- Misses        58142    58247     +105     
  Partials       1929     1929              
Flag Coverage Δ
core 74.78% <ø> (ø)
editoast 71.99% <2.77%> (-0.28%) ⬇️
front 10.22% <ø> (ø)
gateway 2.22% <ø> (ø)
osrdyne 2.46% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 86.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@flomonster flomonster left a comment

Choose a reason for hiding this comment

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

LGTM.

I came across two irritating little things while testing the CLI.

editoast/src/client/roles.rs Outdated Show resolved Hide resolved
editoast/src/client/roles.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@woshilapin woshilapin left a comment

Choose a reason for hiding this comment

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

Tested and might be missing some information on the CLI. Here is an example (I removed all tracing logs).

❯ export RUST_LOG=none 
❯ editoast roles list 1
morane#1 (Bob Morane) has no roles assigned

❯ editoast roles add 1 SuperUser StdcmAdmin

❯ editoast roles list 1
Superuser
StdcmAdmin

❯ editoast roles remove 1 SuperUser StdcmAdmin

A few things to note that could be improved.

  • When adding roles, there is no message confirming everything went fine.
  • When removing roles, there is no message confirming everything went fine.
  • When adding or removing roles of a user that doesn't exist, there is also no message.
  • When listing roles and the user has no roles, the user and its ID are clearly identified... but not when the user has roles, only the roles are displayed: maybe having also the user printed would be nice

Another problem I see is that I would expect add to append roles, but it actually overwrites the existing list. See for example.

❯ editoast roles add 1 SuperUser StdcmAdmin
❯ editoast roles list 1
Superuser
StdcmAdmin
❯ editoast roles add 1 OpsWrite
❯ editoast roles list 1
OpsWrite

I would expect the last command to output 3 values.

Would it make sense to add some tests about it?

@leovalais
Copy link
Contributor Author

As discussed:

Another problem I see is that I would expect add to append roles, but it actually overwrites the existing list.

Can't reproduce.

A few things to note that could be improved.
When adding roles, there is no message confirming everything went fine.
When removing roles, there is no message confirming everything went fine.
When adding or removing roles of a user that doesn't exist, there is also no message.
When listing roles and the user has no roles, the user and its ID are clearly identified... but not when the user has roles, only the roles are displayed: maybe having also the user printed would be nice

My logic for choosing between logging and println! was that logging is only meant to be informative and provide context while println! is an output that can be used in a script (for piping into another process for ex.). This is debatable and can be changed ofc.

@woshilapin Wdyt?

@woshilapin
Copy link
Contributor

woshilapin commented Oct 7, 2024

As discussed:

Another problem I see is that I would expect add to append roles, but it actually overwrites the existing list.

Can't reproduce.

Can't reproduce either, I might have messed up somewhere, sorry.

My logic for choosing between logging and println! was that logging is only meant to be informative and provide context while println! is an output that can be used in a script (for piping into another process for ex.). This is debatable and can be changed ofc.

@woshilapin Wdyt?

I agree, that was a point of view I didn't have and a totally valid one. Fine with me.

Copy link
Contributor

@woshilapin woshilapin 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. Let's merge that 😄

Copy link
Contributor

@flomonster flomonster left a comment

Choose a reason for hiding this comment

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

Thanks!

@leovalais leovalais enabled auto-merge October 8, 2024 08:27
@leovalais leovalais added this pull request to the merge queue Oct 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 8, 2024
@woshilapin woshilapin added this pull request to the merge queue Oct 8, 2024
@woshilapin woshilapin removed this pull request from the merge queue due to a manual request Oct 8, 2024
@woshilapin woshilapin added this pull request to the merge queue Oct 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Oct 8, 2024
@leovalais leovalais added this pull request to the merge queue Oct 9, 2024
Merged via the queue into dev with commit 1da557f Oct 9, 2024
25 checks passed
@leovalais leovalais deleted the lva/roles-cli branch October 9, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RBAC: CLI interface
4 participants