Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTWS-961 - Error on startup due to SessionController2_0 #635

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class SessionController1_9 extends BaseRestController {

public static final String USER_CUSTOM_REP = "(uuid,display,username,systemId,userProperties,person:(uuid,display),privileges:(uuid,display,name),roles:(uuid,display,name),links)";

// The privilege to get providers was changed from "View Providers" to "Get Providers" in OpenMRS 2.0
private static final String GET_PROVIDERS = "Get Providers";

@Autowired
RestService restService;

Expand Down Expand Up @@ -139,12 +142,14 @@ protected Provider getCurrentProvider() {
Collection<Provider> providers = new HashSet<Provider>();
try {
Context.addProxyPrivilege(PrivilegeConstants.VIEW_PROVIDERS);
Context.addProxyPrivilege(GET_PROVIDERS);
if (currentUser.getPerson() != null) {
providers = Context.getProviderService().getProvidersByPerson(currentUser.getPerson(), false);
}
}
finally {
Context.removeProxyPrivilege(PrivilegeConstants.VIEW_PROVIDERS);
Context.removeProxyPrivilege(GET_PROVIDERS);
}
if (providers.size() > 1) {
log.warn("Can't handle users with multiple provider accounts");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
import org.junit.Assert;
import org.junit.Test;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.SessionController1_9;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;

/**
* Tests functionality of {@link SessionController2_0}
* Tests functionality of {@link SessionController1_9} in OpenMRS 2.0
*/
public class SessionController2_0Test extends BaseModuleWebContextSensitiveTest {
public class SessionController1_9Test extends BaseModuleWebContextSensitiveTest {

/**
* @see SessionController2_0#get()
* @see SessionController1_9#get()
* @verifies return the session with current provider if the user doesn't have Get Providers privilege
*/
@Test
Expand All @@ -33,7 +34,7 @@ public void get_shouldReturnCurrentProviderIfTheUserDoesNotHaveGetProvidersPrivi
Context.authenticate("test_user", "test");
Assert.assertTrue(Context.isAuthenticated());

SessionController2_0 controller = Context.getRegisteredComponents(SessionController2_0.class).iterator().next();
SessionController1_9 controller = Context.getRegisteredComponents(SessionController1_9.class).get(0);

Object ret = controller.get();
Object currentProvider = PropertyUtils.getProperty(ret, "currentProvider");
Expand Down
Loading