DT-2918: Add user status info to the user in the GET /me call#2817
Open
DT-2918: Add user status info to the user in the GET /me call#2817
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the GET /api/user/me response to include Sam-derived userStatusInfo (including Terms of Service acceptance), using Sam’s “combined state” endpoint to reduce UI follow-up calls.
Changes:
- Add a Sam “combined state” API call and map it into
UserStatusInfo.tosAccepted. - Attach
userStatusInfoonto theUserobject returned fromGET /api/user/me. - Update OpenAPI schemas and add/adjust unit tests for the new behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/broadinstitute/consent/http/db/SamDAO.java | Adds getCombinedUserStatusInfo and Gson singleton usage for parsing |
| src/main/java/org/broadinstitute/consent/http/service/sam/SamService.java | Exposes getCombinedUserStatusInfo passthrough |
| src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java | Switches status lookup to combined-state call |
| src/main/java/org/broadinstitute/consent/http/resources/UserResource.java | Enriches /me response with userStatusInfo |
| src/main/java/org/broadinstitute/consent/http/models/sam/UserStatusInfo.java | Adds tosAccepted field |
| src/main/java/org/broadinstitute/consent/http/models/sam/CombinedState.java | Adds model wrapper for Sam combined-state response |
| src/main/java/org/broadinstitute/consent/http/models/User.java | Adds userStatusInfo field to API user model |
| src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java | Adds combined-state URL path helper |
| src/main/resources/assets/schemas/User.yaml | Documents userStatusInfo on User schema |
| src/main/resources/assets/schemas/SamUserStatusInfo.yaml | New schema for userStatusInfo object |
| src/test/java/org/broadinstitute/consent/http/service/dao/SamDAOTest.java | Adds combined-state DAO tests + refactors randomness helpers |
| src/test/java/org/broadinstitute/consent/http/service/SamServiceTest.java | New tests for SamService method passthroughs/order |
| src/test/java/org/broadinstitute/consent/http/resources/UserResourceTest.java | Adds tests validating /me includes userStatusInfo |
| src/test/java/org/broadinstitute/consent/http/authentication/AuthorizationHelperTest.java | Updates tests to mock combined-state call |
| src/test/java/org/broadinstitute/consent/http/AbstractTestHelper.java | Adds randomBoolean() helper |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/org/broadinstitute/consent/http/resources/UserResource.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Addresses
Partially addresses https://broadworkbench.atlassian.net/browse/DT-2918
See front end PR here: DataBiosphere/duos-ui#3337
Summary
This PR makes a different call to Sam to get the user's combined state when any API call is made (during the initial OAuth filter process). It then tacks on an additional field to
UserStatusInfoto reflect the currenttosAcceptedthat we would normally get from the diagnostics call. The generateduserStatusInfois then added to the user response object in the currentGET /api/user/mecall.Example response snippet from
GET /api/user/me:The reason to do this is to reduce the number of API calls the UI has to make when a user signs in. Currently, it calls the me API and then after waiting for that, it makes a call to the diagnostics API which returns terms of service information:
In a future UI PR, we can trim that down and skip the diagnostics API call altogether because we'll have terms of service information stored directly on the user.
Have you read CONTRIBUTING.md lately? If not, do that first.