Search in sources :

Example 1 with PluginIdentity

use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.

the class NegotiatorControllerTest method testShowButton.

@Test
public void testShowButton() {
    when(permissionService.hasPermission(new PluginIdentity("directory"), PluginPermission.READ)).thenReturn(true);
    assertTrue(negotiatorController.showDirectoryButton("molgenis_id_1"));
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Test(org.testng.annotations.Test)

Example 2 with PluginIdentity

use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.

the class NegotiatorControllerTest method testShowButtonPermissionsOnPluginNoConfig.

@Test
public void testShowButtonPermissionsOnPluginNoConfig() {
    when(permissionService.hasPermission(new PluginIdentity("directory"), PluginPermission.READ)).thenReturn(false);
    when(entityType.getId()).thenReturn("blah2");
    assertFalse(negotiatorController.showDirectoryButton("blah2"));
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Test(org.testng.annotations.Test)

Example 3 with PluginIdentity

use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.

the class UserPermissionEvaluatorImplTest method hasPermissionOnPluginTrue.

@WithMockUser(username = "USER")
@Test
public void hasPermissionOnPluginTrue() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    when(permissionEvaluator.hasPermission(authentication, "plugin1", "plugin", PluginPermission.READ)).thenReturn(true);
    assertTrue(userPermissionEvaluator.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ));
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Authentication(org.springframework.security.core.Authentication) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.testng.annotations.Test)

Example 4 with PluginIdentity

use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.

the class XmlMolgenisUiMenuTest method getActiveItem_noActiveItem.

@Test
public void getActiveItem_noActiveItem() {
    String menuId = "menuId";
    MenuType menuType = new MenuType();
    menuType.setName(menuId);
    PluginType plugin1Type = new PluginType();
    plugin1Type.setId("plugin1");
    plugin1Type.setName("plugin1");
    PluginType plugin3Type = new PluginType();
    plugin3Type.setId("plugin3");
    plugin3Type.setName("plugin3");
    MenuType menu1Type = new MenuType();
    menu1Type.setName("menu1");
    menu1Type.getMenuOrPlugin().add(plugin3Type);
    menuType.getMenuOrPlugin().add(plugin1Type);
    menuType.getMenuOrPlugin().add(menu1Type);
    when(permissionService.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ)).thenReturn(false);
    when(permissionService.hasPermission(new PluginIdentity("plugin3"), PluginPermission.READ)).thenReturn(true);
    XmlMolgenisUiMenu xmlMolgenisUiMenu = new XmlMolgenisUiMenu(menuType, permissionService);
    assertNull(xmlMolgenisUiMenu.getActiveItem());
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Test(org.testng.annotations.Test)

Example 5 with PluginIdentity

use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.

the class XmlMolgenisUiMenuTest method getItems.

@Test
public void getItems() {
    String menuId = "menuId";
    MenuType menuType = new MenuType();
    menuType.setName(menuId);
    PluginType plugin1Type = new PluginType();
    plugin1Type.setId("plugin1");
    plugin1Type.setName("plugin1");
    PluginType plugin2Type = new PluginType();
    plugin2Type.setId("plugin2");
    plugin2Type.setName("plugin2");
    PluginType plugin3Type = new PluginType();
    plugin3Type.setId("plugin3");
    plugin3Type.setName("plugin3");
    MenuType menu1Type = new MenuType();
    menu1Type.setName("menu1");
    menu1Type.getMenuOrPlugin().add(plugin3Type);
    menuType.getMenuOrPlugin().add(plugin1Type);
    menuType.getMenuOrPlugin().add(plugin2Type);
    menuType.getMenuOrPlugin().add(menu1Type);
    when(permissionService.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ)).thenReturn(true);
    when(permissionService.hasPermission(new PluginIdentity("plugin2"), PluginPermission.READ)).thenReturn(false);
    when(permissionService.hasPermission(new PluginIdentity("plugin3"), PluginPermission.READ)).thenReturn(true);
    XmlMolgenisUiMenu xmlMolgenisUiMenu = new XmlMolgenisUiMenu(menuType, permissionService);
    Iterator<UiMenuItem> it = xmlMolgenisUiMenu.getItems().iterator();
    assertTrue(it.hasNext());
    assertEquals(it.next().getName(), "plugin1");
    assertEquals(it.next().getName(), "menu1");
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) UiMenuItem(org.molgenis.web.UiMenuItem) Test(org.testng.annotations.Test)

Aggregations

PluginIdentity (org.molgenis.data.plugin.model.PluginIdentity)18 Test (org.testng.annotations.Test)13 Group (org.molgenis.data.security.auth.Group)4 Pair (org.molgenis.util.Pair)3 ObjectIdentity (org.springframework.security.acls.model.ObjectIdentity)3 EntityType (org.molgenis.data.meta.model.EntityType)2 PluginPermission (org.molgenis.data.plugin.model.PluginPermission)2 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)2 User (org.molgenis.data.security.auth.User)2 SidUtils.createSid (org.molgenis.security.acl.SidUtils.createSid)2 UiMenu (org.molgenis.web.UiMenu)2 GrantedAuthoritySid (org.springframework.security.acls.domain.GrantedAuthoritySid)2 Permission (org.springframework.security.acls.model.Permission)2 Sid (org.springframework.security.acls.model.Sid)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 Matcher (java.util.regex.Matcher)1 Package (org.molgenis.data.meta.model.Package)1 Plugin (org.molgenis.data.plugin.model.Plugin)1 EntityTypePermission (org.molgenis.data.security.EntityTypePermission)1