use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testUpdatePermissionCannotViewPermission.
@Test
public void testUpdatePermissionCannotViewPermission() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(false);
ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
Assert.assertNull(modelAndView);
Assert.assertEquals(401L, res.getStatus());
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testUpdatePermissionNull.
@Test
public void testUpdatePermissionNull() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
ModelAndView modelAndView = permissionAssignmentMapController.updatePermission("principal", "assignment1", str, "owner", "activity1", "target", req, res);
Assert.assertNull(modelAndView);
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class PermissionAssignmentMapControllerTest method testDeletePermission.
@Test
public void testDeletePermission() throws Exception {
String[] str = new String[] { "principal1", "principal2" };
IPerson person = new PersonImpl();
person.setUserName("jdoe");
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(permissionAdministrationHelper.canViewPermission(person, "target")).thenReturn(true);
Mockito.when(permissionAdministrationHelper.canEditPermission(person, "target")).thenReturn(true);
Mockito.when(groupListHelper.getEntityForPrincipal("principal")).thenReturn(null);
permissionAssignmentMapController.deletePermission("principal", "owner", "activity1", "target", req, res);
Assert.assertEquals(200L, res.getStatus());
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class MarketplaceRESTControllerTest method testMarketplaceEntriesFeedNull.
@Test
public void testMarketplaceEntriesFeedNull() {
IPerson person = new PersonImpl();
person.setUserName(USER_NAME);
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
Mockito.when(marketplaceService.browseableMarketplaceEntriesFor(person, Collections.emptySet())).thenReturn(null);
ModelAndView modelAndView = marketplaceRESTController.marketplaceEntriesFeed(req);
Assert.assertNull(modelAndView.getModel().get("portlets"));
}
use of org.apereo.portal.security.IPerson in project uPortal by Jasig.
the class MarketplaceRESTControllerTest method testMarketplaceEntriesFeed.
@Test
public void testMarketplaceEntriesFeed() {
IPerson person = new PersonImpl();
person.setUserName(USER_NAME);
person.setFullName("john doe");
Mockito.when(personManager.getPerson(req)).thenReturn(person);
MarketplaceEntry entry = new MarketplaceEntry(null, null, person);
Set<MarketplaceEntry> marketplaceEntries = new HashSet<MarketplaceEntry>();
marketplaceEntries.add(entry);
ImmutableSet<MarketplaceEntry> entries = ImmutableSet.copyOf(marketplaceEntries);
Mockito.when(marketplaceService.browseableMarketplaceEntriesFor(person, Collections.emptySet())).thenReturn(entries);
ModelAndView modelAndView = marketplaceRESTController.marketplaceEntriesFeed(req);
Set<MarketplaceEntry> returnEntries = (Set<MarketplaceEntry>) modelAndView.getModel().get("portlets");
Assert.assertEquals(1L, entries.size());
}
Aggregations