use of org.openmrs.User in project openmrs-core by openmrs.
the class ContextDAOTest method authenticate_shouldThrowAPIExceptionIfUsernameIsWhiteSpace.
@Test(expected = ContextAuthenticationException.class)
public void authenticate_shouldThrowAPIExceptionIfUsernameIsWhiteSpace() {
// it would be illegal to save this user (with a whitespace username) but we can get it in the db via xml
User u = Context.getUserService().getUser(507);
dao.authenticate(" ", "password");
}
use of org.openmrs.User in project openmrs-core by openmrs.
the class ContextDAOTest method authenticate_shouldThrowAContextAuthenticationExceptionIfUsernameIsAnEmptyString.
@Test(expected = ContextAuthenticationException.class)
public void authenticate_shouldThrowAContextAuthenticationExceptionIfUsernameIsAnEmptyString() {
// update a user with a username that is an empty string for this test
UserService us = Context.getUserService();
User u = us.getUser(1);
u.setUsername("");
u.getPerson().setGender("M");
us.saveUser(u);
dao.authenticate("", "password");
}
use of org.openmrs.User in project openmrs-core by openmrs.
the class ContextDAOTest method authenticate_shouldAuthenticateGivenSystemIdAndPassword.
/**
* @see ContextDAO#authenticate(String,String)
*/
@Test
public void authenticate_shouldAuthenticateGivenSystemIdAndPassword() {
User u = dao.authenticate("1-8", "test");
Assert.assertEquals("Should be the 1-8 user", "1-8", u.getSystemId());
}
use of org.openmrs.User in project openmrs-core by openmrs.
the class ContextDAOTest method authenticate_shouldAuthenticateGivenUsernameAndPassword.
/**
* @see ContextDAO#authenticate(String,String)
*/
@Test
public void authenticate_shouldAuthenticateGivenUsernameAndPassword() {
User u = dao.authenticate("admin", "test");
Assert.assertEquals("Should be the admin user", "admin", u.getUsername());
}
use of org.openmrs.User in project openmrs-core by openmrs.
the class ContextDAOTest method authenticate_shouldAuthenticateGivenSystemIdWithoutHyphenAndPassword.
/**
* Fixed bug #982
*
* @see ContextDAO#authenticate(String,String)
*/
@Test
public void authenticate_shouldAuthenticateGivenSystemIdWithoutHyphenAndPassword() {
User u = dao.authenticate("18", "test");
Assert.assertEquals("Should be the 1-8 user", "1-8", u.getSystemId());
}
Aggregations