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 isValidUsername method #11

Merged
merged 2 commits into from
Apr 12, 2024
Merged

Add isValidUsername method #11

merged 2 commits into from
Apr 12, 2024

Conversation

MrCreosote
Copy link
Member

No description provided.

@MrCreosote MrCreosote requested review from briehl and Xiangs18 April 10, 2024 02:20
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.08%. Comparing base (d48bd24) to head (c323ad3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #11      +/-   ##
============================================
+ Coverage     95.58%   96.08%   +0.49%     
- Complexity       77       88      +11     
============================================
  Files             5        5              
  Lines           204      230      +26     
  Branches         39       44       +5     
============================================
+ Hits            195      221      +26     
  Misses            7        7              
  Partials          2        2              

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

badlist.add(user);
}
}
final URI target = rootURI.resolve("api/V2/users/?list=" + String.join(",", badlist));
Copy link

@Xiangs18 Xiangs18 Apr 11, 2024

Choose a reason for hiding this comment

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

Let's see if my understanding is correct.

badlist may consist gibberish usernames and expired ones. And you call api/V2/users/ to distinguish them?

Copy link
Member Author

Choose a reason for hiding this comment

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

badlist contains any usernames that don't exist in the cache and are valid usernames, and the endpoint returns extant usernames mapped to their display names

Copy link

@Xiangs18 Xiangs18 Apr 11, 2024

Choose a reason for hiding this comment

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

Saw your test examples. Make sense now. Thanks!

Copy link

@Xiangs18 Xiangs18 left a comment

Choose a reason for hiding this comment

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

LGTM!

throws IOException, AuthException {
// theoretically someone could submit hundreds of users and hit the url size limit
// don't worry about that for now.
checkToken(token);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a valid token for this? I can see a case (mainly at account creation) where you don't have your own username yet, thus no token (maybe a temp token via an auth provider?), and you want to see if your username is available or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this endpoint requires a token. For the use case you're talking about there's https://github.com/kbase/auth2/blob/develop/src/main/java/us/kbase/auth2/service/ui/Login.java#L136-L150

@MrCreosote MrCreosote merged commit 64b2ed6 into main Apr 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants