Skip to content

Conversation

NehaBroad
Copy link
Contributor


PR checklist

  • This PR meets the Acceptance Criteria in the JIRA story
  • The JIRA story has been moved to Dev Review
  • This PR includes appropriate unit tests
  • I have run and tested this change locally
  • I have run the E2E tests on ths change against my local UI and/or API server with yarn test-local or yarn test-local-devup
  • If this includes a UI change, I have taken screen recordings or screenshots of the new behavior and notified the PO and UX designer
  • If this includes an API change, I have updated the appropriate Swagger definitions and notified API consumers
  • If this includes a new feature flag, I have created and linked new JIRA tickets to (a) turn on the feature flag and (b) remove it later

hasAckedTermsOfService: boolean;
}

// TODO: Rename this to TermsOfService
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be creating a follow up PR to rename this component

@NehaBroad NehaBroad marked this pull request as ready for review March 22, 2022 19:25
boolean termsOfServiceAccepted = false;
try {
termsOfServiceAccepted = fireCloudService.getUserTermsOfServiceStatus();
} catch (ApiException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we catch this exception, or simply let the underlying exception propagate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, where does log.log get stored to? Does it go into GCP somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to log the message with userId, was not sure if the underlying exception will do the same
@evrii yes it goes to google cloud console logger

DbUser loggedInUser = userAuthenticationProvider.get().getUser();
userService.submitAouTermsOfService(loggedInUser, termsOfServiceVersion);
userService.acceptTerraTermsOfService(loggedInUser);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does a HttpStatus of NO_CONTENT represent? Does it represent success or failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It represents Success void return

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes - this is HTTP 204

boolean termsOfServiceAccepted = false;
try {
termsOfServiceAccepted = fireCloudService.getUserTermsOfServiceStatus();
} catch (ApiException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, where does log.log get stored to? Does it go into GCP somewhere?

}

@Test
public void testMe_UserHasNotAcceptedTerraTOS()
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "Me" mean in this function name? I see it in the function below too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the profilecontroller has a function getMe() that returns the information about logged in user, thats why the test has tests like testMe_success() etc.

@NehaBroad NehaBroad marked this pull request as draft March 23, 2022 14:34
@NehaBroad NehaBroad marked this pull request as ready for review March 24, 2022 15:33
@NehaBroad
Copy link
Contributor Author

After the change to call the single endpoint (getUserTerraTOS), rather than throwing error in profileController. The terra TOS check will happen just the first time user logs in, not on every page

DbUser loggedInUser = userAuthenticationProvider.get().getUser();
userService.submitAouTermsOfService(loggedInUser, termsOfServiceVersion);
userService.acceptTerraTermsOfService(loggedInUser);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes - this is HTTP 204

}

@Override
public ResponseEntity<Boolean> getUserTerraTermsOfServiceStatus() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The AC for this story includes checking for AoU TOS compliance here as well. If false, we can exit early: we are not compliant. We can then check Terra only when aou-tos=true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, i did not check that because i assumed the account creation was successful hence the AoU TOS has been accepted.
I'll add the check and some tests

<AccountCreationTos
filePath='/aou-tos.html'
onComplete={() => {
onComplete={(tosVersion) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the associated spec file is not passing a tosVersion.

@evrii
Copy link
Collaborator

evrii commented Mar 24, 2022

I am not sure if this is significant or not, but it looks like the TOS page for account creation and non-compliant TerraTOS do look different:
Account Creation:
image

Old TOS:
image

@NehaBroad
Copy link
Contributor Author

@evrii Yes i had to update the HTML height for existing user TOS screen. I can tweek it a little more. In case there is something else i am missing do let me know

Copy link
Collaborator

@evrii evrii left a comment

Choose a reason for hiding this comment

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

In my first pass, the functionality worked fine.

I was trying to see if I could get the TOS screen to show up again if I changed the TOS version. Instead of changing the TOS version, I deleted my record in user_terms_of_service. Now, I cannot seem to get passed the DAR page. I am not sure if this is something to be concerned about or not.

@evrii
Copy link
Collaborator

evrii commented Mar 24, 2022

@evrii Yes i had to update the HTML height for existing user TOS screen. I can tweek it a little more. In case there is something else i am missing do let me know

No worries. It does not seem like a big deal to me. The only things I noticed were the different background colors and the logo in the top left of the screen.

@NehaBroad
Copy link
Contributor Author

@evrii Hmm i was not able to reproduce this, but would really like to debug it with you tomorrow to confirm whats happening

boolean | undefined
>(false);
useEffect(() => {
if (
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice


@Override
public void validateTermsOfService(Integer tosVersion) {
public void validateAllOfUsTermsOfService(Integer tosVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

when this was originally written, we only checked AOU TOS when creating the user. If the TOS was wrong, it made sense to throw a Bad Request.

But now we should be more thoughtful. If an existing user has an outdated TOS, that's not really what I would call a Bad Request. So I'd prefer the previous signature with Boolean

Copy link
Contributor Author

@NehaBroad NehaBroad Mar 24, 2022

Choose a reason for hiding this comment

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

I prefer BadRequest (or maybe Unautorized) because it had message that helped identify why exactly the validation failed, is it a bad user who has not selected TOS (AoU or terra) in the first place or just outdated version .

That could also help in showing the user a more appropriate message if we need to change the UX.

I can make it boolean right now , so that we are unblocked and can discuss this further tomorrow

Copy link
Collaborator

@jmthibault79 jmthibault79 left a comment

Choose a reason for hiding this comment

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

Minor changes requested, but we're looking good!

// by approving the latest AOU Terms of Service, the user also approves the latest Terra TOS
try {
userService.validateTermsOfService(dbUser);
// getUserTermsOfServiceStatus and acceptTos will take care of scenario where user has not
Copy link
Collaborator

Choose a reason for hiding this comment

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

the old comment has important context that we should retain here.

This new comment is good too, but it has some grammar issues that we should fix before merging.

}
if (tosVersion != LATEST_AOU_TOS_VERSION) {
throw new BadRequestException("Terms of Service version is not up to date");
throw new BadRequestException("All of Us Terms of Service version is not up to date");
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch!


// does not throw
userService.validateTermsOfService(user);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this test is not valid anymore. need to check for return value true

return disabled;
};

export const useNeedsToAcceptTOS = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool, I don't think that I have ever seen useEffect used in a custom hook before.

Comment on lines +469 to +476
try {
final int tosVersion =
userTermsOfServiceDao.findByUserIdOrThrow(dbUser.getUserId()).getTosVersion();
return tosVersion == LATEST_AOU_TOS_VERSION;
} catch (BadRequestException ex) {
// In case user doesnt have any terms of service
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to throw an exception and catch it here. This also works:

Suggested change
try {
final int tosVersion =
userTermsOfServiceDao.findByUserIdOrThrow(dbUser.getUserId()).getTosVersion();
return tosVersion == LATEST_AOU_TOS_VERSION;
} catch (BadRequestException ex) {
// In case user doesnt have any terms of service
return false;
}
return userTermsOfServiceDao
.findFirstByUserIdOrderByTosVersionDesc(dbUser.getUserId())
.map(u -> u.getTosVersion() == LATEST_AOU_TOS_VERSION)
.orElse(false);

@NehaBroad NehaBroad merged commit 29e1a34 into main Mar 29, 2022
@NehaBroad NehaBroad deleted the nsaxena/RW7860TOS branch March 29, 2022 17:15
chenchals pushed a commit that referenced this pull request Mar 31, 2022
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