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

List user roles #875

Merged
merged 3 commits into from
Nov 8, 2022
Merged

List user roles #875

merged 3 commits into from
Nov 8, 2022

Conversation

pdeziel
Copy link
Collaborator

@pdeziel pdeziel commented Nov 7, 2022

Scope of changes

This adds a simple endpoint to list the available user roles, which is currently hard coded in the BFF, in order to unblock frontend development of the collaborators feature.

Type of change

  • bug fix
  • new feature
  • documentation
  • other (describe)

Acceptance criteria

Describe how reviewers can test this change to be sure that it works correctly. Add a checklist if possible

Author checklist

  • I have manually tested the change and/or added automation in the form of unit tests or integration tests
  • I have updated the dependencies list
  • I have recompiled and included new protocol buffers to reflect changes I made
  • I have added new test fixtures as needed to support added tests
  • Check this box if a reviewer can merge this pull request after approval (leave it unchecked if you want to do it yourself)
  • I have moved the associated Shortcut story to "Ready for Review"

Reviewer(s) checklist

  • Any new user-facing content that has been added for this PR has been QA'ed to ensure correct grammar, spelling, and understandability.

@pdeziel pdeziel requested a review from bbengfort November 7, 2022 23:12
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2022

Codecov Report

Base: 44.01% // Head: 44.03% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (94add14) compared to base (7dddbb7).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #875      +/-   ##
==========================================
+ Coverage   44.01%   44.03%   +0.01%     
==========================================
  Files         635      635              
  Lines       23176    23192      +16     
  Branches     1416     1416              
==========================================
+ Hits        10202    10213      +11     
- Misses      11639    11642       +3     
- Partials     1335     1337       +2     
Flag Coverage Δ
unittests 44.03% <ø> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...com/trisacrypto/directory/pkg/bff/api/v1/client.go 50.13% <0.00%> (-0.14%) ⬇️
...github.com/trisacrypto/directory/pkg/bff/server.go 66.30% <0.00%> (+0.12%) ⬆️
web/gds-admin-ui/src/utils/index.js 44.75% <0.00%> (+0.69%) ⬆️
.../github.com/trisacrypto/directory/pkg/bff/users.go 13.28% <0.00%> (+2.79%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

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

Thanks for adding this in so quickly!

@@ -19,6 +19,7 @@ type BFFClient interface {

// User Management Endpoints
Login(context.Context) error
ListUserRoles(context.Context) (map[string]struct{}, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why a map[string]struct{} instead of []string? How does this render in JSON - something like below?

{
    "Organization Leader": {},
    "Organization Contributor": {}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't want to impose ordering on it but I can make it a []string if that's easier.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think []string is probably simpler.

func (s *APIv1) ListUserRoles(ctx context.Context) (out map[string]struct{}, err error) {
// Make the HTTP request
var req *http.Request
if req, err = s.NewRequest(ctx, http.MethodGet, "/v1/users/roles", nil, nil); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

good endpoint

@pdeziel pdeziel merged commit eee7776 into main Nov 8, 2022
@pdeziel pdeziel deleted the sc-11016 branch November 8, 2022 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants