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

Bug #4984 fixed-method getAllAuthorities in UBSClientServiceImpl #947

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

LiliaMokhnatska
Copy link
Contributor

changed method getAllAuthorities in UBSClientServiceImpl and in UserRemoteClientFallbackFactory

@LiliaMokhnatska LiliaMokhnatska added bug Something isn't working review done labels Jan 18, 2023
@LiliaMokhnatska LiliaMokhnatska removed bug Something isn't working review done labels Jan 18, 2023
juseti
juseti previously approved these changes Jan 18, 2023
@juseti juseti dismissed their stale review January 18, 2023 15:57

All checks have failed

@LiliaMokhnatska LiliaMokhnatska force-pushed the ita-social-progects/Bug#4984-fixed-response branch from 90239e1 to 33fa371 Compare January 18, 2023 17:50
@juseti juseti self-requested a review January 18, 2023 18:19
}

@Override
public void updateEmployeesAuthorities(UserEmployeeAuthorityDto dto, String email) {
Employee employee = employeeRepository.findByEmail(dto.getEmployeeEmail())
.orElseThrow(() -> new NotFoundException(EMPLOYEE_DOESNT_EXIST));

Choose a reason for hiding this comment

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

Why did you remove this?
Is it possible to update authorities for a non-existent employee?

@@ -1907,13 +1907,15 @@ public TariffsForLocationDto getTariffForOrder(Long id) {
public Set<String> getAllAuthorities(String email) {
Employee employee = employeeRepository.findByEmail(email)
.orElseThrow(() -> new NotFoundException(EMPLOYEE_DOESNT_EXIST));
return userRemoteClient.getAllAuthorities(employee.getEmail());
Set<String> authorities = userRemoteClient.getAllAuthorities(employee.getEmail());
if (authorities.isEmpty()) {

Choose a reason for hiding this comment

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

please add test for this case

Choose a reason for hiding this comment

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

Is it not a valid case when an employee does not have any authorities?
Do we set some authorities when we create employees?

And according to your changes, we will have empty authorities list if some error happens when we call /user/get-all-authorities endpoint
In this case, the employee could have some authorities but we could not get them and your message COULD_NOT_RETRIEVE_EMPLOYEE_AUTHORITY will not be valid

@@ -58,7 +59,7 @@ public void sendEmailNotification(NotificationDto notification, String email) {
@Override
public Set<String> getAllAuthorities(String email) {
log.error(ErrorMessage.COULD_NOT_RETRIEVE_EMPLOYEE_AUTHORITY, throwable);
return Collections.singleton(throwable.getMessage());
return Collections.emptySet();

Choose a reason for hiding this comment

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

please add test for this case

@@ -259,7 +259,8 @@ public ResponseEntity<HttpStatus> deleteEmployeeImage(@PathVariable Long id) {
@ApiResponse(code = 200, message = HttpStatuses.OK),
@ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST),
@ApiResponse(code = 401, message = HttpStatuses.UNAUTHORIZED),
@ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN)
@ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN),
@ApiResponse(code = 404, message = HttpStatuses.NOT_FOUND)

Choose a reason for hiding this comment

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

please add test

@@ -31,6 +31,7 @@ public String findUuidByEmail(String email) {
@Override
public Optional<UserVO> findNotDeactivatedByEmail(String email) {
log.error(ErrorMessage.USER_WITH_THIS_EMAIL_DOES_NOT_EXIST + email, throwable);

Choose a reason for hiding this comment

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

please remove this blank line

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

23.1% 23.1% Coverage
0.0% 0.0% Duplication

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