use of org.springframework.web.context.request.WebRequest in project molgenis by molgenis.
the class PermissionManagerControllerTest method testUpdateUserPackagePermissions.
@Test
public void testUpdateUserPackagePermissions() {
WebRequest webRequest = mock(WebRequest.class);
when(webRequest.getParameter("radio-1")).thenReturn("write");
when(webRequest.getParameter("radio-2")).thenReturn("none");
when(webRequest.getParameter("radio-3")).thenReturn("read");
MutableAcl acl1 = mock(MutableAcl.class);
MutableAcl acl2 = mock(MutableAcl.class);
MutableAcl acl3 = mock(MutableAcl.class);
AccessControlEntry ace1 = mock(AccessControlEntry.class);
AccessControlEntry ace2 = mock(AccessControlEntry.class);
PrincipalSid sid = new PrincipalSid("Ipsum");
when(ace1.getSid()).thenReturn(sid);
when(ace2.getSid()).thenReturn(sid);
when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1));
when(acl2.getEntries()).thenReturn(Collections.singletonList(ace2));
when(acl3.getEntries()).thenReturn(Collections.emptyList());
when(mutableAclService.readAclById(packageIdentity1, singletonList(sid))).thenReturn(acl1);
when(mutableAclService.readAclById(packageIdentity2, singletonList(sid))).thenReturn(acl2);
when(mutableAclService.readAclById(packageIdentity3, singletonList(sid))).thenReturn(acl3);
permissionManagerController.updateUserPackagePermissions("1", webRequest);
verify(acl1).deleteAce(0);
verify(acl1).insertAce(0, cumulativeEntityPermissionWrite, sid, true);
verify(acl2).deleteAce(0);
verify(acl3).insertAce(0, cumulativeEntityPermissionRead, sid, true);
verify(mutableAclService).updateAcl(acl1);
verify(mutableAclService).updateAcl(acl2);
verify(mutableAclService).updateAcl(acl3);
}
use of org.springframework.web.context.request.WebRequest in project molgenis by molgenis.
the class PermissionManagerControllerTest method testUpdateUserEntityClassPermissions.
@Test
public void testUpdateUserEntityClassPermissions() {
WebRequest webRequest = mock(WebRequest.class);
when(webRequest.getParameter("radio-1")).thenReturn("write");
when(webRequest.getParameter("radio-2")).thenReturn("none");
when(webRequest.getParameter("radio-3")).thenReturn("read");
ObjectIdentity objectIdentity1 = new EntityTypeIdentity(entityType1);
ObjectIdentity objectIdentity2 = new EntityTypeIdentity(entityType2);
ObjectIdentity objectIdentity3 = new EntityTypeIdentity(entityType3);
MutableAcl acl1 = mock(MutableAcl.class);
MutableAcl acl2 = mock(MutableAcl.class);
MutableAcl acl3 = mock(MutableAcl.class);
AccessControlEntry ace1 = mock(AccessControlEntry.class);
AccessControlEntry ace2 = mock(AccessControlEntry.class);
PrincipalSid sid = new PrincipalSid("Ipsum");
when(ace1.getSid()).thenReturn(sid);
when(ace2.getSid()).thenReturn(sid);
when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1));
when(acl2.getEntries()).thenReturn(Collections.singletonList(ace2));
when(acl3.getEntries()).thenReturn(Collections.emptyList());
when(mutableAclService.readAclById(objectIdentity1, singletonList(sid))).thenReturn(acl1);
when(mutableAclService.readAclById(objectIdentity2, singletonList(sid))).thenReturn(acl2);
when(mutableAclService.readAclById(objectIdentity3, singletonList(sid))).thenReturn(acl3);
permissionManagerController.updateUserEntityClassPermissions("1", webRequest);
verify(acl1).deleteAce(0);
verify(acl1).insertAce(0, cumulativeEntityPermissionWrite, sid, true);
verify(acl2).deleteAce(0);
verify(acl3).insertAce(0, cumulativeEntityPermissionRead, sid, true);
verify(mutableAclService).updateAcl(acl1);
verify(mutableAclService).updateAcl(acl2);
verify(mutableAclService).updateAcl(acl3);
}
use of org.springframework.web.context.request.WebRequest in project molgenis by molgenis.
the class PermissionManagerControllerTest method testUpdateGroupPackagePermissions.
@Test
public void testUpdateGroupPackagePermissions() {
WebRequest webRequest = mock(WebRequest.class);
when(webRequest.getParameter("radio-1")).thenReturn("write");
when(webRequest.getParameter("radio-2")).thenReturn("none");
when(webRequest.getParameter("radio-3")).thenReturn("read");
MutableAcl acl1 = mock(MutableAcl.class);
MutableAcl acl2 = mock(MutableAcl.class);
MutableAcl acl3 = mock(MutableAcl.class);
AccessControlEntry ace1 = mock(AccessControlEntry.class);
AccessControlEntry ace2 = mock(AccessControlEntry.class);
GrantedAuthoritySid sid = new GrantedAuthoritySid("ROLE_1");
when(ace1.getSid()).thenReturn(sid);
when(ace2.getSid()).thenReturn(sid);
when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1));
when(acl2.getEntries()).thenReturn(Collections.singletonList(ace2));
when(acl3.getEntries()).thenReturn(Collections.emptyList());
when(mutableAclService.readAclById(packageIdentity1, singletonList(sid))).thenReturn(acl1);
when(mutableAclService.readAclById(packageIdentity2, singletonList(sid))).thenReturn(acl2);
when(mutableAclService.readAclById(packageIdentity3, singletonList(sid))).thenReturn(acl3);
permissionManagerController.updateGroupPackagePermissions("1", webRequest);
verify(acl1).deleteAce(0);
verify(acl1).insertAce(0, cumulativeEntityPermissionWrite, sid, true);
verify(acl2).deleteAce(0);
verify(acl3).insertAce(0, cumulativeEntityPermissionRead, sid, true);
verify(mutableAclService).updateAcl(acl1);
verify(mutableAclService).updateAcl(acl2);
verify(mutableAclService).updateAcl(acl3);
}
use of org.springframework.web.context.request.WebRequest in project molgenis by molgenis.
the class PermissionManagerControllerTest method testUpdateGroupEntityClassPermissions.
@Test
public void testUpdateGroupEntityClassPermissions() {
WebRequest webRequest = mock(WebRequest.class);
when(webRequest.getParameter("radio-1")).thenReturn("write");
when(webRequest.getParameter("radio-2")).thenReturn("none");
when(webRequest.getParameter("radio-3")).thenReturn("read");
MutableAcl acl1 = mock(MutableAcl.class);
MutableAcl acl2 = mock(MutableAcl.class);
MutableAcl acl3 = mock(MutableAcl.class);
AccessControlEntry ace1 = mock(AccessControlEntry.class);
AccessControlEntry ace2 = mock(AccessControlEntry.class);
GrantedAuthoritySid sid = new GrantedAuthoritySid("ROLE_1");
when(ace1.getSid()).thenReturn(sid);
when(ace2.getSid()).thenReturn(sid);
when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1));
when(acl2.getEntries()).thenReturn(Collections.singletonList(ace2));
when(acl3.getEntries()).thenReturn(Collections.emptyList());
when(mutableAclService.readAclById(entityIdentity1, singletonList(sid))).thenReturn(acl1);
when(mutableAclService.readAclById(entityIdentity2, singletonList(sid))).thenReturn(acl2);
when(mutableAclService.readAclById(entityIdentity3, singletonList(sid))).thenReturn(acl3);
permissionManagerController.updateGroupEntityClassPermissions("1", webRequest);
verify(acl1).deleteAce(0);
verify(acl1).insertAce(0, cumulativeEntityPermissionWrite, sid, true);
verify(acl2).deleteAce(0);
verify(acl3).insertAce(0, cumulativeEntityPermissionRead, sid, true);
verify(mutableAclService).updateAcl(acl1);
verify(mutableAclService).updateAcl(acl2);
verify(mutableAclService).updateAcl(acl3);
}
use of org.springframework.web.context.request.WebRequest in project molgenis by molgenis.
the class PermissionManagerControllerTest method testUpdateUserPluginPermissions.
@Test
public void testUpdateUserPluginPermissions() {
WebRequest webRequest = mock(WebRequest.class);
when(webRequest.getParameter("radio-1")).thenReturn("read");
when(webRequest.getParameter("radio-2")).thenReturn("none");
ObjectIdentity objectIdentity1 = new PluginIdentity(plugin1);
ObjectIdentity objectIdentity2 = new PluginIdentity(plugin2);
MutableAcl acl1 = mock(MutableAcl.class);
MutableAcl acl2 = mock(MutableAcl.class);
AccessControlEntry ace1 = mock(AccessControlEntry.class);
when(ace1.getSid()).thenReturn(userSid);
when(acl1.getEntries()).thenReturn(Collections.singletonList(ace1));
when(acl2.getEntries()).thenReturn(Collections.emptyList());
when(mutableAclService.readAclById(objectIdentity1, singletonList(userSid))).thenReturn(acl1);
when(mutableAclService.readAclById(objectIdentity2, singletonList(userSid))).thenReturn(acl2);
permissionManagerController.updateUserPluginPermissions("1", webRequest);
verify(acl1).insertAce(0, pluginPermissionRead, userSid, true);
verify(mutableAclService).updateAcl(acl1);
}
Aggregations