Search in sources :

Example 41 with IPerson

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());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 42 with IPerson

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);
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 43 with IPerson

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());
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) Test(org.junit.Test)

Example 44 with IPerson

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"));
}
Also used : IPerson(org.apereo.portal.security.IPerson) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 45 with IPerson

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());
}
Also used : IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) PersonImpl(org.apereo.portal.security.provider.PersonImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

IPerson (org.apereo.portal.security.IPerson)177 Test (org.junit.Test)46 PersonImpl (org.apereo.portal.security.provider.PersonImpl)41 ModelAndView (org.springframework.web.servlet.ModelAndView)41 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)33 HttpServletRequest (javax.servlet.http.HttpServletRequest)26 IUserInstance (org.apereo.portal.user.IUserInstance)26 ArrayList (java.util.ArrayList)22 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)22 HashMap (java.util.HashMap)20 IPersonAttributes (org.apereo.services.persondir.IPersonAttributes)16 EntityIdentifier (org.apereo.portal.EntityIdentifier)15 HttpSession (javax.servlet.http.HttpSession)14 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)14 PortalException (org.apereo.portal.PortalException)11 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)11 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)11 List (java.util.List)10 IUserProfile (org.apereo.portal.IUserProfile)9 ISecurityContext (org.apereo.portal.security.ISecurityContext)9