diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/UserService.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/UserService.java index 452c32f1..e3bc182d 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/UserService.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/UserService.java @@ -15,7 +15,6 @@ import gov.cabinetoffice.gap.adminbackend.repositories.GrantAdminRepository; import gov.cabinetoffice.gap.adminbackend.repositories.GrantApplicantRepository; import gov.cabinetoffice.gap.adminbackend.services.encryption.AwsEncryptionServiceImpl; -import gov.cabinetoffice.gap.adminbackend.utils.HelperUtils; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springframework.core.ParameterizedTypeReference; @@ -117,10 +116,8 @@ public Boolean verifyAdminRoles(final String emailAddress, final String roles) { @PreAuthorize("hasAnyRole('ADMIN', 'SUPER_ADMIN')") public GrantAdmin getGrantAdminIdFromUserServiceEmail(final String email, final String jwt) { try { - String roles = HelperUtils.getAdminSessionForAuthenticatedUser().getRoles(); - String uriRole = roles.contains("SUPER_ADMIN") ? "SUPER_ADMIN" : "ADMIN"; UserV2DTO response = webClientBuilder.build().get() - .uri(userServiceConfig.getDomain() + "/user/email/" + email + "?role=" + uriRole) + .uri(userServiceConfig.getDomain() + "/user/email/" + email) .cookie(userServiceConfig.getCookieName(), jwt).retrieve().bodyToMono(UserV2DTO.class).block(); return grantAdminRepository.findByGapUserUserSub(response.sub()).orElseThrow(() -> new NotFoundException( diff --git a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/UserServiceTest.java b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/UserServiceTest.java index 0a7ef912..4c097965 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/UserServiceTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/UserServiceTest.java @@ -218,7 +218,7 @@ void getGrantAdminIdFromEmailReturnsAValidGrantAdminIdForAdmin() { when(userServiceConfig.getDomain()).thenReturn("http://localhost:8080"); when(webClientBuilder.build()).thenReturn(mockWebClient); when(mockWebClient.get()).thenReturn(mockRequestHeaderUriSpec); - when(mockRequestHeaderUriSpec.uri("http://localhost:8080/user/email/" + email + "?role=ADMIN")) + when(mockRequestHeaderUriSpec.uri("http://localhost:8080/user/email/" + email)) .thenReturn(mockRequestHeadersSpec); when(mockRequestHeadersSpec.cookie(anyString(), anyString())).thenReturn(mockRequestHeadersSpec); when(mockRequestHeadersSpec.retrieve()).thenReturn(mockResponseSpec); @@ -254,7 +254,7 @@ void getGrantAdminIdFromEmailReturnsAValidGrantAdminIdForSuperAdmin() { when(userServiceConfig.getDomain()).thenReturn("http://localhost:8080"); when(webClientBuilder.build()).thenReturn(mockWebClient); when(mockWebClient.get()).thenReturn(mockRequestHeaderUriSpec); - when(mockRequestHeaderUriSpec.uri("http://localhost:8080/user/email/" + email + "?role=SUPER_ADMIN")) + when(mockRequestHeaderUriSpec.uri("http://localhost:8080/user/email/" + email)) .thenReturn(mockRequestHeadersSpec); when(mockRequestHeadersSpec.cookie(anyString(), anyString())).thenReturn(mockRequestHeadersSpec); when(mockRequestHeadersSpec.retrieve()).thenReturn(mockResponseSpec);