Skip to content

Commit

Permalink
RA-552:Adding the View Logged in Users functionality to core
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertYiga committed Mar 10, 2021
1 parent fbe4dfc commit 0bcf600
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.junit.jupiter.api.Test;
import org.openmrs.User;
import org.openmrs.api.UserService;
import org.openmrs.api.context.Context;
import org.openmrs.web.filter.util.CurrentUsers;
import org.openmrs.web.test.BaseWebContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -31,7 +32,10 @@ public void getCurrentUsernames_shoulReturnAllCurrentUserNames() {
executeDataSet(USER_SET);
MockHttpSession session = new MockHttpSession();
User user = userService.getUser(5508);
CurrentUsers.addUser(session,user);
Context.authenticate(user.getUsername(),"User12345");
Assert.assertEquals(Context.getAuthenticatedUser().getUsername(),user.getUsername());
User loggedInUser = Context.getAuthenticatedUser();
CurrentUsers.addUser(session,loggedInUser);
List<String> currentUserNames = CurrentUsers.getCurrentUsernames(session);
Assert.assertTrue(currentUserNames.contains("firstaccount"));

Expand Down

0 comments on commit 0bcf600

Please sign in to comment.