use of org.motechproject.security.model.RoleDto in project motech by motech.
the class RoleControllerSecurityContextIT method shouldAllowRoleDeletionWithoutException.
@Test
public void shouldAllowRoleDeletionWithoutException() {
login(USER_WITH_PERMISSION_TO_MANAGE_ROLE_AND_PERMISSION);
roleController.deleteRole(new RoleDto());
}
use of org.motechproject.security.model.RoleDto in project motech by motech.
the class RoleControllerSecurityContextIT method shouldAllowRoleCreationWithoutException.
@Test
public void shouldAllowRoleCreationWithoutException() {
login(USER_WITH_PERMISSION_TO_MANAGE_ROLE_AND_PERMISSION);
roleController.saveRole(new RoleDto());
}
use of org.motechproject.security.model.RoleDto in project motech by motech.
the class RoleControllerSecurityContextIT method shouldNotAllowRoleDeletion.
@Test(expected = AccessDeniedException.class)
public void shouldNotAllowRoleDeletion() {
login(USER_WITHOUT_PERMISSION_TO_MANAGE_ROLE_AND_PERMISSION);
roleController.deleteRole(new RoleDto("someRole", Collections.<String>emptyList()));
}
use of org.motechproject.security.model.RoleDto in project motech by motech.
the class WebSecurityBundleIT method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
PermissionDto permission = new PermissionDto(PERMISSION_NAME, BUNDLE_NAME);
RoleDto role = new RoleDto(ROLE_NAME, Collections.singletonList(PERMISSION_NAME));
if (!userService.hasActiveMotechAdmin()) {
userService.registerMotechAdmin(ADMIN, ADMIN, "aaa@admin.com", Locale.ENGLISH);
}
setUpSecurityContext(ADMIN, ADMIN, getPermissions());
permissionService.addPermission(permission);
roleService.createRole(role);
userService.register(USER_NAME, USER_PASSWORD, USER_EMAIL, USER_EXTERNAL_ID, Arrays.asList(ROLE_NAME, MOTECH_ADMIN), USER_LOCALE);
originalSecurityProxy = getFromContext(MotechProxyManager.class).getFilterChainProxy();
}
use of org.motechproject.security.model.RoleDto in project motech by motech.
the class WebSecurityBundleIT method testWebSecurityServices.
@Test
public void testWebSecurityServices() throws Exception {
// given
PermissionDto permission = new PermissionDto(PERMISSION_NAME, BUNDLE_NAME);
RoleDto role = new RoleDto(ROLE_NAME, Arrays.asList(PERMISSION_NAME));
// when
permissionService.addPermission(permission);
roleService.createRole(role);
userService.register(USER_NAME, USER_PASSWORD, USER_EMAIL, USER_EXTERNAL_ID, Arrays.asList(ROLE_NAME), USER_LOCALE);
// then
assertTrue(String.format("Permission %s has not been saved", PERMISSION_NAME), permissionService.getPermissions().contains(permission));
assertEquals(String.format("Role %s has not been saved properly", ROLE_NAME), role, roleService.getRole(ROLE_NAME));
assertNotNull(String.format("User %s has not been registered", USER_NAME), userService.hasUser(USER_NAME));
assertTrue(String.format("User doesn't have role %s", ROLE_NAME), userService.getRoles(USER_NAME).contains(ROLE_NAME));
}
Aggregations