Search in sources :

Example 1 with UserPermissionEvaluator

use of org.molgenis.security.core.UserPermissionEvaluator in project molgenis by molgenis.

the class MolgenisAccessDecisionVoterTest method setUp.

@BeforeMethod
public void setUp() {
    UserPermissionEvaluator permissionService = mock(UserPermissionEvaluator.class);
    when(permissionService.hasPermission(new PluginIdentity("plugingranted"), PluginPermission.READ)).thenReturn(true);
    when(permissionService.hasPermission(new PluginIdentity("plugindenied"), PluginPermission.READ)).thenReturn(false);
    Ui molgenisUi = mock(Ui.class);
    UiMenu menu = mock(UiMenu.class);
    when(molgenisUi.getMenu("menugranted")).thenReturn(menu);
    when(molgenisUi.getMenu("menudenied")).thenReturn(null);
    ApplicationContext ctx = mock(ApplicationContext.class);
    when(ctx.getBean(UserPermissionEvaluator.class)).thenReturn(permissionService);
    when(ctx.getBean(Ui.class)).thenReturn(molgenisUi);
    new ApplicationContextProvider().setApplicationContext(ctx);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) UserPermissionEvaluator(org.molgenis.security.core.UserPermissionEvaluator) Ui(org.molgenis.web.Ui) PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) ApplicationContextProvider(org.molgenis.util.ApplicationContextProvider) UiMenu(org.molgenis.web.UiMenu) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

PluginIdentity (org.molgenis.data.plugin.model.PluginIdentity)1 UserPermissionEvaluator (org.molgenis.security.core.UserPermissionEvaluator)1 ApplicationContextProvider (org.molgenis.util.ApplicationContextProvider)1 Ui (org.molgenis.web.Ui)1 UiMenu (org.molgenis.web.UiMenu)1 ApplicationContext (org.springframework.context.ApplicationContext)1 BeforeMethod (org.testng.annotations.BeforeMethod)1