Search in sources :

Example 1 with ProjectOwnerPermission

use of ca.corefacility.bioinformatics.irida.security.permissions.project.ProjectOwnerPermission in project irida by phac-nml.

the class ProjectOwnerPermissionTest method setup.

@SuppressWarnings("unchecked")
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    user.setSystemRole(Role.ROLE_USER);
    user.setUsername("tom");
    permission = new ProjectOwnerPermission(projectRepository, userRepository, pujRepository, ugpjRepository, ugRepository);
    when(projectRepository.findOne(projectId)).thenReturn(project);
    when(userRepository.loadUserByUsername(user.getUsername())).thenReturn(user);
    when(pujRepository.getUsersForProjectByRole(project, ProjectRole.PROJECT_OWNER)).thenReturn(Lists.newArrayList(new ProjectUserJoin(project, user, ProjectRole.PROJECT_OWNER)));
}
Also used : ProjectOwnerPermission(ca.corefacility.bioinformatics.irida.security.permissions.project.ProjectOwnerPermission) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) Before(org.junit.Before)

Example 2 with ProjectOwnerPermission

use of ca.corefacility.bioinformatics.irida.security.permissions.project.ProjectOwnerPermission in project irida by phac-nml.

the class UpdateSamplePermissionTest method setUp.

@Before
public void setUp() {
    projectSampleJoinRepository = mock(ProjectSampleJoinRepository.class);
    projectOwnerPermission = mock(ProjectOwnerPermission.class);
    sampleRepository = mock(SampleRepository.class);
    updateSamplePermission = new UpdateSamplePermission(sampleRepository, projectOwnerPermission, projectSampleJoinRepository);
    Collection<GrantedAuthority> roles = new ArrayList<>();
    roles.add(Role.ROLE_USER);
    auth = new UsernamePasswordAuthenticationToken("fbristow", "password1", roles);
}
Also used : SampleRepository(ca.corefacility.bioinformatics.irida.repositories.sample.SampleRepository) ProjectOwnerPermission(ca.corefacility.bioinformatics.irida.security.permissions.project.ProjectOwnerPermission) ProjectSampleJoinRepository(ca.corefacility.bioinformatics.irida.repositories.joins.project.ProjectSampleJoinRepository) GrantedAuthority(org.springframework.security.core.GrantedAuthority) ArrayList(java.util.ArrayList) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) UpdateSamplePermission(ca.corefacility.bioinformatics.irida.security.permissions.sample.UpdateSamplePermission) Before(org.junit.Before)

Aggregations

ProjectOwnerPermission (ca.corefacility.bioinformatics.irida.security.permissions.project.ProjectOwnerPermission)2 Before (org.junit.Before)2 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)1 ProjectSampleJoinRepository (ca.corefacility.bioinformatics.irida.repositories.joins.project.ProjectSampleJoinRepository)1 SampleRepository (ca.corefacility.bioinformatics.irida.repositories.sample.SampleRepository)1 UpdateSamplePermission (ca.corefacility.bioinformatics.irida.security.permissions.sample.UpdateSamplePermission)1 ArrayList (java.util.ArrayList)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1