Describe the task that needs to be done.(If this issue is about a bug, please describe the problem and steps to reproduce the issue. You can also include screenshots of any stack traces, or any other supporting images).
The Google OAuth2 login is returning a 500 Internal Server Error:
While the backend is returning a NullPointerException, which suggests that the User is not being added to the database before being retrieved by email in the ResponseEntity<String> loginWithGoogle(HttpServletRequest request) method:
The ResponseEntity<String> loginWithGoogle(HttpServletRequest request) method is one of the few methods that were not included in the testing for improving the total test code coverage using TDD pull request, but there were still some refactors so that it could still be used without errors during the earlier stages of the TDD. However, in the later stages of the TDD further changes caused the method to have errors and this was overlooked because the method was not included in the automated testing.
Describe how a solution to your proposed task might look like (and any alternatives considered).
A potantial solution is to remove the now redundant try and catch block:
try {
// Use or store profile information
user = this.userService.retrieveByEmail(email);
} catch (NoSuchElementException e) {
// Persist new user to the database
this.userService.addUser(name, email);
user = this.userService.retrieveByEmail(email);
}
This is because this.userService.retrieveByEmail() no longer throws NoSuchElementException when there is no User in the database matching the email. Furtheremore, conditional for if the tokens are null should be included with 401 being returned if they are null.
Notes
This is entirely @R055A fault, so @R055A will fix this
Describe the task that needs to be done. (If this issue is about a bug, please describe the problem and steps to reproduce the issue. You can also include screenshots of any stack traces, or any other supporting images).
The Google OAuth2 login is returning a 500 Internal Server Error:
While the backend is returning a NullPointerException, which suggests that the User is not being added to the database before being retrieved by email in the
ResponseEntity<String> loginWithGoogle(HttpServletRequest request)
method:The
ResponseEntity<String> loginWithGoogle(HttpServletRequest request)
method is one of the few methods that were not included in the testing for improving the total test code coverage using TDD pull request, but there were still some refactors so that it could still be used without errors during the earlier stages of the TDD. However, in the later stages of the TDD further changes caused the method to have errors and this was overlooked because the method was not included in the automated testing.Describe how a solution to your proposed task might look like (and any alternatives considered).
A potantial solution is to remove the now redundant try and catch block:
This is because
this.userService.retrieveByEmail()
no longer throws NoSuchElementException when there is no User in the database matching the email. Furtheremore, conditional for if the tokens are null should be included with 401 being returned if they are null.Notes This is entirely @R055A fault, so @R055A will fix this