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));
}
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;
}
Aggregations