Search in sources :

Example 66 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class ReadAnalysisSubmissionPermissionTest method testRejectPermission.

/**
 * Tests rejecting permission for a user to read an analysis submission by
 * the submission id.
 */
@Test
public void testRejectPermission() {
    String username = "aaron";
    User u = new User();
    u.setUsername(username);
    Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
    AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(inputSingleFiles).referenceFile(referenceFile).build();
    analysisSubmission.setSubmitter(new User());
    when(userRepository.loadUserByUsername(username)).thenReturn(u);
    when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
    assertFalse("permission was not granted.", readAnalysisSubmissionPermission.isAllowed(auth, 1L));
    verify(userRepository).loadUserByUsername(username);
    verify(analysisSubmissionRepository).findOne(1L);
}
Also used : User(ca.corefacility.bioinformatics.irida.model.user.User) Authentication(org.springframework.security.core.Authentication) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 67 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class ReadAnalysisSubmissionPermissionTest method testPermitAutoAssembly.

@Test
public void testPermitAutoAssembly() {
    String username = "aaron";
    User u = new User();
    u.setUsername(username);
    Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
    Project p = new Project();
    SequenceFilePair pair = new SequenceFilePair();
    AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(ImmutableSet.of(pair)).referenceFile(referenceFile).build();
    analysisSubmission.setSubmitter(new User());
    pair.setAutomatedAssembly(analysisSubmission);
    /*
		 * testing that analysis is shared with a project that user isn't a part
		 * of
		 */
    when(pasRepository.getProjectsForSubmission(analysisSubmission)).thenReturn(ImmutableList.of(new ProjectAnalysisSubmissionJoin(p, analysisSubmission)));
    when(readProjectPermission.customPermissionAllowed(auth, p)).thenReturn(false);
    when(userRepository.loadUserByUsername(username)).thenReturn(u);
    when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
    when(seqObjectPermission.customPermissionAllowed(auth, pair)).thenReturn(true);
    when(sequencingObjectRepository.findSequencingObjectsForAnalysisSubmission(analysisSubmission)).thenReturn(ImmutableSet.of(pair));
    assertTrue("permission should be granted.", readAnalysisSubmissionPermission.isAllowed(auth, 1L));
    verify(userRepository).loadUserByUsername(username);
    verify(analysisSubmissionRepository).findOne(1L);
    verify(seqObjectPermission).customPermissionAllowed(auth, pair);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) User(ca.corefacility.bioinformatics.irida.model.user.User) Authentication(org.springframework.security.core.Authentication) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 68 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class ReadAnalysisSubmissionPermissionTest method testGrantPermissionWithDomainObject.

/**
 * Tests granting permission for a user to read an analysis submission by
 * the submission object.
 */
@Test
public void testGrantPermissionWithDomainObject() {
    String username = "aaron";
    User u = new User();
    u.setUsername(username);
    Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
    AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(inputSingleFiles).referenceFile(referenceFile).build();
    analysisSubmission.setSubmitter(u);
    when(userRepository.loadUserByUsername(username)).thenReturn(u);
    when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
    assertTrue("permission was not granted.", readAnalysisSubmissionPermission.isAllowed(auth, analysisSubmission));
    verify(userRepository).loadUserByUsername(username);
    verifyZeroInteractions(analysisSubmissionRepository);
}
Also used : User(ca.corefacility.bioinformatics.irida.model.user.User) Authentication(org.springframework.security.core.Authentication) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 69 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class DatabaseSetupGalaxyITService method setupPairSubmissionInDatabase.

/**
 * Sets up an {@link AnalysisSubmission} with a list of paired sequence
 * files and saves all dependencies in database.
 *
 * @param sampleId
 *            The id of the sample to associate with the given sequence
 *            file.
 * @param sequenceFilePaths1
 *            A list of paths for the first part of the pair.
 * @param sequenceFilePaths2
 *            A list of paths for the second part of the pair. The path to
 *            an input sequence file for this test.
 * @param iridaWorkflowId
 *            The id of an irida workflow.
 * @return An {@link AnalysisSubmission} which has been saved to the
 *         database.
 */
public AnalysisSubmission setupPairSubmissionInDatabase(long sampleId, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, UUID iridaWorkflowId) {
    List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleId, sequenceFilePaths1, sequenceFilePaths2);
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(Sets.newHashSet(sequenceFilePairs)).build();
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Example 70 with AnalysisSubmission

use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.

the class DatabaseSetupGalaxyITService method setupSubmissionInDatabase.

/**
 * Sets up an AnalysisSubmission and saves all dependencies in database.
 *
 * @param sampleId
 *            The id of the sample to associate with the given sequence
 *            file.
 * @param sequenceFileSet
 *            A set of sequence files to use for this submission.
 * @param referenceFilePath
 *            The path to an input reference file for this test.
 * @param iridaWorkflowId
 *            The id of an irida workflow.
 * @return An AnalysisSubmissionPhylogenomics which has been saved to the
 *         database.
 */
public AnalysisSubmission setupSubmissionInDatabase(long sampleId, Set<SequencingObject> sequenceFileSet, Path referenceFilePath, UUID iridaWorkflowId) {
    ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("my analysis").inputFiles(sequenceFileSet).referenceFile(referenceFile).build();
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Aggregations

AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)183 Test (org.junit.Test)121 WithMockUser (org.springframework.security.test.context.support.WithMockUser)95 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)30 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)30 Path (java.nio.file.Path)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)23 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)19 History (com.github.jmchilton.blend4j.galaxy.beans.History)19 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)18 AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)18 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)15 User (ca.corefacility.bioinformatics.irida.model.user.User)15 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)12 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)12 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)12 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)11