use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class UserServiceImplTest method testCreateGoodPassword.
@Test
public void testCreateGoodPassword() {
final User u = user();
final String password = u.getPassword();
final String encodedPassword = "ENCODED_" + password;
when(passwordEncoder.encode(password)).thenReturn(encodedPassword);
when(userRepository.save(u)).thenReturn(u);
userService.create(u);
assertEquals("User password was not encoded.", encodedPassword, u.getPassword());
verify(passwordEncoder).encode(password);
verify(userRepository).save(u);
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class UserServiceImplTest method user.
private User user() {
String username = "fbristow";
String password = "Password1!";
String email = "fbristow@gmail.com";
String firstName = "Franklin";
String lastName = "Bristow";
String phoneNumber = "7029";
User u = new User(username, email, password, firstName, lastName, phoneNumber);
return u;
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class UserServiceImplTest method testLoadUserByUsername.
@Test
public void testLoadUserByUsername() {
User user = user();
user.setSystemRole(Role.ROLE_USER);
String username = user.getUsername();
String password = user.getPassword();
when(userRepository.loadUserByUsername(username)).thenReturn(user);
UserDetails userDetails = userService.loadUserByUsername(username);
assertEquals(username, userDetails.getUsername());
assertEquals(password, userDetails.getPassword());
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class AssemblyFileProcessorTest method setUp.
@Before
public void setUp() throws IridaWorkflowNotFoundException {
MockitoAnnotations.initMocks(this);
processor = new AssemblyFileProcessor(objectRepository, submissionRepository, workflowsService, userRepository, ssoRepository, psjRepository);
UUID workflowUUID = UUID.randomUUID();
IridaWorkflowDescription workflowDescription = new IridaWorkflowDescription(workflowUUID, null, null, null, null, ImmutableList.of(), ImmutableList.of(), ImmutableList.of());
IridaWorkflow workflow = new IridaWorkflow(workflowDescription, null);
when(workflowsService.getDefaultWorkflowByType(AnalysisType.ASSEMBLY_ANNOTATION)).thenReturn(workflow);
when(userRepository.loadUserByUsername("admin")).thenReturn(new User());
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class RESTUsersController method getUserProjects.
/**
* Get the collection of projects for a specific user.
*
* @param username
* the username for the desired user.
* @return a model containing the collection of projects for that user.
*/
@RequestMapping(value = "/api/{username}/projects", method = RequestMethod.GET)
public ModelMap getUserProjects(@PathVariable String username) {
logger.debug("Loading projects for user [" + username + "]");
ModelMap mav = new ModelMap();
// get the appropriate user from the database
User u = userService.getUserByUsername(username);
// get all of the projects that this user belongs to
ResourceCollection<Project> resources = new ResourceCollection<>();
List<Join<Project, User>> projects = projectService.getProjectsForUser(u);
ControllerLinkBuilder linkBuilder = linkTo(RESTProjectsController.class);
// add the project and a self-rel link to the project representation
for (Join<Project, User> join : projects) {
Project project = join.getSubject();
project.add(linkBuilder.slash(project.getId()).withSelfRel());
resources.add(project);
}
// add the resources to the response
mav.addAttribute("projectResources", resources);
// respond to the user
return mav;
}
Aggregations