Skip to content

Commit

Permalink
[DUOS-3018][risk=no] Remove User-Institution Emails (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong authored Mar 20, 2024
1 parent dcb3279 commit 41c6cfa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public void run(ConsentConfiguration config, Environment env) {
env.jersey().register(new SwaggerResource(config.getGoogleAuthentication()));
env.jersey().register(new StatusResource(env.healthChecks()));
env.jersey().register(
new UserResource(samService, userService, datasetService, supportRequestService,
acknowledgementService));
new UserResource(samService, userService, datasetService, acknowledgementService));
env.jersey().register(new TosResource(samService));
env.jersey().register(injector.getInstance(VersionResource.class));
env.jersey().register(new VoteResource(userService, voteService, electionService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.broadinstitute.consent.http.models.dto.DatasetDTO;
import org.broadinstitute.consent.http.service.AcknowledgementService;
import org.broadinstitute.consent.http.service.DatasetService;
import org.broadinstitute.consent.http.service.SupportRequestService;
import org.broadinstitute.consent.http.service.UserService;
import org.broadinstitute.consent.http.service.UserService.SimplifiedUser;
import org.broadinstitute.consent.http.service.sam.SamService;
Expand All @@ -59,17 +58,14 @@ public class UserResource extends Resource {
private final Gson gson = new Gson();
private final SamService samService;
private final DatasetService datasetService;
private final SupportRequestService supportRequestService;
private final AcknowledgementService acknowledgementService;

@Inject
public UserResource(SamService samService, UserService userService,
DatasetService datasetService, SupportRequestService supportRequestService,
AcknowledgementService acknowledgementService) {
DatasetService datasetService, AcknowledgementService acknowledgementService) {
this.samService = samService;
this.userService = userService;
this.datasetService = datasetService;
this.supportRequestService = supportRequestService;
this.acknowledgementService = acknowledgementService;
}

Expand Down Expand Up @@ -241,7 +237,6 @@ public Response updateSelf(@Auth AuthUser authUser, @Context UriInfo info, Strin
}

user = userService.updateUserFieldsById(userUpdateFields, user.getUserId());
supportRequestService.handleInstitutionSOSupportRequest(userUpdateFields, user);
Gson gson = new Gson();
JsonObject jsonUser = userService.findUserWithPropertiesByIdAsJsonObject(authUser,
user.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;
import static org.mockito.internal.verification.VerificationModeFactory.times;

import com.google.api.client.http.HttpStatusCodes;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.ServerErrorException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.UriBuilder;
Expand Down Expand Up @@ -52,7 +49,6 @@
import org.broadinstitute.consent.http.service.AcknowledgementService;
import org.broadinstitute.consent.http.service.DatasetService;
import org.broadinstitute.consent.http.service.LibraryCardService;
import org.broadinstitute.consent.http.service.SupportRequestService;
import org.broadinstitute.consent.http.service.UserService;
import org.broadinstitute.consent.http.service.sam.SamService;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -73,9 +69,6 @@ public class UserResourceTest {
@Mock
private DatasetService datasetService;

@Mock
private SupportRequestService supportRequestService;

private UserResource userResource;

@Mock
Expand Down Expand Up @@ -108,7 +101,7 @@ public void setUp() throws URISyntaxException {
}

private void initResource() {
userResource = new UserResource(samService, userService, datasetService, supportRequestService,
userResource = new UserResource(samService, userService, datasetService,
acknowledgementService);
}

Expand Down Expand Up @@ -534,7 +527,6 @@ public void testUpdateSelf() {
initResource();
Response response = userResource.updateSelf(authUser, uriInfo, gson.toJson(userUpdateFields));
assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
verify(supportRequestService, times(1)).handleInstitutionSOSupportRequest(any(), any());
}

@Test
Expand All @@ -551,8 +543,6 @@ public void testUpdateSelfRolesNotAdmin() {
initResource();
Response response = userResource.updateSelf(authUser, uriInfo, gson.toJson(userUpdateFields));
assertEquals(HttpStatusCodes.STATUS_CODE_BAD_REQUEST, response.getStatus());
//no support request sent if update to user fails
verify(supportRequestService, times(0)).handleInstitutionSOSupportRequest(any(), any());
}

@Test
Expand Down Expand Up @@ -678,23 +668,6 @@ public void testUpdateSelfInstitutionIdNullAsSO_ExistingInstitution() {
}


@Test
public void testUpdateSelfSupportRequestError() {
User user = createUserWithRole();
UserUpdateFields userUpdateFields = new UserUpdateFields();
Gson gson = new Gson();
when(userService.findUserById(any())).thenReturn(user);
when(userService.findUserByEmail(any())).thenReturn(user);
when(userService.updateUserFieldsById(any(), any())).thenReturn(user);
when(userService.findUserWithPropertiesByIdAsJsonObject(any(), any())).thenReturn(
gson.toJsonTree(user).getAsJsonObject());
doThrow(new ServerErrorException(HttpStatusCodes.STATUS_CODE_SERVER_ERROR))
.when(supportRequestService).handleInstitutionSOSupportRequest(any(), any());
initResource();
Response response = userResource.updateSelf(authUser, uriInfo, gson.toJson(userUpdateFields));
assertEquals(HttpStatusCodes.STATUS_CODE_SERVER_ERROR, response.getStatus());
}

@Test
public void testCanUpdateInstitution() {
initResource();
Expand Down

0 comments on commit 41c6cfa

Please sign in to comment.