Search in sources :

Example 1 with SysAdminParamsImpl

use of org.alfresco.repo.admin.SysAdminParamsImpl in project alfresco-repository by Alfresco.

the class SiteServiceImplTest method testNonDefaultPublicGroupPermissions.

/**
 * ALF-10343 - When the default public group for sites isn't EVERYBODY,
 * check that creating and altering sites results in the correct permissions
 */
@Test
public void testNonDefaultPublicGroupPermissions() throws Exception {
    // Sanity check the current permissions
    assertEquals(PermissionService.ALL_AUTHORITIES, sysAdminParams.getSitePublicGroup());
    // Change the public site group
    SysAdminParamsImpl sp = new SysAdminParamsImpl();
    sp.setSitePublicGroup(groupFour);
    siteServiceImpl.setSysAdminParams(sp);
    // Create sites of the three types
    SiteInfo s1 = this.siteService.createSite(TEST_SITE_PRESET, "SiteTest_priv", "priv", "priv", SiteVisibility.PRIVATE);
    SiteInfo s2 = this.siteService.createSite(TEST_SITE_PRESET, "SiteTest_mod", "mod", "mod", SiteVisibility.MODERATED);
    SiteInfo s3 = this.siteService.createSite(TEST_SITE_PRESET, "SiteTest_pub", "pub", "pub", SiteVisibility.PUBLIC);
    // Check the permissions on them
    // Everyone has read permissions only, not Consumer
    assertTrue(getAllowedPermissionsMap(s1).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s2).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s3).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    // On the public + moderated sites, the special group will be a Consumer
    assertEquals(null, getAllowedPermissionsMap(s1).get(groupFour));
    assertTrue(getAllowedPermissionsMap(s2).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    assertTrue(getAllowedPermissionsMap(s3).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    // Our current user will be Manager
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s1.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s2.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s3.getShortName(), USER_ONE));
    // Swap the visibilites around, private+moderated -> public, public -> private
    s1.setVisibility(SiteVisibility.PUBLIC);
    s2.setVisibility(SiteVisibility.PUBLIC);
    s3.setVisibility(SiteVisibility.PRIVATE);
    siteService.updateSite(s1);
    siteService.updateSite(s2);
    siteService.updateSite(s3);
    // Check the permissions now
    // Everyone still has read permissions everywhere, but nothing more
    assertTrue(getAllowedPermissionsMap(s1).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s2).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s3).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    // The site public group has consumer permissions on mod+public
    assertTrue(getAllowedPermissionsMap(s1).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    assertTrue(getAllowedPermissionsMap(s2).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    assertEquals(null, getAllowedPermissionsMap(s3).get(groupFour));
    // Our user is still the manager
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s1.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s2.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s3.getShortName(), USER_ONE));
    // Swap them back again
    s1.setVisibility(SiteVisibility.PRIVATE);
    s2.setVisibility(SiteVisibility.MODERATED);
    s3.setVisibility(SiteVisibility.PUBLIC);
    siteService.updateSite(s1);
    siteService.updateSite(s2);
    siteService.updateSite(s3);
    // Check the permissions have restored
    // Everyone only has read permissions
    assertTrue(getAllowedPermissionsMap(s1).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s2).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    assertTrue(getAllowedPermissionsMap(s3).get(PermissionService.ALL_AUTHORITIES).contains("ReadPermissions"));
    // The site public group has consumer permissions on mod+public
    assertEquals(null, getAllowedPermissionsMap(s1).get(groupFour));
    assertTrue(getAllowedPermissionsMap(s2).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    assertTrue(getAllowedPermissionsMap(s3).get(groupFour).contains(SiteModel.SITE_CONSUMER));
    // Our user is still the manager
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s1.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s2.getShortName(), USER_ONE));
    assertEquals(SiteModel.SITE_MANAGER, siteService.getMembersRole(s3.getShortName(), USER_ONE));
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) SysAdminParamsImpl(org.alfresco.repo.admin.SysAdminParamsImpl) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 2 with SysAdminParamsImpl

use of org.alfresco.repo.admin.SysAdminParamsImpl in project alfresco-repository by Alfresco.

the class InviteSenderTest method mockServices.

/**
 * @return ServiceRegistry
 */
private ServiceRegistry mockServices() {
    ActionService mockActionService = mockActionService();
    NodeService mockNodeService = mockNodeService();
    PersonService mockPersonService = mockPersonService();
    SearchService mockSearchService = mockSearchService();
    SiteService mockSiteService = mockSiteService();
    FileFolderService mockFileFolderService = mockFileFolderService();
    RepoAdminService mockRepoAdminService = mockRepoAdminService();
    SysAdminParams sysAdminParams = new SysAdminParamsImpl();
    ServiceRegistry services = mock(ServiceRegistry.class);
    when(services.getActionService()).thenReturn(mockActionService);
    when(services.getNodeService()).thenReturn(mockNodeService);
    when(services.getPersonService()).thenReturn(mockPersonService);
    when(services.getSearchService()).thenReturn(mockSearchService);
    when(services.getSiteService()).thenReturn(mockSiteService);
    when(services.getFileFolderService()).thenReturn(mockFileFolderService);
    when(services.getSysAdminParams()).thenReturn(sysAdminParams);
    when(services.getRepoAdminService()).thenReturn(mockRepoAdminService);
    return services;
}
Also used : SiteService(org.alfresco.service.cmr.site.SiteService) SysAdminParamsImpl(org.alfresco.repo.admin.SysAdminParamsImpl) NodeService(org.alfresco.service.cmr.repository.NodeService) PersonService(org.alfresco.service.cmr.security.PersonService) SearchService(org.alfresco.service.cmr.search.SearchService) SysAdminParams(org.alfresco.repo.admin.SysAdminParams) FileFolderService(org.alfresco.service.cmr.model.FileFolderService) ServiceRegistry(org.alfresco.service.ServiceRegistry) ActionService(org.alfresco.service.cmr.action.ActionService) RepoAdminService(org.alfresco.service.cmr.admin.RepoAdminService)

Aggregations

SysAdminParamsImpl (org.alfresco.repo.admin.SysAdminParamsImpl)2 SysAdminParams (org.alfresco.repo.admin.SysAdminParams)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 ActionService (org.alfresco.service.cmr.action.ActionService)1 RepoAdminService (org.alfresco.service.cmr.admin.RepoAdminService)1 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)1 NodeService (org.alfresco.service.cmr.repository.NodeService)1 SearchService (org.alfresco.service.cmr.search.SearchService)1 PersonService (org.alfresco.service.cmr.security.PersonService)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1 SiteService (org.alfresco.service.cmr.site.SiteService)1 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)1 Test (org.junit.Test)1