Search in sources :

Example 76 with User

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");
}
Also used : User(org.openmrs.User) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 77 with User

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");
}
Also used : User(org.openmrs.User) UserService(org.openmrs.api.UserService) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 78 with User

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());
}
Also used : User(org.openmrs.User) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 79 with User

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());
}
Also used : User(org.openmrs.User) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 80 with User

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());
}
Also used : User(org.openmrs.User) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

User (org.openmrs.User)201 Test (org.junit.Test)150 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)132 Date (java.util.Date)38 Person (org.openmrs.Person)33 Encounter (org.openmrs.Encounter)21 Patient (org.openmrs.Patient)18 PersonName (org.openmrs.PersonName)17 Role (org.openmrs.Role)13 GlobalProperty (org.openmrs.GlobalProperty)11 Location (org.openmrs.Location)11 ArrayList (java.util.ArrayList)10 EncounterType (org.openmrs.EncounterType)10 Locale (java.util.Locale)7 UserService (org.openmrs.api.UserService)7 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)7 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 EncounterRole (org.openmrs.EncounterRole)6 PatientIdentifier (org.openmrs.PatientIdentifier)6