use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class TestAuthorityManager method createGroupForTest.
private Group createGroupForTest(String code) {
Group groupForTest = new Group();
groupForTest.setName(code);
groupForTest.setDescription("Description");
return groupForTest;
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class TestAuthorityManager method testSetRemoveUserAuthorization_2.
public void testSetRemoveUserAuthorization_2() throws Throwable {
String username = "pageManagerCustomers";
String groupName = "testgroupname";
String roleName = "pageManager";
Group invalidGroupForTest = this.createGroupForTest(groupName);
try {
this._authorizationManager.addUserAuthorization(username, groupName, roleName);
List<String> usersByGroup = this._authorizationManager.getUsersByGroup(invalidGroupForTest, false);
assertNull(usersByGroup);
} catch (Throwable t) {
this._authorizationManager.deleteUserAuthorization(username, groupName, roleName);
throw t;
}
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class TestAuthorityManager method testGetUsersByAuthority_2.
public void testGetUsersByAuthority_2() throws Throwable {
// name equal to an existing role
Group groupForTest = this.createGroupForTest("pageManager");
try {
((IGroupManager) this._groupManager).addGroup(groupForTest);
Group group = this.getGroup(groupForTest.getName());
assertNotNull(group);
List<String> usersByGroup = this._authorizationManager.getUsersByAuthority(group, false);
assertNotNull(usersByGroup);
assertTrue(usersByGroup.isEmpty());
usersByGroup = this._authorizationManager.getUsersByGroup(group, false);
assertNotNull(usersByGroup);
assertTrue(usersByGroup.isEmpty());
List<String> usersByRole = this._authorizationManager.getUsersByRole(group, false);
assertNull(usersByRole);
} catch (Throwable t) {
throw t;
} finally {
((IGroupManager) this._groupManager).removeGroup(groupForTest);
Group group = this.getGroup(groupForTest.getName());
assertNull(group);
}
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class TestAuthorityManager method testSetRemoveUserAuthorization_1.
public void testSetRemoveUserAuthorization_1() throws Throwable {
String username = "pageManagerCustomers";
String groupName = "coach";
String roleName = "pageManager";
Group groupForTest = this.getGroup(groupName);
assertNotNull(groupForTest);
List<String> usersByGroup = this._authorizationManager.getUsersByAuthority(groupForTest, false);
assertNotNull(usersByGroup);
int initSize = usersByGroup.size();
assertTrue(initSize >= 3);
try {
this._authorizationManager.addUserAuthorization(username, groupName, roleName);
usersByGroup = this._authorizationManager.getUsersByAuthority(groupForTest, false);
assertNotNull(usersByGroup);
assertEquals(initSize + 1, usersByGroup.size());
} catch (Throwable t) {
throw t;
} finally {
this._authorizationManager.deleteUserAuthorization(username, groupName, roleName);
usersByGroup = this._authorizationManager.getUsersByAuthority(groupForTest, false);
assertNotNull(usersByGroup);
assertEquals(initSize, usersByGroup.size());
}
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class TestAuthorizationManager method testCheckCustomerUser.
public void testCheckCustomerUser() throws Throwable {
UserDetails extractedUser = this._authenticationProvider.getUser("pageManagerCustomers", "pageManagerCustomers");
assertNotNull(extractedUser);
assertEquals("pageManagerCustomers", extractedUser.getUsername());
assertEquals(1, extractedUser.getAuthorizations().size());
Group group = this._groupManager.getGroup("coach");
boolean checkGroup = this._authorizationManager.isAuth(extractedUser, group);
assertFalse(checkGroup);
group = this._groupManager.getGroup(Group.FREE_GROUP_NAME);
checkGroup = this._authorizationManager.isAuth(extractedUser, group);
assertFalse(checkGroup);
group = this._groupManager.getGroup("customers");
checkGroup = this._authorizationManager.isAuth(extractedUser, group);
assertTrue(checkGroup);
boolean checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.CONTENT_SUPERVISOR);
assertFalse(checkPermission);
checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.SUPERUSER);
assertFalse(checkPermission);
checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.BACKOFFICE);
assertTrue(checkPermission);
checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.CONTENT_EDITOR);
assertFalse(checkPermission);
checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.MANAGE_PAGES);
assertTrue(checkPermission);
}
Aggregations