use of org.pmiops.workbench.model.Workspace in project workbench by all-of-us.
the class WorkspacesControllerTest method testDeleteWorkspace.
@Test(expected = NotFoundException.class)
public void testDeleteWorkspace() throws Exception {
Workspace workspace = createDefaultWorkspace();
workspacesController.createWorkspace(workspace);
verify(fireCloudService).createWorkspace(workspace.getNamespace(), workspace.getId());
workspacesController.deleteWorkspace(workspace.getNamespace(), workspace.getName());
stubGetWorkspace(workspace.getNamespace(), workspace.getName(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
Workspace workspace2 = workspacesController.getWorkspace(workspace.getNamespace(), workspace.getName()).getBody().getWorkspace();
}
use of org.pmiops.workbench.model.Workspace in project workbench by all-of-us.
the class WorkspacesControllerTest method testCloneWorkspaceDifferentOwner.
@Test
public void testCloneWorkspaceDifferentOwner() throws Exception {
Workspace workspace = createDefaultWorkspace();
workspace = workspacesController.createWorkspace(workspace).getBody();
User cloner = new User();
cloner.setEmail("cloner@gmail.com");
cloner.setUserId(456L);
cloner.setFreeTierBillingProjectName("TestBillingProject1");
cloner.setDisabled(false);
cloner = userDao.save(cloner);
when(userProvider.get()).thenReturn(cloner);
stubGetWorkspace(workspace.getNamespace(), workspace.getName(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.READER);
CloneWorkspaceRequest req = new CloneWorkspaceRequest();
Workspace modWorkspace = new Workspace();
modWorkspace.setName("cloned");
modWorkspace.setNamespace("cloned-ns");
ResearchPurpose modPurpose = new ResearchPurpose();
modPurpose.setAncestry(true);
modWorkspace.setResearchPurpose(modPurpose);
req.setWorkspace(modWorkspace);
stubGetWorkspace(modWorkspace.getNamespace(), modWorkspace.getName(), "cloner@gmail.com", WorkspaceAccessLevel.OWNER);
Workspace workspace2 = workspacesController.cloneWorkspace(workspace.getNamespace(), workspace.getId(), req).getBody().getWorkspace();
assertThat(workspace2.getCreator()).isEqualTo(cloner.getEmail());
assertThat(workspace2.getUserRoles().size()).isEqualTo(1);
assertThat(workspace2.getUserRoles().get(0).getRole()).isEqualTo(WorkspaceAccessLevel.OWNER);
assertThat(workspace2.getUserRoles().get(0).getEmail()).isEqualTo(cloner.getEmail());
}
use of org.pmiops.workbench.model.Workspace in project workbench by all-of-us.
the class WorkspacesControllerTest method testCloneNotFound.
@Test(expected = NotFoundException.class)
public void testCloneNotFound() throws Exception {
doThrow(new ApiException(404, "")).when(fireCloudService).getWorkspace("doesnot", "exist");
CloneWorkspaceRequest req = new CloneWorkspaceRequest();
Workspace modWorkspace = new Workspace();
modWorkspace.setName("cloned");
modWorkspace.setNamespace("cloned-ns");
req.setWorkspace(modWorkspace);
ResearchPurpose modPurpose = new ResearchPurpose();
modPurpose.setAncestry(true);
modWorkspace.setResearchPurpose(modPurpose);
workspacesController.cloneWorkspace("doesnot", "exist", req);
}
use of org.pmiops.workbench.model.Workspace in project workbench by all-of-us.
the class WorkspacesControllerTest method testClonePermissionDenied.
@Test(expected = NotFoundException.class)
public void testClonePermissionDenied() throws Exception {
Workspace workspace = createDefaultWorkspace();
workspace = workspacesController.createWorkspace(workspace).getBody();
// Clone with a different user.
User cloner = new User();
cloner.setEmail("cloner@gmail.com");
cloner.setUserId(456L);
cloner.setFreeTierBillingProjectName("TestBillingProject1");
cloner.setDisabled(false);
cloner = userDao.save(cloner);
when(userProvider.get()).thenReturn(cloner);
// Permission denied manifests as a 404 in Firecloud.
when(fireCloudService.getWorkspace(workspace.getNamespace(), workspace.getName())).thenThrow(new ApiException(404, ""));
CloneWorkspaceRequest req = new CloneWorkspaceRequest();
Workspace modWorkspace = new Workspace();
modWorkspace.setName("cloned");
modWorkspace.setNamespace("cloned-ns");
req.setWorkspace(modWorkspace);
ResearchPurpose modPurpose = new ResearchPurpose();
modPurpose.setAncestry(true);
modWorkspace.setResearchPurpose(modPurpose);
workspacesController.cloneWorkspace(workspace.getNamespace(), workspace.getId(), req);
}
use of org.pmiops.workbench.model.Workspace in project workbench by all-of-us.
the class WorkspacesControllerTest method createDefaultWorkspace.
public Workspace createDefaultWorkspace() throws Exception {
ResearchPurpose researchPurpose = new ResearchPurpose();
researchPurpose.setDiseaseFocusedResearch(true);
researchPurpose.setDiseaseOfFocus("cancer");
researchPurpose.setMethodsDevelopment(true);
researchPurpose.setControlSet(true);
researchPurpose.setAggregateAnalysis(true);
researchPurpose.setAncestry(true);
researchPurpose.setCommercialPurpose(true);
researchPurpose.setPopulation(true);
researchPurpose.setPopulationOfFocus("population");
researchPurpose.setAdditionalNotes("additional notes");
researchPurpose.setTimeRequested(new Long(1000));
researchPurpose.setTimeReviewed(new Long(1500));
researchPurpose.setReviewRequested(true);
researchPurpose.setApproved(false);
Workspace workspace = new Workspace();
workspace.setId("name");
workspace.setName("name");
workspace.setNamespace("namespace");
workspace.setDescription("description");
workspace.setDataAccessLevel(DataAccessLevel.PROTECTED);
workspace.setResearchPurpose(researchPurpose);
workspace.setUserRoles(new ArrayList<UserRole>());
workspace.setCdrVersionId(cdrVersionId);
stubGetWorkspace("namespace", "name", LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
return workspace;
}
Aggregations